From 028a60f003f44dac162c2c4fccd84dabde50817e Mon Sep 17 00:00:00 2001 From: Dan Sandler Date: Tue, 4 Oct 2016 15:01:22 -0400 Subject: [PATCH] Essential packages' notifications can no longer be silenced. Particularly useful for Dialer, whose incoming call notifications are basically useless if you accidentally mute them. Test: manual. With config_nonBlockableNotificationPackages set to include com.android.dialer, receive or miss a call and longpress the notification. No radio buttons should be available. Bug: 31360343 Change-Id: I6b8fa374fb8e811ec6922acbf222f23f18775a61 --- packages/SystemUI/res/layout/notification_guts.xml | 10 +++++ packages/SystemUI/res/values/strings.xml | 5 ++- .../android/systemui/statusbar/BaseStatusBar.java | 2 +- .../systemui/statusbar/NotificationGuts.java | 44 +++++++++++++--------- 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" /> + + Edit order of settings. - + Page %1$d of %2$d + + Notifications can\'t be silenced or blocked 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(); + mNonBlockablePkgs = new ArraySet(); 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); + } } } -- 2.11.0