Merge changes from topic "presubmit-am-cb3c43babe4c45069e5619a744950e15" into sc-qpr1-dev

* changes:
  [automerge] ActivityManagerService: Allow openContentUri from vendor/system/product. 2p: e37820e47c
  ActivityManagerService: Allow openContentUri from vendor/system/product.
This commit is contained in:
Austin Borger
2023-05-04 23:11:16 +00:00
committed by Android (Google) Code Review

View File

@@ -6284,7 +6284,7 @@ public class ActivityManagerService extends IActivityManager.Stub
mActivityTaskManager.unhandledBack(); mActivityTaskManager.unhandledBack();
} }
// TODO: Move to ContentProviderHelper? // TODO: Replace this method with one that returns a bound IContentProvider.
public ParcelFileDescriptor openContentUri(String uriString) throws RemoteException { public ParcelFileDescriptor openContentUri(String uriString) throws RemoteException {
enforceNotIsolatedCaller("openContentUri"); enforceNotIsolatedCaller("openContentUri");
final int userId = UserHandle.getCallingUserId(); final int userId = UserHandle.getCallingUserId();
@@ -6313,6 +6313,16 @@ public class ActivityManagerService extends IActivityManager.Stub
Log.e(TAG, "Cannot find package for uid: " + uid); Log.e(TAG, "Cannot find package for uid: " + uid);
return null; return null;
} }
final ApplicationInfo appInfo = mPackageManagerInt.getApplicationInfo(
androidPackage.getPackageName(), /*flags*/0, Process.SYSTEM_UID,
UserHandle.USER_SYSTEM);
if (!appInfo.isVendor() && !appInfo.isSystemApp() && !appInfo.isSystemExt()
&& !appInfo.isProduct()) {
Log.e(TAG, "openContentUri may only be used by vendor/system/product.");
return null;
}
final AttributionSource attributionSource = new AttributionSource( final AttributionSource attributionSource = new AttributionSource(
Binder.getCallingUid(), androidPackage.getPackageName(), null); Binder.getCallingUid(), androidPackage.getPackageName(), null);
pfd = cph.provider.openFile(attributionSource, uri, "r", null); pfd = cph.provider.openFile(attributionSource, uri, "r", null);