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

Commit 8ad9dc86 authored by Adrian Roos's avatar Adrian Roos Committed by android-build-merger
Browse files

Merge "AOD: Keep doze brightness when unlocking with fingerprint" into oc-dr1-dev

am: 3bd612f9

Change-Id: I2ab9a1842c6e9a5acdde4d5c3470bf645aa55e18
parents fba5a5ba 3bd612f9
Loading
Loading
Loading
Loading
+36 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (C) 2017 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.doze;

/**
 * Forwards the currently used brightness to {@link DozeHost}.
 */
public class DozeBrightnessHostForwarder extends DozeMachine.Service.Delegate {

    private final DozeHost mHost;

    public DozeBrightnessHostForwarder(DozeMachine.Service wrappedService, DozeHost host) {
        super(wrappedService);
        mHost = host;
    }

    @Override
    public void setDozeScreenBrightness(int brightness) {
        super.setDozeScreenBrightness(brightness);
        mHost.setDozeScreenBrightness(brightness);
    }
}
+6 −2
Original line number Original line Diff line number Diff line
@@ -49,8 +49,12 @@ public class DozeFactory {
        WakeLock wakeLock = new DelayedWakeLock(handler,
        WakeLock wakeLock = new DelayedWakeLock(handler,
                WakeLock.createPartial(context, "Doze"));
                WakeLock.createPartial(context, "Doze"));


        DozeMachine.Service wrappedService = DozeSuspendScreenStatePreventingAdapter.wrapIfNeeded(
        DozeMachine.Service wrappedService = dozeService;
                DozeScreenStatePreventingAdapter.wrapIfNeeded(dozeService, params), params);
        wrappedService = new DozeBrightnessHostForwarder(wrappedService, host);
        wrappedService = DozeScreenStatePreventingAdapter.wrapIfNeeded(wrappedService, params);
        wrappedService = DozeSuspendScreenStatePreventingAdapter.wrapIfNeeded(wrappedService,
                params);

        DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock);
        DozeMachine machine = new DozeMachine(wrappedService, config, wakeLock);
        machine.setParts(new DozeMachine.Part[]{
        machine.setParts(new DozeMachine.Part[]{
                new DozePauser(handler, machine, alarmManager),
                new DozePauser(handler, machine, alarmManager),
+1 −0
Original line number Original line Diff line number Diff line
@@ -41,6 +41,7 @@ public interface DozeHost {


    void onDoubleTap(float x, float y);
    void onDoubleTap(float x, float y);


    void setDozeScreenBrightness(int value);


    interface Callback {
    interface Callback {
        default void onNotificationHeadsUp() {}
        default void onNotificationHeadsUp() {}
+8 −4
Original line number Original line Diff line number Diff line
@@ -163,8 +163,8 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
            }
            }
            mHandler.postDelayed(mReleaseFingerprintWakeLockRunnable,
            mHandler.postDelayed(mReleaseFingerprintWakeLockRunnable,
                    FINGERPRINT_WAKELOCK_TIMEOUT_MS);
                    FINGERPRINT_WAKELOCK_TIMEOUT_MS);
            if (mDozeScrimController.isPulsing()) {


            if (pulsingOrAod()) {
                // If we are waking the device up while we are pulsing the clock and the
                // If we are waking the device up while we are pulsing the clock and the
                // notifications would light up first, creating an unpleasant animation.
                // notifications would light up first, creating an unpleasant animation.
                // Defer changing the screen brightness by forcing doze brightness on our window
                // Defer changing the screen brightness by forcing doze brightness on our window
@@ -175,6 +175,12 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
        Trace.endSection();
        Trace.endSection();
    }
    }


    private boolean pulsingOrAod() {
        boolean pulsing = mDozeScrimController.isPulsing();
        boolean dozingWithScreenOn = mStatusBar.isDozing() && !mStatusBar.isScreenFullyOff();
        return pulsing || dozingWithScreenOn;
    }

    @Override
    @Override
    public void onFingerprintAuthenticated(int userId) {
    public void onFingerprintAuthenticated(int userId) {
        Trace.beginSection("FingerprintUnlockController#onFingerprintAuthenticated");
        Trace.beginSection("FingerprintUnlockController#onFingerprintAuthenticated");
@@ -269,13 +275,11 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {


    private int calculateMode() {
    private int calculateMode() {
        boolean unlockingAllowed = mUpdateMonitor.isUnlockingWithFingerprintAllowed();
        boolean unlockingAllowed = mUpdateMonitor.isUnlockingWithFingerprintAllowed();
        boolean pulsing = mDozeScrimController.isPulsing();
        boolean dozingWithScreenOn = mStatusBar.isDozing() && !mStatusBar.isScreenFullyOff();


        if (!mUpdateMonitor.isDeviceInteractive()) {
        if (!mUpdateMonitor.isDeviceInteractive()) {
            if (!mStatusBarKeyguardViewManager.isShowing()) {
            if (!mStatusBarKeyguardViewManager.isShowing()) {
                return MODE_ONLY_WAKE;
                return MODE_ONLY_WAKE;
            } else if ((pulsing || dozingWithScreenOn) && unlockingAllowed) {
            } else if (pulsingOrAod() && unlockingAllowed) {
                return MODE_WAKE_AND_UNLOCK_PULSING;
                return MODE_WAKE_AND_UNLOCK_PULSING;
            } else if (unlockingAllowed || !mUnlockMethodCache.isMethodSecure()) {
            } else if (unlockingAllowed || !mUnlockMethodCache.isMethodSecure()) {
                return MODE_WAKE_AND_UNLOCK;
                return MODE_WAKE_AND_UNLOCK;
+5 −0
Original line number Original line Diff line number Diff line
@@ -5432,6 +5432,11 @@ public class StatusBar extends SystemUI implements DemoMode,
            }
            }
        }
        }


        @Override
        public void setDozeScreenBrightness(int value) {
            mStatusBarWindowManager.setDozeScreenBrightness(value);
        }

        public void dispatchDoubleTap(float viewX, float viewY) {
        public void dispatchDoubleTap(float viewX, float viewY) {
            dispatchTap(mAmbientIndicationContainer, viewX, viewY);
            dispatchTap(mAmbientIndicationContainer, viewX, viewY);
            dispatchTap(mAmbientIndicationContainer, viewX, viewY);
            dispatchTap(mAmbientIndicationContainer, viewX, viewY);
Loading