Merge "Enable "lift to retry" on face-auth devices" into qt-r1-dev
This commit is contained in:
@@ -22,6 +22,7 @@ import static com.android.systemui.Dependency.LEAK_REPORT_EMAIL_NAME;
|
||||
import android.annotation.Nullable;
|
||||
import android.app.AlarmManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
@@ -54,6 +55,7 @@ import com.android.systemui.statusbar.phone.DozeParameters;
|
||||
import com.android.systemui.statusbar.phone.KeyguardBouncer;
|
||||
import com.android.systemui.statusbar.phone.KeyguardBypassController;
|
||||
import com.android.systemui.statusbar.phone.KeyguardEnvironmentImpl;
|
||||
import com.android.systemui.statusbar.phone.KeyguardLiftController;
|
||||
import com.android.systemui.statusbar.phone.LockIcon;
|
||||
import com.android.systemui.statusbar.phone.LockscreenWallpaper;
|
||||
import com.android.systemui.statusbar.phone.NotificationIconAreaController;
|
||||
@@ -64,6 +66,7 @@ import com.android.systemui.statusbar.phone.StatusBar;
|
||||
import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager;
|
||||
import com.android.systemui.statusbar.phone.UnlockMethodCache;
|
||||
import com.android.systemui.statusbar.policy.DeviceProvisionedController;
|
||||
import com.android.systemui.util.AsyncSensorManager;
|
||||
import com.android.systemui.util.InjectionInflationController;
|
||||
import com.android.systemui.util.leak.GarbageMonitor;
|
||||
import com.android.systemui.volume.VolumeDialogComponent;
|
||||
@@ -212,6 +215,18 @@ public class SystemUIFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
@Nullable
|
||||
public KeyguardLiftController provideKeyguardLiftController(Context context,
|
||||
StatusBarStateController statusBarStateController,
|
||||
AsyncSensorManager asyncSensorManager) {
|
||||
if (!context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_FACE)) {
|
||||
return null;
|
||||
}
|
||||
return new KeyguardLiftController(context, statusBarStateController, asyncSensorManager);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
@Provides
|
||||
public NotificationListener provideNotificationListener(Context context) {
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.statusbar.phone
|
||||
|
||||
import android.content.Context
|
||||
import android.hardware.Sensor
|
||||
import android.hardware.TriggerEvent
|
||||
import android.hardware.TriggerEventListener
|
||||
import com.android.keyguard.KeyguardUpdateMonitor
|
||||
import com.android.keyguard.KeyguardUpdateMonitorCallback
|
||||
import com.android.systemui.plugins.statusbar.StatusBarStateController
|
||||
import com.android.systemui.util.Assert
|
||||
import com.android.systemui.util.AsyncSensorManager
|
||||
|
||||
class KeyguardLiftController constructor(
|
||||
context: Context,
|
||||
private val statusBarStateController: StatusBarStateController,
|
||||
private val asyncSensorManager: AsyncSensorManager
|
||||
) : StatusBarStateController.StateListener, KeyguardUpdateMonitorCallback() {
|
||||
|
||||
private val keyguardUpdateMonitor = KeyguardUpdateMonitor.getInstance(context)
|
||||
private val pickupSensor = asyncSensorManager.getDefaultSensor(Sensor.TYPE_PICK_UP_GESTURE)
|
||||
private var isListening = false
|
||||
private var bouncerVisible = false
|
||||
|
||||
init {
|
||||
statusBarStateController.addCallback(this)
|
||||
keyguardUpdateMonitor.registerCallback(this)
|
||||
updateListeningState()
|
||||
}
|
||||
|
||||
private val listener: TriggerEventListener = object : TriggerEventListener() {
|
||||
override fun onTrigger(event: TriggerEvent?) {
|
||||
Assert.isMainThread()
|
||||
// Not listening anymore since trigger events unregister themselves
|
||||
isListening = false
|
||||
updateListeningState()
|
||||
keyguardUpdateMonitor.requestFaceAuth()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDozingChanged(isDozing: Boolean) {
|
||||
updateListeningState()
|
||||
}
|
||||
|
||||
override fun onKeyguardBouncerChanged(bouncer: Boolean) {
|
||||
bouncerVisible = bouncer
|
||||
updateListeningState()
|
||||
}
|
||||
|
||||
override fun onKeyguardVisibilityChanged(showing: Boolean) {
|
||||
updateListeningState()
|
||||
}
|
||||
|
||||
private fun updateListeningState() {
|
||||
val onKeyguard = keyguardUpdateMonitor.isKeyguardVisible &&
|
||||
!statusBarStateController.isDozing
|
||||
|
||||
val shouldListen = onKeyguard || bouncerVisible
|
||||
if (shouldListen != isListening) {
|
||||
isListening = shouldListen
|
||||
|
||||
if (shouldListen) {
|
||||
asyncSensorManager.requestTriggerSensor(listener, pickupSensor)
|
||||
} else {
|
||||
asyncSensorManager.cancelTriggerSensor(listener, pickupSensor)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -373,6 +373,9 @@ public class StatusBar extends SystemUI implements DemoMode,
|
||||
KeyguardBypassController mKeyguardBypassController;
|
||||
@Inject
|
||||
protected HeadsUpManagerPhone mHeadsUpManager;
|
||||
@Nullable
|
||||
@Inject
|
||||
protected KeyguardLiftController mKeyguardLiftController;
|
||||
|
||||
// expanded notifications
|
||||
protected NotificationPanelView mNotificationPanel; // the sliding/resizing panel within the notification window
|
||||
|
||||
Reference in New Issue
Block a user