1 /* 2 * Copyright (C) 2022 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.shade 18 19 import com.android.systemui.log.ConstantStringsLogger 20 import com.android.systemui.log.ConstantStringsLoggerImpl 21 import com.android.systemui.log.LogBuffer 22 import com.android.systemui.log.core.LogLevel 23 import com.android.systemui.log.core.LogLevel.DEBUG 24 import com.android.systemui.log.core.LogMessage 25 import com.android.systemui.log.dagger.ShadeWindowLog 26 import javax.inject.Inject 27 28 private const val TAG = "systemui.shadewindow" 29 30 class ShadeWindowLogger @Inject constructor(@ShadeWindowLog private val buffer: LogBuffer) : <lambda>null31 ConstantStringsLogger by ConstantStringsLoggerImpl(buffer, TAG) { 32 33 fun logNewState(state: Any) { 34 buffer.log( 35 TAG, 36 DEBUG, 37 { str1 = state.toString() }, 38 { "Applying new state: $str1" } 39 ) 40 } 41 42 private inline fun log( 43 logLevel: LogLevel, 44 initializer: LogMessage.() -> Unit, 45 noinline printer: LogMessage.() -> String 46 ) { 47 buffer.log(TAG, logLevel, initializer, printer) 48 } 49 50 fun logApplyVisibility(visible: Boolean) { 51 buffer.log( 52 TAG, 53 DEBUG, 54 { bool1 = visible }, 55 { "Updating visibility, should be visible : $bool1" }) 56 } 57 58 fun logIsExpanded( 59 isExpanded: Boolean, 60 forceWindowCollapsed: Boolean, 61 isKeyguardShowingAndNotOccluded: Boolean, 62 panelVisible: Boolean, 63 keyguardFadingAway: Boolean, 64 bouncerShowing: Boolean, 65 headsUpNotificationShowing: Boolean, 66 scrimsVisibilityNotTransparent: Boolean, 67 backgroundBlurRadius: Boolean, 68 launchingActivityFromNotification: Boolean 69 ) { 70 buffer.log( 71 TAG, 72 DEBUG, 73 { 74 str1 = isExpanded.toString() 75 bool1 = forceWindowCollapsed 76 bool2 = isKeyguardShowingAndNotOccluded 77 bool3 = panelVisible 78 bool4 = keyguardFadingAway 79 int1 = if (bouncerShowing) 1 else 0 80 int2 = if (headsUpNotificationShowing) 1 else 0 81 long1 = if (scrimsVisibilityNotTransparent) 1 else 0 82 long2 = if (backgroundBlurRadius) 1 else 0 83 double1 = if (launchingActivityFromNotification) 1.0 else 0.0 84 }, 85 { "Setting isExpanded to $str1: forceWindowCollapsed $bool1, " + 86 "isKeyguardShowingAndNotOccluded $bool2, panelVisible $bool3, " + 87 "keyguardFadingAway $bool4, bouncerShowing $int1," + 88 "headsUpNotificationShowing $int2, scrimsVisibilityNotTransparent $long1," + 89 "backgroundBlurRadius $long2, launchingActivityFromNotification $double1"} 90 ) 91 } 92 93 fun logShadeVisibleAndFocusable(visible: Boolean) { 94 buffer.log( 95 TAG, 96 DEBUG, 97 { bool1 = visible }, 98 { "Updating shade, should be visible and focusable: $bool1" } 99 ) 100 } 101 102 fun logShadeFocusable(focusable: Boolean) { 103 buffer.log( 104 TAG, 105 DEBUG, 106 { bool1 = focusable }, 107 { "Updating shade, should be focusable : $bool1" } 108 ) 109 } 110 } 111