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.media.controls.ui.controller 18 19 import com.android.systemui.dagger.SysUISingleton 20 import com.android.systemui.log.LogBuffer 21 import com.android.systemui.log.core.LogLevel 22 import com.android.systemui.log.dagger.MediaCarouselControllerLog 23 import javax.inject.Inject 24 25 /** A debug logger for [MediaCarouselController]. */ 26 @SysUISingleton 27 class MediaCarouselControllerLogger 28 @Inject 29 constructor(@MediaCarouselControllerLog private val buffer: LogBuffer) { 30 /** 31 * Log that there might be a potential memory leak for the [MediaControlPanel] and/or 32 * [MediaViewController] related to [key]. 33 */ logPotentialMemoryLeaknull34 fun logPotentialMemoryLeak(key: String) = 35 buffer.log( 36 TAG, 37 LogLevel.DEBUG, 38 { str1 = key }, <lambda>null39 { 40 "Potential memory leak: " + 41 "Removing control panel for $str1 from map without calling #onDestroy" 42 }, 43 ) 44 logMediaLoadednull45 fun logMediaLoaded(key: String, active: Boolean) = 46 buffer.log( 47 TAG, 48 LogLevel.DEBUG, 49 { 50 str1 = key 51 bool1 = active 52 }, <lambda>null53 { "add player $str1, active: $bool1" }, 54 ) 55 logMediaRemovednull56 fun logMediaRemoved(key: String, userInitiated: Boolean) = 57 buffer.log( 58 TAG, 59 LogLevel.DEBUG, 60 { 61 str1 = key 62 bool1 = userInitiated 63 }, <lambda>null64 { "removing player $str1, by user $bool1" }, 65 ) 66 <lambda>null67 fun logCarouselHidden() = buffer.log(TAG, LogLevel.DEBUG, {}, { "hiding carousel" }) 68 <lambda>null69 fun logCarouselVisible() = buffer.log(TAG, LogLevel.DEBUG, {}, { "showing carousel" }) 70 logMediaHostVisibilitynull71 fun logMediaHostVisibility(location: Int, visible: Boolean, oldState: Boolean) { 72 buffer.log( 73 TAG, 74 LogLevel.DEBUG, 75 { 76 int1 = location 77 bool1 = visible 78 bool2 = oldState 79 }, 80 { "media host visibility changed location=$int1, visible:$bool1, was:$bool2" }, 81 ) 82 } 83 } 84 85 private const val TAG = "MediaCarouselCtlrLog" 86