1 /* 2 * Copyright (C) 2023 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.temporarydisplay 18 19 import com.android.internal.logging.InstanceId 20 import com.android.internal.logging.InstanceIdSequence 21 import com.android.internal.logging.UiEvent 22 import com.android.internal.logging.UiEventLogger 23 import com.android.systemui.dagger.SysUISingleton 24 import javax.inject.Inject 25 26 private const val INSTANCE_ID_MAX = 1 shl 20 27 28 /** A helper class to log events related to the temporary view */ 29 @SysUISingleton 30 class TemporaryViewUiEventLogger @Inject constructor(val logger: UiEventLogger) { 31 32 private val instanceIdSequence = InstanceIdSequence(INSTANCE_ID_MAX) 33 34 /** Get a new instance ID for a new media control */ getNewInstanceIdnull35 fun getNewInstanceId(): InstanceId { 36 return instanceIdSequence.newInstanceId() 37 } 38 39 /** Logs that view is added */ logViewAddednull40 fun logViewAdded(instanceId: InstanceId?) { 41 logger.log(TemporaryViewUiEvent.TEMPORARY_VIEW_ADDED, instanceId) 42 } 43 44 /** Logs that view is manually dismissed by user */ logViewManuallyDismissednull45 fun logViewManuallyDismissed(instanceId: InstanceId?) { 46 logger.log(TemporaryViewUiEvent.TEMPORARY_VIEW_MANUALLY_DISMISSED, instanceId) 47 } 48 } 49 50 enum class TemporaryViewUiEvent(val metricId: Int) : UiEventLogger.UiEventEnum { 51 @UiEvent(doc = "The temporary view was added to window manager") TEMPORARY_VIEW_ADDED(1389), 52 @UiEvent(doc = "The temporary view was manually dismissed") 53 TEMPORARY_VIEW_MANUALLY_DISMISSED(1390); 54 getIdnull55 override fun getId() = metricId 56 } 57