From c18ad7a8c917c6388668784461456cc779031e0b Mon Sep 17 00:00:00 2001 From: yueg Date: Wed, 18 Oct 2017 14:45:05 -0700 Subject: Fix NPE in TelecomAdapter.stopForegroundNotification(). In InCallServiceImpl.tearDown(), we should only clear inCallService after InCallPresenter.tearDown() where we remove all notification. Also remove null assertion in stopForegroundNotification() since other crash should only happens when there is no notification. Test: StatusBarNotifierTest PiperOrigin-RevId: 172657924 Change-Id: I86e720b80f885aa93f12215fda899ee62eeaba5b --- java/com/android/incallui/InCallServiceImpl.java | 2 +- java/com/android/incallui/call/TelecomAdapter.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'java/com') diff --git a/java/com/android/incallui/InCallServiceImpl.java b/java/com/android/incallui/InCallServiceImpl.java index 8570c58c4..2c45cb375 100644 --- a/java/com/android/incallui/InCallServiceImpl.java +++ b/java/com/android/incallui/InCallServiceImpl.java @@ -119,8 +119,8 @@ public class InCallServiceImpl extends InCallService { Trace.beginSection("InCallServiceImpl.tearDown"); Log.v(this, "tearDown"); // Tear down the InCall system - TelecomAdapter.getInstance().clearInCallService(); InCallPresenter.getInstance().tearDown(); + TelecomAdapter.getInstance().clearInCallService(); if (returnToCallController != null) { returnToCallController.tearDown(); returnToCallController = null; diff --git a/java/com/android/incallui/call/TelecomAdapter.java b/java/com/android/incallui/call/TelecomAdapter.java index 0c0bbd473..d48ab68c2 100644 --- a/java/com/android/incallui/call/TelecomAdapter.java +++ b/java/com/android/incallui/call/TelecomAdapter.java @@ -185,8 +185,12 @@ public class TelecomAdapter implements InCallServiceListener { * Stop a started foreground notification. This does not stop {@code mInCallService} from running. */ public void stopForegroundNotification() { - Assert.isNotNull( - mInCallService, "No inCallService available for stopping foreground notification"); - mInCallService.stopForeground(true /*removeNotification*/); + if (mInCallService != null) { + mInCallService.stopForeground(true /*removeNotification*/); + } else { + LogUtil.e( + "TelecomAdapter.stopForegroundNotification", + "no inCallService available for stopping foreground notification"); + } } } -- cgit v1.2.3