Merge "Check only if the app is installed on the other user for blob access." into sc-dev am: 2c6a28a5ea am: e595ce17b1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14788767 Change-Id: I810adaeb4260f3b18344dc36f7e6956e1a0c2a79
This commit is contained in:
@@ -50,6 +50,7 @@ import android.content.Context;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.ResourceId;
|
import android.content.res.ResourceId;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.os.Binder;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
import android.os.RevocableFileDescriptor;
|
import android.os.RevocableFileDescriptor;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
@@ -308,7 +309,7 @@ class BlobMetadata {
|
|||||||
if (callingUserId == committerUserId) {
|
if (callingUserId == committerUserId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!checkCallerCanAccessBlobsAcrossUsers(callingPackage, committerUserId)) {
|
if (!isPackageInstalledOnUser(callingPackage, committerUserId)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,8 +327,25 @@ class BlobMetadata {
|
|||||||
|
|
||||||
private static boolean checkCallerCanAccessBlobsAcrossUsers(
|
private static boolean checkCallerCanAccessBlobsAcrossUsers(
|
||||||
String callingPackage, int callingUserId) {
|
String callingPackage, int callingUserId) {
|
||||||
|
final long token = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
return PermissionManager.checkPackageNamePermission(ACCESS_BLOBS_ACROSS_USERS,
|
return PermissionManager.checkPackageNamePermission(ACCESS_BLOBS_ACROSS_USERS,
|
||||||
callingPackage, callingUserId) == PackageManager.PERMISSION_GRANTED;
|
callingPackage, callingUserId) == PackageManager.PERMISSION_GRANTED;
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(token);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPackageInstalledOnUser(String packageName, int userId) {
|
||||||
|
final long token = Binder.clearCallingIdentity();
|
||||||
|
try {
|
||||||
|
mContext.getPackageManager().getPackageInfoAsUser(packageName, 0, userId);
|
||||||
|
return true;
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
Binder.restoreCallingIdentity(token);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasACommitterOrLeaseeInUser(int userId) {
|
boolean hasACommitterOrLeaseeInUser(int userId) {
|
||||||
|
|||||||
Reference in New Issue
Block a user