Remove items from not allowed show summary list (legacy rule)
Bug: 191991503
Test: make SettingsRoboTests
Change-Id: Ieadc97eddcbd149e04ec85477859a9b3ffd8f06b
(cherry picked from commit b6d95d1c4f
)
This commit is contained in:
@@ -1529,8 +1529,6 @@
|
|||||||
<!-- An allowlist which packages won't show summary in battery usage screen.
|
<!-- An allowlist which packages won't show summary in battery usage screen.
|
||||||
[CHAR LIMIT=NONE] -->
|
[CHAR LIMIT=NONE] -->
|
||||||
<string-array name="allowlist_hide_summary_in_battery_usage" translatable="false">
|
<string-array name="allowlist_hide_summary_in_battery_usage" translatable="false">
|
||||||
<!-- Google -->
|
|
||||||
<item>"com.google.android.googlequicksearchbox"</item>
|
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<!-- An allowlist which packages won't show entry in battery usage screen.
|
<!-- An allowlist which packages won't show entry in battery usage screen.
|
||||||
|
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
import android.text.format.DateUtils;
|
import android.text.format.DateUtils;
|
||||||
|
|
||||||
@@ -72,11 +73,14 @@ public class BatteryAppListPreferenceControllerTest {
|
|||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
|
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
|
final Resources resources = spy(mContext.getResources());
|
||||||
|
when(mContext.getResources()).thenReturn(resources);
|
||||||
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
when(mContext.getApplicationContext()).thenReturn(mContext);
|
when(mContext.getApplicationContext()).thenReturn(mContext);
|
||||||
when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
|
when(mContext.getSystemService(UserManager.class)).thenReturn(mUserManager);
|
||||||
when(mUserManager.getProfileIdsWithDisabled(anyInt())).thenReturn(new int[] {});
|
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();
|
FakeFeatureFactory.setupForTest();
|
||||||
|
|
||||||
mPreference = new PowerGaugePreference(mContext);
|
mPreference = new PowerGaugePreference(mContext);
|
||||||
@@ -119,7 +123,7 @@ public class BatteryAppListPreferenceControllerTest {
|
|||||||
public void testSetUsageSummary_timeMoreThanOneMinute_GoogleApp_shouldNotSetScreenSummary() {
|
public void testSetUsageSummary_timeMoreThanOneMinute_GoogleApp_shouldNotSetScreenSummary() {
|
||||||
when(mBatteryEntry.getTimeInForegroundMs()).thenReturn(2 * DateUtils.MINUTE_IN_MILLIS);
|
when(mBatteryEntry.getTimeInForegroundMs()).thenReturn(2 * DateUtils.MINUTE_IN_MILLIS);
|
||||||
when(mBatteryEntry.getDefaultPackageName())
|
when(mBatteryEntry.getDefaultPackageName())
|
||||||
.thenReturn("com.google.android.googlequicksearchbox");
|
.thenReturn("com.android.googlequicksearchbox");
|
||||||
doReturn(mContext.getText(R.string.battery_used_for)).when(mFragment).getText(
|
doReturn(mContext.getText(R.string.battery_used_for)).when(mFragment).getText(
|
||||||
R.string.battery_used_for);
|
R.string.battery_used_for);
|
||||||
doReturn(mContext).when(mFragment).getContext();
|
doReturn(mContext).when(mFragment).getContext();
|
||||||
|
@@ -101,8 +101,11 @@ public final class BatteryChartPreferenceControllerTest {
|
|||||||
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
mFeatureFactory = FakeFeatureFactory.setupForTest();
|
||||||
mMetricsFeatureProvider = mFeatureFactory.metricsFeatureProvider;
|
mMetricsFeatureProvider = mFeatureFactory.metricsFeatureProvider;
|
||||||
mContext = spy(RuntimeEnvironment.application);
|
mContext = spy(RuntimeEnvironment.application);
|
||||||
mContext.getResources().getConfiguration().setLocales(
|
final Resources resources = spy(mContext.getResources());
|
||||||
new LocaleList(new Locale("en_US")));
|
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 = createController();
|
||||||
mBatteryChartPreferenceController.mPrefContext = mContext;
|
mBatteryChartPreferenceController.mPrefContext = mContext;
|
||||||
mBatteryChartPreferenceController.mAppListPrefGroup = mAppListGroup;
|
mBatteryChartPreferenceController.mAppListPrefGroup = mAppListGroup;
|
||||||
@@ -467,7 +470,7 @@ public final class BatteryChartPreferenceControllerTest {
|
|||||||
spy(createBatteryDiffEntry(
|
spy(createBatteryDiffEntry(
|
||||||
/*foregroundUsageTimeInMs=*/ DateUtils.MINUTE_IN_MILLIS,
|
/*foregroundUsageTimeInMs=*/ DateUtils.MINUTE_IN_MILLIS,
|
||||||
/*backgroundUsageTimeInMs=*/ DateUtils.MINUTE_IN_MILLIS));
|
/*backgroundUsageTimeInMs=*/ DateUtils.MINUTE_IN_MILLIS));
|
||||||
doReturn("com.google.android.googlequicksearchbox").when(batteryDiffEntry)
|
doReturn("com.android.googlequicksearchbox").when(batteryDiffEntry)
|
||||||
.getPackageName();
|
.getPackageName();
|
||||||
|
|
||||||
mBatteryChartPreferenceController.setPreferenceSummary(pref, batteryDiffEntry);
|
mBatteryChartPreferenceController.setPreferenceSummary(pref, batteryDiffEntry);
|
||||||
@@ -678,7 +681,7 @@ public final class BatteryChartPreferenceControllerTest {
|
|||||||
|
|
||||||
// Verifies the item which is defined in the array list.
|
// Verifies the item which is defined in the array list.
|
||||||
assertThat(mBatteryChartPreferenceController
|
assertThat(mBatteryChartPreferenceController
|
||||||
.isValidToShowSummary("com.google.android.googlequicksearchbox"))
|
.isValidToShowSummary("com.android.googlequicksearchbox"))
|
||||||
.isFalse();
|
.isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user