AOD: Keep doze brightness when unlocking with fingerprint

Updates the logic that was already in place to prevent lighting up
the display before the unlock transition starts:
- treat AOD as pulsing in FingerprintUnlockController
- now that doze can use more than one brightness level, use the current

Bug: 62885451
Test: Unlock with fingerprint from AOD. Observe that the unlock transition does not prematurely change the brightness level
Change-Id: I266bd5e4c0a1d5b4c347a65c0e7936247e333cfc
This commit is contained in:
Adrian Roos
2017-07-07 15:58:57 +02:00
parent feb5dc3b26
commit 3e23eb59d0
7 changed files with 65 additions and 7 deletions

View File

@@ -0,0 +1,36 @@
/*
* 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);
}
}

View File

@@ -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),

View File

@@ -41,6 +41,7 @@ public interface DozeHost {
void onDoubleTap(float x, float y);
void setDozeScreenBrightness(int value);
interface Callback {
default void onNotificationHeadsUp() {}

View File

@@ -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;

View File

@@ -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);

View File

@@ -58,7 +58,7 @@ public class StatusBarWindowManager implements RemoteInputController.Callback, D
private boolean mHasTopUiChanged;
private int mBarHeight;
private final boolean mKeyguardScreenRotation;
private final float mScreenBrightnessDoze;
private float mScreenBrightnessDoze;
private final State mCurrentState = new State();
private OtherwisedCollapsedListener mListener;
@@ -111,6 +111,10 @@ public class StatusBarWindowManager implements RemoteInputController.Callback, D
mLpChanged.copyFrom(mLp);
}
public void setDozeScreenBrightness(int value) {
mScreenBrightnessDoze = value / 255f;
}
public void setKeyguardDark(boolean dark) {
int vis = mStatusBarView.getSystemUiVisibility();
if (dark) {

View File

@@ -101,4 +101,8 @@ class DozeHostFake implements DozeHost {
doubleTapX = y;
doubleTapY = y;
}
@Override
public void setDozeScreenBrightness(int value) {
}
}