@Test public void testCallback() { if (BuildCompat.isAtLeastP()) { return; } Uri uri = new Uri.Builder() .scheme(ContentResolver.SCHEME_CONTENT) .authority(mContext.getPackageName()) .build(); Slice s = new Slice.Builder(uri).build(); SliceManager.SliceCallback callback = mock(SliceManager.SliceCallback.class); when(mSliceProvider.onBindSlice(eq(uri))).thenReturn(s); mManager.registerSliceCallback(uri, new Executor() { @Override public void execute(@NonNull Runnable command) { command.run(); } }, callback); mContext.getContentResolver().notifyChange(uri, null); verify(callback, timeout(2000)).onSliceUpdated(any(Slice.class)); }
public abstract void registerSliceCallback(@NonNull Uri uri, @NonNull SliceCallback callback);
SliceManager { public abstract void registerSliceCallback(@NonNull Uri uri, @NonNull SliceCallback callback); }
SliceManager { public abstract void registerSliceCallback(@NonNull Uri uri, @NonNull SliceCallback callback); @RestrictTo(RestrictTo.Scope.LIBRARY)  SliceManager(); }
SliceManager { public abstract void registerSliceCallback(@NonNull Uri uri, @NonNull SliceCallback callback); @RestrictTo(RestrictTo.Scope.LIBRARY)  SliceManager(); @SuppressWarnings("NewApi") static @NonNull SliceManager getInstance(@NonNull Context context); abstract void registerSliceCallback(@NonNull Uri uri, @NonNull SliceCallback callback); abstract void registerSliceCallback(@NonNull Uri uri, @NonNull Executor executor,
            @NonNull SliceCallback callback); abstract void unregisterSliceCallback(@NonNull Uri uri, @NonNull SliceCallback callback); abstract void pinSlice(@NonNull Uri uri); abstract void unpinSlice(@NonNull Uri uri); abstract @NonNull Set<SliceSpec> getPinnedSpecs(@NonNull Uri uri); abstract @Nullable Slice bindSlice(@NonNull Uri uri); abstract @Nullable Slice bindSlice(@NonNull Intent intent); abstract @Nullable Uri mapIntentToUri(@NonNull Intent intent); @PermissionChecker.PermissionResult abstract int checkSlicePermission(@NonNull Uri uri, int pid, int uid); abstract void grantSlicePermission(@NonNull String toPackage, @NonNull Uri uri); abstract void revokeSlicePermission(@NonNull String toPackage, @NonNull Uri uri); abstract @NonNull Collection<Uri> getSliceDescendants(@NonNull Uri uri); abstract @NonNull List<Uri> getPinnedSlices(); }
SliceManager { public abstract void registerSliceCallback(@NonNull Uri uri, @NonNull SliceCallback callback); @RestrictTo(RestrictTo.Scope.LIBRARY)  SliceManager(); @SuppressWarnings("NewApi") static @NonNull SliceManager getInstance(@NonNull Context context); abstract void registerSliceCallback(@NonNull Uri uri, @NonNull SliceCallback callback); abstract void registerSliceCallback(@NonNull Uri uri, @NonNull Executor executor,
            @NonNull SliceCallback callback); abstract void unregisterSliceCallback(@NonNull Uri uri, @NonNull SliceCallback callback); abstract void pinSlice(@NonNull Uri uri); abstract void unpinSlice(@NonNull Uri uri); abstract @NonNull Set<SliceSpec> getPinnedSpecs(@NonNull Uri uri); abstract @Nullable Slice bindSlice(@NonNull Uri uri); abstract @Nullable Slice bindSlice(@NonNull Intent intent); abstract @Nullable Uri mapIntentToUri(@NonNull Intent intent); @PermissionChecker.PermissionResult abstract int checkSlicePermission(@NonNull Uri uri, int pid, int uid); abstract void grantSlicePermission(@NonNull String toPackage, @NonNull Uri uri); abstract void revokeSlicePermission(@NonNull String toPackage, @NonNull Uri uri); abstract @NonNull Collection<Uri> getSliceDescendants(@NonNull Uri uri); abstract @NonNull List<Uri> getPinnedSlices();  }