Merge "Allow app lists to have a toggle" into pi-dev

This commit is contained in:
Julia Reynolds
2018-03-28 11:21:51 +00:00
committed by Android (Google) Code Review
7 changed files with 259 additions and 11 deletions

View File

@@ -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);