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

Commit 63ae4a40 authored by Jing Ji's avatar Jing Ji
Browse files

Return the ProcessErrorStateInfo records for the caller's UID only

For regular apps, the ActivityManager.getProcessesInErrorState()
will only return ProcessErrorStateInfo records for the processes
running as the caller's uid, unless the caller has the DUMP permission

Bug: 191058227
Test: atest CtsAppTestCases:ActivityManagerTest
Test: Manual - b/191058227#comment4
Change-Id: I1c5b80b00a9380849ed874e4febe49ee9a51e1f1
parent b9dc2f95
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -2835,7 +2835,12 @@ public class ActivityManager {
     * Returns a list of any processes that are currently in an error condition.  The result
     * will be null if all processes are running properly at this time.
     *
     * @return Returns a list of ProcessErrorStateInfo records, or null if there are no
     * <p>As of {@link android.os.Build.VERSION_CODES#T Android T}, for regular apps this method
     * will only return {@link ProcessErrorStateInfo} records for the processes running as the
     * caller's uid, unless the caller has the permission {@link android.Manifest.permission#DUMP}.
     * </p>
     *
     * @return Returns a list of {@link ProcessErrorStateInfo} records, or null if there are no
     * current error conditions (it will not return an empty list).  This list ordering is not
     * specified.
     */
+9 −2
Original line number Diff line number Diff line
@@ -8396,9 +8396,13 @@ public class ActivityManagerService extends IActivityManager.Stub
        // assume our apps are happy - lazy create the list
        final List<ActivityManager.ProcessErrorStateInfo>[] errList = new List[1];
        final int callingUid = Binder.getCallingUid();
        final boolean allUsers = ActivityManager.checkUidPermission(INTERACT_ACROSS_USERS_FULL,
                Binder.getCallingUid()) == PackageManager.PERMISSION_GRANTED;
        int userId = UserHandle.getUserId(Binder.getCallingUid());
                callingUid) == PackageManager.PERMISSION_GRANTED;
        int userId = UserHandle.getUserId(callingUid);
        final boolean hasDumpPermission = ActivityManager.checkUidPermission(
                android.Manifest.permission.DUMP, callingUid) == PackageManager.PERMISSION_GRANTED;
        synchronized (mProcLock) {
            // iterate across all processes
@@ -8406,6 +8410,9 @@ public class ActivityManagerService extends IActivityManager.Stub
                if (!allUsers && app.userId != userId) {
                    return;
                }
                if (!hasDumpPermission && app.info.uid != callingUid) {
                    return;
                }
                final ProcessErrorStateRecord errState = app.mErrorState;
                final boolean crashing = errState.isCrashing();
                final boolean notResponding = errState.isNotResponding();