Search in sources :

Example 1 with SearchIndexableRaw

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

the class AccountDashboardFragmentTest method searchIndexProvider_hasManagedProfile_shouldNotIndex.

@Test
public void searchIndexProvider_hasManagedProfile_shouldNotIndex() {
    final List<UserInfo> infos = new ArrayList<>();
    infos.add(new UserInfo(PROFILE_ID, PROFILE_NAME, UserInfo.FLAG_MANAGED_PROFILE));
    doReturn(infos).when(mUserManager).getProfiles(anyInt());
    final List<SearchIndexableRaw> indexRaws = AccountDashboardFragment.SEARCH_INDEX_DATA_PROVIDER.getDynamicRawDataToIndex(mContext, true);
    assertThat(indexRaws).isEmpty();
}
Also used : ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) UserInfo(android.content.pm.UserInfo) Test(org.junit.Test)

Example 2 with SearchIndexableRaw

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

the class AccountDashboardFragmentTest method searchIndexProvider_hasAccounts_shouldIndex.

@Test
public void searchIndexProvider_hasAccounts_shouldIndex() {
    final List<UserInfo> infos = new ArrayList<>();
    infos.add(new UserInfo(PROFILE_ID, PROFILE_NAME, UserInfo.FLAG_PRIMARY));
    doReturn(infos).when(mUserManager).getProfiles(anyInt());
    final Account[] accounts = { new Account(ACCOUNT_NAME, ACCOUNT_TYPE) };
    when(AccountManager.get(mContext)).thenReturn(mAccountManager);
    doReturn(accounts).when(mAccountManager).getAccounts();
    final List<SearchIndexableRaw> indexRaws = AccountDashboardFragment.SEARCH_INDEX_DATA_PROVIDER.getDynamicRawDataToIndex(mContext, true);
    assertThat(indexRaws).isNotEmpty();
}
Also used : Account(android.accounts.Account) ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) UserInfo(android.content.pm.UserInfo) Test(org.junit.Test)

Example 3 with SearchIndexableRaw

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

the class EmergencyInfoPreferenceControllerTest method updateRawDataToIndex_prefAvailable_shouldUpdate.

@Test
public void updateRawDataToIndex_prefAvailable_shouldUpdate() {
    final List<SearchIndexableRaw> data = new ArrayList<>();
    final List<ResolveInfo> infos = new ArrayList<>();
    infos.add(new ResolveInfo());
    when(mContext.getPackageManager().queryIntentActivities(any(Intent.class), anyInt())).thenReturn(infos);
    mController.updateRawDataToIndex(data);
    assertThat(mController.isAvailable()).isTrue();
    assertThat(data).isNotEmpty();
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ArrayList(java.util.ArrayList) SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) Intent(android.content.Intent) Test(org.junit.Test)

Example 4 with SearchIndexableRaw

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

the class SupportDashboardActivityTest method shouldIndexSearchActivityForSearch.

@Test
public void shouldIndexSearchActivityForSearch() {
    final List<SearchIndexableRaw> indexables = SupportDashboardActivity.SEARCH_INDEX_DATA_PROVIDER.getRawDataToIndex(mContext, true);
    assertThat(indexables).hasSize(1);
    final SearchIndexableRaw value = indexables.get(0);
    assertThat(value.title).isEqualTo(mContext.getString(R.string.page_tab_title_support));
    assertThat(value.screenTitle).isEqualTo(mContext.getString(R.string.page_tab_title_support));
    assertThat(value.intentTargetPackage).isEqualTo(mContext.getPackageName());
    assertThat(value.intentTargetClass).isEqualTo(SupportDashboardActivity.class.getName());
    assertThat(value.intentAction).isEqualTo(Intent.ACTION_MAIN);
}
Also used : SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) Test(org.junit.Test)

Example 5 with SearchIndexableRaw

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

the class AccountPreferenceController method updateDynamicRawDataToIndex.

@Override
public void updateDynamicRawDataToIndex(List<SearchIndexableRaw> rawData) {
    if (!isAvailable()) {
        return;
    }
    final Resources res = mContext.getResources();
    final String screenTitle = res.getString(R.string.account_settings_title);
    List<UserInfo> profiles = mUm.getProfiles(UserHandle.myUserId());
    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);
        }
    }
}
Also used : SearchIndexableRaw(com.android.settingslib.search.SearchIndexableRaw) UserInfo(android.content.pm.UserInfo) Resources(android.content.res.Resources)

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