1 /* 2 * Copyright (C) 2021 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.statusbar.phone.ongoingcall 18 19 import androidx.annotation.VisibleForTesting 20 import com.android.internal.logging.UiEvent 21 import com.android.internal.logging.UiEventLogger 22 import com.android.systemui.dagger.SysUISingleton 23 import javax.inject.Inject 24 25 /** A class to log events for the ongoing call chip. */ 26 @SysUISingleton 27 class OngoingCallLogger @Inject constructor(private val logger: UiEventLogger) { 28 29 private var chipIsVisible: Boolean = false 30 31 /** Logs that the ongoing call chip was clicked. */ logChipClickednull32 fun logChipClicked() { 33 logger.log(OngoingCallEvents.ONGOING_CALL_CLICKED) 34 } 35 36 /** 37 * If needed, logs that the ongoing call chip's visibility has changed. 38 * 39 * For now, only logs when the chip changes from not visible to visible. 40 */ logChipVisibilityChangednull41 fun logChipVisibilityChanged(chipIsVisible: Boolean) { 42 if (chipIsVisible && chipIsVisible != this.chipIsVisible) { 43 logger.log(OngoingCallEvents.ONGOING_CALL_VISIBLE) 44 } 45 this.chipIsVisible = chipIsVisible 46 } 47 48 @VisibleForTesting 49 enum class OngoingCallEvents(val metricId: Int) : UiEventLogger.UiEventEnum { 50 @UiEvent(doc = "The ongoing call chip became visible") 51 ONGOING_CALL_VISIBLE(813), 52 53 @UiEvent(doc = "The ongoing call chip was clicked") 54 ONGOING_CALL_CLICKED(814); 55 getIdnull56 override fun getId() = metricId 57 } 58 } 59