Loading core/java/android/app/ActivityManager.java +34 −2 Original line number Diff line number Diff line Loading @@ -6257,6 +6257,29 @@ public class ActivityManager { * {@link #RESTRICTION_LEVEL_ADAPTIVE} is a normal state, where there is default lifecycle * management applied to the app. Also, {@link #RESTRICTION_LEVEL_EXEMPTED} is used when the * app is being put in a power-save allowlist. * <p> * Example arguments when user force-stops an app from Settings: * <pre> * noteAppRestrictionEnabled( * "com.example.app", * appUid, * RESTRICTION_LEVEL_FORCE_STOPPED, * true, * RESTRICTION_REASON_USER, * "settings", * 0); * </pre> * Example arguments when app is put in restricted standby bucket for exceeding X hours of jobs: * <pre> * noteAppRestrictionEnabled( * "com.example.app", * appUid, * RESTRICTION_LEVEL_RESTRICTED_BUCKET, * true, * RESTRICTION_REASON_SYSTEM_HEALTH, * "job_duration", * X * 3600 * 1000L); * </pre> * * @param packageName the package name of the app * @param uid the uid of the app Loading @@ -6264,11 +6287,20 @@ public class ActivityManager { * @param enabled whether the state is being applied or removed * @param reason the reason for the restriction state change, from {@code RestrictionReason} * @param subReason a string sub reason limited to 16 characters that specifies additional * information about the reason for restriction. * information about the reason for restriction. This string must only contain * reasons related to excessive system resource usage or in some cases, * source of the restriction. This string must not contain any details that * identify user behavior beyond their actions to restrict/unrestrict/launch * apps in some way. * Examples of system resource usage: wakelock, wakeups, mobile_data, * binder_calls, memory, excessive_threads, excessive_cpu, gps_scans, etc. * Examples of user actions: settings, notification, command_line, launch, etc. * * @param threshold for reasons that are due to exceeding some threshold, the threshold value * must be specified. The unit of the threshold depends on the reason and/or * subReason. For time, use milliseconds. For memory, use KB. For count, use * the actual count or normalized as per-hour. For power, use milliwatts. Etc. * the actual count or if rate limited, normalized per-hour. For power, * use milliwatts. For CPU, use mcycles. * * @hide */ Loading services/core/java/com/android/server/am/ActivityManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -20269,7 +20269,7 @@ public class ActivityManagerService extends IActivityManager.Stub final int userId = UserHandle.getCallingUserId(); final long callingId = Binder.clearCallingIdentity(); try { if (uid == -1) { if (uid == INVALID_UID) { uid = mPackageManagerInt.getPackageUid(packageName, 0, userId); } mAppRestrictionController.noteAppRestrictionEnabled(packageName, uid, restrictionType, services/core/java/com/android/server/am/AppRestrictionController.java +1 −1 Original line number Diff line number Diff line Loading @@ -2387,8 +2387,8 @@ public final class AppRestrictionController { // Limit the length of the free-form subReason string if (subReason != null && subReason.length() > RESTRICTION_SUBREASON_MAX_LENGTH) { Slog.e(TAG, "subReason is too long, truncating " + subReason); subReason = subReason.substring(0, RESTRICTION_SUBREASON_MAX_LENGTH); Slog.e(TAG, "Subreason is too long, truncating: " + subReason); } // Log the restriction reason Loading services/core/java/com/android/server/apphibernation/AppHibernationService.java +1 −5 Original line number Diff line number Diff line Loading @@ -572,12 +572,8 @@ public final class AppHibernationService extends SystemService { packageName, uid, ActivityManager.RESTRICTION_LEVEL_FORCE_STOPPED, true, ActivityManager.RESTRICTION_REASON_DORMANT, null, /* TODO: fetch actual timeout - 90 days */ 90 * 24 * 60 * 60_000L); } else { mIActivityManager.noteAppRestrictionEnabled( packageName, uid, ActivityManager.RESTRICTION_LEVEL_FORCE_STOPPED, false, ActivityManager.RESTRICTION_REASON_USAGE, null, 0L); } // No need to log the unhibernate case as an unstop is logged already in ActivityMS } catch (RemoteException e) { Slog.e(TAG, "Couldn't set restriction state change"); } Loading Loading
core/java/android/app/ActivityManager.java +34 −2 Original line number Diff line number Diff line Loading @@ -6257,6 +6257,29 @@ public class ActivityManager { * {@link #RESTRICTION_LEVEL_ADAPTIVE} is a normal state, where there is default lifecycle * management applied to the app. Also, {@link #RESTRICTION_LEVEL_EXEMPTED} is used when the * app is being put in a power-save allowlist. * <p> * Example arguments when user force-stops an app from Settings: * <pre> * noteAppRestrictionEnabled( * "com.example.app", * appUid, * RESTRICTION_LEVEL_FORCE_STOPPED, * true, * RESTRICTION_REASON_USER, * "settings", * 0); * </pre> * Example arguments when app is put in restricted standby bucket for exceeding X hours of jobs: * <pre> * noteAppRestrictionEnabled( * "com.example.app", * appUid, * RESTRICTION_LEVEL_RESTRICTED_BUCKET, * true, * RESTRICTION_REASON_SYSTEM_HEALTH, * "job_duration", * X * 3600 * 1000L); * </pre> * * @param packageName the package name of the app * @param uid the uid of the app Loading @@ -6264,11 +6287,20 @@ public class ActivityManager { * @param enabled whether the state is being applied or removed * @param reason the reason for the restriction state change, from {@code RestrictionReason} * @param subReason a string sub reason limited to 16 characters that specifies additional * information about the reason for restriction. * information about the reason for restriction. This string must only contain * reasons related to excessive system resource usage or in some cases, * source of the restriction. This string must not contain any details that * identify user behavior beyond their actions to restrict/unrestrict/launch * apps in some way. * Examples of system resource usage: wakelock, wakeups, mobile_data, * binder_calls, memory, excessive_threads, excessive_cpu, gps_scans, etc. * Examples of user actions: settings, notification, command_line, launch, etc. * * @param threshold for reasons that are due to exceeding some threshold, the threshold value * must be specified. The unit of the threshold depends on the reason and/or * subReason. For time, use milliseconds. For memory, use KB. For count, use * the actual count or normalized as per-hour. For power, use milliwatts. Etc. * the actual count or if rate limited, normalized per-hour. For power, * use milliwatts. For CPU, use mcycles. * * @hide */ Loading
services/core/java/com/android/server/am/ActivityManagerService.java +1 −1 Original line number Diff line number Diff line Loading @@ -20269,7 +20269,7 @@ public class ActivityManagerService extends IActivityManager.Stub final int userId = UserHandle.getCallingUserId(); final long callingId = Binder.clearCallingIdentity(); try { if (uid == -1) { if (uid == INVALID_UID) { uid = mPackageManagerInt.getPackageUid(packageName, 0, userId); } mAppRestrictionController.noteAppRestrictionEnabled(packageName, uid, restrictionType,
services/core/java/com/android/server/am/AppRestrictionController.java +1 −1 Original line number Diff line number Diff line Loading @@ -2387,8 +2387,8 @@ public final class AppRestrictionController { // Limit the length of the free-form subReason string if (subReason != null && subReason.length() > RESTRICTION_SUBREASON_MAX_LENGTH) { Slog.e(TAG, "subReason is too long, truncating " + subReason); subReason = subReason.substring(0, RESTRICTION_SUBREASON_MAX_LENGTH); Slog.e(TAG, "Subreason is too long, truncating: " + subReason); } // Log the restriction reason Loading
services/core/java/com/android/server/apphibernation/AppHibernationService.java +1 −5 Original line number Diff line number Diff line Loading @@ -572,12 +572,8 @@ public final class AppHibernationService extends SystemService { packageName, uid, ActivityManager.RESTRICTION_LEVEL_FORCE_STOPPED, true, ActivityManager.RESTRICTION_REASON_DORMANT, null, /* TODO: fetch actual timeout - 90 days */ 90 * 24 * 60 * 60_000L); } else { mIActivityManager.noteAppRestrictionEnabled( packageName, uid, ActivityManager.RESTRICTION_LEVEL_FORCE_STOPPED, false, ActivityManager.RESTRICTION_REASON_USAGE, null, 0L); } // No need to log the unhibernate case as an unstop is logged already in ActivityMS } catch (RemoteException e) { Slog.e(TAG, "Couldn't set restriction state change"); } Loading