<string name="keywords_sounds_and_notifications_interruptions">dont don\u2019t disturb, interrupt, interruption, break</string>
<string name="keywords_app">RAM</string>
<string name="keywords_location">nearby, location, history, reporting, GPS</string>
- <string name="keywords_accounts">account, add an account, work profile</string>
+ <string name="keywords_accounts">account, add an account, work profile, add account</string>
<string name="keywords_users">restriction, restrict, restricted</string>
<string name="keywords_keyboard_and_ime">text correction, correct, sound, vibrate, auto, language, gesture, suggest, suggestion, theme, offensive, word, type, emoji, international</string>
<string name="keywords_reset_apps">reset, preferences, default</string>
import com.android.settings.users.AutoSyncWorkDataPreferenceController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.SearchIndexable;
+import com.android.settingslib.search.SearchIndexableRaw;
import java.util.ArrayList;
import java.util.List;
return buildPreferenceControllers(
context, null /* parent */, null /* authorities*/);
}
+
+ @Override
+ public List<SearchIndexableRaw> getDynamicRawDataToIndex(Context context,
+ boolean enabled) {
+ return null;
+ }
};
-}
\ No newline at end of file
+}
private static final int ORDER_NEXT_TO_LAST = 1001;
private static final int ORDER_NEXT_TO_NEXT_TO_LAST = 1000;
+ private static final String PREF_KEY_REMOVE_PROFILE = "remove_profile";
+ private static final String PREF_KEY_WORK_PROFILE_SETTING = "work_profile_setting";
+
private UserManager mUm;
private SparseArray<ProfileData> mProfiles = new SparseArray<ProfileData>();
private ManagedProfileBroadcastReceiver mManagedProfileBroadcastReceiver =
}
@Override
- public void updateRawDataToIndex(List<SearchIndexableRaw> rawData) {
+ public void updateDynamicRawDataToIndex(List<SearchIndexableRaw> rawData) {
if (!isAvailable()) {
return;
}
final String screenTitle = res.getString(R.string.account_settings_title);
List<UserInfo> profiles = mUm.getProfiles(UserHandle.myUserId());
- final int profilesCount = profiles.size();
- for (int i = 0; i < profilesCount; i++) {
- UserInfo userInfo = profiles.get(i);
- if (userInfo.isEnabled()) {
- if (!mHelper.hasBaseUserRestriction(DISALLOW_MODIFY_ACCOUNTS, userInfo.id)) {
- SearchIndexableRaw data = new SearchIndexableRaw(mContext);
- data.title = res.getString(R.string.add_account_label);
- data.screenTitle = screenTitle;
- rawData.add(data);
- }
- if (userInfo.isManagedProfile()) {
- if (!mHelper.hasBaseUserRestriction(DISALLOW_REMOVE_MANAGED_PROFILE,
- UserHandle.myUserId())) {
- SearchIndexableRaw data = new SearchIndexableRaw(mContext);
- data.title = res.getString(R.string.remove_managed_profile_label);
- data.screenTitle = screenTitle;
- rawData.add(data);
- }
- SearchIndexableRaw data = new SearchIndexableRaw(mContext);
- data.title = res.getString(R.string.managed_profile_settings_title);
+ for (final UserInfo userInfo : profiles) {
+ if (userInfo.isEnabled() && userInfo.isManagedProfile()) {
+ if (!mHelper.hasBaseUserRestriction(DISALLOW_REMOVE_MANAGED_PROFILE,
+ UserHandle.myUserId())) {
+ final SearchIndexableRaw data = new SearchIndexableRaw(mContext);
+ data.key = PREF_KEY_REMOVE_PROFILE;
+ data.title = res.getString(R.string.remove_managed_profile_label);
data.screenTitle = screenTitle;
rawData.add(data);
}
+ final SearchIndexableRaw data = new SearchIndexableRaw(mContext);
+ data.key = PREF_KEY_WORK_PROFILE_SETTING;
+ data.title = res.getString(R.string.managed_profile_settings_title);
+ data.screenTitle = screenTitle;
+ rawData.add(data);
}
}
}
private RestrictedPreference newRemoveWorkProfilePreference() {
RestrictedPreference preference = new RestrictedPreference(
mParent.getPreferenceManager().getContext());
+ preference.setKey(PREF_KEY_REMOVE_PROFILE);
preference.setTitle(R.string.remove_managed_profile_label);
preference.setIcon(R.drawable.ic_delete);
preference.setOnPreferenceClickListener(this);
private Preference newManagedProfileSettings() {
Preference preference = new Preference(mParent.getPreferenceManager().getContext());
+ preference.setKey(PREF_KEY_WORK_PROFILE_SETTING);
preference.setTitle(R.string.managed_profile_settings_title);
preference.setIcon(R.drawable.ic_settings_24dp);
preference.setOnPreferenceClickListener(this);
}
@Test
- public void updateRawDataToIndex_EnabledUser_shouldAddOne() {
+ public void updateDynamicRawDataToIndex_enabledUser_notManagedUser_shouldNotUpdate() {
final List<SearchIndexableRaw> data = new ArrayList<>();
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", 0));
when(mUserManager.isManagedProfile()).thenReturn(false);
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
- mController.updateRawDataToIndex(data);
+ mController.updateDynamicRawDataToIndex(data);
- assertThat(data.size()).isEqualTo(1);
+ assertThat(data.size()).isEqualTo(0);
}
@Test
- public void updateRawDataToIndex_ManagedUser_shouldAddThree() {
+ public void updateDynamicRawDataToIndex_managedUser_shouldAddTwo() {
final List<SearchIndexableRaw> data = new ArrayList<>();
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_MANAGED_PROFILE));
when(mUserManager.isManagedProfile()).thenReturn(false);
when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
- mController.updateRawDataToIndex(data);
+ mController.updateDynamicRawDataToIndex(data);
- assertThat(data.size()).isEqualTo(3);
+ assertThat(data.size()).isEqualTo(2);
}
@Test
- public void updateRawDataToIndex_DisallowRemove_shouldAddTwo() {
+ public void updateDynamicRawDataToIndex_disallowRemove_shouldAddOne() {
final List<SearchIndexableRaw> data = new ArrayList<>();
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_MANAGED_PROFILE));
eq(UserManager.DISALLOW_REMOVE_MANAGED_PROFILE), anyInt()))
.thenReturn(true);
- mController.updateRawDataToIndex(data);
+ mController.updateDynamicRawDataToIndex(data);
- assertThat(data.size()).isEqualTo(2);
+ assertThat(data.size()).isEqualTo(1);
}
@Test
- public void updateRawDataToIndex_DisallowModify_shouldAddTwo() {
+ public void updateDynamicRawDataToIndex_disallowModify_shouldAddTwo() {
final List<SearchIndexableRaw> data = new ArrayList<>();
final List<UserInfo> infos = new ArrayList<>();
infos.add(new UserInfo(1, "user 1", UserInfo.FLAG_MANAGED_PROFILE));
when(mAccountHelper.hasBaseUserRestriction(
eq(UserManager.DISALLOW_MODIFY_ACCOUNTS), anyInt())).thenReturn(true);
- mController.updateRawDataToIndex(data);
+ mController.updateDynamicRawDataToIndex(data);
assertThat(data.size()).isEqualTo(2);
}