Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 028a60f0 authored by Dan Sandler's avatar Dan Sandler Committed by Daniel Sandler
Browse files

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
parent 73c46f06
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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"
+4 −1
Original line number Diff line number Diff line
@@ -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>
+1 −1
Original line number Diff line number Diff line
@@ -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));
    }
+27 −17
Original line number Diff line number Diff line
@@ -184,6 +184,20 @@ public class NotificationGuts extends LinearLayout implements TunerService.Tunab
                    mINotificationManager.getImportance(sbn.getPackageName(), sbn.getUid());
        } catch (RemoteException e) {}
        mNotificationImportance = importance;

        final View importanceSlider = findViewById(R.id.importance_slider);
        final View importanceButtons = findViewById(R.id.importance_buttons);
        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);
            importanceSlider.setVisibility(View.GONE);
            cantTouchThis.setVisibility(View.VISIBLE);
        } else {
            cantTouchThis.setVisibility(View.GONE);

            boolean nonBlockable = false;
            try {
                final PackageInfo info =
@@ -192,12 +206,7 @@ public class NotificationGuts extends LinearLayout implements TunerService.Tunab
            } 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);
@@ -208,6 +217,7 @@ public class NotificationGuts extends LinearLayout implements TunerService.Tunab
                importanceSlider.setVisibility(View.GONE);
            }
        }
    }

    public boolean hasImportanceChanged() {
        return mStartingUserImportance != getSelectedImportance();