Loading services/core/java/android/content/pm/PackageManagerInternal.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -1122,4 +1122,8 @@ public abstract class PackageManagerInternal { public abstract IncrementalStatesInfo getIncrementalStatesInfo(String packageName, public abstract IncrementalStatesInfo getIncrementalStatesInfo(String packageName, int filterCallingUid, int userId); int filterCallingUid, int userId); /** * Notifies that a package has crashed or ANR'd. */ public abstract void notifyPackageCrashOrAnr(String packageName); } } services/core/java/com/android/server/am/ActivityManagerService.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -7595,6 +7595,10 @@ public class ActivityManagerService extends IActivityManager.Stub eventType, r, processName, null, null, null, null, null, null, crashInfo); eventType, r, processName, null, null, null, null, null, null, crashInfo); mAppErrors.crashApplication(r, crashInfo); mAppErrors.crashApplication(r, crashInfo); // Notify package manager service to possibly update package state if (r != null && r.info != null && r.info.packageName != null) { mPackageManagerInt.notifyPackageCrashOrAnr(r.info.packageName); } } } public void handleApplicationStrictModeViolation( public void handleApplicationStrictModeViolation( Loading services/core/java/com/android/server/am/ProcessRecord.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -1764,6 +1764,12 @@ class ProcessRecord implements WindowProcessListener { makeAppNotRespondingLocked(activityShortComponentName, makeAppNotRespondingLocked(activityShortComponentName, annotation != null ? "ANR " + annotation : "ANR", info.toString()); annotation != null ? "ANR " + annotation : "ANR", info.toString()); // Notify package manager service to possibly update package state if (aInfo != null && aInfo.packageName != null) { mService.getPackageManagerInternalLocked().notifyPackageCrashOrAnr( aInfo.packageName); } // mUiHandler can be null if the AMS is constructed with injector only. This will only // mUiHandler can be null if the AMS is constructed with injector only. This will only // happen in tests. // happen in tests. if (mService.mUiHandler != null) { if (mService.mUiHandler != null) { Loading services/core/java/com/android/server/pm/IncrementalStates.java +27 −0 Original line number Original line Diff line number Diff line Loading @@ -119,6 +119,33 @@ public final class IncrementalStates { } } } } /** * Change the startable state if the app has crashed or ANR'd during loading. * If the app is not loading (i.e., fully loaded), this event doesn't change startable state. */ public void onCrashOrAnr() { if (DEBUG) { Slog.i(TAG, "received package crash or ANR event"); } final boolean startableStateChanged; synchronized (mLock) { if (mStartableState.isStartable() && mLoadingState.isLoading()) { // Changing from startable -> unstartable only if app is still loading. mStartableState.adoptNewStartableStateLocked(false); startableStateChanged = true; } else { // If the app is fully loaded, the crash or ANR is caused by the app itself, so // we do not change the startable state. startableStateChanged = false; } } if (startableStateChanged) { mHandler.post(PooledLambda.obtainRunnable( IncrementalStates::reportStartableState, IncrementalStates.this).recycleOnUse()); } } private void reportStartableState() { private void reportStartableState() { final Callback callback; final Callback callback; final boolean startable; final boolean startable; Loading services/core/java/com/android/server/pm/PackageManagerService.java +14 −0 Original line number Original line Diff line number Diff line Loading @@ -25843,6 +25843,20 @@ public class PackageManagerService extends IPackageManager.Stub } } return ps.getIncrementalStates(); return ps.getIncrementalStates(); } } @Override public void notifyPackageCrashOrAnr(@NonNull String packageName) { final PackageSetting ps; synchronized (mLock) { ps = mSettings.mPackages.get(packageName); if (ps == null) { Slog.w(TAG, "Failed notifyPackageCrash. Package " + packageName + " is not installed"); return; } } ps.setStatesOnCrashOrAnr(); } } } Loading
services/core/java/android/content/pm/PackageManagerInternal.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -1122,4 +1122,8 @@ public abstract class PackageManagerInternal { public abstract IncrementalStatesInfo getIncrementalStatesInfo(String packageName, public abstract IncrementalStatesInfo getIncrementalStatesInfo(String packageName, int filterCallingUid, int userId); int filterCallingUid, int userId); /** * Notifies that a package has crashed or ANR'd. */ public abstract void notifyPackageCrashOrAnr(String packageName); } }
services/core/java/com/android/server/am/ActivityManagerService.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -7595,6 +7595,10 @@ public class ActivityManagerService extends IActivityManager.Stub eventType, r, processName, null, null, null, null, null, null, crashInfo); eventType, r, processName, null, null, null, null, null, null, crashInfo); mAppErrors.crashApplication(r, crashInfo); mAppErrors.crashApplication(r, crashInfo); // Notify package manager service to possibly update package state if (r != null && r.info != null && r.info.packageName != null) { mPackageManagerInt.notifyPackageCrashOrAnr(r.info.packageName); } } } public void handleApplicationStrictModeViolation( public void handleApplicationStrictModeViolation( Loading
services/core/java/com/android/server/am/ProcessRecord.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -1764,6 +1764,12 @@ class ProcessRecord implements WindowProcessListener { makeAppNotRespondingLocked(activityShortComponentName, makeAppNotRespondingLocked(activityShortComponentName, annotation != null ? "ANR " + annotation : "ANR", info.toString()); annotation != null ? "ANR " + annotation : "ANR", info.toString()); // Notify package manager service to possibly update package state if (aInfo != null && aInfo.packageName != null) { mService.getPackageManagerInternalLocked().notifyPackageCrashOrAnr( aInfo.packageName); } // mUiHandler can be null if the AMS is constructed with injector only. This will only // mUiHandler can be null if the AMS is constructed with injector only. This will only // happen in tests. // happen in tests. if (mService.mUiHandler != null) { if (mService.mUiHandler != null) { Loading
services/core/java/com/android/server/pm/IncrementalStates.java +27 −0 Original line number Original line Diff line number Diff line Loading @@ -119,6 +119,33 @@ public final class IncrementalStates { } } } } /** * Change the startable state if the app has crashed or ANR'd during loading. * If the app is not loading (i.e., fully loaded), this event doesn't change startable state. */ public void onCrashOrAnr() { if (DEBUG) { Slog.i(TAG, "received package crash or ANR event"); } final boolean startableStateChanged; synchronized (mLock) { if (mStartableState.isStartable() && mLoadingState.isLoading()) { // Changing from startable -> unstartable only if app is still loading. mStartableState.adoptNewStartableStateLocked(false); startableStateChanged = true; } else { // If the app is fully loaded, the crash or ANR is caused by the app itself, so // we do not change the startable state. startableStateChanged = false; } } if (startableStateChanged) { mHandler.post(PooledLambda.obtainRunnable( IncrementalStates::reportStartableState, IncrementalStates.this).recycleOnUse()); } } private void reportStartableState() { private void reportStartableState() { final Callback callback; final Callback callback; final boolean startable; final boolean startable; Loading
services/core/java/com/android/server/pm/PackageManagerService.java +14 −0 Original line number Original line Diff line number Diff line Loading @@ -25843,6 +25843,20 @@ public class PackageManagerService extends IPackageManager.Stub } } return ps.getIncrementalStates(); return ps.getIncrementalStates(); } } @Override public void notifyPackageCrashOrAnr(@NonNull String packageName) { final PackageSetting ps; synchronized (mLock) { ps = mSettings.mPackages.get(packageName); if (ps == null) { Slog.w(TAG, "Failed notifyPackageCrash. Package " + packageName + " is not installed"); return; } } ps.setStatesOnCrashOrAnr(); } } }