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

Commit c1ca4b81 authored by Julia Reynolds's avatar Julia Reynolds
Browse files

Fix some issues with notif blocking in settings

- Fix cast cast exception
- Make sure unblocking a notification channel also actually
unblocks it

Test: make -j64 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.notification"
Fixes: 177968301
Fixes: 177907827
Change-Id: Ibad56e102e167bcf004fbd0f9873cc29834a30c1
parent 02c9b032
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -25,10 +25,9 @@
        android:order="1"
        android:layout="@layout/settings_entity_header" />

    <com.android.settingslib.widget.LayoutPreference
    <com.android.settings.widget.SettingsMainSwitchPreference
        android:key="block"
        android:order="2"
        android:layout="@layout/styled_switch_bar" />
        android:order="2" />

    <!-- Importance toggle -->
    <com.android.settingslib.RestrictedSwitchPreference
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settings.notification.app;

import static android.app.NotificationManager.IMPORTANCE_LOW;
import static android.app.NotificationManager.IMPORTANCE_NONE;
import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED;

@@ -107,7 +108,7 @@ public class BlockPreferenceController extends NotificationPreferenceController
                        ? IMPORTANCE_NONE
                        : isDefaultChannel()
                                ? IMPORTANCE_UNSPECIFIED
                                : mChannel.getOriginalImportance();
                                : Math.max(mChannel.getOriginalImportance(), IMPORTANCE_LOW);
                mChannel.setImportance(importance);
                saveChannel();
            }
+3 −1
Original line number Diff line number Diff line
@@ -339,7 +339,9 @@ public class ChannelListPreferenceController extends NotificationPreferenceContr
        channelPref.setOnPreferenceChangeListener(
                (preference, o) -> {
                    boolean value = (Boolean) o;
                    int importance = value ? channel.getOriginalImportance() : IMPORTANCE_NONE;
                    int importance = value
                            ? Math.max(channel.getOriginalImportance(), IMPORTANCE_LOW)
                            : IMPORTANCE_NONE;
                    channel.setImportance(importance);
                    channel.lockFields(NotificationChannel.USER_LOCKED_IMPORTANCE);
                    PrimarySwitchPreference channelPref1 = (PrimarySwitchPreference) preference;