From c0c7efc442bcab64eba9ceaab03fea880b5a9795 Mon Sep 17 00:00:00 2001 From: Phil Weaver Date: Tue, 2 Apr 2019 09:15:14 -0700 Subject: [PATCH] Add null check to destroyUiAutomationService Fixes: 129704196 Test: atest UiAutomationManagerTest, atest CtsUiAutomationTestCases Change-Id: I257c4f7321e9b3b54efe45e46ede50b010494c6e --- .../accessibility/UiAutomationManager.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/services/accessibility/java/com/android/server/accessibility/UiAutomationManager.java b/services/accessibility/java/com/android/server/accessibility/UiAutomationManager.java index 4bbf68271eb99..72c84e28f24f0 100644 --- a/services/accessibility/java/com/android/server/accessibility/UiAutomationManager.java +++ b/services/accessibility/java/com/android/server/accessibility/UiAutomationManager.java @@ -64,9 +64,7 @@ class UiAutomationManager { public void binderDied() { mUiAutomationServiceOwner.unlinkToDeath(this, 0); mUiAutomationServiceOwner = null; - if (mUiAutomationService != null) { - destroyUiAutomationService(); - } + destroyUiAutomationService(); } }; @@ -201,17 +199,20 @@ class UiAutomationManager { private void destroyUiAutomationService() { synchronized (mLock) { - mUiAutomationService.mServiceInterface.asBinder().unlinkToDeath(mUiAutomationService, - 0); - mUiAutomationService.onRemoved(); - mUiAutomationService.resetLocked(); - mUiAutomationService = null; - mUiAutomationFlags = 0; - if (mUiAutomationServiceOwner != null) { - mUiAutomationServiceOwner.unlinkToDeath(mUiAutomationServiceOwnerDeathRecipient, 0); - mUiAutomationServiceOwner = null; + if (mUiAutomationService != null) { + mUiAutomationService.mServiceInterface.asBinder().unlinkToDeath( + mUiAutomationService, 0); + mUiAutomationService.onRemoved(); + mUiAutomationService.resetLocked(); + mUiAutomationService = null; + mUiAutomationFlags = 0; + if (mUiAutomationServiceOwner != null) { + mUiAutomationServiceOwner.unlinkToDeath( + mUiAutomationServiceOwnerDeathRecipient, 0); + mUiAutomationServiceOwner = null; + } + mSystemSupport.onClientChangeLocked(false); } - mSystemSupport.onClientChangeLocked(false); } }