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

Commit 15a62def authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

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

parents 07430648 f11088a8
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;
    }