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

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

Fix visibility and editability of importance fields

- Block field should always be visible
- Locked by OEM: cannot block or change importance
- Locked by default app: cannot block, can change importance
- Locked by system app: cannot block, can change importance
- system app but blockable: can block, can change importance

Test: robotests
Fixes: 131248127
Change-Id: Ifa718c84573dd5125aefa4f672a79dc4f267d515
parent 2f2a3c40
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -459,7 +459,7 @@ public class NotificationChannelSlice implements CustomSliceable {
    private boolean isChannelConfigurable(NotificationChannel channel,
            NotificationBackend.AppRow appRow) {
        if (channel != null && appRow != null) {
            return !TextUtils.equals(channel.getId(), appRow.lockedChannelId);
            return !channel.isImportanceLockedByOEM();
        }

        return false;
+2 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.settings.homepage.contextualcards.slices;

import android.app.role.RoleManager;
import android.content.Context;
import android.content.pm.PackageInfo;

@@ -46,7 +47,7 @@ class NotificationMultiChannelAppRow implements Callable<NotificationBackend.App
                mPackageInfo.applicationInfo.packageName, mPackageInfo.applicationInfo.uid);
        if (channelCount > 1) {
            return mNotificationBackend.loadAppRow(mContext, mContext.getPackageManager(),
                    mPackageInfo);
                    mContext.getSystemService(RoleManager.class), mPackageInfo);
        }
        return null;
    }
+14 −7
Original line number Diff line number Diff line
@@ -54,13 +54,7 @@ public class BlockPreferenceController extends NotificationPreferenceController
        if (mAppRow == null) {
            return false;
        }
        if (mChannel != null) {
            return isChannelBlockable();
        } else if (mChannelGroup != null) {
            return isChannelGroupBlockable();
        } else {
            return !mAppRow.systemApp || (mAppRow.systemApp && mAppRow.banned);
        }
        return true;
    }

    public void updateState(Preference preference) {
@@ -78,6 +72,19 @@ public class BlockPreferenceController extends NotificationPreferenceController
            }
            bar.setDisabledByAdmin(mAdmin);

            if (mChannel != null && !isChannelBlockable()) {
                bar.setEnabled(false);
            }

            if (mChannelGroup != null && !isChannelGroupBlockable()) {
                bar.setEnabled(false);
            }

            if (mChannel == null && mAppRow.systemApp
                    && (!mAppRow.banned || mAppRow.lockedImportance)) {
                bar.setEnabled(false);
            }

            if (mChannel != null) {
                bar.setChecked(!mAppRow.banned
                        && mChannel.getImportance() != NotificationManager.IMPORTANCE_NONE);
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public class HighImportancePreferenceController extends NotificationPreferenceCo
    @Override
    public void updateState(Preference preference) {
        if (mAppRow != null && mChannel != null) {
            preference.setEnabled(mAdmin == null && isChannelBlockable());
            preference.setEnabled(mAdmin == null && !mChannel.isImportanceLockedByOEM());

            RestrictedSwitchPreference pref = (RestrictedSwitchPreference) preference;
            pref.setChecked(mChannel.getImportance() >= IMPORTANCE_HIGH);
+2 −2
Original line number Diff line number Diff line
@@ -59,9 +59,9 @@ public class ImportancePreferenceController extends NotificationPreferenceContro
    @Override
    public void updateState(Preference preference) {
        if (mAppRow!= null && mChannel != null) {
            preference.setEnabled(mAdmin == null && isChannelBlockable());
            preference.setEnabled(mAdmin == null && !mChannel.isImportanceLockedByOEM());
            ImportancePreference pref = (ImportancePreference) preference;
            pref.setConfigurable(isChannelBlockable());
            pref.setConfigurable(!mChannel.isImportanceLockedByOEM());
            pref.setImportance(mChannel.getImportance());
            pref.setDisplayInStatusBar(mBackend.showSilentInStatusBar(mContext.getPackageName()));
            // TODO: b/128445911 pass along lock screen setting
Loading