Loading res/values/arrays.xml +0 −2 Original line number Diff line number Diff line Loading @@ -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. Loading tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java +6 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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(); Loading tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java +7 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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(); } Loading Loading
res/values/arrays.xml +0 −2 Original line number Diff line number Diff line Loading @@ -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. Loading
tests/robotests/src/com/android/settings/fuelgauge/BatteryAppListPreferenceControllerTest.java +6 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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(); Loading
tests/robotests/src/com/android/settings/fuelgauge/BatteryChartPreferenceControllerTest.java +7 −4 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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(); } Loading