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

Commit 1717e02e authored by Hyunyoung Song's avatar Hyunyoung Song
Browse files

API council review for SearchUiManager

Bug: 184265048
Test: atest CtsSearchUiServiceTestCases

Change-Id: Ib4dd0d3b29438418d4deb31e999a076e5eeff484
parent 2dd3fdce
Loading
Loading
Loading
Loading
+14 −9
Original line number Diff line number Diff line
@@ -1448,11 +1448,12 @@ package android.app.prediction {
package android.app.search {
  public final class Query implements android.os.Parcelable {
    ctor public Query(@NonNull String, long, @Nullable android.os.Bundle);
    ctor public Query(@NonNull String, long, @NonNull android.os.Bundle);
    ctor public Query(@NonNull String, long);
    method public int describeContents();
    method @Nullable public android.os.Bundle getExtras();
    method @NonNull public android.os.Bundle getExtras();
    method @NonNull public String getInput();
    method @NonNull public long getTimestamp();
    method public long getTimestampMillis();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.search.Query> CREATOR;
  }
@@ -1485,9 +1486,10 @@ package android.app.search {
  }
  public final class SearchContext implements android.os.Parcelable {
    ctor public SearchContext(int, int, @Nullable android.os.Bundle);
    ctor public SearchContext(int, int);
    ctor public SearchContext(int, int, @NonNull android.os.Bundle);
    method public int describeContents();
    method @Nullable public android.os.Bundle getExtras();
    method @NonNull public android.os.Bundle getExtras();
    method @Nullable public String getPackageName();
    method @NonNull public int getResultTypes();
    method @NonNull public int getTimeoutMillis();
@@ -1497,7 +1499,6 @@ package android.app.search {
  public final class SearchSession implements java.lang.AutoCloseable {
    method public void close();
    method public void destroy();
    method protected void finalize();
    method public void notifyEvent(@NonNull android.app.search.Query, @NonNull android.app.search.SearchTargetEvent);
    method @Nullable public void query(@NonNull android.app.search.Query, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<java.util.List<android.app.search.SearchTarget>>);
@@ -1512,7 +1513,7 @@ package android.app.search {
  public final class SearchTarget implements android.os.Parcelable {
    method public int describeContents();
    method @Nullable public android.appwidget.AppWidgetProviderInfo getAppWidgetProviderInfo();
    method @Nullable public android.os.Bundle getExtras();
    method @NonNull public android.os.Bundle getExtras();
    method @NonNull public String getId();
    method @NonNull public String getLayoutType();
    method @NonNull public String getPackageName();
@@ -1526,13 +1527,17 @@ package android.app.search {
    method public boolean shouldHide();
    method public void writeToParcel(@NonNull android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.app.search.SearchTarget> CREATOR;
    field public static final int RESULT_TYPE_APPLICATION = 1; // 0x1
    field public static final int RESULT_TYPE_SHORTCUT = 2; // 0x2
    field public static final int RESULT_TYPE_SLICE = 4; // 0x4
    field public static final int RESULT_TYPE_WIDGETS = 8; // 0x8
  }
  public static final class SearchTarget.Builder {
    ctor public SearchTarget.Builder(int, @NonNull String, @NonNull String);
    method @NonNull public android.app.search.SearchTarget build();
    method @NonNull public android.app.search.SearchTarget.Builder setAppWidgetProviderInfo(@NonNull android.appwidget.AppWidgetProviderInfo);
    method @NonNull public android.app.search.SearchTarget.Builder setExtras(@Nullable android.os.Bundle);
    method @NonNull public android.app.search.SearchTarget.Builder setExtras(@NonNull android.os.Bundle);
    method @NonNull public android.app.search.SearchTarget.Builder setPackageName(@NonNull String);
    method @NonNull public android.app.search.SearchTarget.Builder setParentId(@NonNull String);
    method @NonNull public android.app.search.SearchTarget.Builder setScore(float);
@@ -10260,10 +10265,10 @@ package android.service.search {
  public abstract class SearchUiService extends android.app.Service {
    ctor public SearchUiService();
    method @NonNull public final android.os.IBinder onBind(@NonNull android.content.Intent);
    method public void onCreateSearchSession(@NonNull android.app.search.SearchContext, @NonNull android.app.search.SearchSessionId);
    method @MainThread public abstract void onDestroy(@NonNull android.app.search.SearchSessionId);
    method @MainThread public abstract void onNotifyEvent(@NonNull android.app.search.SearchSessionId, @NonNull android.app.search.Query, @NonNull android.app.search.SearchTargetEvent);
    method @MainThread public abstract void onQuery(@NonNull android.app.search.SearchSessionId, @NonNull android.app.search.Query, @NonNull java.util.function.Consumer<java.util.List<android.app.search.SearchTarget>>);
    method public void onSearchSessionCreated(@NonNull android.app.search.SearchContext, @NonNull android.app.search.SearchSessionId);
  }
}
+20 −0
Original line number Diff line number Diff line
@@ -48,6 +48,18 @@ package android.app.prediction {

}

package android.app.search {

  public final class Query implements android.os.Parcelable {
    method @Deprecated @NonNull public long getTimestamp();
  }

  public final class SearchSession implements java.lang.AutoCloseable {
    method @Deprecated public void destroy();
  }

}

package android.bluetooth {

  public final class BluetoothHeadset implements android.bluetooth.BluetoothProfile {
@@ -163,6 +175,14 @@ package android.service.notification {

}

package android.service.search {

  public abstract class SearchUiService extends android.app.Service {
    method @Deprecated public void onCreateSearchSession(@NonNull android.app.search.SearchContext, @NonNull android.app.search.SearchSessionId);
  }

}

package android.telecom {

  public class TelecomManager {
+64 −19
Original line number Diff line number Diff line
@@ -16,63 +16,108 @@
package android.app.search;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

/**
 * Query object is sent over from client to the service.
 *
 * Inside the query object, there is a timestamp that trackes when the query string was typed.
 *
 * If this object was created for the {@link SearchSession#query},
 * the client expects first consumer to be returned
 * within {@link #getTimestampMillis()} + {@link SearchContext#getTimeoutMillis()}
 * Base of the timestamp should be SystemClock.elasedRealTime()
 *
 * @hide
 */
@SystemApi
public final class Query implements Parcelable {

    /**
     * Query string typed from the client.
     * string typed from the client.
     */
    @NonNull
    private final String mInput;

    private final long mTimestampMillis;

    /**
     * The timestamp that the query string was typed. If this object was created for the
     * {@link SearchSession#query}, the client expects first consumer to be returned
     * within mTimestamp + {@link SearchContext#mTimeoutMillis}
     * Contains other client UI constraints related data
     */
    private final long mTimestamp;

    @Nullable
    @NonNull
    private final Bundle mExtras;

    /**
     * Query object used to pass search box input from client to service.
     *
     * @param input string typed from the client
     * @param timestampMillis timestamp that query string was typed.
     * @param extras bundle that contains other client UI constraints data
     */
    public Query(@NonNull String input,
            long timestamp,
            @SuppressLint("NullableCollection")
            @Nullable Bundle extras) {
            long timestampMillis,
            @NonNull Bundle extras) {
        mInput = input;
        mTimestamp = timestamp;
        mExtras = extras;
        mTimestampMillis = timestampMillis;
        mExtras = extras == null ? extras : new Bundle();
    }

    /**
     * Query object used to pass search box input from client to service.
     *
     * @param input string typed from the client
     * @param timestampMillis timestamp that query string was typed
     */
    public Query(@NonNull String input, long timestampMillis) {
        this(input, timestampMillis, new Bundle());
    }

    private Query(Parcel parcel) {
        mInput = parcel.readString();
        mTimestamp = parcel.readLong();
        mTimestampMillis = parcel.readLong();
        mExtras = parcel.readBundle();
    }

    /**
     * @return string typed from the client
     */
    @NonNull
    public String getInput() {
        return mInput;
    }

    /**
     * @deprecated Will be replaced by {@link #getTimestampMillis()} as soon as
     * new SDK is adopted.
     *
     * @removed
     */
    @Deprecated
    @NonNull
    public long getTimestamp() {
        return mTimestamp;
        return mTimestampMillis;
    }

    /**
     * Base of the timestamp should be SystemClock.elasedRealTime()
     *
     * @return timestamp that query string was typed
     */
    public long getTimestampMillis() {
        return mTimestampMillis;
    }

    @Nullable
    @SuppressLint("NullableCollection")
    /**
     * @return bundle that contains other client constraints related to the query
     */
    @NonNull
    public Bundle getExtras() {
        if (mExtras == null) {
            return new Bundle();
        }
        return mExtras;
    }

@@ -84,7 +129,7 @@ public final class Query implements Parcelable {
    @Override
    public void writeToParcel(@NonNull Parcel dest, int flags) {
        dest.writeString(mInput);
        dest.writeLong(mTimestamp);
        dest.writeLong(mTimestampMillis);
        dest.writeBundle(mExtras);
    }

+27 −8
Original line number Diff line number Diff line
@@ -17,13 +17,20 @@ package android.app.search;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.annotation.SystemApi;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable;

import java.util.Objects;
import java.util.concurrent.Executor;
import java.util.function.Consumer;

/**
 * When {@link SearchSession} is created, {@link SearchContext} object is created
 * to pass the result types from the {@link SearchSession#query(Query, Executor, Consumer)}
 * method that the client wants.
 *
 * @hide
 */
@SystemApi
@@ -51,12 +58,25 @@ public final class SearchContext implements Parcelable {
    @Nullable
    private String mPackageName;

    /**
     * @param resultTypes {@link SearchTarget.SearchResultType}s combined using bit OR operation
     * @param timeoutMillis timeout before client renders its own fallback result
     */
    public SearchContext(int resultTypes, int timeoutMillis) {
        this(resultTypes, timeoutMillis, new Bundle());
    }

    /**
     * @param resultTypes {@link SearchTarget.SearchResultType}s combined using bit OR operation
     * @param timeoutMillis timeout before client renders its own fallback result
     * @param extras other client constraints (e.g., height of the search surface)
     */
    public SearchContext(int resultTypes,
            int queryTimeoutMillis,
            @SuppressLint("NullableCollection") @Nullable Bundle extras) {
            int timeoutMillis,
            @NonNull Bundle extras) {
        mResultTypes = resultTypes;
        mTimeoutMillis = queryTimeoutMillis;
        mExtras = extras;
        mTimeoutMillis = timeoutMillis;
        mExtras = Objects.requireNonNull(extras);
    }

    private SearchContext(Parcel parcel) {
@@ -74,7 +94,7 @@ public final class SearchContext implements Parcelable {
    /**
     * @hide
     */
    public void setPackageName(@Nullable String packageName) {
    void setPackageName(@Nullable String packageName) {
        mPackageName = packageName;
    }

@@ -83,8 +103,7 @@ public final class SearchContext implements Parcelable {
        return mTimeoutMillis;
    }

    @Nullable
    @SuppressLint("NullableCollection")
    @NonNull
    public Bundle getExtras() {
        return mExtras;
    }
+17 −3
Original line number Diff line number Diff line
@@ -37,7 +37,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;

/**
 * Client API to share information about the search UI state and execute query.
 * Client needs to create {@link SearchSession} object from in order to execute
 * {@link #query(Query, Executor, Consumer)} method and share client side signals
 * back to the service using {@link #notifyEvent(Query, SearchTargetEvent)}.
 *
 * <p>
 * Usage: <pre> {@code
@@ -60,7 +62,7 @@ import java.util.function.Consumer;
 *    }
 *
 *    void onDestroy() {
 *        mSearchSession.destroy();
 *        mSearchSession.close();
 *    }
 *
 * }</pre>
@@ -108,7 +110,10 @@ public final class SearchSession implements AutoCloseable{
    }

    /**
     * Notifies the search service of an search target event.
     * Notifies the search service of an search target event (e.g., user interaction
     * and lifecycle event of the search surface).
     *
     * {@see SearchTargetEvent}
     *
     * @param query input object associated with the event.
     * @param event The {@link SearchTargetEvent} that represents the search target event.
@@ -153,7 +158,11 @@ public final class SearchSession implements AutoCloseable{
    /**
     * Destroys the client and unregisters the callback. Any method on this class after this call
     * will throw {@link IllegalStateException}.
     *
     * @deprecated
     * @removed
     */
    @Deprecated
    public void destroy() {
        if (!mIsClosed.getAndSet(true)) {
            mCloseGuard.close();
@@ -188,6 +197,11 @@ public final class SearchSession implements AutoCloseable{
        }
    }

    /**
     * Destroys the client and unregisters the callback. Any method on this class after this call
     * will throw {@link IllegalStateException}.
     *
     */
    @Override
    public void close() {
        try {
Loading