diff options
4 files changed, 42 insertions, 19 deletions
diff --git a/packages/SystemUI/res/layout/notification_guts.xml b/packages/SystemUI/res/layout/notification_guts.xml index e84ed23fbc86..17bade4a85c7 100644 --- a/packages/SystemUI/res/layout/notification_guts.xml +++ b/packages/SystemUI/res/layout/notification_guts.xml @@ -91,6 +91,16 @@ style="@style/TextAppearance.NotificationGuts.Radio" android:buttonTint="@color/notification_guts_buttons" /> </RadioGroup> + <!-- When neither blocking or silencing is available --> + <TextView + android:id="@+id/cant_silence_or_block" + android:layout_width="match_parent" + android:layout_height="48dp" + android:gravity="center_vertical" + style="@style/TextAppearance.NotificationGuts.Radio" + android:text="@string/cant_silence_or_block" + android:visibility="gone" + /> <!-- Importance slider --> <LinearLayout android:id="@+id/importance_slider" diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml index d13039e4bb66..2ea475a1166b 100644 --- a/packages/SystemUI/res/values/strings.xml +++ b/packages/SystemUI/res/values/strings.xml @@ -1666,7 +1666,10 @@ <!-- accessibility label for button to edit quick settings [CHAR LIMIT=NONE] --> <string name="accessibility_quick_settings_edit">Edit order of settings.</string> - <!-- accessibility label for paging indicator in quick settings [CHAR LIMITi=NONE] --> + <!-- accessibility label for paging indicator in quick settings [CHAR LIMIT=NONE] --> <string name="accessibility_quick_settings_page">Page <xliff:g name="current_page" example="1">%1$d</xliff:g> of <xliff:g name="num_pages" example="2">%2$d</xliff:g></string> + <!-- Label that replaces other notification controls when the notification is from the system + and cannot be silenced (see @string/show_silently) or blocked (see @string/block) --> + <string name="cant_silence_or_block">Notifications can\'t be silenced or blocked</string> </resources> diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java index 98957ddd5c00..abe3b7ee617a 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/BaseStatusBar.java @@ -829,7 +829,7 @@ public abstract class BaseStatusBar extends SystemUI implements Slog.e(TAG, "Failed to register VR mode state listener: " + e); } - mNonBlockablePkgs = new HashSet<String>(); + mNonBlockablePkgs = new ArraySet<String>(); Collections.addAll(mNonBlockablePkgs, mContext.getResources().getStringArray( com.android.internal.R.array.config_nonBlockableNotificationPackages)); } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java index 62d730a42732..c850a25672d2 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationGuts.java @@ -184,28 +184,38 @@ public class NotificationGuts extends LinearLayout implements TunerService.Tunab mINotificationManager.getImportance(sbn.getPackageName(), sbn.getUid()); } catch (RemoteException e) {} mNotificationImportance = importance; - boolean nonBlockable = false; - try { - final PackageInfo info = - pm.getPackageInfo(sbn.getPackageName(), PackageManager.GET_SIGNATURES); - nonBlockable = Utils.isSystemPackage(getResources(), pm, info); - } catch (PackageManager.NameNotFoundException e) { - // unlikely. - } - if (nonBlockablePkgs != null) { - nonBlockable |= nonBlockablePkgs.contains(sbn.getPackageName()); - } final View importanceSlider = findViewById(R.id.importance_slider); final View importanceButtons = findViewById(R.id.importance_buttons); - if (mShowSlider) { - bindSlider(importanceSlider, nonBlockable); - importanceSlider.setVisibility(View.VISIBLE); + final View cantTouchThis = findViewById(R.id.cant_silence_or_block); + + final boolean essentialPackage = + (nonBlockablePkgs != null && nonBlockablePkgs.contains(sbn.getPackageName())); + if (essentialPackage) { importanceButtons.setVisibility(View.GONE); - } else { - bindToggles(importanceButtons, mStartingUserImportance, nonBlockable); - importanceButtons.setVisibility(View.VISIBLE); importanceSlider.setVisibility(View.GONE); + cantTouchThis.setVisibility(View.VISIBLE); + } else { + cantTouchThis.setVisibility(View.GONE); + + boolean nonBlockable = false; + try { + final PackageInfo info = + pm.getPackageInfo(sbn.getPackageName(), PackageManager.GET_SIGNATURES); + nonBlockable = Utils.isSystemPackage(getResources(), pm, info); + } catch (PackageManager.NameNotFoundException e) { + // unlikely. + } + + if (mShowSlider) { + bindSlider(importanceSlider, nonBlockable); + importanceSlider.setVisibility(View.VISIBLE); + importanceButtons.setVisibility(View.GONE); + } else { + bindToggles(importanceButtons, mStartingUserImportance, nonBlockable); + importanceButtons.setVisibility(View.VISIBLE); + importanceSlider.setVisibility(View.GONE); + } } } |