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

Commit a3029f02 authored by Hai Zhang's avatar Hai Zhang Committed by Android (Google) Code Review
Browse files

Merge "Don't log stacktrace for non-application UIDs mismatch in AppOpsService." into main

parents 08e49e6b 6b72e9db
Loading
Loading
Loading
Loading
+16 −25
Original line number Diff line number Diff line
@@ -2124,11 +2124,7 @@ public class AppOpsService extends IAppOpsService.Stub {
        try {
            pvr = verifyAndGetBypass(uid, packageName, null);
        } catch (SecurityException e) {
            if (Process.isIsolated(uid)) {
                Slog.e(TAG, "Cannot setMode: isolated process");
            } else {
                Slog.e(TAG, "Cannot setMode", e);
            }
            logVerifyAndGetBypassFailure(uid, e, "setMode");
            return;
        }

@@ -2580,11 +2576,7 @@ public class AppOpsService extends IAppOpsService.Stub {
        try {
            pvr = verifyAndGetBypass(uid, packageName, null);
        } catch (SecurityException e) {
            if (Process.isIsolated(uid)) {
                Slog.e(TAG, "Cannot checkOperation: isolated process");
            } else {
                Slog.e(TAG, "Cannot checkOperation", e);
            }
            logVerifyAndGetBypassFailure(uid, e, "checkOperation");
            return AppOpsManager.opToDefaultMode(code);
        }

@@ -2796,11 +2788,7 @@ public class AppOpsService extends IAppOpsService.Stub {
                attributionTag = null;
            }
        } catch (SecurityException e) {
            if (Process.isIsolated(uid)) {
                Slog.e(TAG, "Cannot noteOperation: isolated process");
            } else {
                Slog.e(TAG, "Cannot noteOperation", e);
            }
            logVerifyAndGetBypassFailure(uid, e, "noteOperation");
            return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
                    packageName);
        }
@@ -3333,11 +3321,7 @@ public class AppOpsService extends IAppOpsService.Stub {
                attributionTag = null;
            }
        } catch (SecurityException e) {
            if (Process.isIsolated(uid)) {
                Slog.e(TAG, "Cannot startOperation: isolated process");
            } else {
                Slog.e(TAG, "Cannot startOperation", e);
            }
            logVerifyAndGetBypassFailure(uid, e, "startOperation");
            return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag,
                    packageName);
        }
@@ -3513,11 +3497,7 @@ public class AppOpsService extends IAppOpsService.Stub {
                attributionTag = null;
            }
        } catch (SecurityException e) {
            if (Process.isIsolated(uid)) {
                Slog.e(TAG, "Cannot finishOperation: isolated process");
            } else {
                Slog.e(TAG, "Cannot finishOperation", e);
            }
            logVerifyAndGetBypassFailure(uid, e, "finishOperation");
            return;
        }

@@ -4073,6 +4053,17 @@ public class AppOpsService extends IAppOpsService.Stub {
        return false;
    }

    private void logVerifyAndGetBypassFailure(int uid, @NonNull SecurityException e,
            @NonNull String methodName) {
        if (Process.isIsolated(uid)) {
            Slog.e(TAG, "Cannot " + methodName + ": isolated UID");
        } else if (UserHandle.getAppId(uid) < Process.FIRST_APPLICATION_UID) {
            Slog.e(TAG, "Cannot " + methodName + ": non-application UID " + uid);
        } else {
            Slog.e(TAG, "Cannot " + methodName, e);
        }
    }

    /**
     * Get (and potentially create) ops.
     *