Don't warn finishing ops for gone packages
We finish ops when packages get removed to guarantee no dangling
started ops. However, some part of the system may asynchronously
finish ops for an already gone package. Hence, finishing an op
for a non existing package is fine and we don't log as a wtf.
Test: manual
bug:75436227
Change-Id: I33156d3f999f671ea65a70b485dac8afd4639b42
diff --git a/services/core/java/com/android/server/AppOpsService.java b/services/core/java/com/android/server/AppOpsService.java
index 9756d17..a2f676b 100644
--- a/services/core/java/com/android/server/AppOpsService.java
+++ b/services/core/java/com/android/server/AppOpsService.java
@@ -1346,8 +1346,24 @@
return;
}
if (!client.mStartedOps.remove(op)) {
- Slog.wtf(TAG, "Operation not started: uid" + op.uid
- + " pkg=" + op.packageName + " op=" + op.op);
+ // We finish ops when packages get removed to guarantee no dangling
+ // started ops. However, some part of the system may asynchronously
+ // finish ops for an already gone package. Hence, finishing an op
+ // for a non existing package is fine and we don't log as a wtf.
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ if (LocalServices.getService(PackageManagerInternal.class).getPackageUid(
+ resolvedPackageName, 0, UserHandle.getUserId(uid)) < 0) {
+ Slog.i(TAG, "Finishing op=" + AppOpsManager.opToName(code)
+ + " for non-existing package=" + resolvedPackageName
+ + " in uid=" + uid);
+ return;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ Slog.wtf(TAG, "Operation not started: uid=" + op.uid + " pkg="
+ + op.packageName + " op=" + AppOpsManager.opToName(op.op));
return;
}
finishOperationLocked(op, /*finishNested*/ false);