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

Commit d7753f4c authored by YUKAI HUNG's avatar YUKAI HUNG Committed by Android (Google) Code Review
Browse files

Merge "Remove items from not allowed show summary list (legacy rule)" into sc-dev

parents 9d2048ab 09e1164c
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -1529,8 +1529,6 @@
    <!-- An allowlist which packages won't show summary in battery usage screen.
         [CHAR LIMIT=NONE] -->
    <string-array name="allowlist_hide_summary_in_battery_usage" translatable="false">
        <!-- Google -->
        <item>"com.google.android.googlequicksearchbox"</item>
    </string-array>

    <!-- An allowlist which packages won't show entry in battery usage screen.
+6 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.when;

import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.UserManager;
import android.text.format.DateUtils;

@@ -72,11 +73,14 @@ public class BatteryAppListPreferenceControllerTest {
        MockitoAnnotations.initMocks(this);

        mContext = spy(RuntimeEnvironment.application);
        final Resources resources = spy(mContext.getResources());
        when(mContext.getResources()).thenReturn(resources);
        when(mContext.getPackageManager()).thenReturn(mPackageManager);
        when(mContext.getApplicationContext()).thenReturn(mContext);
        when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
        when(mUserManager.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {});

        when(resources.getTextArray(R.array.allowlist_hide_summary_in_battery_usage))
                .thenReturn(new String[] {"com.android.googlequicksearchbox"});
        FakeFeatureFactory.setupForTest();

        mPreference = new PowerGaugePreference(mContext);
@@ -119,7 +123,7 @@ public class BatteryAppListPreferenceControllerTest {
    public void testSetUsageSummary_timeMoreThanOneMinute_GoogleApp_shouldNotSetScreenSummary() {
        when(mBatteryEntry.getTimeInForegroundMs()).thenReturn(2 * DateUtils.MINUTE_IN_MILLIS);
        when(mBatteryEntry.getDefaultPackageName())
                .thenReturn("com.google.android.googlequicksearchbox");
                .thenReturn("com.android.googlequicksearchbox");
        doReturn(mContext.getText(R.string.battery_used_for)).when(mFragment).getText(
                R.string.battery_used_for);
        doReturn(mContext).when(mFragment).getContext();
+7 −4
Original line number Diff line number Diff line
@@ -101,8 +101,11 @@ public final class BatteryChartPreferenceControllerTest {
        mFeatureFactory = FakeFeatureFactory.setupForTest();
        mMetricsFeatureProvider = mFeatureFactory.metricsFeatureProvider;
        mContext = spy(RuntimeEnvironment.application);
        mContext.getResources().getConfiguration().setLocales(
            new LocaleList(new Locale("en_US")));
        final Resources resources = spy(mContext.getResources());
        resources.getConfiguration().setLocales(new LocaleList(new Locale("en_US")));
        doReturn(resources).when(mContext).getResources();
        doReturn(new String[] {"com.android.googlequicksearchbox"})
            .when(resources).getTextArray(R.array.allowlist_hide_summary_in_battery_usage);
        mBatteryChartPreferenceController = createController();
        mBatteryChartPreferenceController.mPrefContext = mContext;
        mBatteryChartPreferenceController.mAppListPrefGroup = mAppListGroup;
@@ -467,7 +470,7 @@ public final class BatteryChartPreferenceControllerTest {
            spy(createBatteryDiffEntry(
                /*foregroundUsageTimeInMs=*/ DateUtils.MINUTE_IN_MILLIS,
                /*backgroundUsageTimeInMs=*/ DateUtils.MINUTE_IN_MILLIS));
        doReturn("com.google.android.googlequicksearchbox").when(batteryDiffEntry)
        doReturn("com.android.googlequicksearchbox").when(batteryDiffEntry)
            .getPackageName();

        mBatteryChartPreferenceController.setPreferenceSummary(pref, batteryDiffEntry);
@@ -678,7 +681,7 @@ public final class BatteryChartPreferenceControllerTest {

        // Verifies the item which is defined in the array list.
        assertThat(mBatteryChartPreferenceController
                .isValidToShowSummary("com.google.android.googlequicksearchbox"))
                .isValidToShowSummary("com.android.googlequicksearchbox"))
            .isFalse();
    }