Merge "Update language to comply with Android's inclusive language guidance"
This commit is contained in:
@@ -16,42 +16,24 @@
|
||||
|
||||
package com.android.settings.applications.manageapplications;
|
||||
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry
|
||||
.FILTER_APPS_ALL;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry
|
||||
.FILTER_APPS_INSTALL_SOURCES;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry
|
||||
.FILTER_APPS_POWER_WHITELIST;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry
|
||||
.FILTER_APPS_RECENT;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry
|
||||
.FILTER_APPS_USAGE_ACCESS;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry
|
||||
.FILTER_APPS_WITH_OVERLAY;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry
|
||||
.FILTER_APPS_WRITE_SETTINGS;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||
.LIST_TYPE_GAMES;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||
.LIST_TYPE_HIGH_POWER;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||
.LIST_TYPE_MAIN;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||
.LIST_TYPE_MANAGE_SOURCES;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||
.LIST_TYPE_MOVIES;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||
.LIST_TYPE_NOTIFICATION;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||
.LIST_TYPE_OVERLAY;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||
.LIST_TYPE_PHOTOGRAPHY;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||
.LIST_TYPE_STORAGE;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||
.LIST_TYPE_USAGE_ACCESS;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications
|
||||
.LIST_TYPE_WRITE_SETTINGS;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_ALL;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_INSTALL_SOURCES;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_POWER_ALLOWLIST;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_RECENT;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_USAGE_ACCESS;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_WITH_OVERLAY;
|
||||
import static com.android.settings.applications.manageapplications.AppFilterRegistry.FILTER_APPS_WRITE_SETTINGS;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_GAMES;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_HIGH_POWER;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MAIN;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MANAGE_SOURCES;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_MOVIES;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_NOTIFICATION;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_OVERLAY;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_PHOTOGRAPHY;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_STORAGE;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_USAGE_ACCESS;
|
||||
import static com.android.settings.applications.manageapplications.ManageApplications.LIST_TYPE_WRITE_SETTINGS;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
@@ -62,27 +44,27 @@ import org.robolectric.RobolectricTestRunner;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class AppFilterRegistryTest {
|
||||
|
||||
@Test
|
||||
public void getDefaultType_shouldMatchForAllListType() {
|
||||
final AppFilterRegistry registry = AppFilterRegistry.getInstance();
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_USAGE_ACCESS))
|
||||
.isEqualTo(FILTER_APPS_USAGE_ACCESS);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_HIGH_POWER))
|
||||
.isEqualTo(FILTER_APPS_POWER_WHITELIST);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_OVERLAY))
|
||||
.isEqualTo(FILTER_APPS_WITH_OVERLAY);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_WRITE_SETTINGS))
|
||||
.isEqualTo(FILTER_APPS_WRITE_SETTINGS);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_MANAGE_SOURCES))
|
||||
.isEqualTo(FILTER_APPS_INSTALL_SOURCES);
|
||||
@Test
|
||||
public void getDefaultType_shouldMatchForAllListType() {
|
||||
final AppFilterRegistry registry = AppFilterRegistry.getInstance();
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_USAGE_ACCESS))
|
||||
.isEqualTo(FILTER_APPS_USAGE_ACCESS);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_HIGH_POWER))
|
||||
.isEqualTo(FILTER_APPS_POWER_ALLOWLIST);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_OVERLAY))
|
||||
.isEqualTo(FILTER_APPS_WITH_OVERLAY);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_WRITE_SETTINGS))
|
||||
.isEqualTo(FILTER_APPS_WRITE_SETTINGS);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_MANAGE_SOURCES))
|
||||
.isEqualTo(FILTER_APPS_INSTALL_SOURCES);
|
||||
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_MAIN)).isEqualTo(FILTER_APPS_ALL);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_NOTIFICATION))
|
||||
.isEqualTo(FILTER_APPS_RECENT);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_STORAGE)).isEqualTo(FILTER_APPS_ALL);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_MAIN)).isEqualTo(FILTER_APPS_ALL);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_NOTIFICATION))
|
||||
.isEqualTo(FILTER_APPS_RECENT);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_STORAGE)).isEqualTo(FILTER_APPS_ALL);
|
||||
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_GAMES)).isEqualTo(FILTER_APPS_ALL);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_MOVIES)).isEqualTo(FILTER_APPS_ALL);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_PHOTOGRAPHY)).isEqualTo(FILTER_APPS_ALL);
|
||||
}
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_GAMES)).isEqualTo(FILTER_APPS_ALL);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_MOVIES)).isEqualTo(FILTER_APPS_ALL);
|
||||
assertThat(registry.getDefaultFilterType(LIST_TYPE_PHOTOGRAPHY)).isEqualTo(FILTER_APPS_ALL);
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowFragment;
|
||||
import com.android.settingslib.RestrictedPreference;
|
||||
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
|
||||
import com.android.settingslib.fuelgauge.PowerAllowlistBackend;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -79,7 +79,7 @@ public class BackgroundActivityPreferenceControllerTest {
|
||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||
private AdvancedPowerUsageDetail mFragment;
|
||||
@Mock
|
||||
private PowerWhitelistBackend mPowerWhitelistBackend;
|
||||
private PowerAllowlistBackend mPowerAllowlistBackend;
|
||||
private BackgroundActivityPreferenceController mController;
|
||||
private RestrictedPreference mPreference;
|
||||
private Context mShadowContext;
|
||||
@@ -103,7 +103,7 @@ public class BackgroundActivityPreferenceControllerTest {
|
||||
when(mPackageManager.getApplicationInfo(LOW_SDK_PACKAGE, PackageManager.GET_META_DATA))
|
||||
.thenReturn(mLowApplicationInfo);
|
||||
|
||||
when(mPowerWhitelistBackend.isWhitelisted(LOW_SDK_PACKAGE)).thenReturn(false);
|
||||
when(mPowerAllowlistBackend.isAllowlisted(LOW_SDK_PACKAGE)).thenReturn(false);
|
||||
mHighApplicationInfo.targetSdkVersion = Build.VERSION_CODES.O;
|
||||
mLowApplicationInfo.targetSdkVersion = Build.VERSION_CODES.L;
|
||||
|
||||
@@ -113,7 +113,7 @@ public class BackgroundActivityPreferenceControllerTest {
|
||||
mPreference = spy(new RestrictedPreference(mShadowContext, null /* attrs */));
|
||||
mPreference.setKey(BackgroundActivityPreferenceController.KEY_BACKGROUND_ACTIVITY);
|
||||
mController = spy(new BackgroundActivityPreferenceController(
|
||||
mContext, mFragment, UID_LOW_SDK, LOW_SDK_PACKAGE, mPowerWhitelistBackend));
|
||||
mContext, mFragment, UID_LOW_SDK, LOW_SDK_PACKAGE, mPowerAllowlistBackend));
|
||||
mController.mDpm = mDevicePolicyManagerWrapper;
|
||||
mController.mBatteryUtils = mBatteryUtils;
|
||||
}
|
||||
@@ -150,8 +150,8 @@ public class BackgroundActivityPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateState_whitelisted() {
|
||||
when(mPowerWhitelistBackend.isWhitelisted(LOW_SDK_PACKAGE)).thenReturn(true);
|
||||
public void updateState_allowlisted() {
|
||||
when(mPowerAllowlistBackend.isAllowlisted(LOW_SDK_PACKAGE)).thenReturn(true);
|
||||
mController.updateState(mPreference);
|
||||
assertThat(mPreference.isEnabled()).isFalse();
|
||||
assertThat(mPreference.getSummary()).isEqualTo(
|
||||
|
@@ -33,7 +33,7 @@ import androidx.preference.SwitchPreference;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
|
||||
import com.android.settingslib.fuelgauge.PowerAllowlistBackend;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -46,8 +46,8 @@ import org.robolectric.RuntimeEnvironment;
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class BatteryOptimizationPreferenceControllerTest {
|
||||
|
||||
private static final String PKG_IN_WHITELIST = "com.pkg.in.whitelist";
|
||||
private static final String PKG_NOT_IN_WHITELIST = "com.pkg.not.in.whitelist";
|
||||
private static final String PKG_IN_ALLOWLIST = "com.pkg.in.allowlist";
|
||||
private static final String PKG_NOT_IN_ALLOWLIST = "com.pkg.not.in.allowlist";
|
||||
private static final String KEY_OPTIMIZATION = "battery_optimization";
|
||||
private static final String KEY_OTHER = "other";
|
||||
@Mock
|
||||
@@ -55,7 +55,7 @@ public class BatteryOptimizationPreferenceControllerTest {
|
||||
@Mock
|
||||
private DashboardFragment mFragment;
|
||||
@Mock
|
||||
private TestPowerWhitelistBackend mBackend;
|
||||
private TestPowerAllowlistBackend mBackend;
|
||||
|
||||
private BatteryOptimizationPreferenceController mController;
|
||||
private Preference mPreference;
|
||||
@@ -66,12 +66,12 @@ public class BatteryOptimizationPreferenceControllerTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
mContext = RuntimeEnvironment.application;
|
||||
doReturn(false).when(mBackend).isWhitelisted(PKG_NOT_IN_WHITELIST);
|
||||
doReturn(true).when(mBackend).isWhitelisted(PKG_IN_WHITELIST);
|
||||
doReturn(false).when(mBackend).isAllowlisted(PKG_NOT_IN_ALLOWLIST);
|
||||
doReturn(true).when(mBackend).isAllowlisted(PKG_IN_ALLOWLIST);
|
||||
|
||||
mPreference = new SwitchPreference(mContext);
|
||||
mController = spy(new BatteryOptimizationPreferenceController(mSettingsActivity, mFragment,
|
||||
PKG_NOT_IN_WHITELIST, mBackend));
|
||||
PKG_NOT_IN_ALLOWLIST, mBackend));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -95,10 +95,10 @@ public class BatteryOptimizationPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_appInWhitelist_showSummaryNotOptimized() {
|
||||
public void testUpdateState_appInAllowlist_showSummaryNotOptimized() {
|
||||
BatteryOptimizationPreferenceController controller =
|
||||
new BatteryOptimizationPreferenceController(mSettingsActivity, mFragment,
|
||||
PKG_IN_WHITELIST, mBackend);
|
||||
PKG_IN_ALLOWLIST, mBackend);
|
||||
|
||||
controller.updateState(mPreference);
|
||||
|
||||
@@ -106,7 +106,7 @@ public class BatteryOptimizationPreferenceControllerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateState_appNotInWhitelist_showSummaryOptimized() {
|
||||
public void testUpdateState_appNotInAllowlist_showSummaryOptimized() {
|
||||
mController.updateState(mPreference);
|
||||
|
||||
assertThat(mPreference.getSummary()).isEqualTo(mContext.getString(R.string.high_power_off));
|
||||
@@ -115,9 +115,9 @@ public class BatteryOptimizationPreferenceControllerTest {
|
||||
/**
|
||||
* Create this test class so we could mock it
|
||||
*/
|
||||
public static class TestPowerWhitelistBackend extends PowerWhitelistBackend {
|
||||
public static class TestPowerAllowlistBackend extends PowerAllowlistBackend {
|
||||
|
||||
public TestPowerWhitelistBackend(Context context) {
|
||||
public TestPowerAllowlistBackend(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
|
@@ -63,7 +63,7 @@ import com.android.settings.fuelgauge.batterytip.BatteryDatabaseManager;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowThreadUtils;
|
||||
import com.android.settingslib.fuelgauge.Estimate;
|
||||
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
|
||||
import com.android.settingslib.fuelgauge.PowerAllowlistBackend;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
@@ -160,7 +160,7 @@ public class BatteryUtilsTest {
|
||||
@Mock
|
||||
private ApplicationInfo mLowApplicationInfo;
|
||||
@Mock
|
||||
private PowerWhitelistBackend mPowerWhitelistBackend;
|
||||
private PowerAllowlistBackend mPowerAllowlistBackend;
|
||||
@Mock
|
||||
private BatteryDatabaseManager mBatteryDatabaseManager;
|
||||
private AnomalyInfo mAnomalyInfo;
|
||||
@@ -642,7 +642,7 @@ public class BatteryUtilsTest {
|
||||
doReturn(new String[]{HIGH_SDK_PACKAGE}).when(mPackageManager).getPackagesForUid(UID);
|
||||
mHighApplicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
|
||||
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerWhitelistBackend, UID,
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerAllowlistBackend, UID,
|
||||
mAnomalyInfo)).isTrue();
|
||||
}
|
||||
|
||||
@@ -652,7 +652,7 @@ public class BatteryUtilsTest {
|
||||
doReturn(new String[]{HIGH_SDK_PACKAGE}).when(mPackageManager).getPackagesForUid(UID);
|
||||
mHighApplicationInfo.flags = ApplicationInfo.FLAG_SYSTEM;
|
||||
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerWhitelistBackend, UID,
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerAllowlistBackend, UID,
|
||||
mAnomalyInfo)).isTrue();
|
||||
}
|
||||
|
||||
@@ -661,16 +661,16 @@ public class BatteryUtilsTest {
|
||||
final int systemUid = Process.ROOT_UID;
|
||||
doReturn(new String[]{HIGH_SDK_PACKAGE}).when(mPackageManager).getPackagesForUid(systemUid);
|
||||
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerWhitelistBackend, systemUid,
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerAllowlistBackend, systemUid,
|
||||
mAnomalyInfo)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testShouldHideAnomaly_AppInDozeList_returnTrue() {
|
||||
doReturn(new String[]{HIGH_SDK_PACKAGE}).when(mPackageManager).getPackagesForUid(UID);
|
||||
doReturn(true).when(mPowerWhitelistBackend).isWhitelisted(new String[]{HIGH_SDK_PACKAGE});
|
||||
doReturn(true).when(mPowerAllowlistBackend).isAllowlisted(new String[]{HIGH_SDK_PACKAGE});
|
||||
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerWhitelistBackend, UID,
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerAllowlistBackend, UID,
|
||||
mAnomalyInfo)).isTrue();
|
||||
}
|
||||
|
||||
@@ -678,7 +678,7 @@ public class BatteryUtilsTest {
|
||||
public void testShouldHideAnomaly_normalApp_returnFalse() {
|
||||
doReturn(new String[]{HIGH_SDK_PACKAGE}).when(mPackageManager).getPackagesForUid(UID);
|
||||
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerWhitelistBackend, UID,
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerAllowlistBackend, UID,
|
||||
mAnomalyInfo)).isFalse();
|
||||
}
|
||||
|
||||
@@ -687,7 +687,7 @@ public class BatteryUtilsTest {
|
||||
doReturn(new String[]{LOW_SDK_PACKAGE}).when(mPackageManager).getPackagesForUid(UID);
|
||||
mAnomalyInfo = new AnomalyInfo(INFO_EXCESSIVE);
|
||||
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerWhitelistBackend, UID,
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerAllowlistBackend, UID,
|
||||
mAnomalyInfo)).isFalse();
|
||||
}
|
||||
|
||||
@@ -696,7 +696,7 @@ public class BatteryUtilsTest {
|
||||
doReturn(new String[]{HIGH_SDK_PACKAGE}).when(mPackageManager).getPackagesForUid(UID);
|
||||
mAnomalyInfo = new AnomalyInfo(INFO_EXCESSIVE);
|
||||
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerWhitelistBackend, UID,
|
||||
assertThat(mBatteryUtils.shouldHideAnomaly(mPowerAllowlistBackend, UID,
|
||||
mAnomalyInfo)).isTrue();
|
||||
}
|
||||
|
||||
|
@@ -32,7 +32,7 @@ import android.content.DialogInterface;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
|
||||
import com.android.settingslib.fuelgauge.PowerAllowlistBackend;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -52,7 +52,7 @@ public class HighPowerDetailTest {
|
||||
|
||||
private Context mContext;
|
||||
@Mock
|
||||
private PowerWhitelistBackend mPowerWhitelistBackend;
|
||||
private PowerAllowlistBackend mPowerAllowlistBackend;
|
||||
@Mock
|
||||
private BatteryUtils mBatteryUtils;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class HighPowerDetailTest {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mContext = RuntimeEnvironment.application;
|
||||
mFragment = spy(new HighPowerDetail());
|
||||
mFragment.mBackend = mPowerWhitelistBackend;
|
||||
mFragment.mBackend = mPowerAllowlistBackend;
|
||||
mFragment.mBatteryUtils = mBatteryUtils;
|
||||
mFragment.mPackageUid = TEST_UID;
|
||||
mFragment.mPackageName = TEST_PACKAGE;
|
||||
@@ -71,21 +71,21 @@ public class HighPowerDetailTest {
|
||||
|
||||
@Test
|
||||
public void logSpecialPermissionChange() {
|
||||
// Deny means app is whitelisted to opt out of power save restrictions
|
||||
// Deny means app is allowlisted to opt out of power save restrictions
|
||||
HighPowerDetail.logSpecialPermissionChange(true, "app", RuntimeEnvironment.application);
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(any(Context.class),
|
||||
eq(MetricsProto.MetricsEvent.APP_SPECIAL_PERMISSION_BATTERY_DENY), eq("app"));
|
||||
|
||||
// Allow means app is NOT whitelisted to opt out of power save restrictions
|
||||
// Allow means app is NOT allowlisted to opt out of power save restrictions
|
||||
HighPowerDetail.logSpecialPermissionChange(false, "app", RuntimeEnvironment.application);
|
||||
verify(mFeatureFactory.metricsFeatureProvider).action(any(Context.class),
|
||||
eq(MetricsProto.MetricsEvent.APP_SPECIAL_PERMISSION_BATTERY_ALLOW), eq("app"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onClick_appAddedToDozeWhitelist_getsUnrestricted() {
|
||||
public void onClick_appAddedToDozeAllowlist_getsUnrestricted() {
|
||||
mFragment.mIsEnabled = true;
|
||||
when(mPowerWhitelistBackend.isWhitelisted(TEST_PACKAGE)).thenReturn(false);
|
||||
when(mPowerAllowlistBackend.isAllowlisted(TEST_PACKAGE)).thenReturn(false);
|
||||
mFragment.onClick(null, DialogInterface.BUTTON_POSITIVE);
|
||||
verify(mBatteryUtils).setForceAppStandby(TEST_UID, TEST_PACKAGE,
|
||||
AppOpsManager.MODE_ALLOWED);
|
||||
@@ -93,9 +93,9 @@ public class HighPowerDetailTest {
|
||||
|
||||
@Test
|
||||
public void getSummary_defaultActivePackage_returnUnavailable() {
|
||||
doReturn(true).when(mPowerWhitelistBackend).isDefaultActiveApp(TEST_PACKAGE);
|
||||
doReturn(true).when(mPowerAllowlistBackend).isDefaultActiveApp(TEST_PACKAGE);
|
||||
|
||||
assertThat(HighPowerDetail.getSummary(mContext, mPowerWhitelistBackend, TEST_PACKAGE))
|
||||
assertThat(HighPowerDetail.getSummary(mContext, mPowerAllowlistBackend, TEST_PACKAGE))
|
||||
.isEqualTo(mContext.getString(R.string.high_power_system));
|
||||
}
|
||||
}
|
||||
|
@@ -36,7 +36,6 @@ import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.robolectric.RuntimeEnvironment.application;
|
||||
|
||||
import android.app.JobSchedulerImpl;
|
||||
import android.app.StatsManager;
|
||||
@@ -59,8 +58,7 @@ import com.android.settings.R;
|
||||
import com.android.settings.fuelgauge.BatteryUtils;
|
||||
import com.android.settings.testutils.FakeFeatureFactory;
|
||||
import com.android.settings.testutils.shadow.ShadowConnectivityManager;
|
||||
import com.android.settings.testutils.shadow.ShadowPowerWhitelistBackend;
|
||||
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
|
||||
import com.android.settingslib.fuelgauge.PowerAllowlistBackend;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -78,7 +76,7 @@ import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(shadows = {ShadowConnectivityManager.class, ShadowPowerWhitelistBackend.class})
|
||||
@Config(shadows = {ShadowConnectivityManager.class})
|
||||
public class AnomalyDetectionJobServiceTest {
|
||||
private static final int UID = 12345;
|
||||
private static final String SYSTEM_PACKAGE = "com.android.system";
|
||||
@@ -95,7 +93,7 @@ public class AnomalyDetectionJobServiceTest {
|
||||
@Mock
|
||||
private BatteryUtils mBatteryUtils;
|
||||
@Mock
|
||||
private PowerWhitelistBackend mPowerWhitelistBackend;
|
||||
private PowerAllowlistBackend mPowerAllowlistBackend;
|
||||
@Mock
|
||||
private StatsDimensionsValue mStatsDimensionsValue;
|
||||
@Mock
|
||||
@@ -145,13 +143,13 @@ public class AnomalyDetectionJobServiceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void saveAnomalyToDatabase_systemWhitelisted_doNotSave() {
|
||||
public void saveAnomalyToDatabase_systemAllowlisted_doNotSave() {
|
||||
doReturn(UID).when(mAnomalyDetectionJobService).extractUidFromStatsDimensionsValue(any());
|
||||
doReturn(true).when(mPowerWhitelistBackend).isWhitelisted(any(String[].class));
|
||||
doReturn(true).when(mPowerAllowlistBackend).isAllowlisted(any(String[].class));
|
||||
|
||||
mAnomalyDetectionJobService.saveAnomalyToDatabase(mContext,
|
||||
mUserManager, mBatteryDatabaseManager, mBatteryUtils, mPolicy,
|
||||
mPowerWhitelistBackend, mContext.getContentResolver(),
|
||||
mPowerAllowlistBackend, mContext.getContentResolver(),
|
||||
mFeatureFactory.powerUsageFeatureProvider,
|
||||
mFeatureFactory.metricsFeatureProvider, mBundle);
|
||||
|
||||
@@ -165,14 +163,14 @@ public class AnomalyDetectionJobServiceTest {
|
||||
cookies.add(SUBSCRIBER_COOKIES_AUTO_RESTRICTION);
|
||||
mBundle.putStringArrayList(StatsManager.EXTRA_STATS_BROADCAST_SUBSCRIBER_COOKIES, cookies);
|
||||
doReturn(SYSTEM_PACKAGE).when(mBatteryUtils).getPackageName(anyInt());
|
||||
doReturn(false).when(mPowerWhitelistBackend).isSysWhitelisted(SYSTEM_PACKAGE);
|
||||
doReturn(false).when(mPowerAllowlistBackend).isSysAllowlisted(SYSTEM_PACKAGE);
|
||||
doReturn(Process.FIRST_APPLICATION_UID).when(
|
||||
mAnomalyDetectionJobService).extractUidFromStatsDimensionsValue(any());
|
||||
doReturn(true).when(mBatteryUtils).shouldHideAnomaly(any(), anyInt(), any());
|
||||
|
||||
mAnomalyDetectionJobService.saveAnomalyToDatabase(mContext,
|
||||
mUserManager, mBatteryDatabaseManager, mBatteryUtils, mPolicy,
|
||||
mPowerWhitelistBackend, mContext.getContentResolver(),
|
||||
mPowerAllowlistBackend, mContext.getContentResolver(),
|
||||
mFeatureFactory.powerUsageFeatureProvider,
|
||||
mFeatureFactory.metricsFeatureProvider, mBundle);
|
||||
|
||||
@@ -192,7 +190,7 @@ public class AnomalyDetectionJobServiceTest {
|
||||
|
||||
mAnomalyDetectionJobService.saveAnomalyToDatabase(mContext,
|
||||
mUserManager, mBatteryDatabaseManager, mBatteryUtils, mPolicy,
|
||||
mPowerWhitelistBackend, mContext.getContentResolver(),
|
||||
mPowerAllowlistBackend, mContext.getContentResolver(),
|
||||
mFeatureFactory.powerUsageFeatureProvider, mFeatureFactory.metricsFeatureProvider,
|
||||
mBundle);
|
||||
|
||||
@@ -207,7 +205,7 @@ public class AnomalyDetectionJobServiceTest {
|
||||
|
||||
mAnomalyDetectionJobService.saveAnomalyToDatabase(mContext,
|
||||
mUserManager, mBatteryDatabaseManager, mBatteryUtils, mPolicy,
|
||||
mPowerWhitelistBackend, mContext.getContentResolver(),
|
||||
mPowerAllowlistBackend, mContext.getContentResolver(),
|
||||
mFeatureFactory.powerUsageFeatureProvider, mFeatureFactory.metricsFeatureProvider,
|
||||
mBundle);
|
||||
|
||||
@@ -221,13 +219,13 @@ public class AnomalyDetectionJobServiceTest {
|
||||
cookies.add(SUBSCRIBER_COOKIES_AUTO_RESTRICTION);
|
||||
mBundle.putStringArrayList(StatsManager.EXTRA_STATS_BROADCAST_SUBSCRIBER_COOKIES, cookies);
|
||||
doReturn(SYSTEM_PACKAGE).when(mBatteryUtils).getPackageName(anyInt());
|
||||
doReturn(false).when(mPowerWhitelistBackend).isSysWhitelisted(SYSTEM_PACKAGE);
|
||||
doReturn(false).when(mPowerAllowlistBackend).isSysAllowlisted(SYSTEM_PACKAGE);
|
||||
doReturn(Process.FIRST_APPLICATION_UID).when(
|
||||
mAnomalyDetectionJobService).extractUidFromStatsDimensionsValue(any());
|
||||
|
||||
mAnomalyDetectionJobService.saveAnomalyToDatabase(mContext,
|
||||
mUserManager, mBatteryDatabaseManager, mBatteryUtils, mPolicy,
|
||||
mPowerWhitelistBackend, mContext.getContentResolver(),
|
||||
mPowerAllowlistBackend, mContext.getContentResolver(),
|
||||
mFeatureFactory.powerUsageFeatureProvider, mFeatureFactory.metricsFeatureProvider,
|
||||
mBundle);
|
||||
|
||||
@@ -246,13 +244,13 @@ public class AnomalyDetectionJobServiceTest {
|
||||
cookies.add(SUBSCRIBER_COOKIES_NOT_AUTO_RESTRICTION);
|
||||
mBundle.putStringArrayList(StatsManager.EXTRA_STATS_BROADCAST_SUBSCRIBER_COOKIES, cookies);
|
||||
doReturn(SYSTEM_PACKAGE).when(mBatteryUtils).getPackageName(anyInt());
|
||||
doReturn(false).when(mPowerWhitelistBackend).isSysWhitelisted(SYSTEM_PACKAGE);
|
||||
doReturn(false).when(mPowerAllowlistBackend).isSysAllowlisted(SYSTEM_PACKAGE);
|
||||
doReturn(Process.FIRST_APPLICATION_UID).when(
|
||||
mAnomalyDetectionJobService).extractUidFromStatsDimensionsValue(any());
|
||||
|
||||
mAnomalyDetectionJobService.saveAnomalyToDatabase(mContext,
|
||||
mUserManager, mBatteryDatabaseManager, mBatteryUtils, mPolicy,
|
||||
mPowerWhitelistBackend, mContext.getContentResolver(),
|
||||
mPowerAllowlistBackend, mContext.getContentResolver(),
|
||||
mFeatureFactory.powerUsageFeatureProvider, mFeatureFactory.metricsFeatureProvider,
|
||||
mBundle);
|
||||
|
||||
|
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.settings.testutils.shadow;
|
||||
|
||||
import com.android.settingslib.fuelgauge.PowerWhitelistBackend;
|
||||
|
||||
import org.robolectric.annotation.Implements;
|
||||
|
||||
@Implements(PowerWhitelistBackend.class)
|
||||
public class ShadowPowerWhitelistBackend {
|
||||
protected void __constructor__() {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user