From 3dec27fff426b0805ef352658f935da7923d2cfb Mon Sep 17 00:00:00 2001 From: Ned Burns Date: Thu, 6 Feb 2020 19:38:00 -0500 Subject: [PATCH] DO NOT MERGE Log remote exceptions in NotifCollection Followup from ag/10056177 Also cleans up a few small nits. Test: atest Bug: 112656837 Change-Id: I116b8f70df62b7c37c02325d54660624aa7bd78b (cherry picked from commit a5c6f2e07af5cb20e5e7d9aaaf13602f317bf563) --- .../collection/NotifCollection.java | 4 +++- .../notifcollection/NotifCollectionLogger.kt | 21 ++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java index b90cfa8ae25e2..c9cc670093996 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/NotifCollection.java @@ -249,6 +249,7 @@ public class NotifCollection implements Dumpable { stats.notificationVisibility); } catch (RemoteException e) { // system process is dead if we're here. + mLogger.logRemoteExceptionOnNotificationClear(entry.getKey(), e); } } } @@ -277,6 +278,7 @@ public class NotifCollection implements Dumpable { mStatusBarService.onClearAllNotifications(userId); } catch (RemoteException e) { // system process is dead if we're here. + mLogger.logRemoteExceptionOnClearAllNotifications(e); } final List entries = new ArrayList<>(getAllNotifs()); @@ -743,6 +745,6 @@ public class NotifCollection implements Dumpable { @Retention(RetentionPolicy.SOURCE) public @interface CancellationReason {} - public static final int REASON_NOT_CANCELED = -1; + static final int REASON_NOT_CANCELED = -1; public static final int REASON_UNKNOWN = 0; } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/notifcollection/NotifCollectionLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/notifcollection/NotifCollectionLogger.kt index 8675cca3cffe3..ef302f682df82 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/notifcollection/NotifCollectionLogger.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/collection/notifcollection/NotifCollectionLogger.kt @@ -16,11 +16,13 @@ package com.android.systemui.statusbar.notification.collection.notifcollection +import android.os.RemoteException import android.service.notification.NotificationListenerService.RankingMap import com.android.systemui.log.LogBuffer import com.android.systemui.log.LogLevel.DEBUG import com.android.systemui.log.LogLevel.INFO import com.android.systemui.log.LogLevel.WARNING +import com.android.systemui.log.LogLevel.WTF import com.android.systemui.log.dagger.NotificationLog import javax.inject.Inject @@ -92,6 +94,23 @@ class NotifCollectionLogger @Inject constructor( buffer.log(TAG, DEBUG, { str1 = entry }, { " $str1" }) } } + + fun logRemoteExceptionOnNotificationClear(key: String, e: RemoteException) { + buffer.log(TAG, WTF, { + str1 = key + str2 = e.toString() + }, { + "RemoteException while attempting to clear $str1:\n$str2" + }) + } + + fun logRemoteExceptionOnClearAllNotifications(e: RemoteException) { + buffer.log(TAG, WTF, { + str1 = e.toString() + }, { + "RemoteException while attempting to clear all notifications:\n$str1" + }) + } } -private const val TAG = "NotifCollection" \ No newline at end of file +private const val TAG = "NotifCollection"