Loading packages/SystemUI/src/com/android/keyguard/logging/DeviceEntryIconLogger.kt 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.logging import com.android.systemui.dagger.SysUISingleton import com.android.systemui.log.LogBuffer import com.android.systemui.log.core.LogLevel import com.android.systemui.log.core.LogLevel.DEBUG import com.android.systemui.log.core.LogLevel.INFO import com.android.systemui.log.dagger.DeviceEntryIconLog import com.google.errorprone.annotations.CompileTimeConstant import javax.inject.Inject private const val GENERIC_TAG = "DeviceEntryIconLogger" /** Helper class for logging for the DeviceEntryIcon */ @SysUISingleton class DeviceEntryIconLogger @Inject constructor(@DeviceEntryIconLog private val logBuffer: LogBuffer) { fun i(@CompileTimeConstant msg: String) = log(msg, INFO) fun d(@CompileTimeConstant msg: String) = log(msg, DEBUG) fun log(@CompileTimeConstant msg: String, level: LogLevel) = logBuffer.log(GENERIC_TAG, level, msg) fun logDeviceEntryUdfpsTouchOverlayShouldHandleTouches( shouldHandleTouches: Boolean, canTouchDeviceEntryViewAlpha: Boolean, alternateBouncerVisible: Boolean, hideAffordancesRequest: Boolean, ) { logBuffer.log( "DeviceEntryUdfpsTouchOverlay", DEBUG, { bool1 = canTouchDeviceEntryViewAlpha bool2 = alternateBouncerVisible bool3 = hideAffordancesRequest bool4 = shouldHandleTouches }, { "shouldHandleTouches=$bool4 canTouchDeviceEntryViewAlpha=$bool1 " + "alternateBouncerVisible=$bool2 hideAffordancesRequest=$bool3" } ) } } packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/DeviceEntryUdfpsTouchOverlayViewModel.kt +24 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.biometrics.ui.viewmodel import com.android.keyguard.logging.DeviceEntryIconLogger import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor import com.android.systemui.keyguard.ui.viewmodel.DeviceEntryIconViewModel import com.android.systemui.statusbar.phone.SystemUIDialogManager Loading @@ -24,6 +25,8 @@ import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map /** * View model for the UdfpsTouchOverlay for when UDFPS is being requested for device entry. Handles Loading @@ -37,16 +40,30 @@ constructor( deviceEntryIconViewModel: DeviceEntryIconViewModel, alternateBouncerInteractor: AlternateBouncerInteractor, systemUIDialogManager: SystemUIDialogManager, logger: DeviceEntryIconLogger, ) : UdfpsTouchOverlayViewModel { private val deviceEntryViewAlphaIsMostlyVisible: Flow<Boolean> = deviceEntryIconViewModel.deviceEntryViewAlpha .map { it > ALLOW_TOUCH_ALPHA_THRESHOLD } .distinctUntilChanged() override val shouldHandleTouches: Flow<Boolean> = combine( deviceEntryIconViewModel.deviceEntryViewAlpha, deviceEntryViewAlphaIsMostlyVisible, alternateBouncerInteractor.isVisible, systemUIDialogManager.hideAffordancesRequest ) { deviceEntryViewAlpha, alternateBouncerVisible, hideAffordancesRequest -> (deviceEntryViewAlpha > ALLOW_TOUCH_ALPHA_THRESHOLD && !hideAffordancesRequest) || systemUIDialogManager.hideAffordancesRequest, ) { canTouchDeviceEntryViewAlpha, alternateBouncerVisible, hideAffordancesRequest -> val shouldHandleTouches = (canTouchDeviceEntryViewAlpha && !hideAffordancesRequest) || alternateBouncerVisible logger.logDeviceEntryUdfpsTouchOverlayShouldHandleTouches( shouldHandleTouches, canTouchDeviceEntryViewAlpha, alternateBouncerVisible, hideAffordancesRequest ) shouldHandleTouches } .distinctUntilChanged() companion object { // only allow touches if the view is still mostly visible Loading packages/SystemUI/src/com/android/systemui/log/dagger/DeviceEntryIconLog.kt 0 → 100644 +22 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.log.dagger import java.lang.annotation.Documented import javax.inject.Qualifier /** A [com.android.systemui.log.LogBuffer] for DeviceEntryIcon state. */ @Qualifier @Documented @Retention(AnnotationRetention.RUNTIME) annotation class DeviceEntryIconLog packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +9 −0 Original line number Diff line number Diff line Loading @@ -654,4 +654,13 @@ public class LogModule { public static LogBuffer provideNavbarOrientationTrackingLogBuffer(LogBufferFactory factory) { return factory.create("NavbarOrientationTrackingLog", 50); } /** Provides a {@link LogBuffer} for use by the DeviceEntryIcon and related classes. */ @Provides @SysUISingleton @DeviceEntryIconLog public static LogBuffer provideDeviceEntryIconLogBuffer(LogBufferFactory factory) { return factory.create("DeviceEntryIconLog", 100); } } packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/ui/viewmodel/DeviceEntryUdfpsTouchOverlayViewModelKosmos.kt +3 −0 Original line number Diff line number Diff line Loading @@ -16,11 +16,13 @@ package com.android.systemui.biometrics.ui.viewmodel import com.android.keyguard.logging.DeviceEntryIconLogger import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor import com.android.systemui.keyguard.ui.viewmodel.deviceEntryIconViewModel import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture import com.android.systemui.statusbar.phone.systemUIDialogManager import com.android.systemui.util.mockito.mock import kotlinx.coroutines.ExperimentalCoroutinesApi @ExperimentalCoroutinesApi Loading @@ -29,5 +31,6 @@ val Kosmos.deviceEntryUdfpsTouchOverlayViewModel by Fixture { deviceEntryIconViewModel = deviceEntryIconViewModel, alternateBouncerInteractor = alternateBouncerInteractor, systemUIDialogManager = systemUIDialogManager, logger = mock<DeviceEntryIconLogger>(), ) } Loading
packages/SystemUI/src/com/android/keyguard/logging/DeviceEntryIconLogger.kt 0 → 100644 +61 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.logging import com.android.systemui.dagger.SysUISingleton import com.android.systemui.log.LogBuffer import com.android.systemui.log.core.LogLevel import com.android.systemui.log.core.LogLevel.DEBUG import com.android.systemui.log.core.LogLevel.INFO import com.android.systemui.log.dagger.DeviceEntryIconLog import com.google.errorprone.annotations.CompileTimeConstant import javax.inject.Inject private const val GENERIC_TAG = "DeviceEntryIconLogger" /** Helper class for logging for the DeviceEntryIcon */ @SysUISingleton class DeviceEntryIconLogger @Inject constructor(@DeviceEntryIconLog private val logBuffer: LogBuffer) { fun i(@CompileTimeConstant msg: String) = log(msg, INFO) fun d(@CompileTimeConstant msg: String) = log(msg, DEBUG) fun log(@CompileTimeConstant msg: String, level: LogLevel) = logBuffer.log(GENERIC_TAG, level, msg) fun logDeviceEntryUdfpsTouchOverlayShouldHandleTouches( shouldHandleTouches: Boolean, canTouchDeviceEntryViewAlpha: Boolean, alternateBouncerVisible: Boolean, hideAffordancesRequest: Boolean, ) { logBuffer.log( "DeviceEntryUdfpsTouchOverlay", DEBUG, { bool1 = canTouchDeviceEntryViewAlpha bool2 = alternateBouncerVisible bool3 = hideAffordancesRequest bool4 = shouldHandleTouches }, { "shouldHandleTouches=$bool4 canTouchDeviceEntryViewAlpha=$bool1 " + "alternateBouncerVisible=$bool2 hideAffordancesRequest=$bool3" } ) } }
packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/DeviceEntryUdfpsTouchOverlayViewModel.kt +24 −7 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.biometrics.ui.viewmodel import com.android.keyguard.logging.DeviceEntryIconLogger import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor import com.android.systemui.keyguard.ui.viewmodel.DeviceEntryIconViewModel import com.android.systemui.statusbar.phone.SystemUIDialogManager Loading @@ -24,6 +25,8 @@ import javax.inject.Inject import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.map /** * View model for the UdfpsTouchOverlay for when UDFPS is being requested for device entry. Handles Loading @@ -37,16 +40,30 @@ constructor( deviceEntryIconViewModel: DeviceEntryIconViewModel, alternateBouncerInteractor: AlternateBouncerInteractor, systemUIDialogManager: SystemUIDialogManager, logger: DeviceEntryIconLogger, ) : UdfpsTouchOverlayViewModel { private val deviceEntryViewAlphaIsMostlyVisible: Flow<Boolean> = deviceEntryIconViewModel.deviceEntryViewAlpha .map { it > ALLOW_TOUCH_ALPHA_THRESHOLD } .distinctUntilChanged() override val shouldHandleTouches: Flow<Boolean> = combine( deviceEntryIconViewModel.deviceEntryViewAlpha, deviceEntryViewAlphaIsMostlyVisible, alternateBouncerInteractor.isVisible, systemUIDialogManager.hideAffordancesRequest ) { deviceEntryViewAlpha, alternateBouncerVisible, hideAffordancesRequest -> (deviceEntryViewAlpha > ALLOW_TOUCH_ALPHA_THRESHOLD && !hideAffordancesRequest) || systemUIDialogManager.hideAffordancesRequest, ) { canTouchDeviceEntryViewAlpha, alternateBouncerVisible, hideAffordancesRequest -> val shouldHandleTouches = (canTouchDeviceEntryViewAlpha && !hideAffordancesRequest) || alternateBouncerVisible logger.logDeviceEntryUdfpsTouchOverlayShouldHandleTouches( shouldHandleTouches, canTouchDeviceEntryViewAlpha, alternateBouncerVisible, hideAffordancesRequest ) shouldHandleTouches } .distinctUntilChanged() companion object { // only allow touches if the view is still mostly visible Loading
packages/SystemUI/src/com/android/systemui/log/dagger/DeviceEntryIconLog.kt 0 → 100644 +22 −0 Original line number Diff line number Diff line /* * Copyright (C) 2024 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.log.dagger import java.lang.annotation.Documented import javax.inject.Qualifier /** A [com.android.systemui.log.LogBuffer] for DeviceEntryIcon state. */ @Qualifier @Documented @Retention(AnnotationRetention.RUNTIME) annotation class DeviceEntryIconLog
packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java +9 −0 Original line number Diff line number Diff line Loading @@ -654,4 +654,13 @@ public class LogModule { public static LogBuffer provideNavbarOrientationTrackingLogBuffer(LogBufferFactory factory) { return factory.create("NavbarOrientationTrackingLog", 50); } /** Provides a {@link LogBuffer} for use by the DeviceEntryIcon and related classes. */ @Provides @SysUISingleton @DeviceEntryIconLog public static LogBuffer provideDeviceEntryIconLogBuffer(LogBufferFactory factory) { return factory.create("DeviceEntryIconLog", 100); } }
packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/ui/viewmodel/DeviceEntryUdfpsTouchOverlayViewModelKosmos.kt +3 −0 Original line number Diff line number Diff line Loading @@ -16,11 +16,13 @@ package com.android.systemui.biometrics.ui.viewmodel import com.android.keyguard.logging.DeviceEntryIconLogger import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor import com.android.systemui.keyguard.ui.viewmodel.deviceEntryIconViewModel import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture import com.android.systemui.statusbar.phone.systemUIDialogManager import com.android.systemui.util.mockito.mock import kotlinx.coroutines.ExperimentalCoroutinesApi @ExperimentalCoroutinesApi Loading @@ -29,5 +31,6 @@ val Kosmos.deviceEntryUdfpsTouchOverlayViewModel by Fixture { deviceEntryIconViewModel = deviceEntryIconViewModel, alternateBouncerInteractor = alternateBouncerInteractor, systemUIDialogManager = systemUIDialogManager, logger = mock<DeviceEntryIconLogger>(), ) }