Merge "Enforce owner rights check to get/setMimeGroup" into sc-dev am: fe7866001a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14419577 Change-Id: I29b2b0291b82394971c84b7398977e6cb70a0852
This commit is contained in:
@@ -23191,16 +23191,17 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
if (UserHandle.getAppId(callingUid) == Process.SYSTEM_UID) {
|
||||
return;
|
||||
}
|
||||
final String[] callerPackageNames = getPackagesForUid(callingUid);
|
||||
if (!ArrayUtils.contains(callerPackageNames, pkg)) {
|
||||
throw new SecurityException("Calling uid " + callingUid
|
||||
+ " does not own package " + pkg);
|
||||
}
|
||||
final int callingUserId = UserHandle.getUserId(callingUid);
|
||||
PackageInfo pi = getPackageInfo(pkg, 0, callingUserId);
|
||||
if (pi == null) {
|
||||
throw new IllegalArgumentException("Unknown package " + pkg + " on user "
|
||||
+ callingUserId);
|
||||
}
|
||||
if (!UserHandle.isSameApp(pi.applicationInfo.uid, callingUid)) {
|
||||
throw new SecurityException("Calling uid " + callingUid
|
||||
+ " does not own package " + pkg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -27932,7 +27933,7 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
|
||||
@Override
|
||||
public List<String> getMimeGroup(String packageName, String mimeGroup) {
|
||||
return PackageManagerService.this.getMimeGroup(packageName, mimeGroup);
|
||||
return PackageManagerService.this.getMimeGroupInternal(packageName, mimeGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -28558,9 +28559,11 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
|
||||
@Override
|
||||
public void setMimeGroup(String packageName, String mimeGroup, List<String> mimeTypes) {
|
||||
boolean changed = mSettings.getPackageLPr(packageName)
|
||||
.setMimeGroup(mimeGroup, mimeTypes);
|
||||
|
||||
enforceOwnerRights(packageName, Binder.getCallingUid());
|
||||
final boolean changed;
|
||||
synchronized (mLock) {
|
||||
changed = mSettings.getPackageLPr(packageName).setMimeGroup(mimeGroup, mimeTypes);
|
||||
}
|
||||
if (changed) {
|
||||
applyMimeGroupChanges(packageName, mimeGroup);
|
||||
}
|
||||
@@ -28568,7 +28571,14 @@ public class PackageManagerService extends IPackageManager.Stub
|
||||
|
||||
@Override
|
||||
public List<String> getMimeGroup(String packageName, String mimeGroup) {
|
||||
return mSettings.getPackageLPr(packageName).getMimeGroup(mimeGroup);
|
||||
enforceOwnerRights(packageName, Binder.getCallingUid());
|
||||
return getMimeGroupInternal(packageName, mimeGroup);
|
||||
}
|
||||
|
||||
private List<String> getMimeGroupInternal(String packageName, String mimeGroup) {
|
||||
synchronized (mLock) {
|
||||
return mSettings.getPackageLPr(packageName).getMimeGroup(mimeGroup);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user