diff options
| author | 2023-06-30 17:40:19 +0000 | |
|---|---|---|
| committer | 2023-06-30 17:40:19 +0000 | |
| commit | d3deb1ca5dc41dca8036fee44b5b9d03b8b86471 (patch) | |
| tree | 750078537a942d6f0082ba391a974cad679a2ed9 | |
| parent | 58b60a30afd5400a314493f0e7d7b3533bb6cc5e (diff) | |
| parent | e55d075b374491e276cc792710645f5891fa0f9a (diff) | |
Merge "Support test skipping when power save modes aren't enabled." am: 57538e6b92 am: e55d075b37
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2635501
Change-Id: Ie2c62755ad6f7fb9487554e367706b4a2bf41bc7
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
8 files changed, 52 insertions, 2 deletions
diff --git a/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java b/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java index b27ff411dd58..c46b24e8dfe8 100644 --- a/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java +++ b/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java @@ -1565,8 +1565,10 @@ public class AppStandbyController @Override @StandbyBuckets public int getAppStandbyBucket(String packageName, int userId, long elapsedRealtime, boolean shouldObfuscateInstantApps) { - if (!mAppIdleEnabled || (shouldObfuscateInstantApps - && mInjector.isPackageEphemeral(userId, packageName))) { + if (!mAppIdleEnabled) { + return STANDBY_BUCKET_EXEMPTED; + } + if (shouldObfuscateInstantApps && mInjector.isPackageEphemeral(userId, packageName)) { return STANDBY_BUCKET_ACTIVE; } diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 04b48ceadf96..83bbf324162b 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -683,6 +683,7 @@ package android.app.usage { public final class UsageStatsManager { method public void forceUsageSourceSettingRead(); + method public boolean isAppStandbyEnabled(); } } @@ -1834,6 +1835,7 @@ package android.os { } 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); 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 diff --git a/core/java/android/app/usage/IUsageStatsManager.aidl b/core/java/android/app/usage/IUsageStatsManager.aidl index d4fbdc6850a4..dc173132a58d 100644 --- a/core/java/android/app/usage/IUsageStatsManager.aidl +++ b/core/java/android/app/usage/IUsageStatsManager.aidl @@ -44,6 +44,7 @@ interface IUsageStatsManager { UsageEvents queryEventsForPackageForUser(long beginTime, long endTime, int userId, String pkg, String callingPackage); @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) void setAppInactive(String packageName, boolean inactive, int userId); + boolean isAppStandbyEnabled(); @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553) boolean isAppInactive(String packageName, int userId, String callingPackage); void onCarrierPrivilegedAppsChanged(); diff --git a/core/java/android/app/usage/UsageStatsManager.java b/core/java/android/app/usage/UsageStatsManager.java index 1dfc7d48640e..4b0ca2826656 100644 --- a/core/java/android/app/usage/UsageStatsManager.java +++ b/core/java/android/app/usage/UsageStatsManager.java @@ -642,6 +642,19 @@ public final class UsageStatsManager { } /** + * 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 * app hasn't been used directly or indirectly for a period of time defined by the system. This * could be of the order of several hours or days. Apps are not considered inactive when the diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl index 4fe6524dee27..f1e3ab07686b 100644 --- a/core/java/android/os/IPowerManager.aidl +++ b/core/java/android/os/IPowerManager.aidl @@ -53,6 +53,7 @@ interface IPowerManager float getBrightnessConstraint(int constraint); @UnsupportedAppUsage boolean isInteractive(); + boolean areAutoPowerSaveModesEnabled(); boolean isPowerSaveMode(); PowerSaveState getPowerSaveState(int serviceType); boolean setPowerSaveModeEnabled(boolean mode); diff --git a/core/java/android/os/PowerManager.java b/core/java/android/os/PowerManager.java index 132bd667f6db..aa733b5c6d49 100644 --- a/core/java/android/os/PowerManager.java +++ b/core/java/android/os/PowerManager.java @@ -1866,6 +1866,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, * applications should reduce their functionality in order to conserve battery as * much as possible. You can monitor for changes to this state with diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java index 6fb7af1a3610..9e0d9c6a3240 100644 --- a/services/core/java/com/android/server/power/PowerManagerService.java +++ b/services/core/java/com/android/server/power/PowerManagerService.java @@ -5825,6 +5825,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 public boolean isPowerSaveMode() { final long ident = Binder.clearCallingIdentity(); try { diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java index 3d34f0509bf7..2d27a09a9e64 100644 --- a/services/usage/java/com/android/server/usage/UsageStatsService.java +++ b/services/usage/java/com/android/server/usage/UsageStatsService.java @@ -2289,6 +2289,11 @@ public class UsageStatsService extends SystemService implements } @Override + public boolean isAppStandbyEnabled() { + return mAppStandby.isAppIdleEnabled(); + } + + @Override public boolean isAppInactive(String packageName, int userId, String callingPackage) { final int callingUid = Binder.getCallingUid(); try { |