From eaf1564d9fcb644825d2f0275564f039c52fc4ea Mon Sep 17 00:00:00 2001 From: Jason Chiu Date: Wed, 1 Jul 2020 17:00:48 +0800 Subject: [PATCH] Guard against SecurityException of accessing to slice uri - Sometimes unregistering a Slice callback will have no permission to unpin the Slice uri and throw an exception. - Guard against the exception as the first solution. Bug: 159722324 Test: robotest Change-Id: Ic227331fef64c3fa6fe3e4442fba2a9b754d520d --- .../homepage/contextualcards/EligibleCardChecker.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java b/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java index 46b4c869ecb..f98d7955218 100644 --- a/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java +++ b/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java @@ -120,9 +120,13 @@ public class EligibleCardChecker implements Callable { // Workaround of unpinning slice in the same SerialExecutor of AsyncTask as SliceCallback's // observer. - ThreadUtils.postOnMainThread(() -> - AsyncTask.execute(() -> manager.unregisterSliceCallback(uri, callback)) - ); + ThreadUtils.postOnMainThread(() -> AsyncTask.execute(() -> { + try { + manager.unregisterSliceCallback(uri, callback); + } catch (SecurityException e) { + Log.d(TAG, "No permission currently: " + e); + } + })); return slice; }