Search in sources :

Example 11 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class AccountPreferenceControllerTest method updateDynamicRawDataToIndex_disallowRemove_shouldAddOne.

@Test
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));
    when(mUserManager.isManagedProfile()).thenReturn(false);
    when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
    when(mAccountHelper.hasBaseUserRestriction(eq(UserManager.DISALLOW_REMOVE_MANAGED_PROFILE), anyInt())).thenReturn(true);
    mController.updateDynamicRawDataToIndex(data);
    assertThat(data.size()).isEqualTo(1);
}
Also used : ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) UserInfo(android.content.pm.UserInfo) Test(org.junit.Test)

Example 12 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class AccountPreferenceControllerTest method updateDynamicRawDataToIndex_managedUser_shouldAddTwo.

@Test
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.updateDynamicRawDataToIndex(data);
    assertThat(data.size()).isEqualTo(2);
}
Also used : ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) UserInfo(android.content.pm.UserInfo) Test(org.junit.Test)

Example 13 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class TrustAgentListPreferenceController method updateDynamicRawDataToIndex.

@Override
public void updateDynamicRawDataToIndex(List<SearchIndexableRaw> rawData) {
    if (!isAvailable()) {
        return;
    }
    final List<TrustAgentManager.TrustAgentComponentInfo> agents = getActiveTrustAgents(mContext);
    if (agents == null) {
        return;
    }
    for (int i = 0, size = agents.size(); i < size; i++) {
        final SearchIndexableRaw raw = new SearchIndexableRaw(mContext);
        final TrustAgentManager.TrustAgentComponentInfo agent = agents.get(i);
        raw.key = PREF_KEY_TRUST_AGENT + i;
        raw.title = agent.title;
        rawData.add(raw);
    }
}
Also used : SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw)

Example 14 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class AccountPreferenceControllerTest method updateDynamicRawDataToIndex_disallowModify_shouldAddTwo.

@Test
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(mUserManager.isManagedProfile()).thenReturn(false);
    when(mUserManager.getProfiles(anyInt())).thenReturn(infos);
    when(mAccountHelper.hasBaseUserRestriction(eq(UserManager.DISALLOW_MODIFY_ACCOUNTS), anyInt())).thenReturn(true);
    mController.updateDynamicRawDataToIndex(data);
    assertThat(data.size()).isEqualTo(2);
}
Also used : ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) UserInfo(android.content.pm.UserInfo) Test(org.junit.Test)

Example 15 with SearchIndexableRaw

use of com.android.settingslib.search.SearchIndexableRaw in project android_packages_apps_Settings by omnirom.

the class AccountPreferenceControllerTest method updateDynamicRawDataToIndex_enabledUser_notManagedUser_shouldNotUpdate.

@Test
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.updateDynamicRawDataToIndex(data);
    assertThat(data.size()).isEqualTo(0);
}
Also used : ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) UserInfo(android.content.pm.UserInfo) Test(org.junit.Test)

Aggregations

SearchIndexableRaw (com.android.settingslib.search.SearchIndexableRaw)19 ArrayList (java.util.ArrayList)14 Test (org.junit.Test)10 UserInfo (android.content.pm.UserInfo)8 Indexable (com.android.settingslib.search.Indexable)3 Resources (android.content.res.Resources)2 MatrixCursor (android.database.MatrixCursor)2 SearchIndexableData (com.android.settingslib.search.SearchIndexableData)2 Account (android.accounts.Account)1 ComponentName (android.content.ComponentName)1 Context (android.content.Context)1 Intent (android.content.Intent)1 ResolveInfo (android.content.pm.ResolveInfo)1 CallSuper (androidx.annotation.CallSuper)1 Nullable (androidx.annotation.Nullable)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 BasePreferenceController (com.android.settings.core.BasePreferenceController)1 PreferenceControllerMixin (com.android.settings.core.PreferenceControllerMixin)1 DashboardFeatureProvider (com.android.settings.dashboard.DashboardFeatureProvider)1 AbstractPreferenceController (com.android.settingslib.core.AbstractPreferenceController)1