Merge "Nuanced Uri handling related to WM/AM locking." into rvc-dev am: de5b073b05

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12010084

Change-Id: I16d237eb3f1d4c458e2de915da1e3c9eda841515
This commit is contained in:
TreeHugger Robot
2020-06-26 19:39:46 +00:00
committed by Automerger Merge Worker
2 changed files with 9 additions and 6 deletions

View File

@@ -8086,6 +8086,12 @@ public class ActivityManagerService extends IActivityManager.Stub
}
int checkContentProviderUriPermission(Uri uri, int userId, int callingUid, int modeFlags) {
if (Thread.holdsLock(mActivityTaskManager.getGlobalLock())) {
Slog.wtf(TAG, new IllegalStateException("Unable to check Uri permission"
+ " because caller is holding WM lock; assuming permission denied"));
return PackageManager.PERMISSION_DENIED;
}
final String name = uri.getAuthority();
final long ident = Binder.clearCallingIdentity();
ContentProviderHolder holder = null;

View File

@@ -640,13 +640,10 @@ class ActivityStarter {
}
// If the caller hasn't already resolved the activity, we're willing
// to do so here, but because that may require acquiring the AM lock
// as part of calculating the NeededUriGrants, we must never hold
// the WM lock here to avoid deadlocking.
// to do so here. If the caller is already holding the WM lock here,
// and we need to check dynamic Uri permissions, then we're forced
// to assume those permissions are denied to avoid deadlocking.
if (mRequest.activityInfo == null) {
if (Thread.holdsLock(mService.mGlobalLock)) {
Slog.wtf(TAG, new IllegalStateException("Caller must not hold WM lock"));
}
mRequest.resolveActivity(mSupervisor);
}