Merge "Revert "Workaround of Slice not pinned bug when using SliceCallback"" into rvc-dev am: 77dcc34b26 am: 0d26f24dbf am: 134254ee2b

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

Change-Id: I103593c76f3968ca9e5d77ee02cfdbb67819aa4a
This commit is contained in:
TreeHugger Robot
2020-06-25 18:25:23 +00:00
committed by Automerger Merge Worker

View File

@@ -22,7 +22,6 @@ 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;
@@ -33,7 +32,6 @@ 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;
@@ -117,12 +115,7 @@ public class EligibleCardChecker implements Callable<ContextualCard> {
// Register a trivial callback to pin the slice
manager.registerSliceCallback(uri, callback);
final Slice slice = manager.bindSlice(uri);
// Workaround of unpinning slice in the same SerialExecutor of AsyncTask as SliceCallback's
// observer.
ThreadUtils.postOnMainThread(() ->
AsyncTask.execute(() -> manager.unregisterSliceCallback(uri, callback))
);
manager.unregisterSliceCallback(uri, callback);
return slice;
}