Merge "[Safety Labels] Guard explicit broadcast to PermissionController with DeviceConfig flags"
This commit is contained in:
committed by
Android (Google) Code Review
commit
f00201114c
@@ -18,6 +18,8 @@ package com.android.server.pm;
|
||||
|
||||
import static android.os.PowerExemptionManager.REASON_LOCKED_BOOT_COMPLETED;
|
||||
import static android.os.PowerExemptionManager.TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED;
|
||||
import static android.safetylabel.SafetyLabelConstants.PERMISSION_RATIONALE_ENABLED;
|
||||
import static android.safetylabel.SafetyLabelConstants.SAFETY_LABEL_CHANGE_NOTIFICATIONS_ENABLED;
|
||||
|
||||
import static com.android.server.pm.PackageManagerService.DEBUG_INSTALL;
|
||||
import static com.android.server.pm.PackageManagerService.PACKAGE_SCHEME;
|
||||
@@ -42,6 +44,7 @@ import android.os.Bundle;
|
||||
import android.os.PowerExemptionManager;
|
||||
import android.os.RemoteException;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.DeviceConfig;
|
||||
import android.util.IntArray;
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
@@ -335,11 +338,13 @@ public final class BroadcastHelper {
|
||||
broadcastAllowlist, null /* filterExtrasForReceiver */, null);
|
||||
// Send to PermissionController for all new users, even if it may not be running for some
|
||||
// users
|
||||
sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED,
|
||||
packageName, extras, 0,
|
||||
mContext.getPackageManager().getPermissionControllerPackageName(),
|
||||
null, userIds, instantUserIds,
|
||||
broadcastAllowlist, null /* filterExtrasForReceiver */, null);
|
||||
if (isPrivacySafetyLabelChangeNotificationsEnabled()) {
|
||||
sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED,
|
||||
packageName, extras, 0,
|
||||
mContext.getPackageManager().getPermissionControllerPackageName(),
|
||||
null, userIds, instantUserIds,
|
||||
broadcastAllowlist, null /* filterExtrasForReceiver */, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendFirstLaunchBroadcast(String pkgName, String installerPkg,
|
||||
@@ -384,6 +389,13 @@ public final class BroadcastHelper {
|
||||
return filteredExtras;
|
||||
}
|
||||
|
||||
/** Returns whether the Safety Label Change notification, a privacy feature, is enabled. */
|
||||
public static boolean isPrivacySafetyLabelChangeNotificationsEnabled() {
|
||||
return DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_PRIVACY,
|
||||
SAFETY_LABEL_CHANGE_NOTIFICATIONS_ENABLED, false) && DeviceConfig.getBoolean(
|
||||
DeviceConfig.NAMESPACE_PRIVACY, PERMISSION_RATIONALE_ENABLED, false);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static Pair<String[], int[]> filterPackages(@NonNull Computer snapshot,
|
||||
@NonNull String[] pkgs, @Nullable int[] uids, int callingUid, int userId) {
|
||||
|
||||
@@ -2857,10 +2857,12 @@ final class InstallPackageHelper {
|
||||
}
|
||||
// Send to PermissionController for all update users, even if it may not be running
|
||||
// for some users
|
||||
mPm.sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName,
|
||||
extras, 0 /*flags*/,
|
||||
mPm.mRequiredPermissionControllerPackage, null /*finishedReceiver*/,
|
||||
updateUserIds, instantUserIds, null /* broadcastAllowList */, null);
|
||||
if (BroadcastHelper.isPrivacySafetyLabelChangeNotificationsEnabled()) {
|
||||
mPm.sendPackageBroadcast(Intent.ACTION_PACKAGE_ADDED, packageName,
|
||||
extras, 0 /*flags*/,
|
||||
mPm.mRequiredPermissionControllerPackage, null /*finishedReceiver*/,
|
||||
updateUserIds, instantUserIds, null /* broadcastAllowList */, null);
|
||||
}
|
||||
// Notify required verifier(s) that are not the installer of record for the package.
|
||||
for (String verifierPackageName : mPm.mRequiredVerifierPackages) {
|
||||
if (verifierPackageName != null && !verifierPackageName.equals(
|
||||
|
||||
Reference in New Issue
Block a user