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
This commit is contained in:
Jason Chiu
2020-07-01 17:00:48 +08:00
parent f002dd72ac
commit eaf1564d9f

View File

@@ -120,9 +120,13 @@ public class EligibleCardChecker implements Callable<ContextualCard> {
// 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;
}