Remove notification permission feature flag

Tes: Settings notification robotests
Bug: 231344755
Change-Id: I3e35eede94ea88bee4c2e7fc03ce998ed68b4f81
This commit is contained in:
Julia Reynolds
2022-05-04 16:24:23 -04:00
parent 73c8e2f45a
commit 4138b6f68a
4 changed files with 21 additions and 131 deletions

View File

@@ -115,40 +115,27 @@ public class NotificationBackend {
void recordCanBeBlocked(Context context, PackageManager pm, RoleManager rm, PackageInfo app,
AppRow row) {
if (Settings.Secure.getIntForUser(context.getContentResolver(),
Settings.Secure.NOTIFICATION_PERMISSION_ENABLED, 0, USER_SYSTEM) != 0) {
try {
row.systemApp = row.lockedImportance =
sINM.isPermissionFixed(app.packageName, row.userId);
} catch (RemoteException e) {
Log.w(TAG, "Error calling NMS", e);
}
// The permission system cannot make role permissions 'fixed', so check for these
// roles explicitly
List<String> roles = rm.getHeldRolesFromController(app.packageName);
if (roles.contains(RoleManager.ROLE_DIALER)
|| roles.contains(RoleManager.ROLE_EMERGENCY)) {
row.systemApp = row.lockedImportance = true;
}
// if the app targets T but has not requested the permission, we cannot change the
// permission state
if (app.applicationInfo.targetSdkVersion > Build.VERSION_CODES.S_V2) {
if (app.requestedPermissions == null || Arrays.stream(app.requestedPermissions)
.noneMatch(p -> p.equals(android.Manifest.permission.POST_NOTIFICATIONS))) {
row.lockedImportance = true;
}
}
} else {
row.systemApp = Utils.isSystemPackage(context.getResources(), pm, app);
List<String> roles = rm.getHeldRolesFromController(app.packageName);
if (roles.contains(RoleManager.ROLE_DIALER)
|| roles.contains(RoleManager.ROLE_EMERGENCY)) {
row.systemApp = true;
try {
row.systemApp = row.lockedImportance =
sINM.isPermissionFixed(app.packageName, row.userId);
} catch (RemoteException e) {
Log.w(TAG, "Error calling NMS", e);
}
// The permission system cannot make role permissions 'fixed', so check for these
// roles explicitly
List<String> roles = rm.getHeldRolesFromController(app.packageName);
if (roles.contains(RoleManager.ROLE_DIALER)
|| roles.contains(RoleManager.ROLE_EMERGENCY)) {
row.systemApp = row.lockedImportance = true;
}
// if the app targets T but has not requested the permission, we cannot change the
// permission state
if (app.applicationInfo.targetSdkVersion > Build.VERSION_CODES.S_V2) {
if (app.requestedPermissions == null || Arrays.stream(app.requestedPermissions)
.noneMatch(p -> p.equals(android.Manifest.permission.POST_NOTIFICATIONS))) {
row.lockedImportance = true;
}
final String[] nonBlockablePkgs = context.getResources().getStringArray(
com.android.internal.R.array.config_nonBlockableNotificationPackages);
markAppRowWithBlockables(nonBlockablePkgs, row, app.packageName);
}
}

View File

@@ -64,7 +64,6 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
@Nullable
protected ShortcutInfo mConversationInfo;
protected List<String> mPreferenceFilter;
boolean mMigratedPermission;
boolean overrideCanBlock;
boolean overrideCanConfigure;
@@ -78,8 +77,6 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
mBackend = backend;
mUm = (UserManager) mContext.getSystemService(Context.USER_SERVICE);
mPm = mContext.getPackageManager();
mMigratedPermission = Settings.Secure.getIntForUser(context.getContentResolver(),
Settings.Secure.NOTIFICATION_PERMISSION_ENABLED, 0, USER_SYSTEM) != 0;
}
/**
@@ -155,9 +152,7 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
return overrideCanConfigureValue;
}
if (channel != null && mAppRow != null) {
boolean locked = mMigratedPermission ? mAppRow.lockedImportance
: channel.isImportanceLockedByCriticalDeviceFunction()
|| channel.isImportanceLockedByOEM();
boolean locked = mAppRow.lockedImportance;
if (locked) {
return channel.isBlockable() || channel.getImportance() == IMPORTANCE_NONE;
}
@@ -186,8 +181,7 @@ public abstract class NotificationPreferenceController extends AbstractPreferenc
return overrideCanConfigureValue;
}
if (channel != null && mAppRow != null) {
boolean locked = mMigratedPermission ? mAppRow.lockedImportance
: channel.isImportanceLockedByOEM();
boolean locked = mAppRow.lockedImportance;
return !locked || channel.isBlockable();
}
return false;