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.statusbar 18 19 import android.app.PendingIntent 20 import com.android.systemui.log.dagger.NotifInteractionLog 21 import com.android.systemui.log.LogBuffer 22 import com.android.systemui.log.core.LogLevel 23 import com.android.systemui.statusbar.notification.collection.NotificationEntry 24 import javax.inject.Inject 25 26 /** 27 * Logger class for events related to the user clicking on notification actions 28 */ 29 class ActionClickLogger @Inject constructor( 30 @NotifInteractionLog private val buffer: LogBuffer 31 ) { logInitialClicknull32 fun logInitialClick( 33 entry: NotificationEntry?, 34 index: Integer?, 35 pendingIntent: PendingIntent 36 ) { 37 buffer.log(TAG, LogLevel.DEBUG, { 38 str1 = entry?.key 39 str2 = entry?.ranking?.channel?.id 40 str3 = pendingIntent.toString() 41 int1 = index?.toInt() ?: Int.MIN_VALUE 42 }, { 43 "ACTION CLICK $str1 (channel=$str2) for pending intent $str3 at index $int1" 44 }) 45 } 46 logRemoteInputWasHandlednull47 fun logRemoteInputWasHandled( 48 entry: NotificationEntry?, 49 index: Int? 50 ) { 51 buffer.log(TAG, LogLevel.DEBUG, { 52 str1 = entry?.key 53 int1 = index ?: Int.MIN_VALUE 54 }, { 55 " [Action click] Triggered remote input (for $str1) at index $int1" 56 }) 57 } 58 logStartingIntentWithDefaultHandlernull59 fun logStartingIntentWithDefaultHandler( 60 entry: NotificationEntry?, 61 pendingIntent: PendingIntent, 62 index: Int? 63 ) { 64 buffer.log(TAG, LogLevel.DEBUG, { 65 str1 = entry?.key 66 str2 = pendingIntent.toString() 67 int1 = index ?: Int.MIN_VALUE 68 }, { 69 " [Action click] Launching intent $str2 via default handler (for $str1 at index $int1)" 70 }) 71 } 72 logWaitingToCloseKeyguardnull73 fun logWaitingToCloseKeyguard( 74 pendingIntent: PendingIntent, 75 index: Int? 76 ) { 77 buffer.log(TAG, LogLevel.DEBUG, { 78 str1 = pendingIntent.toString() 79 int1 = index ?: Int.MIN_VALUE 80 }, { 81 " [Action click] Intent $str1 at index $int1 launches an activity, dismissing " + 82 "keyguard first..." 83 }) 84 } 85 logKeyguardGonenull86 fun logKeyguardGone( 87 pendingIntent: PendingIntent, 88 index: Int? 89 ) { 90 buffer.log(TAG, LogLevel.DEBUG, { 91 str1 = pendingIntent.toString() 92 int1 = index ?: Int.MIN_VALUE 93 }, { 94 " [Action click] Keyguard dismissed, calling default handler for intent $str1 at " + 95 "index $int1" 96 }) 97 } 98 } 99 100 private const val TAG = "ActionClickLogger"