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

Commit 3b6bcc70 authored by Darrell Shi's avatar Darrell Shi Committed by Android (Google) Code Review
Browse files

Merge "Remove doze low light clock." into tm-qpr-dev

parents 486626b5 ac3a50e0
Loading
Loading
Loading
Loading
+0 −17
Original line number Original line Diff line number Diff line
@@ -42,7 +42,6 @@ import com.android.systemui.dump.DumpManager;
import com.android.systemui.flags.FlagsModule;
import com.android.systemui.flags.FlagsModule;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.fragments.FragmentService;
import com.android.systemui.log.dagger.LogModule;
import com.android.systemui.log.dagger.LogModule;
import com.android.systemui.lowlightclock.LowLightClockController;
import com.android.systemui.media.dagger.MediaProjectionModule;
import com.android.systemui.media.dagger.MediaProjectionModule;
import com.android.systemui.model.SysUiState;
import com.android.systemui.model.SysUiState;
import com.android.systemui.navigationbar.NavigationBarComponent;
import com.android.systemui.navigationbar.NavigationBarComponent;
@@ -94,7 +93,6 @@ import com.android.systemui.util.time.SystemClockImpl;
import com.android.systemui.wallet.dagger.WalletModule;
import com.android.systemui.wallet.dagger.WalletModule;
import com.android.systemui.wmshell.BubblesManager;
import com.android.systemui.wmshell.BubblesManager;
import com.android.wm.shell.bubbles.Bubbles;
import com.android.wm.shell.bubbles.Bubbles;
import com.android.wm.shell.dagger.DynamicOverride;


import java.util.Optional;
import java.util.Optional;
import java.util.concurrent.Executor;
import java.util.concurrent.Executor;
@@ -246,21 +244,6 @@ public abstract class SystemUIModule {
                sysuiMainExecutor));
                sysuiMainExecutor));
    }
    }


    @BindsOptionalOf
    @DynamicOverride
    abstract LowLightClockController optionalLowLightClockController();

    @SysUISingleton
    @Provides
    static Optional<LowLightClockController> provideLowLightClockController(
            @DynamicOverride Optional<LowLightClockController> optionalController) {
        if (optionalController.isPresent() && optionalController.get().isLowLightClockEnabled()) {
            return optionalController;
        } else {
            return Optional.empty();
        }
    }

    @Binds
    @Binds
    abstract FgsManagerController bindFgsManagerController(FgsManagerControllerImpl impl);
    abstract FgsManagerController bindFgsManagerController(FgsManagerControllerImpl impl);
}
}
+0 −48
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.lowlightclock;

import android.view.ViewGroup;

/**
 * A controller responsible for attaching and showing an optional low-light clock while dozing.
 */
public interface LowLightClockController {
    /**
     * Returns {@code true} if the low-light clock is enabled.
     */
    boolean isLowLightClockEnabled();

    /**
     * Attach the low light-clock to the given parent {@link ViewGroup}.
     * @param parent The parent {@link ViewGroup} to which the low-light clock view should be
     *               attached.
     */
    void attachLowLightClockView(ViewGroup parent);

    /**
     * Show or hide the low-light clock.
     * @param show Whether to show the low-light clock.
     * @return {@code true} if the low-light clock was shown.
     */
    boolean showLowLightClock(boolean show);

    /**
     * An opportunity to perform burn-in prevention.
     */
    void dozeTimeTick();
}
+0 −22
Original line number Original line Diff line number Diff line
@@ -34,7 +34,6 @@ import com.android.systemui.R;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.classifier.FalsingCollector;
import com.android.systemui.dock.DockManager;
import com.android.systemui.dock.DockManager;
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.keyguard.KeyguardUnlockAnimationController;
import com.android.systemui.lowlightclock.LowLightClockController;
import com.android.systemui.statusbar.DragDownHelper;
import com.android.systemui.statusbar.DragDownHelper;
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
import com.android.systemui.statusbar.LockscreenShadeTransitionController;
import com.android.systemui.statusbar.NotificationShadeDepthController;
import com.android.systemui.statusbar.NotificationShadeDepthController;
@@ -51,7 +50,6 @@ import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManage
import com.android.systemui.statusbar.window.StatusBarWindowStateController;
import com.android.systemui.statusbar.window.StatusBarWindowStateController;


import java.io.PrintWriter;
import java.io.PrintWriter;
import java.util.Optional;


import javax.inject.Inject;
import javax.inject.Inject;


