Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 83c6bc5d authored by Jing Ji's avatar Jing Ji
Browse files

Add API to allow app to report ANR by its own

Bug: 140025078
Test: atest CtsAppTestCases:ActivityManagerTest#testAppNotResponding
Change-Id: Iaa57057b18a41a2f934d709b88790625ffcf5478
parent e97bfe48
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3954,6 +3954,7 @@ package android.app {
  public class ActivityManager {
    method public int addAppTask(@NonNull android.app.Activity, @NonNull android.content.Intent, @Nullable android.app.ActivityManager.TaskDescription, @NonNull android.graphics.Bitmap);
    method public void appNotResponding(@NonNull String);
    method public boolean clearApplicationUserData();
    method public void clearWatchHeapLimit();
    method @RequiresPermission(android.Manifest.permission.DUMP) public void dumpPackageState(java.io.FileDescriptor, String);
+13 −0
Original line number Diff line number Diff line
@@ -4547,4 +4547,17 @@ public class ActivityManager {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Method for the app to tell system that it's wedged and would like to trigger an ANR.
     *
     * @param reason The description of that what happened
     */
    public void appNotResponding(@NonNull final String reason) {
        try {
            getService().appNotResponding(reason);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -583,4 +583,9 @@ interface IActivityManager {
     * unlockProgressListener can be null if monitoring progress is not necessary.
     */
    boolean startUserInForegroundWithListener(int userid, IProgressListener unlockProgressListener);

    /**
     * Method for the app to tell system that it's wedged and would like to trigger an ANR.
     */
    void appNotResponding(String reason);
}
+20 −0
Original line number Diff line number Diff line
@@ -7558,6 +7558,26 @@ public class ActivityManagerService extends IActivityManager.Stub
        });
    }
    @Override
    public void appNotResponding(final String reason) {
        final int callingPid = Binder.getCallingPid();
        synchronized (mPidsSelfLocked) {
            final ProcessRecord app = mPidsSelfLocked.get(callingPid);
            if (app == null) {
                throw new SecurityException("Unknown process: " + callingPid);
            }
            mHandler.post(new Runnable() {
                @Override
                public void run() {
                    app.appNotResponding(
                            null, app.info, null, null, false, "App requested: " + reason);
                }
            });
        }
    }
    public final void installSystemProviders() {
        List<ProviderInfo> providers;
        synchronized (this) {