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

Commit 263de56a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Revert "Revert "Workaround of Slice not pinned bug when using Sl...""...

Merge "Revert "Revert "Workaround of Slice not pinned bug when using Sl..."" into rvc-dev am: 15a62def

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/12003874

Change-Id: I9d9c01e7ff707dd2024f8d880fdeed7dcea17faa
parents 63cfc7a3 15a62def
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.app.settings.SettingsEnums;
import android.content.ContentResolver;
import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;

import androidx.annotation.VisibleForTesting;
@@ -32,6 +33,7 @@ import androidx.slice.core.SliceAction;

import com.android.settings.overlay.FeatureFactory;
import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
import com.android.settingslib.utils.ThreadUtils;

import java.util.List;
import java.util.concurrent.Callable;
@@ -115,7 +117,12 @@ public class EligibleCardChecker implements Callable<ContextualCard> {
        // Register a trivial callback to pin the slice
        manager.registerSliceCallback(uri, callback);
        final Slice slice = manager.bindSlice(uri);
        manager.unregisterSliceCallback(uri, callback);

        // Workaround of unpinning slice in the same SerialExecutor of AsyncTask as SliceCallback's
        // observer.
        ThreadUtils.postOnMainThread(() ->
                AsyncTask.execute(() -> manager.unregisterSliceCallback(uri, callback))
        );

        return slice;
    }