Allow app lists to have a toggle
And make the notifications app list toggle block/unblock notifications. Test: make -j RunSettingsRoboTests Change-Id: I7417b98fb1c66504897df515c4c84afad591764e Fixes: 74318867
This commit is contained in:
@@ -65,11 +65,15 @@ public class NotificationBackend {
|
||||
|
||||
public AppRow loadAppRow(Context context, PackageManager pm, PackageInfo app) {
|
||||
final AppRow row = loadAppRow(context, pm, app.applicationInfo);
|
||||
recordCanBeBlocked(context, pm, app, row);
|
||||
return row;
|
||||
}
|
||||
|
||||
void recordCanBeBlocked(Context context, PackageManager pm, PackageInfo app, AppRow row) {
|
||||
row.systemApp = Utils.isSystemPackage(context.getResources(), pm, app);
|
||||
final String[] nonBlockablePkgs = context.getResources().getStringArray(
|
||||
com.android.internal.R.array.config_nonBlockableNotificationPackages);
|
||||
com.android.internal.R.array.config_nonBlockableNotificationPackages);
|
||||
markAppRowWithBlockables(nonBlockablePkgs, row, app.packageName);
|
||||
return row;
|
||||
}
|
||||
|
||||
@VisibleForTesting static void markAppRowWithBlockables(String[] nonBlockablePkgs, AppRow row,
|
||||
@@ -92,6 +96,19 @@ public class NotificationBackend {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSystemApp(Context context, ApplicationInfo app) {
|
||||
try {
|
||||
PackageInfo info = context.getPackageManager().getPackageInfo(
|
||||
app.packageName, PackageManager.GET_SIGNATURES);
|
||||
final AppRow row = new AppRow();
|
||||
recordCanBeBlocked(context, context.getPackageManager(), info, row);
|
||||
return row.systemApp;
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getNotificationsBanned(String pkg, int uid) {
|
||||
try {
|
||||
final boolean enabled = sINM.areNotificationsEnabledForPackage(pkg, uid);
|
||||
|
Reference in New Issue
Block a user