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

Commit 8d15ff04 authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "Remove registerSliceCallback and formalize setCallerNeeded" into pi-dev

parents 4a28bbaf b8e5fa9d
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -7172,13 +7172,13 @@ package android.app.slice {
    method public java.util.List<android.app.slice.SliceItem> getItems();
    method public android.app.slice.SliceSpec getSpec();
    method public android.net.Uri getUri();
    method public boolean isCallerNeeded();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.app.slice.Slice> CREATOR;
    field public static final java.lang.String EXTRA_RANGE_VALUE = "android.app.slice.extra.RANGE_VALUE";
    field public static final deprecated java.lang.String EXTRA_SLIDER_VALUE = "android.app.slice.extra.SLIDER_VALUE";
    field public static final java.lang.String EXTRA_TOGGLE_STATE = "android.app.slice.extra.TOGGLE_STATE";
    field public static final java.lang.String HINT_ACTIONS = "actions";
    field public static final java.lang.String HINT_CALLER_NEEDED = "caller_needed";
    field public static final java.lang.String HINT_HORIZONTAL = "horizontal";
    field public static final java.lang.String HINT_KEY_WORDS = "key_words";
    field public static final java.lang.String HINT_LARGE = "large";
@@ -7225,6 +7225,7 @@ package android.app.slice {
    method public android.app.slice.Slice.Builder addTimestamp(long, java.lang.String, java.lang.String...);
    method public android.app.slice.Slice.Builder addTimestamp(long, java.lang.String, java.util.List<java.lang.String>);
    method public android.app.slice.Slice build();
    method public android.app.slice.Slice.Builder setCallerNeeded(boolean);
    method public android.app.slice.Slice.Builder setSpec(android.app.slice.SliceSpec);
  }
@@ -7261,19 +7262,10 @@ package android.app.slice {
    method public java.util.Collection<android.net.Uri> getSliceDescendants(android.net.Uri);
    method public android.net.Uri mapIntentToUri(android.content.Intent);
    method public void pinSlice(android.net.Uri, java.util.List<android.app.slice.SliceSpec>);
    method public deprecated void registerSliceCallback(android.net.Uri, android.app.slice.SliceManager.SliceCallback, java.util.List<android.app.slice.SliceSpec>);
    method public deprecated void registerSliceCallback(android.net.Uri, android.app.slice.SliceManager.SliceCallback, java.util.List<android.app.slice.SliceSpec>, java.util.concurrent.Executor);
    method public void registerSliceCallback(android.net.Uri, java.util.List<android.app.slice.SliceSpec>, android.app.slice.SliceManager.SliceCallback);
    method public void registerSliceCallback(android.net.Uri, java.util.List<android.app.slice.SliceSpec>, java.util.concurrent.Executor, android.app.slice.SliceManager.SliceCallback);
    method public void unpinSlice(android.net.Uri);
    method public void unregisterSliceCallback(android.net.Uri, android.app.slice.SliceManager.SliceCallback);
    field public static final java.lang.String SLICE_METADATA_KEY = "android.metadata.SLICE_URI";
  }
  public static abstract interface SliceManager.SliceCallback {
    method public abstract void onSliceUpdated(android.app.slice.Slice);
  }
  public abstract class SliceProvider extends android.content.ContentProvider {
    ctor public SliceProvider();
    method public final int delete(android.net.Uri, java.lang.String, java.lang.String[]);
+25 −5
Original line number Diff line number Diff line
@@ -142,11 +142,8 @@ public final class Slice implements Parcelable {
     */
    public static final String HINT_SEE_MORE = "see_more";
    /**
     * A hint used when implementing app-specific slice permissions.
     * Tells the system that for this slice the return value of
     * {@link SliceProvider#onBindSlice(Uri, List)} may be different depending on
     * {@link SliceProvider#getBindingPackage} and should not be cached for multiple
     * apps.
     * @see Builder#setCallerNeeded
     * @hide
     */
    public static final String HINT_CALLER_NEEDED = "caller_needed";
    /**
@@ -289,6 +286,14 @@ public final class Slice implements Parcelable {
        return ArrayUtils.contains(mHints, hint);
    }

    /**
     * Returns whether the caller for this slice matters.
     * @see Builder#setCallerNeeded
     */
    public boolean isCallerNeeded() {
        return hasHint(HINT_CALLER_NEEDED);
    }

    /**
     * A Builder used to construct {@link Slice}s
     */
@@ -317,6 +322,21 @@ public final class Slice implements Parcelable {
                    .appendPath(String.valueOf(mItems.size())).build();
        }

        /**
         * Tells the system whether for this slice the return value of
         * {@link SliceProvider#onBindSlice(Uri, List)} may be different depending on
         * {@link SliceProvider#getCallingPackage()} and should not be cached for multiple
         * apps.
         */
        public Builder setCallerNeeded(boolean callerNeeded) {
            if (callerNeeded) {
                mHints.add(HINT_CALLER_NEEDED);
            } else {
                mHints.remove(HINT_CALLER_NEEDED);
            }
            return this;
        }

        /**
         * Add hints to the Slice being constructed
         */
+0 −85
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package android.app.slice;

import android.annotation.CallbackExecutor;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemService;
@@ -34,9 +33,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager.ServiceNotFoundException;
import android.util.ArrayMap;
import android.util.Log;
import android.util.Pair;

import com.android.internal.util.Preconditions;

@@ -45,7 +42,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.Executor;

/**
 * Class to handle interactions with {@link Slice}s.
@@ -74,8 +70,6 @@ public class SliceManager {

    private final ISliceManager mService;
    private final Context mContext;
    private final ArrayMap<Pair<Uri, SliceCallback>, ISliceListener> mListenerLookup =
            new ArrayMap<>();
    private final IBinder mToken = new Binder();

    /**
@@ -103,71 +97,6 @@ public class SliceManager {
                ServiceManager.getServiceOrThrow(Context.SLICE_SERVICE));
    }

    /**
     * @deprecated TO BE REMOVED.
     */
    @Deprecated
    public void registerSliceCallback(@NonNull Uri uri, @NonNull SliceCallback callback,
            @NonNull List<SliceSpec> specs) {
    }

    /**
     * @deprecated TO BE REMOVED.
     */
    @Deprecated
    public void registerSliceCallback(@NonNull Uri uri, @NonNull SliceCallback callback,
            @NonNull List<SliceSpec> specs, Executor executor) {
    }

    /**
     * Adds a callback to a specific slice uri.
     * <p>
     * This is a convenience that performs a few slice actions at once. It will put
     * the slice in a pinned state since there is a callback attached. It will also
     * listen for content changes, when a content change observes, the android system
     * will bind the new slice and provide it to all registered {@link SliceCallback}s.
     *
     * @param uri The uri of the slice being listened to.
     * @param callback The listener that should receive the callbacks.
     * @param specs The list of supported {@link SliceSpec}s of the callback.
     * @see SliceProvider#onSlicePinned(Uri)
     */
    public void registerSliceCallback(@NonNull Uri uri, @NonNull List<SliceSpec> specs,
            @NonNull SliceCallback callback) {
    }

    /**
     * Adds a callback to a specific slice uri.
     * <p>
     * This is a convenience that performs a few slice actions at once. It will put
     * the slice in a pinned state since there is a callback attached. It will also
     * listen for content changes, when a content change observes, the android system
     * will bind the new slice and provide it to all registered {@link SliceCallback}s.
     *
     * @param uri The uri of the slice being listened to.
     * @param callback The listener that should receive the callbacks.
     * @param specs The list of supported {@link SliceSpec}s of the callback.
     * @see SliceProvider#onSlicePinned(Uri)
     */
    public void registerSliceCallback(@NonNull Uri uri, @NonNull List<SliceSpec> specs,
            @NonNull @CallbackExecutor Executor executor, @NonNull SliceCallback callback) {

    }

    /**
     * Removes a callback for a specific slice uri.
     * <p>
     * Removes the app from the pinned state (if there are no other apps/callbacks pinning it)
     * in addition to removing the callback.
     *
     * @param uri The uri of the slice being listened to
     * @param callback The listener that should no longer receive callbacks.
     * @see #registerSliceCallback
     */
    public void unregisterSliceCallback(@NonNull Uri uri, @NonNull SliceCallback callback) {

    }

    /**
     * Ensures that a slice is in a pinned state.
     * <p>
@@ -451,18 +380,4 @@ public class SliceManager {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Class that listens to changes in {@link Slice}s.
     */
    public interface SliceCallback {

        /**
         * Called when slice is updated.
         *
         * @param s The updated slice.
         * @see #registerSliceCallback
         */
        void onSliceUpdated(Slice s);
    }
}