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
diff --git a/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java b/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java
index 46b4c86..f98d795 100644
--- a/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java
+++ b/src/com/android/settings/homepage/contextualcards/EligibleCardChecker.java
@@ -120,9 +120,13 @@
// 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;
}