summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kweku Adams <kwekua@google.com> 2021-05-06 15:21:05 -0700
committer Kweku Adams <kwekua@google.com> 2021-05-06 15:21:05 -0700
commit3901c1be65a97ecc54ef9ac0ac8c16c25adcaafc (patch)
tree3799390f224b26002295026393f615cf3cd2b872
parent0214d012f6f0c06e6297d676fc02620c059dd12a (diff)
Put bad apps in the RESTRICTED bucket.
Put an app in the RESTRICTED bucket if it's crashed enough to be marked bad. Bug: 183103253 Test: manual (consistently crash an app via 'adb shell am crash <pkg>' in intervals larger than MIN_CRASH_INTERVAL until the limit is reached and check 'dumpsys activity usage' to ensure lastRestrictAttempt and lastRestrictReason are both set for the app Change-Id: Ie8c36075573efcb4f63bf6f8d836f2edb3bb27cd
-rw-r--r--services/core/java/com/android/server/am/AppErrors.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/am/AppErrors.java b/services/core/java/com/android/server/am/AppErrors.java
index 5a59eabde6f0..bcb42bb38495 100644
--- a/services/core/java/com/android/server/am/AppErrors.java
+++ b/services/core/java/com/android/server/am/AppErrors.java
@@ -32,6 +32,7 @@ import android.app.ActivityOptions;
import android.app.AnrController;
import android.app.ApplicationErrorReport;
import android.app.ApplicationExitInfo;
+import android.app.usage.UsageStatsManager;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
@@ -57,7 +58,9 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.app.ProcessMap;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto;
+import com.android.server.LocalServices;
import com.android.server.PackageWatchdog;
+import com.android.server.usage.AppStandbyInternal;
import com.android.server.wm.WindowProcessController;
import java.io.FileDescriptor;
@@ -885,6 +888,16 @@ class AppErrors {
}
errState.setBad(true);
app.setRemoved(true);
+ final AppStandbyInternal appStandbyInternal =
+ LocalServices.getService(AppStandbyInternal.class);
+ if (appStandbyInternal != null) {
+ appStandbyInternal.restrictApp(
+ // Sometimes the processName is the same as the package name, so use
+ // that if we don't have the ApplicationInfo object.
+ // AppStandbyController will just return if it can't find the app.
+ app.info != null ? app.info.packageName : processName,
+ userId, UsageStatsManager.REASON_SUB_FORCED_SYSTEM_FLAG_BUGGY);
+ }
// Don't let services in this process be restarted and potentially
// annoy the user repeatedly. Unless it is persistent, since those
// processes run critical code.