Profile select only shows with multiple profiles present.

Bug: 133328247
Change-Id: Id5d03a1aa74f1789c41af37562848603a90db84f
Test: manual verification
This commit is contained in:
Adam He
2019-05-29 14:21:33 -07:00
parent e4ede480d7
commit 83f0d24f67

View File

@@ -96,19 +96,24 @@ public final class EnableContentCaptureWithServiceSettingsPreferenceController
for (UserInfo info: userInfos) {
userHandles.add(info.getUserHandle());
}
if (userHandles.size() == 1) {
final Intent intent = pref.getIntent().addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivityAsUser(intent, userHandles.get(0));
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
UserAdapter adapter = UserAdapter.createUserAdapter(userManager, context, userHandles);
UserAdapter adapter = UserAdapter.createUserAdapter(userManager, context,
userHandles);
builder.setTitle(com.android.settingslib.R.string.choose_profile)
.setAdapter(adapter, (DialogInterface dialog, int which) -> {
final UserHandle user = userHandles.get(which);
// Show menu on top level items.
final Intent intent = pref.getIntent();
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
final Intent intent = pref.getIntent()
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
context.startActivityAsUser(intent, user);
})
.show();
}
}
}
}