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

Unverified Commit 36e35798 authored by Fred Underwood's avatar Fred Underwood Committed by Michael Bestas
Browse files

SystemUI: fix Keyguard slice

Upstream refactor in commit 1f73b12d
removed too much and as a result the legacy Keyguard slice code was
broken. This adds back the needed elements.

Change-Id: I0ba66d98bb8b76c48a204ff4cb37bcf41154a4ae
parent cac4d40b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ public class KeyguardSliceViewControllerTest extends SysuiTestCase {
        when(mView.getContext()).thenReturn(mContext);
        mController = new KeyguardSliceViewController(mHandler, mBgHandler, mView,
                mActivityStarter, mConfigurationController, mDumpManager,
                mDisplayTracker);
                mDisplayTracker, null, null);
        mController.setupUri(KeyguardSliceProvider.KEYGUARD_SLICE_URI);
    }

+35 −1
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.keyguard;

import static android.app.slice.Slice.HINT_LIST_ITEM;

import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow;

import android.app.PendingIntent;
import android.net.Uri;
import android.os.Handler;
@@ -43,11 +45,17 @@ import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.KeyguardSliceProvider;
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor;
import com.android.systemui.plugins.ActivityStarter;
import com.android.systemui.power.domain.interactor.PowerInteractor;
import com.android.systemui.power.shared.model.ScreenPowerState;
import com.android.systemui.settings.DisplayTracker;
import com.android.systemui.statusbar.policy.ConfigurationController;
import com.android.systemui.util.ViewController;

import kotlin.coroutines.CoroutineContext;
import kotlin.coroutines.EmptyCoroutineContext;

import java.io.PrintWriter;
import java.util.List;
import java.util.Map;
@@ -71,6 +79,8 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie
    private Uri mKeyguardSliceUri;
    private Slice mSlice;
    private Map<View, PendingIntent> mClickActions;
    private KeyguardInteractor mKeyguardInteractor;
    private PowerInteractor mPowerInteractor;

    ConfigurationController.ConfigurationListener mConfigurationListener =
            new ConfigurationController.ConfigurationListener() {
@@ -110,7 +120,9 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie
            ActivityStarter activityStarter,
            ConfigurationController configurationController,
            DumpManager dumpManager,
            DisplayTracker displayTracker) {
            DisplayTracker displayTracker,
            KeyguardInteractor keyguardInteractor,
            PowerInteractor powerInteractor) {
        super(keyguardSliceView);
        mHandler = handler;
        mBgHandler = bgHandler;
@@ -118,6 +130,28 @@ public class KeyguardSliceViewController extends ViewController<KeyguardSliceVie
        mConfigurationController = configurationController;
        mDumpManager = dumpManager;
        mDisplayTracker = displayTracker;
        mKeyguardInteractor = keyguardInteractor;
        mPowerInteractor = powerInteractor;
    }

    @Override
    public void onInit() {
        setupUri(null);
        startCoroutines(EmptyCoroutineContext.INSTANCE);
    }

    void startCoroutines(CoroutineContext context) {
        collectFlow(mView, mKeyguardInteractor.getDozeTimeTick(),
                (Long millis) -> {
                    refresh();
                }, context);

        collectFlow(mView, mPowerInteractor.getScreenPowerState(),
                (ScreenPowerState powerState) -> {
                    if (powerState == ScreenPowerState.SCREEN_TURNING_ON) {
                        refresh();
                    }
                }, context);
    }

    @Override
+6 −0
Original line number Diff line number Diff line
@@ -27,9 +27,11 @@ import com.android.keyguard.KeyguardSliceViewController
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.dump.DumpManager
import com.android.systemui.keyguard.domain.interactor.KeyguardInteractor
import com.android.systemui.keyguard.shared.model.KeyguardSection
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.plugins.clocks.ClockViewIds
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.res.R
import com.android.systemui.settings.DisplayTracker
import com.android.systemui.statusbar.lockscreen.LockscreenSmartspaceController
@@ -47,6 +49,8 @@ constructor(
    val configurationController: ConfigurationController,
    val dumpManager: DumpManager,
    val displayTracker: DisplayTracker,
    val keyguardInteractor: KeyguardInteractor,
    val powerInteractor: PowerInteractor,
) : KeyguardSection() {
    private lateinit var sliceView: KeyguardSliceView

@@ -70,6 +74,8 @@ constructor(
                configurationController,
                dumpManager,
                displayTracker,
                keyguardInteractor,
                powerInteractor,
            )
        controller.init()
    }