1 /* 2 * Copyright (C) 2024 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.screenrecord 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 javax.inject.Inject 23 24 /** Helper class for logging events to [RecordingControllerLog] from Java. */ 25 @SysUISingleton 26 class RecordingControllerLogger 27 @Inject 28 constructor( 29 @RecordingControllerLog private val logger: LogBuffer, 30 ) { logStateUpdatednull31 fun logStateUpdated(isRecording: Boolean) = 32 logger.log( 33 TAG, 34 LogLevel.DEBUG, 35 { bool1 = isRecording }, <lambda>null36 { "Updating state. isRecording=$bool1" }, 37 ) 38 logIntentStateUpdatednull39 fun logIntentStateUpdated(isRecording: Boolean) = 40 logger.log( 41 TAG, 42 LogLevel.DEBUG, 43 { bool1 = isRecording }, <lambda>null44 { "Update intent has state. isRecording=$bool1" }, 45 ) 46 logIntentMissingStatenull47 fun logIntentMissingState() = 48 logger.log(TAG, LogLevel.ERROR, {}, { "Received update intent with no state" }) 49 <lambda>null50 fun logSentStartIntent() = logger.log(TAG, LogLevel.DEBUG, {}, { "Sent start intent" }) 51 logPendingIntentCancellednull52 fun logPendingIntentCancelled(e: Exception) = 53 logger.log(TAG, LogLevel.ERROR, {}, { "Pending intent was cancelled" }, e) 54 logCountdownCancellednull55 fun logCountdownCancelled() = 56 logger.log(TAG, LogLevel.DEBUG, {}, { "Record countdown cancelled" }) 57 logCountdownCancelErrorNoTimernull58 fun logCountdownCancelErrorNoTimer() = 59 logger.log(TAG, LogLevel.ERROR, {}, { "Couldn't cancel countdown because timer was null" }) 60 <lambda>null61 fun logRecordingStopped() = logger.log(TAG, LogLevel.DEBUG, {}, { "Stopping recording" }) 62 logRecordingStopErrorNoStopIntentnull63 fun logRecordingStopErrorNoStopIntent() = 64 logger.log( 65 TAG, 66 LogLevel.ERROR, 67 {}, <lambda>null68 { "Couldn't stop recording because stop intent was null" }, 69 ) 70 logRecordingStopErrornull71 fun logRecordingStopError(e: Exception) = 72 logger.log(TAG, LogLevel.DEBUG, {}, { "Couldn't stop recording" }, e) 73 74 companion object { 75 private const val TAG = "RecordingController" 76 } 77 } 78