summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.txt12
-rw-r--r--core/java/android/app/slice/Slice.java30
-rw-r--r--core/java/android/app/slice/SliceManager.java85
3 files changed, 27 insertions, 100 deletions
diff --git a/api/current.txt b/api/current.txt
index 7bdff3f7c794..b477503a8fa4 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -7171,13 +7171,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";
@@ -7224,6 +7224,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);
}
@@ -7260,19 +7261,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[]);
diff --git a/core/java/android/app/slice/Slice.java b/core/java/android/app/slice/Slice.java
index 65e54f97e215..d6f23521bf3c 100644
--- a/core/java/android/app/slice/Slice.java
+++ b/core/java/android/app/slice/Slice.java
@@ -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";
/**
@@ -290,6 +287,14 @@ public final class Slice implements Parcelable {
}
/**
+ * 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
*/
public static class Builder {
@@ -318,6 +323,21 @@ public final class Slice implements Parcelable {
}
/**
+ * 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
*/
public Builder addHints(@SliceHint String... hints) {
diff --git a/core/java/android/app/slice/SliceManager.java b/core/java/android/app/slice/SliceManager.java
index ae1d8d79caf0..9f9ce8d3f386 100644
--- a/core/java/android/app/slice/SliceManager.java
+++ b/core/java/android/app/slice/SliceManager.java
@@ -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();
/**
@@ -104,71 +98,6 @@ public class SliceManager {
}
/**
- * @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>
* Pinned state is not persisted across reboots, so apps are expected to re-pin any slices
@@ -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);
- }
}