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
This commit is contained in:
Svet Ganov
2022-10-29 22:18:00 -07:00
parent 9e7649d5e7
commit 008a660443

View File

@@ -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;
}