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

Commit a49725a6 authored by Beverly's avatar Beverly
Browse files

Locally store Setting in KeyguardCoordinator

Locally store the setting for LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS
instead of making an IPC call each time the new notification pipeline
runs.

Test: manual
Change-Id: Icf4242951c90ec40c0998429f7be38b4f2902520
parent 8d260a46
Loading
Loading
Loading
Loading
+24 −6
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ public class KeyguardCoordinator implements Coordinator {
    private final KeyguardUpdateMonitor mKeyguardUpdateMonitor;
    private final HighPriorityProvider mHighPriorityProvider;

    private boolean mHideSilentNotificationsOnLockscreen;

    @Inject
    public KeyguardCoordinator(
            Context context,
@@ -86,6 +88,8 @@ public class KeyguardCoordinator implements Coordinator {

    @Override
    public void attach(NotifPipeline pipeline) {
        readShowSilentNotificationSetting();

        setupInvalidateNotifListCallbacks();
        pipeline.addFinalizeFilter(mNotifFilter);
    }
@@ -147,7 +151,7 @@ public class KeyguardCoordinator implements Coordinator {
            return false;
        }
        if (NotificationUtils.useNewInterruptionModel(mContext)
                && hideSilentNotificationsOnLockscreen()) {
                && mHideSilentNotificationsOnLockscreen) {
            return mHighPriorityProvider.isHighPriority(entry);
        } else {
            return entry.getRepresentativeEntry() != null
@@ -155,11 +159,6 @@ public class KeyguardCoordinator implements Coordinator {
        }
    }

    private boolean hideSilentNotificationsOnLockscreen() {
        return Settings.Secure.getInt(mContext.getContentResolver(),
                Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS, 1) == 0;
    }

    private void setupInvalidateNotifListCallbacks() {
        // register onKeyguardShowing callback
        mKeyguardStateController.addCallback(mKeyguardCallback);
@@ -169,6 +168,11 @@ public class KeyguardCoordinator implements Coordinator {
        final ContentObserver settingsObserver = new ContentObserver(mMainHandler) {
            @Override
            public void onChange(boolean selfChange, Uri uri) {
                if (uri.equals(Settings.Secure.getUriFor(
                        Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS))) {
                    readShowSilentNotificationSetting();
                }

                if (mKeyguardStateController.isShowing()) {
                    invalidateListFromFilter("Settings " + uri + " changed");
                }
@@ -192,6 +196,12 @@ public class KeyguardCoordinator implements Coordinator {
                false,
                settingsObserver);

        mContext.getContentResolver().registerContentObserver(
                Settings.Secure.getUriFor(Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS),
                false,
                settingsObserver,
                UserHandle.USER_ALL);

        // register (maybe) public mode changed callbacks:
        mStatusBarStateController.addCallback(mStatusBarStateListener);
        mBroadcastDispatcher.registerReceiver(new BroadcastReceiver() {
@@ -208,6 +218,14 @@ public class KeyguardCoordinator implements Coordinator {
        mNotifFilter.invalidateList();
    }

    private void readShowSilentNotificationSetting() {
        mHideSilentNotificationsOnLockscreen =
                Settings.Secure.getInt(
                        mContext.getContentResolver(),
                        Settings.Secure.LOCK_SCREEN_SHOW_SILENT_NOTIFICATIONS,
                        1) == 0;
    }

    private final KeyguardStateController.Callback mKeyguardCallback =
            new KeyguardStateController.Callback() {
        @Override