@@ -88,7 +86,6 @@ public class NotificationShadeWindowViewController {
    private final DockManager mDockManager;
    private final DockManager mDockManager;
    private final NotificationPanelViewController mNotificationPanelViewController;
    private final NotificationPanelViewController mNotificationPanelViewController;
    private final PanelExpansionStateManager mPanelExpansionStateManager;
    private final PanelExpansionStateManager mPanelExpansionStateManager;
    private final Optional<LowLightClockController> mLowLightClockController;


    private boolean mIsTrackingBarGesture = false;
    private boolean mIsTrackingBarGesture = false;


@@ -106,7 +103,6 @@ public class NotificationShadeWindowViewController {
            StatusBarKeyguardViewManager statusBarKeyguardViewManager,
            StatusBarKeyguardViewManager statusBarKeyguardViewManager,
            StatusBarWindowStateController statusBarWindowStateController,
            StatusBarWindowStateController statusBarWindowStateController,
            LockIconViewController lockIconViewController,
            LockIconViewController lockIconViewController,
            Optional<LowLightClockController> lowLightClockController,
            CentralSurfaces centralSurfaces,
            CentralSurfaces centralSurfaces,
            NotificationShadeWindowController controller,
            NotificationShadeWindowController controller,
            KeyguardUnlockAnimationController keyguardUnlockAnimationController,
            KeyguardUnlockAnimationController keyguardUnlockAnimationController,
@@ -125,7 +121,6 @@ public class NotificationShadeWindowViewController {
        mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
        mStatusBarKeyguardViewManager = statusBarKeyguardViewManager;
        mStatusBarWindowStateController = statusBarWindowStateController;
        mStatusBarWindowStateController = statusBarWindowStateController;
        mLockIconViewController = lockIconViewController;
        mLockIconViewController = lockIconViewController;
        mLowLightClockController = lowLightClockController;
        mService = centralSurfaces;
        mService = centralSurfaces;
        mNotificationShadeWindowController = controller;
        mNotificationShadeWindowController = controller;
        mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
        mKeyguardUnlockAnimationController = keyguardUnlockAnimationController;
@@ -148,8 +143,6 @@ public class NotificationShadeWindowViewController {
        mStackScrollLayout = mView.findViewById(R.id.notification_stack_scroller);
        mStackScrollLayout = mView.findViewById(R.id.notification_stack_scroller);
        mGestureDetector = new GestureDetector(mView.getContext(), mPulsingGestureListener);
        mGestureDetector = new GestureDetector(mView.getContext(), mPulsingGestureListener);


        mLowLightClockController.ifPresent(controller -> controller.attachLowLightClockView(mView));

        mView.setInteractionEventHandler(new NotificationShadeWindowView.InteractionEventHandler() {
        mView.setInteractionEventHandler(new NotificationShadeWindowView.InteractionEventHandler() {
            @Override
            @Override
            public Boolean handleDispatchTouchEvent(MotionEvent ev) {
            public Boolean handleDispatchTouchEvent(MotionEvent ev) {
@@ -434,21 +427,6 @@ public class NotificationShadeWindowViewController {
        mStatusBarViewController = statusBarViewController;
        mStatusBarViewController = statusBarViewController;
    }
    }


    /**
     * Tell the controller that dozing has begun or ended.
     * @param dozing True if dozing has begun.
     */
    public void setDozing(boolean dozing) {
        mLowLightClockController.ifPresent(controller -> controller.showLowLightClock(dozing));
    }

    /**
     * Tell the controller to perform burn-in prevention.
     */
    public void dozeTimeTick() {
        mLowLightClockController.ifPresent(LowLightClockController::dozeTimeTick);
    }

    @VisibleForTesting
    @VisibleForTesting
    void setDragDownHelper(DragDownHelper dragDownHelper) {
    void setDragDownHelper(DragDownHelper dragDownHelper) {
        mDragDownHelper = dragDownHelper;
        mDragDownHelper = dragDownHelper;
+0 −2
Original line number Original line Diff line number Diff line
@@ -226,7 +226,6 @@ public final class DozeServiceHost implements DozeHost {
        }
        }


        mStatusBarStateController.setIsDozing(dozing);
        mStatusBarStateController.setIsDozing(dozing);
        mNotificationShadeWindowViewController.setDozing(dozing);
        if (mFoldAodAnimationController != null) {
        if (mFoldAodAnimationController != null) {
            mFoldAodAnimationController.setIsDozing(dozing);
            mFoldAodAnimationController.setIsDozing(dozing);
        }
        }
@@ -310,7 +309,6 @@ public final class DozeServiceHost implements DozeHost {
    public void dozeTimeTick() {
    public void dozeTimeTick() {
        mNotificationPanel.dozeTimeTick();
        mNotificationPanel.dozeTimeTick();
        mAuthController.dozeTimeTick();
        mAuthController.dozeTimeTick();
        mNotificationShadeWindowViewController.dozeTimeTick();
        if (mAmbientIndicationContainer instanceof DozeReceiver) {
        if (mAmbientIndicationContainer instanceof DozeReceiver) {
            ((DozeReceiver) mAmbientIndicationContainer).dozeTimeTick();
            ((DozeReceiver) mAmbientIndicationContainer).dozeTimeTick();
        }
        }
+0 −31
Original line number Original line Diff line number Diff line
@@ -25,7 +25,6 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.classifier.FalsingCollectorFake
import com.android.systemui.classifier.FalsingCollectorFake
import com.android.systemui.dock.DockManager
import com.android.systemui.dock.DockManager
import com.android.systemui.keyguard.KeyguardUnlockAnimationController
import com.android.systemui.keyguard.KeyguardUnlockAnimationController
import com.android.systemui.lowlightclock.LowLightClockController
import com.android.systemui.shade.NotificationShadeWindowView.InteractionEventHandler
import com.android.systemui.shade.NotificationShadeWindowView.InteractionEventHandler
import com.android.systemui.statusbar.LockscreenShadeTransitionController
import com.android.systemui.statusbar.LockscreenShadeTransitionController
import com.android.systemui.statusbar.NotificationShadeDepthController
import com.android.systemui.statusbar.NotificationShadeDepthController
@@ -39,12 +38,10 @@ import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager
import com.android.systemui.statusbar.phone.panelstate.PanelExpansionStateManager
import com.android.systemui.statusbar.window.StatusBarWindowStateController
import com.android.systemui.statusbar.window.StatusBarWindowStateController
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertThat
import java.util.Optional
import org.junit.Before
import org.junit.Before
import org.junit.Test
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.ArgumentCaptor
import org.mockito.ArgumentMatchers
import org.mockito.Mock
import org.mockito.Mock
import org.mockito.Mockito.anyFloat
import org.mockito.Mockito.anyFloat
import org.mockito.Mockito.never
import org.mockito.Mockito.never
@@ -87,8 +84,6 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
    @Mock
    @Mock
    private lateinit var phoneStatusBarViewController: PhoneStatusBarViewController
    private lateinit var phoneStatusBarViewController: PhoneStatusBarViewController
    @Mock
    @Mock
    private lateinit var lowLightClockController: LowLightClockController
    @Mock
    private lateinit var pulsingGestureListener: PulsingGestureListener
    private lateinit var pulsingGestureListener: PulsingGestureListener


    private lateinit var interactionEventHandlerCaptor: ArgumentCaptor<InteractionEventHandler>
    private lateinit var interactionEventHandlerCaptor: ArgumentCaptor<InteractionEventHandler>
@@ -114,7 +109,6 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
            statusBarKeyguardViewManager,
            statusBarKeyguardViewManager,
            statusBarWindowStateController,
            statusBarWindowStateController,
            lockIconViewController,
            lockIconViewController,
            Optional.of(lowLightClockController),
            centralSurfaces,
            centralSurfaces,
            notificationShadeWindowController,
            notificationShadeWindowController,
            keyguardUnlockAnimationController,
            keyguardUnlockAnimationController,
@@ -252,31 +246,6 @@ class NotificationShadeWindowViewControllerTest : SysuiTestCase() {
        verify(phoneStatusBarViewController).sendTouchToView(nextEvent)
        verify(phoneStatusBarViewController).sendTouchToView(nextEvent)
        assertThat(returnVal).isTrue()
        assertThat(returnVal).isTrue()
    }
    }

    @Test
    fun testLowLightClockAttachedWhenExpandedStatusBarSetup() {
        verify(lowLightClockController).attachLowLightClockView(ArgumentMatchers.any())
    }

    @Test
    fun testLowLightClockShownWhenDozing() {
        underTest.setDozing(true)
        verify(lowLightClockController).showLowLightClock(true)
    }

    @Test
    fun testLowLightClockDozeTimeTickCalled() {
        underTest.dozeTimeTick()
        verify(lowLightClockController).dozeTimeTick()
    }

    @Test
    fun testLowLightClockHiddenWhenNotDozing() {
        underTest.setDozing(true)
        verify(lowLightClockController).showLowLightClock(true)
        underTest.setDozing(false)
        verify(lowLightClockController).showLowLightClock(false)
    }
}
}


private val downEv = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0)
private val downEv = MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_DOWN, 0f, 0f, 0)
Loading