Merge "Replace KeyguardListenQueue with DumpsysTableLogger" into tm-qpr-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d8aadbd70b
@@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
* 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.keyguard
|
||||||
|
|
||||||
|
import android.annotation.CurrentTimeMillisLong
|
||||||
|
import com.android.systemui.dump.DumpsysTableLogger
|
||||||
|
import com.android.systemui.dump.Row
|
||||||
|
import com.android.systemui.plugins.util.RingBuffer
|
||||||
|
|
||||||
|
/** Verbose debug information. */
|
||||||
|
data class KeyguardActiveUnlockModel(
|
||||||
|
@CurrentTimeMillisLong override var timeMillis: Long = 0L,
|
||||||
|
override var userId: Int = 0,
|
||||||
|
override var listening: Boolean = false,
|
||||||
|
// keep sorted
|
||||||
|
var awakeKeyguard: Boolean = false,
|
||||||
|
var authInterruptActive: Boolean = false,
|
||||||
|
var fpLockedOut: Boolean = false,
|
||||||
|
var primaryAuthRequired: Boolean = false,
|
||||||
|
var switchingUser: Boolean = false,
|
||||||
|
var triggerActiveUnlockForAssistant: Boolean = false,
|
||||||
|
var userCanDismissLockScreen: Boolean = false,
|
||||||
|
) : KeyguardListenModel() {
|
||||||
|
|
||||||
|
/** List of [String] to be used as a [Row] with [DumpsysTableLogger]. */
|
||||||
|
val asStringList: List<String> by lazy {
|
||||||
|
listOf(
|
||||||
|
DATE_FORMAT.format(timeMillis),
|
||||||
|
timeMillis.toString(),
|
||||||
|
userId.toString(),
|
||||||
|
listening.toString(),
|
||||||
|
// keep sorted
|
||||||
|
awakeKeyguard.toString(),
|
||||||
|
authInterruptActive.toString(),
|
||||||
|
fpLockedOut.toString(),
|
||||||
|
primaryAuthRequired.toString(),
|
||||||
|
switchingUser.toString(),
|
||||||
|
triggerActiveUnlockForAssistant.toString(),
|
||||||
|
userCanDismissLockScreen.toString(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [RingBuffer] to store [KeyguardActiveUnlockModel]. After the buffer is full, it will recycle
|
||||||
|
* old events.
|
||||||
|
*
|
||||||
|
* Do not use [append] to add new elements. Instead use [insert], as it will recycle if
|
||||||
|
* necessary.
|
||||||
|
*/
|
||||||
|
class Buffer {
|
||||||
|
private val buffer = RingBuffer(CAPACITY) { KeyguardActiveUnlockModel() }
|
||||||
|
|
||||||
|
fun insert(model: KeyguardActiveUnlockModel) {
|
||||||
|
buffer.advance().apply {
|
||||||
|
timeMillis = model.timeMillis
|
||||||
|
userId = model.userId
|
||||||
|
listening = model.listening
|
||||||
|
// keep sorted
|
||||||
|
awakeKeyguard = model.awakeKeyguard
|
||||||
|
authInterruptActive = model.authInterruptActive
|
||||||
|
fpLockedOut = model.fpLockedOut
|
||||||
|
primaryAuthRequired = model.primaryAuthRequired
|
||||||
|
switchingUser = model.switchingUser
|
||||||
|
triggerActiveUnlockForAssistant = model.triggerActiveUnlockForAssistant
|
||||||
|
userCanDismissLockScreen = model.userCanDismissLockScreen
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the content of the buffer (sorted from latest to newest).
|
||||||
|
*
|
||||||
|
* @see KeyguardFingerprintListenModel.asStringList
|
||||||
|
*/
|
||||||
|
fun toList(): List<Row> {
|
||||||
|
return buffer.asSequence().map { it.asStringList }.toList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val CAPACITY = 20 // number of logs to retain
|
||||||
|
|
||||||
|
/** Headers for dumping a table using [DumpsysTableLogger]. */
|
||||||
|
@JvmField
|
||||||
|
val TABLE_HEADERS =
|
||||||
|
listOf(
|
||||||
|
"timestamp",
|
||||||
|
"time_millis",
|
||||||
|
"userId",
|
||||||
|
"listening",
|
||||||
|
// keep sorted
|
||||||
|
"awakeKeyguard",
|
||||||
|
"authInterruptActive",
|
||||||
|
"fpLockedOut",
|
||||||
|
"primaryAuthRequired",
|
||||||
|
"switchingUser",
|
||||||
|
"triggerActiveUnlockForAssistant",
|
||||||
|
"userCanDismissLockScreen",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,162 @@
|
|||||||
|
/*
|
||||||
|
* 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.keyguard
|
||||||
|
|
||||||
|
import android.annotation.CurrentTimeMillisLong
|
||||||
|
import com.android.systemui.dump.DumpsysTableLogger
|
||||||
|
import com.android.systemui.dump.Row
|
||||||
|
import com.android.systemui.plugins.util.RingBuffer
|
||||||
|
|
||||||
|
/** Verbose debug information associated. */
|
||||||
|
data class KeyguardFaceListenModel(
|
||||||
|
@CurrentTimeMillisLong override var timeMillis: Long = 0L,
|
||||||
|
override var userId: Int = 0,
|
||||||
|
override var listening: Boolean = false,
|
||||||
|
// keep sorted
|
||||||
|
var authInterruptActive: Boolean = false,
|
||||||
|
var biometricSettingEnabledForUser: Boolean = false,
|
||||||
|
var bouncerFullyShown: Boolean = false,
|
||||||
|
var faceAndFpNotAuthenticated: Boolean = false,
|
||||||
|
var faceAuthAllowed: Boolean = false,
|
||||||
|
var faceDisabled: Boolean = false,
|
||||||
|
var faceLockedOut: Boolean = false,
|
||||||
|
var goingToSleep: Boolean = false,
|
||||||
|
var keyguardAwake: Boolean = false,
|
||||||
|
var keyguardGoingAway: Boolean = false,
|
||||||
|
var listeningForFaceAssistant: Boolean = false,
|
||||||
|
var occludingAppRequestingFaceAuth: Boolean = false,
|
||||||
|
var primaryUser: Boolean = false,
|
||||||
|
var secureCameraLaunched: Boolean = false,
|
||||||
|
var supportsDetect: Boolean = false,
|
||||||
|
var switchingUser: Boolean = false,
|
||||||
|
var udfpsBouncerShowing: Boolean = false,
|
||||||
|
var udfpsFingerDown: Boolean = false,
|
||||||
|
var userNotTrustedOrDetectionIsNeeded: Boolean = false,
|
||||||
|
) : KeyguardListenModel() {
|
||||||
|
|
||||||
|
/** List of [String] to be used as a [Row] with [DumpsysTableLogger]. */
|
||||||
|
val asStringList: List<String> by lazy {
|
||||||
|
listOf(
|
||||||
|
DATE_FORMAT.format(timeMillis),
|
||||||
|
timeMillis.toString(),
|
||||||
|
userId.toString(),
|
||||||
|
listening.toString(),
|
||||||
|
// keep sorted
|
||||||
|
authInterruptActive.toString(),
|
||||||
|
biometricSettingEnabledForUser.toString(),
|
||||||
|
bouncerFullyShown.toString(),
|
||||||
|
faceAndFpNotAuthenticated.toString(),
|
||||||
|
faceAuthAllowed.toString(),
|
||||||
|
faceDisabled.toString(),
|
||||||
|
faceLockedOut.toString(),
|
||||||
|
goingToSleep.toString(),
|
||||||
|
keyguardAwake.toString(),
|
||||||
|
keyguardGoingAway.toString(),
|
||||||
|
listeningForFaceAssistant.toString(),
|
||||||
|
occludingAppRequestingFaceAuth.toString(),
|
||||||
|
primaryUser.toString(),
|
||||||
|
secureCameraLaunched.toString(),
|
||||||
|
supportsDetect.toString(),
|
||||||
|
switchingUser.toString(),
|
||||||
|
udfpsBouncerShowing.toString(),
|
||||||
|
udfpsFingerDown.toString(),
|
||||||
|
userNotTrustedOrDetectionIsNeeded.toString(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [RingBuffer] to store [KeyguardFaceListenModel]. After the buffer is full, it will recycle
|
||||||
|
* old events.
|
||||||
|
*
|
||||||
|
* Do not use [append] to add new elements. Instead use [insert], as it will recycle if
|
||||||
|
* necessary.
|
||||||
|
*/
|
||||||
|
class Buffer {
|
||||||
|
private val buffer = RingBuffer(CAPACITY) { KeyguardFaceListenModel() }
|
||||||
|
|
||||||
|
fun insert(model: KeyguardFaceListenModel) {
|
||||||
|
buffer.advance().apply {
|
||||||
|
timeMillis = model.timeMillis
|
||||||
|
userId = model.userId
|
||||||
|
listening = model.listening
|
||||||
|
// keep sorted
|
||||||
|
biometricSettingEnabledForUser = model.biometricSettingEnabledForUser
|
||||||
|
bouncerFullyShown = model.bouncerFullyShown
|
||||||
|
faceAndFpNotAuthenticated = model.faceAndFpNotAuthenticated
|
||||||
|
faceAuthAllowed = model.faceAuthAllowed
|
||||||
|
faceDisabled = model.faceDisabled
|
||||||
|
faceLockedOut = model.faceLockedOut
|
||||||
|
goingToSleep = model.goingToSleep
|
||||||
|
keyguardAwake = model.keyguardAwake
|
||||||
|
goingToSleep = model.goingToSleep
|
||||||
|
keyguardGoingAway = model.keyguardGoingAway
|
||||||
|
listeningForFaceAssistant = model.listeningForFaceAssistant
|
||||||
|
occludingAppRequestingFaceAuth = model.occludingAppRequestingFaceAuth
|
||||||
|
primaryUser = model.primaryUser
|
||||||
|
secureCameraLaunched = model.secureCameraLaunched
|
||||||
|
supportsDetect = model.supportsDetect
|
||||||
|
switchingUser = model.switchingUser
|
||||||
|
udfpsBouncerShowing = model.udfpsBouncerShowing
|
||||||
|
switchingUser = model.switchingUser
|
||||||
|
udfpsFingerDown = model.udfpsFingerDown
|
||||||
|
userNotTrustedOrDetectionIsNeeded = model.userNotTrustedOrDetectionIsNeeded
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns the content of the buffer (sorted from latest to newest).
|
||||||
|
*
|
||||||
|
* @see KeyguardFingerprintListenModel.asStringList
|
||||||
|
*/
|
||||||
|
fun toList(): List<Row> {
|
||||||
|
return buffer.asSequence().map { it.asStringList }.toList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val CAPACITY = 40 // number of logs to retain
|
||||||
|
|
||||||
|
/** Headers for dumping a table using [DumpsysTableLogger]. */
|
||||||
|
@JvmField
|
||||||
|
val TABLE_HEADERS =
|
||||||
|
listOf(
|
||||||
|
"timestamp",
|
||||||
|
"time_millis",
|
||||||
|
"userId",
|
||||||
|
"listening",
|
||||||
|
// keep sorted
|
||||||
|
"authInterruptActive",
|
||||||
|
"biometricSettingEnabledForUser",
|
||||||
|
"bouncerFullyShown",
|
||||||
|
"faceAndFpNotAuthenticated",
|
||||||
|
"faceAuthAllowed",
|
||||||
|
"faceDisabled",
|
||||||
|
"faceLockedOut",
|
||||||
|
"goingToSleep",
|
||||||
|
"keyguardAwake",
|
||||||
|
"keyguardGoingAway",
|
||||||
|
"listeningForFaceAssistant",
|
||||||
|
"occludingAppRequestingFaceAuth",
|
||||||
|
"primaryUser",
|
||||||
|
"secureCameraLaunched",
|
||||||
|
"supportsDetect",
|
||||||
|
"switchingUser",
|
||||||
|
"udfpsBouncerShowing",
|
||||||
|
"udfpsFingerDown",
|
||||||
|
"userNotTrustedOrDetectionIsNeeded",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,166 @@
|
|||||||
|
/*
|
||||||
|
* 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.keyguard
|
||||||
|
|
||||||
|
import android.annotation.CurrentTimeMillisLong
|
||||||
|
import com.android.systemui.dump.DumpsysTableLogger
|
||||||
|
import com.android.systemui.dump.Row
|
||||||
|
import com.android.systemui.plugins.util.RingBuffer
|
||||||
|
|
||||||
|
/** Verbose debug information. */
|
||||||
|
data class KeyguardFingerprintListenModel(
|
||||||
|
@CurrentTimeMillisLong override var timeMillis: Long = 0L,
|
||||||
|
override var userId: Int = 0,
|
||||||
|
override var listening: Boolean = false,
|
||||||
|
// keepSorted
|
||||||
|
var biometricEnabledForUser: Boolean = false,
|
||||||
|
var bouncerIsOrWillShow: Boolean = false,
|
||||||
|
var canSkipBouncer: Boolean = false,
|
||||||
|
var credentialAttempted: Boolean = false,
|
||||||
|
var deviceInteractive: Boolean = false,
|
||||||
|
var dreaming: Boolean = false,
|
||||||
|
var fingerprintDisabled: Boolean = false,
|
||||||
|
var fingerprintLockedOut: Boolean = false,
|
||||||
|
var goingToSleep: Boolean = false,
|
||||||
|
var keyguardGoingAway: Boolean = false,
|
||||||
|
var keyguardIsVisible: Boolean = false,
|
||||||
|
var keyguardOccluded: Boolean = false,
|
||||||
|
var occludingAppRequestingFp: Boolean = false,
|
||||||
|
var primaryUser: Boolean = false,
|
||||||
|
var shouldListenSfpsState: Boolean = false,
|
||||||
|
var shouldListenForFingerprintAssistant: Boolean = false,
|
||||||
|
var strongerAuthRequired: Boolean = false,
|
||||||
|
var switchingUser: Boolean = false,
|
||||||
|
var udfps: Boolean = false,
|
||||||
|
var userDoesNotHaveTrust: Boolean = false,
|
||||||
|
) : KeyguardListenModel() {
|
||||||
|
|
||||||
|
/** List of [String] to be used as a [Row] with [DumpsysTableLogger]. */
|
||||||
|
val asStringList: List<String> by lazy {
|
||||||
|
listOf(
|
||||||
|
DATE_FORMAT.format(timeMillis),
|
||||||
|
timeMillis.toString(),
|
||||||
|
userId.toString(),
|
||||||
|
listening.toString(),
|
||||||
|
// keep sorted
|
||||||
|
biometricEnabledForUser.toString(),
|
||||||
|
bouncerIsOrWillShow.toString(),
|
||||||
|
canSkipBouncer.toString(),
|
||||||
|
credentialAttempted.toString(),
|
||||||
|
deviceInteractive.toString(),
|
||||||
|
dreaming.toString(),
|
||||||
|
fingerprintDisabled.toString(),
|
||||||
|
fingerprintLockedOut.toString(),
|
||||||
|
goingToSleep.toString(),
|
||||||
|
keyguardGoingAway.toString(),
|
||||||
|
keyguardIsVisible.toString(),
|
||||||
|
keyguardOccluded.toString(),
|
||||||
|
occludingAppRequestingFp.toString(),
|
||||||
|
primaryUser.toString(),
|
||||||
|
shouldListenSfpsState.toString(),
|
||||||
|
shouldListenForFingerprintAssistant.toString(),
|
||||||
|
strongerAuthRequired.toString(),
|
||||||
|
switchingUser.toString(),
|
||||||
|
udfps.toString(),
|
||||||
|
userDoesNotHaveTrust.toString(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [RingBuffer] to store [KeyguardFingerprintListenModel]. After the buffer is full, it will
|
||||||
|
* recycle old events.
|
||||||
|
*
|
||||||
|
* Do not use [append] to add new elements. Instead use [insert], as it will recycle if
|
||||||
|
* necessary.
|
||||||
|
*/
|
||||||
|
class Buffer {
|
||||||
|
private val buffer = RingBuffer(CAPACITY) { KeyguardFingerprintListenModel() }
|
||||||
|
|
||||||
|
fun insert(model: KeyguardFingerprintListenModel) {
|
||||||
|
buffer.advance().apply {
|
||||||
|
timeMillis = model.timeMillis
|
||||||
|
userId = model.userId
|
||||||
|
listening = model.listening
|
||||||
|
// keep sorted
|
||||||
|
biometricEnabledForUser = model.biometricEnabledForUser
|
||||||
|
bouncerIsOrWillShow = model.bouncerIsOrWillShow
|
||||||
|
canSkipBouncer = model.canSkipBouncer
|
||||||
|
credentialAttempted = model.credentialAttempted
|
||||||
|
deviceInteractive = model.deviceInteractive
|
||||||
|
dreaming = model.dreaming
|
||||||
|
fingerprintDisabled = model.fingerprintDisabled
|
||||||
|
fingerprintLockedOut = model.fingerprintLockedOut
|
||||||
|
goingToSleep = model.goingToSleep
|
||||||
|
keyguardGoingAway = model.keyguardGoingAway
|
||||||
|
keyguardIsVisible = model.keyguardIsVisible
|
||||||
|
keyguardOccluded = model.keyguardOccluded
|
||||||
|
occludingAppRequestingFp = model.occludingAppRequestingFp
|
||||||
|
primaryUser = model.primaryUser
|
||||||
|
shouldListenSfpsState = model.shouldListenSfpsState
|
||||||
|
shouldListenForFingerprintAssistant = model.shouldListenForFingerprintAssistant
|
||||||
|
strongerAuthRequired = model.strongerAuthRequired
|
||||||
|
switchingUser = model.switchingUser
|
||||||
|
udfps = model.udfps
|
||||||
|
userDoesNotHaveTrust = model.userDoesNotHaveTrust
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the content of the buffer (sorted from latest to newest).
|
||||||
|
*
|
||||||
|
* @see KeyguardFingerprintListenModel.asStringList
|
||||||
|
*/
|
||||||
|
fun toList(): List<Row> {
|
||||||
|
return buffer.asSequence().map { it.asStringList }.toList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
const val CAPACITY = 20 // number of logs to retain
|
||||||
|
|
||||||
|
/** Headers for dumping a table using [DumpsysTableLogger]. */
|
||||||
|
@JvmField
|
||||||
|
val TABLE_HEADERS =
|
||||||
|
listOf(
|
||||||
|
"timestamp",
|
||||||
|
"time_millis",
|
||||||
|
"userId",
|
||||||
|
"listening",
|
||||||
|
// keep sorted
|
||||||
|
"biometricAllowedForUser",
|
||||||
|
"bouncerIsOrWillShow",
|
||||||
|
"canSkipBouncer",
|
||||||
|
"credentialAttempted",
|
||||||
|
"deviceInteractive",
|
||||||
|
"dreaming",
|
||||||
|
"fingerprintDisabled",
|
||||||
|
"fingerprintLockedOut",
|
||||||
|
"goingToSleep",
|
||||||
|
"keyguardGoingAway",
|
||||||
|
"keyguardIsVisible",
|
||||||
|
"keyguardOccluded",
|
||||||
|
"occludingAppRequestingFp",
|
||||||
|
"primaryUser",
|
||||||
|
"shouldListenSidFingerprintState",
|
||||||
|
"shouldListenForFingerprintAssistant",
|
||||||
|
"strongAuthRequired",
|
||||||
|
"switchingUser",
|
||||||
|
"underDisplayFingerprint",
|
||||||
|
"userDoesNotHaveTrust",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,87 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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.keyguard
|
package com.android.keyguard
|
||||||
|
|
||||||
import android.annotation.CurrentTimeMillisLong
|
import java.text.SimpleDateFormat
|
||||||
|
import java.util.Locale
|
||||||
|
|
||||||
/** Verbose logging for various keyguard listening states. */
|
/** Verbose logging for various keyguard listening states. */
|
||||||
sealed class KeyguardListenModel {
|
sealed class KeyguardListenModel {
|
||||||
/** Timestamp of the state change. */
|
/** Timestamp of the state change. */
|
||||||
abstract val timeMillis: Long
|
abstract var timeMillis: Long
|
||||||
/** Current user. */
|
/** Current user. */
|
||||||
abstract val userId: Int
|
abstract var userId: Int
|
||||||
/** If keyguard is listening for the modality represented by this model. */
|
/** If keyguard is listening for the modality represented by this model. */
|
||||||
abstract val listening: Boolean
|
abstract var listening: Boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
val DATE_FORMAT = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US)
|
||||||
* Verbose debug information associated with [KeyguardUpdateMonitor.shouldListenForFingerprint].
|
|
||||||
*/
|
|
||||||
data class KeyguardFingerprintListenModel(
|
|
||||||
@CurrentTimeMillisLong override val timeMillis: Long,
|
|
||||||
override val userId: Int,
|
|
||||||
override val listening: Boolean,
|
|
||||||
// keep sorted
|
|
||||||
val biometricEnabledForUser: Boolean,
|
|
||||||
val bouncerIsOrWillShow: Boolean,
|
|
||||||
val canSkipBouncer: Boolean,
|
|
||||||
val credentialAttempted: Boolean,
|
|
||||||
val deviceInteractive: Boolean,
|
|
||||||
val dreaming: Boolean,
|
|
||||||
val fingerprintDisabled: Boolean,
|
|
||||||
val fingerprintLockedOut: Boolean,
|
|
||||||
val goingToSleep: Boolean,
|
|
||||||
val keyguardGoingAway: Boolean,
|
|
||||||
val keyguardIsVisible: Boolean,
|
|
||||||
val keyguardOccluded: Boolean,
|
|
||||||
val occludingAppRequestingFp: Boolean,
|
|
||||||
val primaryUser: Boolean,
|
|
||||||
val shouldListenSfpsState: Boolean,
|
|
||||||
val shouldListenForFingerprintAssistant: Boolean,
|
|
||||||
val strongerAuthRequired: Boolean,
|
|
||||||
val switchingUser: Boolean,
|
|
||||||
val udfps: Boolean,
|
|
||||||
val userDoesNotHaveTrust: Boolean
|
|
||||||
) : KeyguardListenModel()
|
|
||||||
/**
|
|
||||||
* Verbose debug information associated with [KeyguardUpdateMonitor.shouldListenForFace].
|
|
||||||
*/
|
|
||||||
data class KeyguardFaceListenModel(
|
|
||||||
@CurrentTimeMillisLong override val timeMillis: Long,
|
|
||||||
override val userId: Int,
|
|
||||||
override val listening: Boolean,
|
|
||||||
// keep sorted
|
|
||||||
val authInterruptActive: Boolean,
|
|
||||||
val biometricSettingEnabledForUser: Boolean,
|
|
||||||
val bouncerFullyShown: Boolean,
|
|
||||||
val faceAndFpNotAuthenticated: Boolean,
|
|
||||||
val faceAuthAllowed: Boolean,
|
|
||||||
val faceDisabled: Boolean,
|
|
||||||
val faceLockedOut: Boolean,
|
|
||||||
val goingToSleep: Boolean,
|
|
||||||
val keyguardAwake: Boolean,
|
|
||||||
val keyguardGoingAway: Boolean,
|
|
||||||
val listeningForFaceAssistant: Boolean,
|
|
||||||
val occludingAppRequestingFaceAuth: Boolean,
|
|
||||||
val primaryUser: Boolean,
|
|
||||||
val secureCameraLaunched: Boolean,
|
|
||||||
val supportsDetect: Boolean,
|
|
||||||
val switchingUser: Boolean,
|
|
||||||
val udfpsBouncerShowing: Boolean,
|
|
||||||
val udfpsFingerDown: Boolean,
|
|
||||||
val userNotTrustedOrDetectionIsNeeded: Boolean,
|
|
||||||
) : KeyguardListenModel()
|
|
||||||
/**
|
|
||||||
* Verbose debug information associated with [KeyguardUpdateMonitor.shouldTriggerActiveUnlock].
|
|
||||||
*/
|
|
||||||
data class KeyguardActiveUnlockModel(
|
|
||||||
@CurrentTimeMillisLong override val timeMillis: Long,
|
|
||||||
override val userId: Int,
|
|
||||||
override val listening: Boolean,
|
|
||||||
// keep sorted
|
|
||||||
val awakeKeyguard: Boolean,
|
|
||||||
val authInterruptActive: Boolean,
|
|
||||||
val fpLockedOut: Boolean,
|
|
||||||
val primaryAuthRequired: Boolean,
|
|
||||||
val switchingUser: Boolean,
|
|
||||||
val triggerActiveUnlockForAssistant: Boolean,
|
|
||||||
val userCanDismissLockScreen: Boolean
|
|
||||||
) : KeyguardListenModel()
|
|
||||||
|
|||||||
@@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021 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.keyguard
|
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting
|
|
||||||
import java.io.PrintWriter
|
|
||||||
import java.text.DateFormat
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.Date
|
|
||||||
import java.util.Locale
|
|
||||||
import kotlin.collections.ArrayDeque
|
|
||||||
|
|
||||||
private val DEFAULT_FORMATTING = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS", Locale.US)
|
|
||||||
|
|
||||||
/** Queue for verbose logging checks for the listening state. */
|
|
||||||
class KeyguardListenQueue(
|
|
||||||
val sizePerModality: Int = 20
|
|
||||||
) {
|
|
||||||
private val faceQueue = ArrayDeque<KeyguardFaceListenModel>()
|
|
||||||
private val fingerprintQueue = ArrayDeque<KeyguardFingerprintListenModel>()
|
|
||||||
private val activeUnlockQueue = ArrayDeque<KeyguardActiveUnlockModel>()
|
|
||||||
|
|
||||||
@get:VisibleForTesting val models: List<KeyguardListenModel>
|
|
||||||
get() = faceQueue + fingerprintQueue + activeUnlockQueue
|
|
||||||
|
|
||||||
/** Push a [model] to the queue (will be logged until the queue exceeds [sizePerModality]). */
|
|
||||||
fun add(model: KeyguardListenModel) {
|
|
||||||
val queue = when (model) {
|
|
||||||
is KeyguardFaceListenModel -> faceQueue.apply { add(model) }
|
|
||||||
is KeyguardFingerprintListenModel -> fingerprintQueue.apply { add(model) }
|
|
||||||
is KeyguardActiveUnlockModel -> activeUnlockQueue.apply { add(model) }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (queue.size > sizePerModality) {
|
|
||||||
queue.removeFirstOrNull()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Print verbose logs via the [writer]. */
|
|
||||||
@JvmOverloads
|
|
||||||
fun print(writer: PrintWriter, dateFormat: DateFormat = DEFAULT_FORMATTING) {
|
|
||||||
val stringify: (KeyguardListenModel) -> String = { model ->
|
|
||||||
" ${dateFormat.format(Date(model.timeMillis))} $model"
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.println(" Face listen results (last ${faceQueue.size} calls):")
|
|
||||||
for (model in faceQueue) {
|
|
||||||
writer.println(stringify(model))
|
|
||||||
}
|
|
||||||
writer.println(" Fingerprint listen results (last ${fingerprintQueue.size} calls):")
|
|
||||||
for (model in fingerprintQueue) {
|
|
||||||
writer.println(stringify(model))
|
|
||||||
}
|
|
||||||
writer.println(" Active unlock triggers (last ${activeUnlockQueue.size} calls):")
|
|
||||||
for (model in activeUnlockQueue) {
|
|
||||||
writer.println(stringify(model))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -146,6 +146,7 @@ import com.android.systemui.dagger.SysUISingleton;
|
|||||||
import com.android.systemui.dagger.qualifiers.Background;
|
import com.android.systemui.dagger.qualifiers.Background;
|
||||||
import com.android.systemui.dagger.qualifiers.Main;
|
import com.android.systemui.dagger.qualifiers.Main;
|
||||||
import com.android.systemui.dump.DumpManager;
|
import com.android.systemui.dump.DumpManager;
|
||||||
|
import com.android.systemui.dump.DumpsysTableLogger;
|
||||||
import com.android.systemui.log.SessionTracker;
|
import com.android.systemui.log.SessionTracker;
|
||||||
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
import com.android.systemui.plugins.statusbar.StatusBarStateController;
|
||||||
import com.android.systemui.settings.UserTracker;
|
import com.android.systemui.settings.UserTracker;
|
||||||
@@ -461,14 +462,18 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
private final SparseBooleanArray mBiometricEnabledForUser = new SparseBooleanArray();
|
private final SparseBooleanArray mBiometricEnabledForUser = new SparseBooleanArray();
|
||||||
private final Map<Integer, Intent> mSecondaryLockscreenRequirement = new HashMap<>();
|
private final Map<Integer, Intent> mSecondaryLockscreenRequirement = new HashMap<>();
|
||||||
|
|
||||||
|
private final KeyguardFingerprintListenModel.Buffer mFingerprintListenBuffer =
|
||||||
|
new KeyguardFingerprintListenModel.Buffer();
|
||||||
|
private final KeyguardFaceListenModel.Buffer mFaceListenBuffer =
|
||||||
|
new KeyguardFaceListenModel.Buffer();
|
||||||
|
private final KeyguardActiveUnlockModel.Buffer mActiveUnlockTriggerBuffer =
|
||||||
|
new KeyguardActiveUnlockModel.Buffer();
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
SparseArray<BiometricAuthenticated> mUserFingerprintAuthenticated = new SparseArray<>();
|
SparseArray<BiometricAuthenticated> mUserFingerprintAuthenticated = new SparseArray<>();
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
SparseArray<BiometricAuthenticated> mUserFaceAuthenticated = new SparseArray<>();
|
SparseArray<BiometricAuthenticated> mUserFaceAuthenticated = new SparseArray<>();
|
||||||
|
|
||||||
// Keep track of recent calls to shouldListenFor*() for debugging.
|
|
||||||
private final KeyguardListenQueue mListenModels = new KeyguardListenQueue();
|
|
||||||
|
|
||||||
private static int sCurrentUser;
|
private static int sCurrentUser;
|
||||||
|
|
||||||
public synchronized static void setCurrentUser(int currentUser) {
|
public synchronized static void setCurrentUser(int currentUser) {
|
||||||
@@ -2650,7 +2655,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
&& !mSecureCameraLaunched;
|
&& !mSecureCameraLaunched;
|
||||||
|
|
||||||
// Aggregate relevant fields for debug logging.
|
// Aggregate relevant fields for debug logging.
|
||||||
maybeLogListenerModelData(
|
logListenerModelData(
|
||||||
new KeyguardActiveUnlockModel(
|
new KeyguardActiveUnlockModel(
|
||||||
System.currentTimeMillis(),
|
System.currentTimeMillis(),
|
||||||
user,
|
user,
|
||||||
@@ -2731,7 +2736,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
boolean shouldListen = shouldListenKeyguardState && shouldListenUserState
|
boolean shouldListen = shouldListenKeyguardState && shouldListenUserState
|
||||||
&& shouldListenBouncerState && shouldListenUdfpsState
|
&& shouldListenBouncerState && shouldListenUdfpsState
|
||||||
&& shouldListenSideFpsState;
|
&& shouldListenSideFpsState;
|
||||||
maybeLogListenerModelData(
|
logListenerModelData(
|
||||||
new KeyguardFingerprintListenModel(
|
new KeyguardFingerprintListenModel(
|
||||||
System.currentTimeMillis(),
|
System.currentTimeMillis(),
|
||||||
user,
|
user,
|
||||||
@@ -2816,7 +2821,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
&& !mGoingToSleep;
|
&& !mGoingToSleep;
|
||||||
|
|
||||||
// Aggregate relevant fields for debug logging.
|
// Aggregate relevant fields for debug logging.
|
||||||
maybeLogListenerModelData(
|
logListenerModelData(
|
||||||
new KeyguardFaceListenModel(
|
new KeyguardFaceListenModel(
|
||||||
System.currentTimeMillis(),
|
System.currentTimeMillis(),
|
||||||
user,
|
user,
|
||||||
@@ -2844,28 +2849,14 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
return shouldListen;
|
return shouldListen;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void maybeLogListenerModelData(@NonNull KeyguardListenModel model) {
|
private void logListenerModelData(@NonNull KeyguardListenModel model) {
|
||||||
mLogger.logKeyguardListenerModel(model);
|
mLogger.logKeyguardListenerModel(model);
|
||||||
|
if (model instanceof KeyguardFingerprintListenModel) {
|
||||||
if (model instanceof KeyguardActiveUnlockModel) {
|
mFingerprintListenBuffer.insert((KeyguardFingerprintListenModel) model);
|
||||||
mListenModels.add(model);
|
} else if (model instanceof KeyguardActiveUnlockModel) {
|
||||||
return;
|
mActiveUnlockTriggerBuffer.insert((KeyguardActiveUnlockModel) model);
|
||||||
}
|
} else if (model instanceof KeyguardFaceListenModel) {
|
||||||
|
mFaceListenBuffer.insert((KeyguardFaceListenModel) model);
|
||||||
// Add model data to the historical buffer.
|
|
||||||
final boolean notYetRunning =
|
|
||||||
(model instanceof KeyguardFaceListenModel
|
|
||||||
&& mFaceRunningState != BIOMETRIC_STATE_RUNNING)
|
|
||||||
|| (model instanceof KeyguardFingerprintListenModel
|
|
||||||
&& mFingerprintRunningState != BIOMETRIC_STATE_RUNNING);
|
|
||||||
final boolean running =
|
|
||||||
(model instanceof KeyguardFaceListenModel
|
|
||||||
&& mFaceRunningState == BIOMETRIC_STATE_RUNNING)
|
|
||||||
|| (model instanceof KeyguardFingerprintListenModel
|
|
||||||
&& mFingerprintRunningState == BIOMETRIC_STATE_RUNNING);
|
|
||||||
if (notYetRunning && model.getListening()
|
|
||||||
|| running && !model.getListening()) {
|
|
||||||
mListenModels.add(model);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3938,6 +3929,11 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
pw.println(" mSfpsRequireScreenOnToAuthPrefEnabled="
|
pw.println(" mSfpsRequireScreenOnToAuthPrefEnabled="
|
||||||
+ mSfpsRequireScreenOnToAuthPrefEnabled);
|
+ mSfpsRequireScreenOnToAuthPrefEnabled);
|
||||||
}
|
}
|
||||||
|
new DumpsysTableLogger(
|
||||||
|
"KeyguardFingerprintListen",
|
||||||
|
KeyguardFingerprintListenModel.TABLE_HEADERS,
|
||||||
|
mFingerprintListenBuffer.toList()
|
||||||
|
).printTableData(pw);
|
||||||
}
|
}
|
||||||
if (mFaceManager != null && mFaceManager.isHardwareDetected()) {
|
if (mFaceManager != null && mFaceManager.isHardwareDetected()) {
|
||||||
final int userId = mUserTracker.getUserId();
|
final int userId = mUserTracker.getUserId();
|
||||||
@@ -3963,7 +3959,17 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener, Dumpab
|
|||||||
pw.println(" mSecureCameraLaunched=" + mSecureCameraLaunched);
|
pw.println(" mSecureCameraLaunched=" + mSecureCameraLaunched);
|
||||||
pw.println(" mPrimaryBouncerFullyShown=" + mPrimaryBouncerFullyShown);
|
pw.println(" mPrimaryBouncerFullyShown=" + mPrimaryBouncerFullyShown);
|
||||||
pw.println(" mNeedsSlowUnlockTransition=" + mNeedsSlowUnlockTransition);
|
pw.println(" mNeedsSlowUnlockTransition=" + mNeedsSlowUnlockTransition);
|
||||||
|
new DumpsysTableLogger(
|
||||||
|
"KeyguardFaceListen",
|
||||||
|
KeyguardFaceListenModel.TABLE_HEADERS,
|
||||||
|
mFaceListenBuffer.toList()
|
||||||
|
).printTableData(pw);
|
||||||
}
|
}
|
||||||
mListenModels.print(pw);
|
|
||||||
|
new DumpsysTableLogger(
|
||||||
|
"KeyguardActiveUnlockTriggers",
|
||||||
|
KeyguardActiveUnlockModel.TABLE_HEADERS,
|
||||||
|
mActiveUnlockTriggerBuffer.toList()
|
||||||
|
).printTableData(pw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,105 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2021 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.keyguard
|
|
||||||
|
|
||||||
import android.testing.AndroidTestingRunner
|
|
||||||
import androidx.test.filters.SmallTest
|
|
||||||
import com.android.systemui.SysuiTestCase
|
|
||||||
import com.google.common.truth.Truth.assertThat
|
|
||||||
import org.junit.Test
|
|
||||||
import org.junit.runner.RunWith
|
|
||||||
|
|
||||||
@RunWith(AndroidTestingRunner::class)
|
|
||||||
@SmallTest
|
|
||||||
class KeyguardListenQueueTest : SysuiTestCase() {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testQueueIsBounded() {
|
|
||||||
val size = 5
|
|
||||||
val queue = KeyguardListenQueue(sizePerModality = size)
|
|
||||||
|
|
||||||
val fingerprints = List(100) { fingerprintModel(it) }
|
|
||||||
fingerprints.forEach { queue.add(it) }
|
|
||||||
|
|
||||||
assertThat(queue.models).containsExactlyElementsIn(fingerprints.takeLast(size))
|
|
||||||
|
|
||||||
val faces = List(100) { faceModel(it) }
|
|
||||||
faces.forEach { queue.add(it) }
|
|
||||||
|
|
||||||
assertThat(queue.models).containsExactlyElementsIn(
|
|
||||||
faces.takeLast(size) + fingerprints.takeLast(5)
|
|
||||||
)
|
|
||||||
|
|
||||||
repeat(100) {
|
|
||||||
queue.add(faceModel(-1))
|
|
||||||
queue.add(fingerprintModel(-1))
|
|
||||||
}
|
|
||||||
assertThat(queue.models).hasSize(2 * size)
|
|
||||||
assertThat(queue.models.count { it.userId == -1 }).isEqualTo(2 * size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun fingerprintModel(user: Int) = KeyguardFingerprintListenModel(
|
|
||||||
timeMillis = System.currentTimeMillis(),
|
|
||||||
userId = user,
|
|
||||||
listening = false,
|
|
||||||
biometricEnabledForUser = false,
|
|
||||||
bouncerIsOrWillShow = false,
|
|
||||||
canSkipBouncer = false,
|
|
||||||
credentialAttempted = false,
|
|
||||||
deviceInteractive = false,
|
|
||||||
dreaming = false,
|
|
||||||
fingerprintDisabled = false,
|
|
||||||
fingerprintLockedOut = false,
|
|
||||||
goingToSleep = false,
|
|
||||||
keyguardGoingAway = false,
|
|
||||||
keyguardIsVisible = false,
|
|
||||||
keyguardOccluded = false,
|
|
||||||
occludingAppRequestingFp = false,
|
|
||||||
primaryUser = false,
|
|
||||||
shouldListenSfpsState = false,
|
|
||||||
shouldListenForFingerprintAssistant = false,
|
|
||||||
strongerAuthRequired = false,
|
|
||||||
switchingUser = false,
|
|
||||||
udfps = false,
|
|
||||||
userDoesNotHaveTrust = false
|
|
||||||
)
|
|
||||||
|
|
||||||
private fun faceModel(user: Int) = KeyguardFaceListenModel(
|
|
||||||
timeMillis = System.currentTimeMillis(),
|
|
||||||
userId = user,
|
|
||||||
listening = false,
|
|
||||||
authInterruptActive = false,
|
|
||||||
biometricSettingEnabledForUser = false,
|
|
||||||
bouncerFullyShown = false,
|
|
||||||
faceAndFpNotAuthenticated = false,
|
|
||||||
faceAuthAllowed = true,
|
|
||||||
faceDisabled = false,
|
|
||||||
faceLockedOut = false,
|
|
||||||
goingToSleep = false,
|
|
||||||
keyguardAwake = false,
|
|
||||||
keyguardGoingAway = false,
|
|
||||||
listeningForFaceAssistant = false,
|
|
||||||
occludingAppRequestingFaceAuth = false,
|
|
||||||
primaryUser = false,
|
|
||||||
secureCameraLaunched = false,
|
|
||||||
supportsDetect = true,
|
|
||||||
switchingUser = false,
|
|
||||||
udfpsBouncerShowing = false,
|
|
||||||
udfpsFingerDown = false,
|
|
||||||
userNotTrustedOrDetectionIsNeeded = false
|
|
||||||
)
|
|
||||||
Reference in New Issue
Block a user