Merge "Add grant and revoke default permissions to active LUI app." into pi-dev

This commit is contained in:
Jiuyu Sun
2018-03-28 17:44:35 +00:00
committed by Android (Google) Code Review
3 changed files with 55 additions and 0 deletions

View File

@@ -619,6 +619,8 @@ interface IPackageManager {
in String[] packageNames, int userId);
void revokeDefaultPermissionsFromDisabledTelephonyDataServices(
in String[] packageNames, int userId);
void grantDefaultPermissionsToActiveLuiApp(in String packageName, int userId);
void revokeDefaultPermissionsFromLuiApps(in String[] packageNames, int userId);
boolean isPermissionRevokedByPolicy(String permission, String packageName, int userId);

View File

@@ -24094,6 +24094,33 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
}
}
@Override
public void grantDefaultPermissionsToActiveLuiApp(String packageName, int userId) {
enforceSystemOrPhoneCaller("grantDefaultPermissionsToActiveLuiApp");
synchronized (mPackages) {
final long identity = Binder.clearCallingIdentity();
try {
mDefaultPermissionPolicy.grantDefaultPermissionsToActiveLuiApp(
packageName, userId);
} finally {
Binder.restoreCallingIdentity(identity);
}
}
}
@Override
public void revokeDefaultPermissionsFromLuiApps(String[] packageNames, int userId) {
enforceSystemOrPhoneCaller("revokeDefaultPermissionsFromLuiApps");
synchronized (mPackages) {
final long identity = Binder.clearCallingIdentity();
try {
mDefaultPermissionPolicy.revokeDefaultPermissionsFromLuiApps(packageNames, userId);
} finally {
Binder.restoreCallingIdentity(identity);
}
}
}
private static void enforceSystemOrPhoneCaller(String tag) {
int callingUid = Binder.getCallingUid();
if (callingUid != Process.PHONE_UID && callingUid != Process.SYSTEM_UID) {

View File

@@ -1010,6 +1010,32 @@ public final class DefaultPermissionGrantPolicy {
}
}
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) {