Merge "Merge "Sets COARSE_LOCATION permission for VrCore when in vr mode." into nyc-dev am: dfd72d4" into nyc-dev-plus-aosp
This commit is contained in:
committed by
Android (Google) Code Review
commit
381a6db0fd
@@ -105,6 +105,7 @@ public class VrManagerService extends SystemService implements EnabledComponentC
|
|||||||
new RemoteCallbackList<>();
|
new RemoteCallbackList<>();
|
||||||
private final ArraySet<String> mPreviousToggledListenerSettings = new ArraySet<>();
|
private final ArraySet<String> mPreviousToggledListenerSettings = new ArraySet<>();
|
||||||
private String mPreviousNotificationPolicyAccessPackage;
|
private String mPreviousNotificationPolicyAccessPackage;
|
||||||
|
private String mPreviousCoarseLocationPackage;
|
||||||
private String mPreviousManageOverlayPackage;
|
private String mPreviousManageOverlayPackage;
|
||||||
|
|
||||||
private static final int MSG_VR_STATE_CHANGE = 0;
|
private static final int MSG_VR_STATE_CHANGE = 0;
|
||||||
@@ -446,6 +447,7 @@ public class VrManagerService extends SystemService implements EnabledComponentC
|
|||||||
|
|
||||||
mWasDefaultGranted = true;
|
mWasDefaultGranted = true;
|
||||||
|
|
||||||
|
grantCoarseLocationAccess(pName, userId);
|
||||||
grantOverlayAccess(pName, userId);
|
grantOverlayAccess(pName, userId);
|
||||||
grantNotificationPolicyAccess(pName);
|
grantNotificationPolicyAccess(pName);
|
||||||
grantNotificationListenerAccess(pName, userId);
|
grantNotificationListenerAccess(pName, userId);
|
||||||
@@ -475,6 +477,7 @@ public class VrManagerService extends SystemService implements EnabledComponentC
|
|||||||
|
|
||||||
String pName = component.getPackageName();
|
String pName = component.getPackageName();
|
||||||
if (mWasDefaultGranted) {
|
if (mWasDefaultGranted) {
|
||||||
|
revokeCoarseLocationAccess(userId);
|
||||||
revokeOverlayAccess(userId);
|
revokeOverlayAccess(userId);
|
||||||
revokeNotificationPolicyAccess(pName);
|
revokeNotificationPolicyAccess(pName);
|
||||||
revokeNotificiationListenerAccess();
|
revokeNotificiationListenerAccess();
|
||||||
@@ -483,6 +486,27 @@ public class VrManagerService extends SystemService implements EnabledComponentC
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void grantCoarseLocationAccess(String pkg, UserHandle userId) {
|
||||||
|
PackageManager pm = mContext.getPackageManager();
|
||||||
|
boolean prev = (PackageManager.PERMISSION_GRANTED ==
|
||||||
|
pm.checkPermission(android.Manifest.permission.ACCESS_COARSE_LOCATION, pkg));
|
||||||
|
mPreviousCoarseLocationPackage = null;
|
||||||
|
if (!prev) {
|
||||||
|
pm.grantRuntimePermission(pkg, android.Manifest.permission.ACCESS_COARSE_LOCATION,
|
||||||
|
userId);
|
||||||
|
mPreviousCoarseLocationPackage = pkg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void revokeCoarseLocationAccess(UserHandle userId) {
|
||||||
|
PackageManager pm = mContext.getPackageManager();
|
||||||
|
if (mPreviousCoarseLocationPackage != null) {
|
||||||
|
pm.revokeRuntimePermission(mPreviousCoarseLocationPackage,
|
||||||
|
android.Manifest.permission.ACCESS_COARSE_LOCATION, userId);
|
||||||
|
mPreviousCoarseLocationPackage = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void grantOverlayAccess(String pkg, UserHandle userId) {
|
private void grantOverlayAccess(String pkg, UserHandle userId) {
|
||||||
PackageManager pm = mContext.getPackageManager();
|
PackageManager pm = mContext.getPackageManager();
|
||||||
boolean prev = (PackageManager.PERMISSION_GRANTED ==
|
boolean prev = (PackageManager.PERMISSION_GRANTED ==
|
||||||
@@ -504,7 +528,6 @@ public class VrManagerService extends SystemService implements EnabledComponentC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void grantNotificationPolicyAccess(String pkg) {
|
private void grantNotificationPolicyAccess(String pkg) {
|
||||||
NotificationManager nm = mContext.getSystemService(NotificationManager.class);
|
NotificationManager nm = mContext.getSystemService(NotificationManager.class);
|
||||||
boolean prev = nm.isNotificationPolicyAccessGrantedForPackage(pkg);
|
boolean prev = nm.isNotificationPolicyAccessGrantedForPackage(pkg);
|
||||||
|
|||||||
Reference in New Issue
Block a user