Check the permission of the callingUid instead of the calling package
Bug: 372671447 Test: atest Flag: EXEMPT bug fix (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:e719575e92c1e6bd0b9088663e6c909bccf2b007) Merged-In: Ib36c0a3ba482bcddd53c2c09409ea818e6f43cad Change-Id: Ib36c0a3ba482bcddd53c2c09409ea818e6f43cad
This commit is contained in:
committed by
Cherrypicker Worker
parent
e37a2247f1
commit
353cfc1b08
@@ -20,6 +20,7 @@ import static com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
|
|||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
@@ -33,6 +34,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||||||
import android.hardware.usb.IUsbManager;
|
import android.hardware.usb.IUsbManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.os.RemoteException;
|
||||||
import android.os.ServiceManager;
|
import android.os.ServiceManager;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.os.UserManager;
|
import android.os.UserManager;
|
||||||
@@ -171,20 +173,19 @@ public abstract class AppInfoBase extends SettingsPreferenceFragment
|
|||||||
if (!(activity instanceof SettingsActivity)) {
|
if (!(activity instanceof SettingsActivity)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final String callingPackageName =
|
try {
|
||||||
((SettingsActivity) activity).getInitialCallingPackage();
|
int callerUid = ActivityManager.getService().getLaunchedFromUid(
|
||||||
|
activity.getActivityToken());
|
||||||
if (TextUtils.isEmpty(callingPackageName)) {
|
if (ActivityManager.checkUidPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL,
|
||||||
Log.w(TAG, "Not able to get calling package name for permission check");
|
callerUid) != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
Log.w(TAG, "Uid " + callerUid + " does not have required permission "
|
||||||
|
+ Manifest.permission.INTERACT_ACROSS_USERS_FULL);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (RemoteException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (mPm.checkPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL, callingPackageName)
|
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
|
||||||
Log.w(TAG, "Package " + callingPackageName + " does not have required permission "
|
|
||||||
+ Manifest.permission.INTERACT_ACROSS_USERS_FULL);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setIntentAndFinish(boolean appChanged) {
|
protected void setIntentAndFinish(boolean appChanged) {
|
||||||
|
Reference in New Issue
Block a user