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.statusbar.phone.ongoingcall.shared.model 18 19 import android.app.PendingIntent 20 import com.android.internal.logging.InstanceId 21 import com.android.systemui.statusbar.StatusBarIconView 22 import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModels 23 24 /** Represents the state of any ongoing calls. */ 25 sealed interface OngoingCallModel { 26 /** A string to use in logs that only includes the key information. */ logStringnull27 fun logString(): String 28 29 /** There is no ongoing call. */ 30 data object NoCall : OngoingCallModel { 31 override fun logString() = "NoCall" 32 } 33 34 /** 35 * There *is* an ongoing call. 36 * 37 * @property startTimeMs the time that the phone call started, based on the notification's 38 * `when` field. Importantly, this time is relative to 39 * [com.android.systemui.util.time.SystemClock.currentTimeMillis], **not** 40 * [com.android.systemui.util.time.SystemClock.elapsedRealtime]. This value can be 0 if the 41 * user has started an outgoing call that hasn't been answered yet - see b/192379214. 42 * @property notificationIconView the [android.app.Notification.getSmallIcon] that's set on the 43 * call notification. We may use this icon in the chip instead of the default phone icon. 44 * @property intent the intent associated with the call notification. 45 * @property appName the user-readable name of the app that posted the call notification. 46 * @property promotedContent if the call notification also meets promoted notification criteria, 47 * this field is filled in with the content related to promotion. Otherwise null. 48 * @property isAppVisible whether the app to which the call belongs is currently visible. 49 * @property notificationInstanceId an optional per-chip ID used for logging. Should stay the 50 * same throughout the lifetime of a single chip. 51 */ 52 data class InCall( 53 val startTimeMs: Long, 54 val notificationIconView: StatusBarIconView?, 55 val intent: PendingIntent?, 56 val notificationKey: String, 57 val appName: String, 58 val promotedContent: PromotedNotificationContentModels?, 59 val isAppVisible: Boolean, 60 val notificationInstanceId: InstanceId?, 61 ) : OngoingCallModel { logStringnull62 override fun logString(): String { 63 return "InCall(notifKey=$notificationKey " + 64 "hasPromotedContent=${promotedContent != null} " + 65 "isAppVisible=$isAppVisible)" 66 } 67 } 68 } 69