Change BatteryUtils.isLegacyApp() to isPreOApp()
Bug: 73792442 Test: RunSettingsRoboTests make -j40 RunSettingsRoboTests Change-Id: I770030a8f38ec6156aa2a40f4c88ac9e0673751d
This commit is contained in:
@@ -397,7 +397,7 @@ public class BatteryUtils {
|
|||||||
|
|
||||||
public void setForceAppStandby(int uid, String packageName,
|
public void setForceAppStandby(int uid, String packageName,
|
||||||
int mode) {
|
int mode) {
|
||||||
final boolean isPreOApp = isLegacyApp(packageName);
|
final boolean isPreOApp = isPreOApp(packageName);
|
||||||
if (isPreOApp) {
|
if (isPreOApp) {
|
||||||
// Control whether app could run in the background if it is pre O app
|
// Control whether app could run in the background if it is pre O app
|
||||||
mAppOpsManager.setMode(AppOpsManager.OP_RUN_IN_BACKGROUND, uid, packageName, mode);
|
mAppOpsManager.setMode(AppOpsManager.OP_RUN_IN_BACKGROUND, uid, packageName, mode);
|
||||||
@@ -483,7 +483,7 @@ public class BatteryUtils {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLegacyApp(final String packageName) {
|
public boolean isPreOApp(final String packageName) {
|
||||||
try {
|
try {
|
||||||
ApplicationInfo info = mPackageManager.getApplicationInfo(packageName,
|
ApplicationInfo info = mPackageManager.getApplicationInfo(packageName,
|
||||||
PackageManager.GET_META_DATA);
|
PackageManager.GET_META_DATA);
|
||||||
|
@@ -127,7 +127,7 @@ public class AnomalyDetectionJobService extends JobService {
|
|||||||
&& !isSystemUid(uid)) {
|
&& !isSystemUid(uid)) {
|
||||||
if (anomalyType == StatsManagerConfig.AnomalyType.EXCESSIVE_BG) {
|
if (anomalyType == StatsManagerConfig.AnomalyType.EXCESSIVE_BG) {
|
||||||
// TODO(b/72385333): check battery percentage draining in batterystats
|
// TODO(b/72385333): check battery percentage draining in batterystats
|
||||||
if (batteryUtils.isLegacyApp(packageName) && batteryUtils.isAppHeavilyUsed(
|
if (batteryUtils.isPreOApp(packageName) && batteryUtils.isAppHeavilyUsed(
|
||||||
batteryStatsHelper, userManager, uid,
|
batteryStatsHelper, userManager, uid,
|
||||||
policy.excessiveBgDrainPercentage)) {
|
policy.excessiveBgDrainPercentage)) {
|
||||||
Log.e(TAG, "Excessive detected uid=" + uid);
|
Log.e(TAG, "Excessive detected uid=" + uid);
|
||||||
|
@@ -516,12 +516,12 @@ public class BatteryUtilsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsLegacyApp_SdkLowerThanO_ReturnTrue() {
|
public void testIsLegacyApp_SdkLowerThanO_ReturnTrue() {
|
||||||
assertThat(mBatteryUtils.isLegacyApp(LOW_SDK_PACKAGE)).isTrue();
|
assertThat(mBatteryUtils.isPreOApp(LOW_SDK_PACKAGE)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIsLegacyApp_SdkLargerOrEqualThanO_ReturnFalse() {
|
public void testIsLegacyApp_SdkLargerOrEqualThanO_ReturnFalse() {
|
||||||
assertThat(mBatteryUtils.isLegacyApp(HIGH_SDK_PACKAGE)).isFalse();
|
assertThat(mBatteryUtils.isPreOApp(HIGH_SDK_PACKAGE)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Reference in New Issue
Block a user