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(TAG, DEBUG, { str1 = state.toString() }, { "Applying new state: $str1" }) 35 } 36 37 private inline fun log( 38 logLevel: LogLevel, 39 initializer: LogMessage.() -> Unit, 40 noinline printer: LogMessage.() -> String, 41 ) { 42 buffer.log(TAG, logLevel, initializer, printer) 43 } 44 45 fun logApplyVisibility(visible: Boolean) { 46 buffer.log( 47 TAG, 48 DEBUG, 49 { bool1 = visible }, 50 { "Updating visibility, should be visible : $bool1" }, 51 ) 52 } 53 54 fun logIsExpanded( 55 isExpanded: Boolean, 56 forceWindowCollapsed: Boolean, 57 isKeyguardShowingAndNotOccluded: Boolean, 58 panelVisible: Boolean, 59 keyguardFadingAway: Boolean, 60 bouncerShowing: Boolean, 61 headsUpNotificationShowing: Boolean, 62 scrimsVisibilityNotTransparent: Boolean, 63 backgroundBlurRadius: Boolean, 64 launchingActivityFromNotification: Boolean, 65 ) { 66 buffer.log( 67 TAG, 68 DEBUG, 69 { 70 str1 = isExpanded.toString() 71 bool1 = forceWindowCollapsed 72 bool2 = isKeyguardShowingAndNotOccluded 73 bool3 = panelVisible 74 bool4 = keyguardFadingAway 75 int1 = if (bouncerShowing) 1 else 0 76 int2 = if (headsUpNotificationShowing) 1 else 0 77 long1 = if (scrimsVisibilityNotTransparent) 1 else 0 78 long2 = if (backgroundBlurRadius) 1 else 0 79 double1 = if (launchingActivityFromNotification) 1.0 else 0.0 80 }, 81 { 82 "Setting isExpanded to $str1: forceWindowCollapsed $bool1, " + 83 "isKeyguardShowingAndNotOccluded $bool2, panelVisible $bool3, " + 84 "keyguardFadingAway $bool4, bouncerShowing $int1," + 85 "headsUpNotificationShowing $int2, scrimsVisibilityNotTransparent $long1," + 86 "backgroundBlurRadius $long2, launchingActivityFromNotification $double1" 87 }, 88 ) 89 } 90 91 fun logShadeVisibleAndFocusable(visible: Boolean) { 92 buffer.log( 93 TAG, 94 DEBUG, 95 { bool1 = visible }, 96 { "Updating shade, should be visible and focusable: $bool1" }, 97 ) 98 } 99 100 fun logShadeFocusable(focusable: Boolean) { 101 buffer.log( 102 TAG, 103 DEBUG, 104 { bool1 = focusable }, 105 { "Updating shade, should be focusable : $bool1" }, 106 ) 107 } 108 109 fun logConfigChangeWidthAdjust(originalWidth: Int, newWidth: Int) { 110 buffer.log( 111 TAG, 112 DEBUG, 113 { 114 int1 = originalWidth 115 int2 = newWidth 116 }, 117 { "Config changed. SceneWindowRootView width updating from $int1 to $int2." }, 118 ) 119 } 120 } 121