From 008a660443a34948c507218f33b129cd922518dd Mon Sep 17 00:00:00 2001 From: Svet Ganov Date: Sat, 29 Oct 2022 22:18:00 -0700 Subject: [PATCH] AppOpsService: Don't log stack traces for isolated processes AppOpsService logs a stack trace if the package and the UID of the call don't match, which includes a stack trace. Since an isolated process is running under UID that is different from that of the app, it is expected that the package and the UID don't match - this is by design. In this case, a stack trace is not helpful and spams the logs. Therefore, for isolated processes we log a short message. Test: isloated process logs have no stack trace Upstream from Meta Change-Id: Ife7bff103c3a4d1823de92461248451ff313de0e --- .../android/server/appop/AppOpsService.java | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/appop/AppOpsService.java b/services/core/java/com/android/server/appop/AppOpsService.java index b56654fd7b9a2..d190c918df057 100644 --- a/services/core/java/com/android/server/appop/AppOpsService.java +++ b/services/core/java/com/android/server/appop/AppOpsService.java @@ -2795,7 +2795,11 @@ public class AppOpsService extends IAppOpsService.Stub { try { pvr = verifyAndGetBypass(uid, packageName, null); } catch (SecurityException e) { - Slog.e(TAG, "Cannot setMode", e); + if (Process.isIsolated(uid)) { + Slog.e(TAG, "Cannot setMode: isolated process"); + } else { + Slog.e(TAG, "Cannot setMode", e); + } return; } @@ -3250,7 +3254,11 @@ public class AppOpsService extends IAppOpsService.Stub { try { pvr = verifyAndGetBypass(uid, packageName, null); } catch (SecurityException e) { - Slog.e(TAG, "checkOperation", e); + if (Process.isIsolated(uid)) { + Slog.e(TAG, "Cannot checkOperation: isolated process"); + } else { + Slog.e(TAG, "Cannot checkOperation", e); + } return AppOpsManager.opToDefaultMode(code); } @@ -3456,7 +3464,11 @@ public class AppOpsService extends IAppOpsService.Stub { attributionTag = null; } } catch (SecurityException e) { - Slog.e(TAG, "noteOperation", e); + if (Process.isIsolated(uid)) { + Slog.e(TAG, "Cannot noteOperation: isolated process"); + } else { + Slog.e(TAG, "Cannot noteOperation", e); + } return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag, packageName); } @@ -3972,7 +3984,11 @@ public class AppOpsService extends IAppOpsService.Stub { attributionTag = null; } } catch (SecurityException e) { - Slog.e(TAG, "startOperation", e); + if (Process.isIsolated(uid)) { + Slog.e(TAG, "Cannot startOperation: isolated process"); + } else { + Slog.e(TAG, "Cannot startOperation", e); + } return new SyncNotedAppOp(AppOpsManager.MODE_ERRORED, code, attributionTag, packageName); } @@ -4146,7 +4162,11 @@ public class AppOpsService extends IAppOpsService.Stub { attributionTag = null; } } catch (SecurityException e) { - Slog.e(TAG, "Cannot finishOperation", e); + if (Process.isIsolated(uid)) { + Slog.e(TAG, "Cannot finishOperation: isolated process"); + } else { + Slog.e(TAG, "Cannot finishOperation", e); + } return; }