Refactor bindPreferenceToTile to properly handle multi-user
Change-Id: I751eb645663b3546c212925e2ba4a0a94714013b Fixes: 32470791 Test: RunSettingsRoboTests
This commit is contained in:
@@ -98,16 +98,17 @@ public class DashboardFeatureProviderImpl implements DashboardFeatureProvider {
|
||||
}
|
||||
if (!TextUtils.isEmpty(clsName)) {
|
||||
pref.setFragment(clsName);
|
||||
} else if (tile.userHandle != null && tile.userHandle.size() > 1) {
|
||||
pref.setOnPreferenceClickListener(preference -> {
|
||||
ProfileSelectDialog.updateUserHandlesIfNeeded(activity, tile);
|
||||
ProfileSelectDialog.show(activity.getFragmentManager(), tile);
|
||||
return true;
|
||||
});
|
||||
} else if (tile.intent != null) {
|
||||
final Intent intent = new Intent(tile.intent);
|
||||
pref.setOnPreferenceClickListener(preference -> {
|
||||
activity.startActivityForResult(intent, 0);
|
||||
ProfileSelectDialog.updateUserHandlesIfNeeded(mContext, tile);
|
||||
if (tile.userHandle == null) {
|
||||
activity.startActivityForResult(intent, 0);
|
||||
} else if (tile.userHandle.size() == 1) {
|
||||
activity.startActivityForResultAsUser(intent, 0, tile.userHandle.get(0));
|
||||
} else {
|
||||
ProfileSelectDialog.show(activity.getFragmentManager(), tile);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
@@ -112,7 +112,9 @@ public class DashboardFeatureProviderImplTest {
|
||||
tile.userHandle.add(mock(UserHandle.class));
|
||||
tile.userHandle.add(mock(UserHandle.class));
|
||||
tile.intent = new Intent();
|
||||
when(mActivity.getSystemService(Context.USER_SERVICE)).thenReturn(mUserManager);
|
||||
|
||||
when(mActivity.getApplicationContext().getSystemService(Context.USER_SERVICE))
|
||||
.thenReturn(mUserManager);
|
||||
|
||||
mImpl.bindPreferenceToTile(mActivity, preference, tile, "123");
|
||||
preference.getOnPreferenceClickListener().onPreferenceClick(null);
|
||||
|
Reference in New Issue
Block a user