1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.log 18 19 import android.graphics.Point 20 import com.android.systemui.dagger.SysUISingleton 21 import com.android.systemui.log.core.LogLevel 22 import com.android.systemui.log.dagger.BouncerLog 23 import javax.inject.Inject 24 25 private const val TAG = "SideFpsLogger" 26 27 /** 28 * Helper class for logging for SFPS related functionality 29 * 30 * To enable logcat echoing for an entire buffer: 31 * ``` 32 * adb shell settings put global systemui/buffer/BouncerLog <logLevel> 33 * 34 * ``` 35 */ 36 @SysUISingleton 37 class SideFpsLogger @Inject constructor(@BouncerLog private val buffer: LogBuffer) { sfpsProgressBarStateChangednull38 fun sfpsProgressBarStateChanged( 39 visible: Boolean, 40 location: Point, 41 fpDetectRunning: Boolean, 42 sensorWidth: Int, 43 rotation: Float, 44 ) { 45 buffer.log( 46 TAG, 47 LogLevel.DEBUG, 48 { 49 bool1 = visible 50 int1 = location.x 51 int2 = location.y 52 str1 = "$rotation" 53 bool3 = fpDetectRunning 54 long1 = sensorWidth.toLong() 55 }, 56 { 57 "SFPS progress bar state changed: visible: $bool1, " + 58 "sensorLocation (x, y): ($int1, $int2), " + 59 "rotation = $str1, " + 60 "fpDetectRunning: $bool3, " + 61 "sensorWidth: $long1" 62 } 63 ) 64 } 65 hidingSfpsIndicatornull66 fun hidingSfpsIndicator() { 67 buffer.log(TAG, LogLevel.DEBUG, "hiding SFPS indicator to show progress bar") 68 } 69 showingSfpsIndicatornull70 fun showingSfpsIndicator() { 71 buffer.log( 72 TAG, 73 LogLevel.DEBUG, 74 "Requesting show SFPS indicator because progress bar " + 75 "is being hidden and FP detect is currently running" 76 ) 77 } 78 isProlongedTouchRequiredForAuthenticationChangednull79 fun isProlongedTouchRequiredForAuthenticationChanged(enabled: Boolean) { 80 buffer.log( 81 TAG, 82 LogLevel.DEBUG, 83 { bool1 = enabled }, 84 { "isProlongedTouchRequiredForAuthentication: $bool1" } 85 ) 86 } 87 sensorLocationStateChangednull88 fun sensorLocationStateChanged( 89 pointOnScreenX: Int, 90 pointOnScreenY: Int, 91 sensorLength: Int, 92 isSensorVerticalInDefaultOrientation: Boolean 93 ) { 94 buffer.log( 95 TAG, 96 LogLevel.DEBUG, 97 { 98 int1 = pointOnScreenX 99 int2 = pointOnScreenY 100 str2 = "$sensorLength" 101 bool1 = isSensorVerticalInDefaultOrientation 102 }, 103 { 104 "SideFpsSensorLocation state changed: " + 105 "pointOnScreen: ($int1, $int2), " + 106 "sensorLength: $str2, " + 107 "sensorVerticalInDefaultOrientation: $bool1" 108 } 109 ) 110 } 111 authDurationChangednull112 fun authDurationChanged(duration: Long) { 113 buffer.log( 114 TAG, 115 LogLevel.DEBUG, 116 { long1 = duration }, 117 { "SideFpsSensor auth duration changed: $long1" } 118 ) 119 } 120 restToUnlockSettingEnabledChangednull121 fun restToUnlockSettingEnabledChanged(enabled: Boolean) { 122 buffer.log( 123 TAG, 124 LogLevel.DEBUG, 125 { bool1 = enabled }, 126 { "restToUnlockSettingEnabled: $bool1" } 127 ) 128 } 129 } 130