Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4d9a1ae9 authored by Matthew Fritze's avatar Matthew Fritze
Browse files

Remove default app duplicates in search

Default Work Browser and Phone app search results look
identical to the regular defaults. Supress the results
until we differentiate work results.

"Assist and voice input" duplicate is a parent-child
duplication and is removed, as well.

Bug: 36101902
Test: make RunSettingsRoboTests
Change-Id: I3bb75c199cd76e24de42548dd166c4bccd0c7f0a
parent 8fc602fe
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -43,6 +43,8 @@ public class AdvancedAppSettings extends DashboardFragment {

    static final String TAG = "AdvancedAppSettings";

    private static final String KEY_ASSIST_VOICE_INPUT = "assist_and_voice_input";

    @Override
    protected String getLogTag() {
        return TAG;
@@ -80,6 +82,18 @@ public class AdvancedAppSettings extends DashboardFragment {
                    sir.xmlResId = R.xml.app_default_settings;
                    return Arrays.asList(sir);
                }

                @Override
                public List<String> getNonIndexableKeys(Context context) {
                    List<String> keys = super.getNonIndexableKeys(context);
                    keys.add(KEY_ASSIST_VOICE_INPUT);
                    // TODO (b/38230148) Remove these keys when we can differentiate work results
                    keys.add((new DefaultWorkPhonePreferenceController(context))
                            .getPreferenceKey());
                    keys.add((new DefaultWorkBrowserPreferenceController(context))
                            .getPreferenceKey());
                    return keys;
                }
            };

    static class SummaryProvider implements SummaryLoader.SummaryProvider {
+1 −1
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ public class BaseSearchIndexProvider implements Indexable.SearchIndexProvider {
            }
            return nonIndexableKeys;
        } else {
            return EMPTY_LIST;
            return new ArrayList<>();
        }
    }

+16 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.settings.applications.defaultapps.DefaultBrowserPreferenceCon
import com.android.settings.applications.defaultapps.DefaultPhonePreferenceController;
import com.android.settings.applications.defaultapps.DefaultSmsPreferenceController;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.testutils.XmlTestUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -34,11 +35,14 @@ import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.util.ReflectionHelpers;

import java.util.List;

import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

@@ -136,4 +140,16 @@ public class AdvancedAppSettingsTest {

    }


    @Test
    public void testNonIndexableKeys_existInXmlLayout() {
        final Context context = spy(RuntimeEnvironment.application);
        final List<String> niks = AdvancedAppSettings.SEARCH_INDEX_DATA_PROVIDER
                .getNonIndexableKeys(context);
        final int xmlId = (new AdvancedAppSettings()).getPreferenceScreenResId();

        final List<String> keys = XmlTestUtils.getKeysFromPreferenceXml(context, xmlId);

        assertThat(keys).containsAllIn(niks);
    }
}