1 /* 2 * Copyright (C) 2020 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.toast 18 19 import com.android.systemui.log.LogBuffer 20 import com.android.systemui.log.LogLevel 21 import com.android.systemui.log.LogLevel.DEBUG 22 import com.android.systemui.log.LogMessage 23 import com.android.systemui.log.dagger.ToastLog 24 import javax.inject.Inject 25 26 private const val TAG = "ToastLog" 27 28 class ToastLogger @Inject constructor( 29 @ToastLog private val buffer: LogBuffer 30 ) { 31 logOnShowToastnull32 fun logOnShowToast(uid: Int, packageName: String, text: String, token: String) { 33 log(DEBUG, { 34 int1 = uid 35 str1 = packageName 36 str2 = text 37 str3 = token 38 }, { 39 "[$str3] Show toast for ($str1, $int1). msg=\'$str2\'" 40 }) 41 } 42 logOnHideToastnull43 fun logOnHideToast(packageName: String, token: String) { 44 log(DEBUG, { 45 str1 = packageName 46 str2 = token 47 }, { 48 "[$str2] Hide toast for [$str1]" 49 }) 50 } 51 logOrientationChangenull52 fun logOrientationChange(text: String, isPortrait: Boolean) { 53 log(DEBUG, { 54 str1 = text 55 bool1 = isPortrait 56 }, { 57 "Orientation change for toast. msg=\'$str1\' isPortrait=$bool1" 58 }) 59 } 60 lognull61 private inline fun log( 62 logLevel: LogLevel, 63 initializer: LogMessage.() -> Unit, 64 noinline printer: LogMessage.() -> String 65 ) { 66 buffer.log(TAG, logLevel, initializer, printer) 67 } 68 }