summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Shashwat Razdan <srazdan@google.com> 2021-04-14 23:39:10 +0000
committer Shashwat Razdan <srazdan@google.com> 2021-04-20 08:06:25 +0000
commit8c63ca65814af72f660dcf84075aba68148c883e (patch)
tree4761e5f23d1dc4e561403f550c8f1ff0bb07f172
parentad6ad2644135478bf3de7f3335ac44e290d88b48 (diff)
Addressing the feedback received in the API review.
API Review bugs list is here: https://b.corp.google.com/issues?q=blockingid:176851064 Test: CTS tests: Fixes:185226923 Fixes:185226755 Fixes:185226674 Fixes:185226597 Fixes:185226790 Fixes:184585058 Fixes:184585080 Fixes:184585117 Fixes:184585343 Fixes:184585079 Change-Id: Idacee5f95ce104d1fb6de40a04ac2b74691f977e
-rw-r--r--core/api/system-current.txt47
-rw-r--r--core/java/android/app/smartspace/SmartspaceConfig.java17
-rw-r--r--core/java/android/app/smartspace/SmartspaceSession.java46
-rw-r--r--core/java/android/app/smartspace/SmartspaceSessionId.java21
-rw-r--r--core/java/android/app/smartspace/SmartspaceTarget.java73
-rw-r--r--core/java/android/app/smartspace/SmartspaceTargetEvent.java16
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt4
-rw-r--r--services/smartspace/java/com/android/server/smartspace/SmartspaceManagerService.java2
9 files changed, 121 insertions, 113 deletions
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 80c533cbdd86..5adb95dfd103 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -1615,7 +1615,7 @@ package android.app.smartspace {
ctor public SmartspaceConfig.Builder(@NonNull android.content.Context, @NonNull String);
method @NonNull public android.app.smartspace.SmartspaceConfig build();
method @NonNull public android.app.smartspace.SmartspaceConfig.Builder setExtras(@NonNull android.os.Bundle);
- method @NonNull public android.app.smartspace.SmartspaceConfig.Builder setSmartspaceTargetCount(int);
+ method @NonNull public android.app.smartspace.SmartspaceConfig.Builder setSmartspaceTargetCount(@IntRange(from=0, to=50) int);
}
public final class SmartspaceManager {
@@ -1623,23 +1623,22 @@ package android.app.smartspace {
}
public final class SmartspaceSession implements java.lang.AutoCloseable {
+ method public void addOnTargetsAvailableListener(@NonNull java.util.concurrent.Executor, @NonNull android.app.smartspace.SmartspaceSession.OnTargetsAvailableListener);
method public void close();
- method public void destroy();
method protected void finalize();
method public void notifySmartspaceEvent(@NonNull android.app.smartspace.SmartspaceTargetEvent);
- method public void registerSmartspaceUpdates(@NonNull java.util.concurrent.Executor, @NonNull android.app.smartspace.SmartspaceSession.Callback);
+ method public void removeOnTargetsAvailableListener(@NonNull android.app.smartspace.SmartspaceSession.OnTargetsAvailableListener);
method public void requestSmartspaceUpdate();
- method public void unregisterSmartspaceUpdates(@NonNull android.app.smartspace.SmartspaceSession.Callback);
}
- public static interface SmartspaceSession.Callback {
+ public static interface SmartspaceSession.OnTargetsAvailableListener {
method public void onTargetsAvailable(@NonNull java.util.List<android.app.smartspace.SmartspaceTarget>);
}
public final class SmartspaceSessionId implements android.os.Parcelable {
method public int describeContents();
method @Nullable public String getId();
- method @NonNull public int getUserId();
+ method @NonNull public android.os.UserHandle getUserHandle();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.app.smartspace.SmartspaceSessionId> CREATOR;
}
@@ -1650,19 +1649,19 @@ package android.app.smartspace {
method @Nullable public String getAssociatedSmartspaceTargetId();
method @Nullable public android.app.smartspace.SmartspaceAction getBaseAction();
method @NonNull public android.content.ComponentName getComponentName();
- method @NonNull public long getCreationTimeMillis();
- method @NonNull public long getExpiryTimeMillis();
- method @NonNull public int getFeatureType();
+ method public long getCreationTimeMillis();
+ method public long getExpiryTimeMillis();
+ method public int getFeatureType();
method @Nullable public android.app.smartspace.SmartspaceAction getHeaderAction();
method @NonNull public java.util.List<android.app.smartspace.SmartspaceAction> getIconGrid();
- method @NonNull public float getScore();
+ method public float getScore();
method @Nullable public android.net.Uri getSliceUri();
method @NonNull public String getSmartspaceTargetId();
method @Nullable public String getSourceNotificationKey();
method @NonNull public android.os.UserHandle getUserHandle();
- method @Nullable public android.appwidget.AppWidgetProviderInfo getWidgetId();
- method @NonNull public boolean isSensitive();
- method @NonNull public boolean shouldShowExpanded();
+ method @Nullable public android.appwidget.AppWidgetProviderInfo getWidget();
+ method public boolean isSensitive();
+ method public boolean shouldShowExpanded();
method public void writeToParcel(@NonNull android.os.Parcel, int);
field @NonNull public static final android.os.Parcelable.Creator<android.app.smartspace.SmartspaceTarget> CREATOR;
field public static final int FEATURE_ALARM = 7; // 0x7
@@ -1697,17 +1696,17 @@ package android.app.smartspace {
method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setActionChips(@NonNull java.util.List<android.app.smartspace.SmartspaceAction>);
method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setAssociatedSmartspaceTargetId(@NonNull String);
method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setBaseAction(@NonNull android.app.smartspace.SmartspaceAction);
- method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setCreationTimeMillis(@NonNull long);
- method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setExpiryTimeMillis(@NonNull long);
- method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setFeatureType(@NonNull int);
+ method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setCreationTimeMillis(long);
+ method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setExpiryTimeMillis(long);
+ method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setFeatureType(int);
method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setHeaderAction(@NonNull android.app.smartspace.SmartspaceAction);
method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setIconGrid(@NonNull java.util.List<android.app.smartspace.SmartspaceAction>);
- method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setScore(@NonNull float);
- method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setSensitive(@NonNull boolean);
- method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setShouldShowExpanded(@NonNull boolean);
+ method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setScore(float);
+ method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setSensitive(boolean);
+ method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setShouldShowExpanded(boolean);
method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setSliceUri(@NonNull android.net.Uri);
method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setSourceNotificationKey(@NonNull String);
- method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setWidgetId(@NonNull android.appwidget.AppWidgetProviderInfo);
+ method @NonNull public android.app.smartspace.SmartspaceTarget.Builder setWidget(@NonNull android.appwidget.AppWidgetProviderInfo);
}
public final class SmartspaceTargetEvent implements android.os.Parcelable {
@@ -1719,11 +1718,11 @@ package android.app.smartspace {
field @NonNull public static final android.os.Parcelable.Creator<android.app.smartspace.SmartspaceTargetEvent> CREATOR;
field public static final int EVENT_TARGET_BLOCK = 5; // 0x5
field public static final int EVENT_TARGET_DISMISS = 4; // 0x4
+ field public static final int EVENT_TARGET_HIDDEN = 3; // 0x3
field public static final int EVENT_TARGET_INTERACTION = 1; // 0x1
- field public static final int EVENT_TARGET_IN_VIEW = 2; // 0x2
- field public static final int EVENT_TARGET_OUT_OF_VIEW = 3; // 0x3
- field public static final int EVENT_UI_SURFACE_IN_VIEW = 6; // 0x6
- field public static final int EVENT_UI_SURFACE_OUT_OF_VIEW = 7; // 0x7
+ field public static final int EVENT_TARGET_SHOWN = 2; // 0x2
+ field public static final int EVENT_UI_SURFACE_HIDDEN = 7; // 0x7
+ field public static final int EVENT_UI_SURFACE_SHOWN = 6; // 0x6
}
public static final class SmartspaceTargetEvent.Builder {
diff --git a/core/java/android/app/smartspace/SmartspaceConfig.java b/core/java/android/app/smartspace/SmartspaceConfig.java
index 07d7bf0e33af..0897b5fb81e7 100644
--- a/core/java/android/app/smartspace/SmartspaceConfig.java
+++ b/core/java/android/app/smartspace/SmartspaceConfig.java
@@ -15,6 +15,7 @@
*/
package android.app.smartspace;
+import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
@@ -41,6 +42,7 @@ public final class SmartspaceConfig implements Parcelable {
* The least number of smartspace targets expected to be predicted by the backend. The backend
* will always try to satisfy this threshold but it is not guaranteed to always meet it.
*/
+ @IntRange(from = 0, to = 50)
private final int mSmartspaceTargetCount;
/**
@@ -54,13 +56,15 @@ public final class SmartspaceConfig implements Parcelable {
@NonNull
private String mPackageName;
- /** Send other client UI configurations in extras.
+ /**
+ * Send other client UI configurations in extras.
*
* This can include:
*
- * - Desired maximum update frequency
- * - Request to get periodic updates
- * - Request to support multiple clients for the same UISurface.
+ * - Desired maximum update frequency (For example 1 minute update frequency for AoD, 1 second
+ * update frequency for home screen etc).
+ * - Request to get periodic updates
+ * - Request to support multiple clients for the same UISurface.
*/
@Nullable
private final Bundle mExtras;
@@ -165,7 +169,7 @@ public final class SmartspaceConfig implements Parcelable {
private Bundle mExtras = Bundle.EMPTY;
/**
- * @param context The {@link Context} which is used to fetch the package name.
+ * @param context The {@link Context} which is used to fetch the package name.
* @param uiSurface the UI Surface name associated with this context.
* @hide
*/
@@ -179,7 +183,8 @@ public final class SmartspaceConfig implements Parcelable {
* Used to set the expected number of cards for this context.
*/
@NonNull
- public Builder setSmartspaceTargetCount(int smartspaceTargetCount) {
+ public Builder setSmartspaceTargetCount(
+ @IntRange(from = 0, to = 50) int smartspaceTargetCount) {
this.mSmartspaceTargetCount = smartspaceTargetCount;
return this;
}
diff --git a/core/java/android/app/smartspace/SmartspaceSession.java b/core/java/android/app/smartspace/SmartspaceSession.java
index 16def61239cf..9199581c3149 100644
--- a/core/java/android/app/smartspace/SmartspaceSession.java
+++ b/core/java/android/app/smartspace/SmartspaceSession.java
@@ -63,7 +63,7 @@ import java.util.function.Consumer;
*
* void onDestroy() {
* mSmartspaceSession.unregisterPredictionUpdates()
- * mSmartspaceSession.destroy();
+ * mSmartspaceSession.close();
* }
*
* }</pre>
@@ -81,7 +81,8 @@ public final class SmartspaceSession implements AutoCloseable {
private final AtomicBoolean mIsClosed = new AtomicBoolean(false);
private final SmartspaceSessionId mSessionId;
- private final ArrayMap<Callback, CallbackWrapper> mRegisteredCallbacks = new ArrayMap<>();
+ private final ArrayMap<OnTargetsAvailableListener, CallbackWrapper> mRegisteredCallbacks =
+ new ArrayMap<>();
private final IBinder mToken = new Binder();
/**
@@ -98,11 +99,11 @@ public final class SmartspaceSession implements AutoCloseable {
IBinder b = ServiceManager.getService(Context.SMARTSPACE_SERVICE);
mInterface = android.app.smartspace.ISmartspaceManager.Stub.asInterface(b);
mSessionId = new SmartspaceSessionId(
- context.getPackageName() + ":" + UUID.randomUUID().toString(), context.getUserId());
+ context.getPackageName() + ":" + UUID.randomUUID().toString(), context.getUser());
try {
mInterface.createSmartspaceSession(smartspaceConfig, mSessionId, mToken);
} catch (RemoteException e) {
- Log.e(TAG, "Failed to cerate Smartspace session", e);
+ Log.e(TAG, "Failed to create Smartspace session", e);
e.rethrowFromSystemServer();
}
@@ -145,24 +146,24 @@ public final class SmartspaceSession implements AutoCloseable {
* Requests the smartspace service provide continuous updates of smartspace cards via the
* provided callback, until the given callback is unregistered.
*
- * @param callbackExecutor The callback executor to use when calling the callback.
- * @param callback The Callback to be called when updates of Smartspace targets are
+ * @param listenerExecutor The listener executor to use when firing the listener.
+ * @param listener The listener to be called when updates of Smartspace targets are
* available.
*/
- public void registerSmartspaceUpdates(@NonNull @CallbackExecutor Executor callbackExecutor,
- @NonNull Callback callback) {
+ public void addOnTargetsAvailableListener(@NonNull @CallbackExecutor Executor listenerExecutor,
+ @NonNull OnTargetsAvailableListener listener) {
if (mIsClosed.get()) {
throw new IllegalStateException("This client has already been destroyed.");
}
- if (mRegisteredCallbacks.containsKey(callback)) {
+ if (mRegisteredCallbacks.containsKey(listener)) {
// Skip if this callback is already registered
return;
}
try {
- final CallbackWrapper callbackWrapper = new CallbackWrapper(callbackExecutor,
- callback::onTargetsAvailable);
- mRegisteredCallbacks.put(callback, callbackWrapper);
+ final CallbackWrapper callbackWrapper = new CallbackWrapper(listenerExecutor,
+ listener::onTargetsAvailable);
+ mRegisteredCallbacks.put(listener, callbackWrapper);
mInterface.registerSmartspaceUpdates(mSessionId, callbackWrapper);
mInterface.requestSmartspaceUpdate(mSessionId);
} catch (RemoteException e) {
@@ -175,21 +176,21 @@ public final class SmartspaceSession implements AutoCloseable {
* Requests the smartspace service to stop providing continuous updates to the provided
* callback until the callback is re-registered.
*
- * @see {@link SmartspaceSession#registerSmartspaceUpdates(Executor, Callback)}.
- *
- * @param callback The callback to be unregistered.
+ * @param listener The callback to be unregistered.
+ * @see {@link SmartspaceSession#addOnTargetsAvailableListener(Executor,
+ * OnTargetsAvailableListener)}.
*/
- public void unregisterSmartspaceUpdates(@NonNull Callback callback) {
+ public void removeOnTargetsAvailableListener(@NonNull OnTargetsAvailableListener listener) {
if (mIsClosed.get()) {
throw new IllegalStateException("This client has already been destroyed.");
}
- if (!mRegisteredCallbacks.containsKey(callback)) {
+ if (!mRegisteredCallbacks.containsKey(listener)) {
// Skip if this callback was never registered
return;
}
try {
- final CallbackWrapper callbackWrapper = mRegisteredCallbacks.remove(callback);
+ final CallbackWrapper callbackWrapper = mRegisteredCallbacks.remove(listener);
mInterface.unregisterSmartspaceUpdates(mSessionId, callbackWrapper);
} catch (RemoteException e) {
Log.e(TAG, "Failed to unregister for smartspace updates", e);
@@ -201,7 +202,7 @@ public final class SmartspaceSession implements AutoCloseable {
* Destroys the client and unregisters the callback. Any method on this class after this call
* will throw {@link IllegalStateException}.
*/
- public void destroy() {
+ private void destroy() {
if (!mIsClosed.getAndSet(true)) {
mCloseGuard.close();
@@ -238,6 +239,7 @@ public final class SmartspaceSession implements AutoCloseable {
@Override
public void close() {
try {
+ destroy();
finalize();
} catch (Throwable throwable) {
throwable.printStackTrace();
@@ -245,14 +247,14 @@ public final class SmartspaceSession implements AutoCloseable {
}
/**
- * Callback for receiving smartspace updates.
+ * Listener to receive smartspace targets from the service.
*/
- public interface Callback {
+ public interface OnTargetsAvailableListener {
/**
* Called when a new set of smartspace targets are available.
*
- * @param targets Sorted list of smartspace targets.
+ * @param targets Ranked list of smartspace targets.
*/
void onTargetsAvailable(@NonNull List<SmartspaceTarget> targets);
}
diff --git a/core/java/android/app/smartspace/SmartspaceSessionId.java b/core/java/android/app/smartspace/SmartspaceSessionId.java
index 5220c35d7064..4040cb37b99b 100644
--- a/core/java/android/app/smartspace/SmartspaceSessionId.java
+++ b/core/java/android/app/smartspace/SmartspaceSessionId.java
@@ -21,6 +21,7 @@ import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
+import android.os.UserHandle;
import java.util.Objects;
@@ -36,21 +37,21 @@ public final class SmartspaceSessionId implements Parcelable {
private final String mId;
@NonNull
- private final int mUserId;
+ private final UserHandle mUserHandle;
/**
* Creates a new id for a Smartspace session.
*
* @hide
*/
- public SmartspaceSessionId(@NonNull final String id, @NonNull final int userId) {
+ public SmartspaceSessionId(@NonNull final String id, @NonNull final UserHandle userHandle) {
mId = id;
- mUserId = userId;
+ mUserHandle = userHandle;
}
private SmartspaceSessionId(Parcel p) {
mId = p.readString();
- mUserId = p.readInt();
+ mUserHandle = p.readTypedObject(UserHandle.CREATOR);
}
/**
@@ -65,8 +66,8 @@ public final class SmartspaceSessionId implements Parcelable {
* Returns the userId associated with this sessionId.
*/
@NonNull
- public int getUserId() {
- return mUserId;
+ public UserHandle getUserHandle() {
+ return mUserHandle;
}
@Override
@@ -74,20 +75,20 @@ public final class SmartspaceSessionId implements Parcelable {
if (!getClass().equals(o != null ? o.getClass() : null)) return false;
SmartspaceSessionId other = (SmartspaceSessionId) o;
- return mId.equals(other.mId) && mUserId == other.mUserId;
+ return mId.equals(other.mId) && mUserHandle == other.mUserHandle;
}
@Override
public String toString() {
return "SmartspaceSessionId{"
+ "mId='" + mId + '\''
- + ", mUserId=" + mUserId
+ + ", mUserId=" + mUserHandle.getIdentifier()
+ '}';
}
@Override
public int hashCode() {
- return Objects.hash(mId, mUserId);
+ return Objects.hash(mId, mUserHandle);
}
@Override
@@ -98,7 +99,7 @@ public final class SmartspaceSessionId implements Parcelable {
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeString(mId);
- dest.writeInt(mUserId);
+ dest.writeTypedObject(this.mUserHandle, flags);
}
public static final @NonNull Creator<SmartspaceSessionId> CREATOR =
diff --git a/core/java/android/app/smartspace/SmartspaceTarget.java b/core/java/android/app/smartspace/SmartspaceTarget.java
index ce5040eb0a3e..8e9853575c31 100644
--- a/core/java/android/app/smartspace/SmartspaceTarget.java
+++ b/core/java/android/app/smartspace/SmartspaceTarget.java
@@ -15,6 +15,7 @@
*/
package android.app.smartspace;
+import android.annotation.CurrentTimeMillisLong;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -39,7 +40,7 @@ import java.util.Objects;
* {@link SmartspaceAction} as their type because they can have associated actions.
*
* <p><b>NOTE: </b>
- * If {@link mWidgetId} is set, it should be preferred over all other properties.
+ * If {@link mWidget} is set, it should be preferred over all other properties.
* Else, if {@link mSliceUri} is set, it should be preferred over all other data properties.
* Otherwise, the instance should be treated as a data object.
*
@@ -61,18 +62,17 @@ public final class SmartspaceTarget implements Parcelable {
private final SmartspaceAction mBaseAction;
/** A timestamp indicating when the card was created. */
- @NonNull
+ @CurrentTimeMillisLong
private final long mCreationTimeMillis;
/**
* A timestamp indicating when the card should be removed from view, in case the service
* disconnects or restarts.
*/
- @NonNull
+ @CurrentTimeMillisLong
private final long mExpiryTimeMillis;
/** A score assigned to a target. */
- @NonNull
private final float mScore;
/** A {@link List<SmartspaceAction>} containing all action chips. */
@@ -89,18 +89,15 @@ public final class SmartspaceTarget implements Parcelable {
* @see FeatureType
*/
@FeatureType
- @NonNull
private final int mFeatureType;
/**
* Indicates whether the content is sensitive. Certain UI surfaces may choose to skip rendering
* real content until the device is unlocked.
*/
- @NonNull
private final boolean mSensitive;
/** Indicating if the UI should show this target in its expanded state. */
- @NonNull
private final boolean mShouldShowExpanded;
/** A Notification key if the target was generated using a notification. */
@@ -115,7 +112,14 @@ public final class SmartspaceTarget implements Parcelable {
@NonNull
private final UserHandle mUserHandle;
- /** Target Ids of other {@link SmartspaceTarget}s if they are associated with this target. */
+ /**
+ * Target Id of other {@link SmartspaceTarget}s if it is associated with this target. This
+ * association is added to tell the UI that a card would be more useful if displayed with the
+ * associated smartspace target. This field is supposed to be taken as a suggestion and the
+ * association can be ignored based on the situation in the UI. It is possible to have a one way
+ * card association. In other words, Card B can be associated with Card A but not the other way
+ * around.
+ */
@Nullable
private final String mAssociatedSmartspaceTargetId;
@@ -125,7 +129,7 @@ public final class SmartspaceTarget implements Parcelable {
/** {@link AppWidgetProviderInfo} if this target is a widget. */
@Nullable
- private final AppWidgetProviderInfo mWidgetId;
+ private final AppWidgetProviderInfo mWidget;
public static final int FEATURE_UNDEFINED = 0;
public static final int FEATURE_WEATHER = 1;
@@ -202,7 +206,7 @@ public final class SmartspaceTarget implements Parcelable {
this.mUserHandle = in.readTypedObject(UserHandle.CREATOR);
this.mAssociatedSmartspaceTargetId = in.readString();
this.mSliceUri = in.readTypedObject(Uri.CREATOR);
- this.mWidgetId = in.readTypedObject(AppWidgetProviderInfo.CREATOR);
+ this.mWidget = in.readTypedObject(AppWidgetProviderInfo.CREATOR);
}
private SmartspaceTarget(String smartspaceTargetId,
@@ -213,7 +217,7 @@ public final class SmartspaceTarget implements Parcelable {
boolean shouldShowExpanded, String sourceNotificationKey,
ComponentName componentName, UserHandle userHandle,
String associatedSmartspaceTargetId, Uri sliceUri,
- AppWidgetProviderInfo widgetId) {
+ AppWidgetProviderInfo widget) {
mSmartspaceTargetId = smartspaceTargetId;
mHeaderAction = headerAction;
mBaseAction = baseAction;
@@ -230,7 +234,7 @@ public final class SmartspaceTarget implements Parcelable {
mUserHandle = userHandle;
mAssociatedSmartspaceTargetId = associatedSmartspaceTargetId;
mSliceUri = sliceUri;
- mWidgetId = widgetId;
+ mWidget = widget;
}
/**
@@ -260,7 +264,7 @@ public final class SmartspaceTarget implements Parcelable {
/**
* Returns the creation time of the target.
*/
- @NonNull
+ @CurrentTimeMillisLong
public long getCreationTimeMillis() {
return mCreationTimeMillis;
}
@@ -268,7 +272,7 @@ public final class SmartspaceTarget implements Parcelable {
/**
* Returns the expiry time of the target.
*/
- @NonNull
+ @CurrentTimeMillisLong
public long getExpiryTimeMillis() {
return mExpiryTimeMillis;
}
@@ -276,7 +280,6 @@ public final class SmartspaceTarget implements Parcelable {
/**
* Returns the score of the target.
*/
- @NonNull
public float getScore() {
return mScore;
}
@@ -300,7 +303,7 @@ public final class SmartspaceTarget implements Parcelable {
/**
* Returns the feature type of the target.
*/
- @NonNull
+ @FeatureType
public int getFeatureType() {
return mFeatureType;
}
@@ -308,7 +311,6 @@ public final class SmartspaceTarget implements Parcelable {
/**
* Returns whether the target is sensitive or not.
*/
- @NonNull
public boolean isSensitive() {
return mSensitive;
}
@@ -316,7 +318,6 @@ public final class SmartspaceTarget implements Parcelable {
/**
* Returns whether the target should be shown in expanded state.
*/
- @NonNull
public boolean shouldShowExpanded() {
return mShouldShowExpanded;
}
@@ -365,8 +366,8 @@ public final class SmartspaceTarget implements Parcelable {
* Returns the AppWidgetProviderInfo, if the target is a widget.
*/
@Nullable
- public AppWidgetProviderInfo getWidgetId() {
- return mWidgetId;
+ public AppWidgetProviderInfo getWidget() {
+ return mWidget;
}
/**
@@ -403,7 +404,7 @@ public final class SmartspaceTarget implements Parcelable {
dest.writeTypedObject(this.mUserHandle, flags);
dest.writeString(this.mAssociatedSmartspaceTargetId);
dest.writeTypedObject(this.mSliceUri, flags);
- dest.writeTypedObject(this.mWidgetId, flags);
+ dest.writeTypedObject(this.mWidget, flags);
}
@Override
@@ -430,7 +431,7 @@ public final class SmartspaceTarget implements Parcelable {
+ ", mUserHandle=" + mUserHandle
+ ", mAssociatedSmartspaceTargetId='" + mAssociatedSmartspaceTargetId + '\''
+ ", mSliceUri=" + mSliceUri
- + ", mWidgetId=" + mWidgetId
+ + ", mWidget=" + mWidget
+ '}';
}
@@ -456,7 +457,7 @@ public final class SmartspaceTarget implements Parcelable {
&& Objects.equals(mAssociatedSmartspaceTargetId,
that.mAssociatedSmartspaceTargetId)
&& Objects.equals(mSliceUri, that.mSliceUri)
- && Objects.equals(mWidgetId, that.mWidgetId);
+ && Objects.equals(mWidget, that.mWidget);
}
@Override
@@ -464,7 +465,7 @@ public final class SmartspaceTarget implements Parcelable {
return Objects.hash(mSmartspaceTargetId, mHeaderAction, mBaseAction, mCreationTimeMillis,
mExpiryTimeMillis, mScore, mActionChips, mIconGrid, mFeatureType, mSensitive,
mShouldShowExpanded, mSourceNotificationKey, mComponentName, mUserHandle,
- mAssociatedSmartspaceTargetId, mSliceUri, mWidgetId);
+ mAssociatedSmartspaceTargetId, mSliceUri, mWidget);
}
/**
@@ -490,7 +491,7 @@ public final class SmartspaceTarget implements Parcelable {
private final UserHandle mUserHandle;
private String mAssociatedSmartspaceTargetId;
private Uri mSliceUri;
- private AppWidgetProviderInfo mWidgetId;
+ private AppWidgetProviderInfo mWidget;
/**
* A builder for {@link SmartspaceTarget}.
@@ -528,7 +529,7 @@ public final class SmartspaceTarget implements Parcelable {
* Sets the creation time.
*/
@NonNull
- public Builder setCreationTimeMillis(@NonNull long creationTimeMillis) {
+ public Builder setCreationTimeMillis(@CurrentTimeMillisLong long creationTimeMillis) {
this.mCreationTimeMillis = creationTimeMillis;
return this;
}
@@ -537,7 +538,7 @@ public final class SmartspaceTarget implements Parcelable {
* Sets the expiration time.
*/
@NonNull
- public Builder setExpiryTimeMillis(@NonNull long expiryTimeMillis) {
+ public Builder setExpiryTimeMillis(@CurrentTimeMillisLong long expiryTimeMillis) {
this.mExpiryTimeMillis = expiryTimeMillis;
return this;
}
@@ -546,7 +547,7 @@ public final class SmartspaceTarget implements Parcelable {
* Sets the score.
*/
@NonNull
- public Builder setScore(@NonNull float score) {
+ public Builder setScore(float score) {
this.mScore = score;
return this;
}
@@ -573,7 +574,7 @@ public final class SmartspaceTarget implements Parcelable {
* Sets the feature type.
*/
@NonNull
- public Builder setFeatureType(@NonNull int featureType) {
+ public Builder setFeatureType(int featureType) {
this.mFeatureType = featureType;
return this;
}
@@ -582,7 +583,7 @@ public final class SmartspaceTarget implements Parcelable {
* Sets whether the contents are sensitive.
*/
@NonNull
- public Builder setSensitive(@NonNull boolean sensitive) {
+ public Builder setSensitive(boolean sensitive) {
this.mSensitive = sensitive;
return this;
}
@@ -591,7 +592,7 @@ public final class SmartspaceTarget implements Parcelable {
* Sets whether to show the card as expanded.
*/
@NonNull
- public Builder setShouldShowExpanded(@NonNull boolean shouldShowExpanded) {
+ public Builder setShouldShowExpanded(boolean shouldShowExpanded) {
this.mShouldShowExpanded = shouldShowExpanded;
return this;
}
@@ -618,7 +619,7 @@ public final class SmartspaceTarget implements Parcelable {
/**
* Sets the slice uri.
*
- * <p><b>NOTE: </b> If {@link mWidgetId} is also set, {@link mSliceUri} should be ignored.
+ * <p><b>NOTE: </b> If {@link mWidget} is also set, {@link mSliceUri} should be ignored.
*/
@NonNull
public Builder setSliceUri(@NonNull Uri sliceUri) {
@@ -629,12 +630,12 @@ public final class SmartspaceTarget implements Parcelable {
/**
* Sets the widget id.
*
- * <p><b>NOTE: </b> If {@link mWidgetId} is set, all other @Nullable params should be
+ * <p><b>NOTE: </b> If {@link mWidget} is set, all other @Nullable params should be
* ignored.
*/
@NonNull
- public Builder setWidgetId(@NonNull AppWidgetProviderInfo widgetId) {
- this.mWidgetId = widgetId;
+ public Builder setWidget(@NonNull AppWidgetProviderInfo widget) {
+ this.mWidget = widget;
return this;
}
@@ -654,7 +655,7 @@ public final class SmartspaceTarget implements Parcelable {
mHeaderAction, mBaseAction, mCreationTimeMillis, mExpiryTimeMillis, mScore,
mActionChips, mIconGrid, mFeatureType, mSensitive, mShouldShowExpanded,
mSourceNotificationKey, mComponentName, mUserHandle,
- mAssociatedSmartspaceTargetId, mSliceUri, mWidgetId);
+ mAssociatedSmartspaceTargetId, mSliceUri, mWidget);
}
}
}
diff --git a/core/java/android/app/smartspace/SmartspaceTargetEvent.java b/core/java/android/app/smartspace/SmartspaceTargetEvent.java
index 920b9fe6a34f..61f8723ca393 100644
--- a/core/java/android/app/smartspace/SmartspaceTargetEvent.java
+++ b/core/java/android/app/smartspace/SmartspaceTargetEvent.java
@@ -41,11 +41,11 @@ public final class SmartspaceTargetEvent implements Parcelable {
/**
* Smartspace target was brought into view.
*/
- public static final int EVENT_TARGET_IN_VIEW = 2;
+ public static final int EVENT_TARGET_SHOWN = 2;
/**
* Smartspace target went out of view.
*/
- public static final int EVENT_TARGET_OUT_OF_VIEW = 3;
+ public static final int EVENT_TARGET_HIDDEN = 3;
/**
* A dismiss action was issued by the user.
*/
@@ -57,11 +57,11 @@ public final class SmartspaceTargetEvent implements Parcelable {
/**
* The Ui surface came into view.
*/
- public static final int EVENT_UI_SURFACE_IN_VIEW = 6;
+ public static final int EVENT_UI_SURFACE_SHOWN = 6;
/**
* The Ui surface went out of view.
*/
- public static final int EVENT_UI_SURFACE_OUT_OF_VIEW = 7;
+ public static final int EVENT_UI_SURFACE_HIDDEN = 7;
/**
* @see Parcelable.Creator
@@ -152,12 +152,12 @@ public final class SmartspaceTargetEvent implements Parcelable {
*/
@IntDef(prefix = {"EVENT_"}, value = {
EVENT_TARGET_INTERACTION,
- EVENT_TARGET_IN_VIEW,
- EVENT_TARGET_OUT_OF_VIEW,
+ EVENT_TARGET_SHOWN,
+ EVENT_TARGET_HIDDEN,
EVENT_TARGET_DISMISS,
EVENT_TARGET_BLOCK,
- EVENT_UI_SURFACE_IN_VIEW,
- EVENT_UI_SURFACE_OUT_OF_VIEW
+ EVENT_UI_SURFACE_SHOWN,
+ EVENT_UI_SURFACE_HIDDEN
})
@Retention(RetentionPolicy.SOURCE)
public @interface EventType {
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
index e7418e6a1619..96421f3a4981 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java
@@ -86,7 +86,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
private FrameLayout mLargeClockFrame;
private SmartspaceSession mSmartspaceSession;
- private SmartspaceSession.Callback mSmartspaceCallback;
+ private SmartspaceSession.OnTargetsAvailableListener mSmartspaceCallback;
private float mDozeAmount;
private int mWallpaperTextColor;
private int mDozeColor = Color.WHITE;
@@ -234,7 +234,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
.createSmartspaceSession(
new SmartspaceConfig.Builder(getContext(), "lockscreen").build());
mSmartspaceCallback = targets -> smartspaceDataPlugin.onTargetsAvailable(targets);
- mSmartspaceSession.registerSmartspaceUpdates(mUiExecutor, mSmartspaceCallback);
+ mSmartspaceSession.addOnTargetsAvailableListener(mUiExecutor, mSmartspaceCallback);
mSmartspaceSession.requestSmartspaceUpdate();
}
}
@@ -261,8 +261,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
mView.setClockPlugin(null, mStatusBarStateController.getState());
if (mSmartspaceSession != null) {
- mSmartspaceSession.unregisterSmartspaceUpdates(mSmartspaceCallback);
- mSmartspaceSession.destroy();
+ mSmartspaceSession.removeOnTargetsAvailableListener(mSmartspaceCallback);
+ mSmartspaceSession.close();
mSmartspaceSession = null;
}
mStatusBarStateController.removeCallback(mStatusBarStateListener);
diff --git a/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt b/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt
index 574ce0dffee0..5ba04a03a8d5 100644
--- a/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/MediaDataManager.kt
@@ -227,7 +227,7 @@ class MediaDataManager(
smartspaceSession = smartspaceManager.createSmartspaceSession(
SmartspaceConfig.Builder(context, SMARTSPACE_UI_SURFACE_LABEL).build())
smartspaceSession?.let {
- it.registerSmartspaceUpdates(
+ it.addOnTargetsAvailableListener(
// Use a new thread listening to Smartspace updates instead of using the existing
// backgroundExecutor. SmartspaceSession has scheduled routine updates which can be
// unpredictable on test simulators, using the backgroundExecutor makes it's hard to
@@ -235,7 +235,7 @@ class MediaDataManager(
// Switch to use backgroundExecutor when SmartspaceSession has a good way to be
// mocked.
Executors.newCachedThreadPool(),
- SmartspaceSession.Callback { targets ->
+ SmartspaceSession.OnTargetsAvailableListener { targets ->
smartspaceMediaDataProvider.onTargetsAvailable(targets)
})
}
diff --git a/services/smartspace/java/com/android/server/smartspace/SmartspaceManagerService.java b/services/smartspace/java/com/android/server/smartspace/SmartspaceManagerService.java
index b07fe19393b2..39ed4dda35a7 100644
--- a/services/smartspace/java/com/android/server/smartspace/SmartspaceManagerService.java
+++ b/services/smartspace/java/com/android/server/smartspace/SmartspaceManagerService.java
@@ -156,7 +156,7 @@ public class SmartspaceManagerService extends
@NonNull final Consumer<SmartspacePerUserService> c) {
ActivityManagerInternal am = LocalServices.getService(ActivityManagerInternal.class);
final int userId = am.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
- sessionId.getUserId(), false, ALLOW_NON_FULL, null, null);
+ sessionId.getUserHandle().getIdentifier(), false, ALLOW_NON_FULL, null, null);
if (DEBUG) {
Slog.d(TAG, "runForUserLocked:" + func + " from pid=" + Binder.getCallingPid()