Add grant and revoke default permissions to active LUI app.
Grant the camera permission to the active LUI app since LUI uses QR scanner
to download profile.
Before it, revoke the previously granted permissions first.
Bug: 35068517
Test: test on phone
Change-Id: I2db9597eed423835b9499ef6000579b5ee5b2cb6
diff --git a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
index 3116480..658e63d 100644
--- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
@@ -1010,6 +1010,32 @@
}
}
+ public void grantDefaultPermissionsToActiveLuiApp(String packageName, int userId) {
+ Log.i(TAG, "Granting permissions to active LUI app for user:" + userId);
+ if (packageName == null) {
+ return;
+ }
+ PackageParser.Package luiAppPackage = getSystemPackage(packageName);
+ if (luiAppPackage != null
+ && doesPackageSupportRuntimePermissions(luiAppPackage)) {
+ grantRuntimePermissions(luiAppPackage, CAMERA_PERMISSIONS, true, userId);
+ }
+ }
+
+ public void revokeDefaultPermissionsFromLuiApps(String[] packageNames, int userId) {
+ Log.i(TAG, "Revoke permissions from LUI apps for user:" + userId);
+ if (packageNames == null) {
+ return;
+ }
+ for (String packageName : packageNames) {
+ PackageParser.Package luiAppPackage = getSystemPackage(packageName);
+ if (luiAppPackage != null
+ && doesPackageSupportRuntimePermissions(luiAppPackage)) {
+ revokeRuntimePermissions(luiAppPackage, CAMERA_PERMISSIONS, true, userId);
+ }
+ }
+ }
+
public void grantDefaultPermissionsToDefaultBrowser(String packageName, int userId) {
Log.i(TAG, "Granting permissions to default browser for user:" + userId);
if (packageName == null) {