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

Commit 4804ee11 authored by Aaron Liu's avatar Aaron Liu Committed by Android (Google) Code Review
Browse files

Merge "Register contentObserver on bg thread." into main

parents 62d998ce 8ad94cb6
Loading
Loading
Loading
Loading
+25 −15
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import androidx.annotation.VisibleForTesting;

import com.android.systemui.Dumpable;
import com.android.systemui.common.ui.ConfigurationState;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FeatureFlagsClassic;
@@ -78,6 +79,7 @@ import com.android.systemui.util.settings.SecureSettings;

import java.io.PrintWriter;
import java.util.Locale;
import java.util.concurrent.Executor;
import java.util.function.Consumer;

import javax.inject.Inject;
@@ -136,6 +138,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
    private KeyguardInteractor mKeyguardInteractor;
    private KeyguardClockInteractor mKeyguardClockInteractor;
    private final DelayableExecutor mUiExecutor;
    private final Executor mBgExecutor;
    private boolean mCanShowDoubleLineClock = true;
    private DisposableHandle mAodIconsBindHandle;
    @Nullable private NotificationIconContainer mAodIconContainer;
@@ -186,6 +189,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
            KeyguardUnlockAnimationController keyguardUnlockAnimationController,
            SecureSettings secureSettings,
            @Main DelayableExecutor uiExecutor,
            @Background Executor bgExecutor,
            DumpManager dumpManager,
            ClockEventController clockEventController,
            @KeyguardClockLog LogBuffer logBuffer,
@@ -209,6 +213,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
        mIconViewBindingFailureTracker = iconViewBindingFailureTracker;
        mSecureSettings = secureSettings;
        mUiExecutor = uiExecutor;
        mBgExecutor = bgExecutor;
        mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
        mDumpManager = dumpManager;
        mClockEventController = clockEventController;
@@ -328,6 +333,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
        updateAodIcons();
        mStatusArea = mView.findViewById(R.id.keyguard_status_area);

        mBgExecutor.execute(() -> {
            mSecureSettings.registerContentObserverForUser(
                    Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK,
                    false, /* notifyForDescendants */
@@ -341,6 +347,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
                    mShowWeatherObserver,
                    UserHandle.USER_ALL
            );
        });

        updateDoubleLineClock();

        mKeyguardUnlockAnimationController.addKeyguardUnlockAnimationListener(
@@ -382,8 +390,10 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
        mClockEventController.unregisterListeners();
        setClock(null);

        mBgExecutor.execute(() -> {
            mSecureSettings.unregisterContentObserver(mDoubleLineClockObserver);
            mSecureSettings.unregisterContentObserver(mShowWeatherObserver);
        });

        mKeyguardUnlockAnimationController.removeKeyguardUnlockAnimationListener(
                mKeyguardUnlockAnimationListener);
+1 −0
Original line number Diff line number Diff line
@@ -195,6 +195,7 @@ public class KeyguardClockSwitchControllerBaseTest extends SysuiTestCase {
                mKeyguardUnlockAnimationController,
                mSecureSettings,
                mExecutor,
                mExecutor,
                mDumpManager,
                mClockEventController,
                mLogBuffer,
+2 −0
Original line number Diff line number Diff line
@@ -157,6 +157,7 @@ public class KeyguardClockSwitchControllerTest extends KeyguardClockSwitchContro
        ArgumentCaptor<ContentObserver> observerCaptor =
                ArgumentCaptor.forClass(ContentObserver.class);
        mController.init();
        mExecutor.runAllReady();
        verify(mSecureSettings).registerContentObserverForUser(
                eq(Settings.Secure.LOCKSCREEN_USE_DOUBLE_LINE_CLOCK),
                    anyBoolean(), observerCaptor.capture(), eq(UserHandle.USER_ALL));
@@ -212,6 +213,7 @@ public class KeyguardClockSwitchControllerTest extends KeyguardClockSwitchContro
        ArgumentCaptor<ContentObserver> observerCaptor =
                ArgumentCaptor.forClass(ContentObserver.class);
        mController.init();
        mExecutor.runAllReady();
        verify(mSecureSettings).registerContentObserverForUser(
                eq(Settings.Secure.LOCK_SCREEN_WEATHER_ENABLED), anyBoolean(),
                    observerCaptor.capture(), eq(UserHandle.USER_ALL));