Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eaf1564d authored by Jason Chiu's avatar Jason Chiu
Browse files

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
parent f002dd72
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -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;
    }