Support test skipping when power save modes aren't enabled.
Some classes of devices will not have auto power save modes enabled. On those devices, we should skip tests that require the modes be enabled. Bug: 240108412 Bug: 240630396 Test: Manually go through CTS-V "Ignore Battery Optimizations Test" Test: atest CtsUsageStatsTestCases:UsageStatsTest Change-Id: Icc64fbe75213386a1f41fae258e50c4032920b0a
This commit is contained in:
@@ -1543,8 +1543,10 @@ public class AppStandbyController
|
|||||||
@Override
|
@Override
|
||||||
@StandbyBuckets public int getAppStandbyBucket(String packageName, int userId,
|
@StandbyBuckets public int getAppStandbyBucket(String packageName, int userId,
|
||||||
long elapsedRealtime, boolean shouldObfuscateInstantApps) {
|
long elapsedRealtime, boolean shouldObfuscateInstantApps) {
|
||||||
if (!mAppIdleEnabled || (shouldObfuscateInstantApps
|
if (!mAppIdleEnabled) {
|
||||||
&& mInjector.isPackageEphemeral(userId, packageName))) {
|
return STANDBY_BUCKET_EXEMPTED;
|
||||||
|
}
|
||||||
|
if (shouldObfuscateInstantApps && mInjector.isPackageEphemeral(userId, packageName)) {
|
||||||
return STANDBY_BUCKET_ACTIVE;
|
return STANDBY_BUCKET_ACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -670,6 +670,7 @@ package android.app.usage {
|
|||||||
|
|
||||||
public final class UsageStatsManager {
|
public final class UsageStatsManager {
|
||||||
method public void forceUsageSourceSettingRead();
|
method public void forceUsageSourceSettingRead();
|
||||||
|
method public boolean isAppStandbyEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1795,6 +1796,7 @@ package android.os {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final class PowerManager {
|
public final class PowerManager {
|
||||||
|
method public boolean areAutoPowerSaveModesEnabled();
|
||||||
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_LOW_POWER_STANDBY, android.Manifest.permission.DEVICE_POWER}) public void forceLowPowerStandbyActive(boolean);
|
method @RequiresPermission(anyOf={android.Manifest.permission.MANAGE_LOW_POWER_STANDBY, android.Manifest.permission.DEVICE_POWER}) public void forceLowPowerStandbyActive(boolean);
|
||||||
field public static final String ACTION_ENHANCED_DISCHARGE_PREDICTION_CHANGED = "android.os.action.ENHANCED_DISCHARGE_PREDICTION_CHANGED";
|
field public static final String ACTION_ENHANCED_DISCHARGE_PREDICTION_CHANGED = "android.os.action.ENHANCED_DISCHARGE_PREDICTION_CHANGED";
|
||||||
field @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public static final int SYSTEM_WAKELOCK = -2147483648; // 0x80000000
|
field @RequiresPermission(android.Manifest.permission.DEVICE_POWER) public static final int SYSTEM_WAKELOCK = -2147483648; // 0x80000000
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ interface IUsageStatsManager {
|
|||||||
UsageEvents queryEventsForPackageForUser(long beginTime, long endTime, int userId, String pkg, String callingPackage);
|
UsageEvents queryEventsForPackageForUser(long beginTime, long endTime, int userId, String pkg, String callingPackage);
|
||||||
@UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
|
@UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
|
||||||
void setAppInactive(String packageName, boolean inactive, int userId);
|
void setAppInactive(String packageName, boolean inactive, int userId);
|
||||||
|
boolean isAppStandbyEnabled();
|
||||||
@UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
|
@UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
|
||||||
boolean isAppInactive(String packageName, int userId, String callingPackage);
|
boolean isAppInactive(String packageName, int userId, String callingPackage);
|
||||||
void onCarrierPrivilegedAppsChanged();
|
void onCarrierPrivilegedAppsChanged();
|
||||||
|
|||||||
@@ -641,6 +641,19 @@ public final class UsageStatsManager {
|
|||||||
return aggregatedStats;
|
return aggregatedStats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the app standby bucket feature is enabled.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@TestApi
|
||||||
|
public boolean isAppStandbyEnabled() {
|
||||||
|
try {
|
||||||
|
return mService.isAppStandbyEnabled();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the specified app is currently considered inactive. This will be true if the
|
* Returns whether the specified app is currently considered inactive. This will be true if the
|
||||||
* app hasn't been used directly or indirectly for a period of time defined by the system. This
|
* app hasn't been used directly or indirectly for a period of time defined by the system. This
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ interface IPowerManager
|
|||||||
float getBrightnessConstraint(int constraint);
|
float getBrightnessConstraint(int constraint);
|
||||||
@UnsupportedAppUsage
|
@UnsupportedAppUsage
|
||||||
boolean isInteractive();
|
boolean isInteractive();
|
||||||
|
boolean areAutoPowerSaveModesEnabled();
|
||||||
boolean isPowerSaveMode();
|
boolean isPowerSaveMode();
|
||||||
PowerSaveState getPowerSaveState(int serviceType);
|
PowerSaveState getPowerSaveState(int serviceType);
|
||||||
boolean setPowerSaveModeEnabled(boolean mode);
|
boolean setPowerSaveModeEnabled(boolean mode);
|
||||||
|
|||||||
@@ -1809,6 +1809,21 @@ public final class PowerManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the platform has auto power save modes (eg. Doze & app standby) enabled.
|
||||||
|
* This doesn't necessarily mean that the individual features are enabled. For example, if this
|
||||||
|
* returns true, Doze might be enabled while app standby buckets remain disabled.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@TestApi
|
||||||
|
public boolean areAutoPowerSaveModesEnabled() {
|
||||||
|
try {
|
||||||
|
return mService.areAutoPowerSaveModesEnabled();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
throw e.rethrowFromSystemServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the device is currently in power save mode. When in this mode,
|
* Returns true if the device is currently in power save mode. When in this mode,
|
||||||
* applications should reduce their functionality in order to conserve battery as
|
* applications should reduce their functionality in order to conserve battery as
|
||||||
|
|||||||
@@ -5787,6 +5787,17 @@ public final class PowerManagerService extends SystemService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override // Binder call
|
||||||
|
public boolean areAutoPowerSaveModesEnabled() {
|
||||||
|
final long ident = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
return mContext.getResources().getBoolean(
|
||||||
|
com.android.internal.R.bool.config_enableAutoPowerModes);
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(ident);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override // Binder call
|
@Override // Binder call
|
||||||
public boolean isPowerSaveMode() {
|
public boolean isPowerSaveMode() {
|
||||||
final long ident = Binder.clearCallingIdentity();
|
final long ident = Binder.clearCallingIdentity();
|
||||||
|
|||||||
@@ -2288,6 +2288,11 @@ public class UsageStatsService extends SystemService implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAppStandbyEnabled() {
|
||||||
|
return mAppStandby.isAppIdleEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAppInactive(String packageName, int userId, String callingPackage) {
|
public boolean isAppInactive(String packageName, int userId, String callingPackage) {
|
||||||
final int callingUid = Binder.getCallingUid();
|
final int callingUid = Binder.getCallingUid();
|
||||||
|
|||||||
Reference in New Issue
Block a user