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

Commit 3bd612f9 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 2fb78baf 3e23eb59
Loading
Loading
Loading
Loading
+36 −0
Original line number 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 Diff line number Diff line
@@ -49,8 +49,12 @@ public class DozeFactory {
        WakeLock wakeLock = new DelayedWakeLock(handler,
                WakeLock.createPartial(context, "Doze"));

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

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

    void onDoubleTap(float x, float y);

    void setDozeScreenBrightness(int value);

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

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

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

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

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

        if (!mUpdateMonitor.isDeviceInteractive()) {
            if (!mStatusBarKeyguardViewManager.isShowing()) {
                return MODE_ONLY_WAKE;
            } else if ((pulsing || dozingWithScreenOn) && unlockingAllowed) {
            } else if (pulsingOrAod() && unlockingAllowed) {
                return MODE_WAKE_AND_UNLOCK_PULSING;
            } else if (unlockingAllowed || !mUnlockMethodCache.isMethodSecure()) {
                return MODE_WAKE_AND_UNLOCK;
+5 −0
Original line number 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) {
            dispatchTap(mAmbientIndicationContainer, viewX, viewY);
            dispatchTap(mAmbientIndicationContainer, viewX, viewY);
Loading