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

Commit 2f4b64ae authored by Mehdi Alizadeh's avatar Mehdi Alizadeh
Browse files

Adds class and method documentation in all app prediction classes

Test: None
Bug: 126179623
Bug: 126179640
Bug: 126180079
Bug: 126179807
Bug: 126180060
Change-Id: I7bf9bde4ccd8cca645d66433504045683fc55444
parent f99986a0
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -26,7 +26,8 @@ import android.os.Parcel;
import android.os.Parcelable;

/**
 * TODO(b/111701043): Add java docs
 * Class that provides contextual information about the environment in which the app prediction is
 * used, such as package name, UI in which the app targets are shown, and number of targets.
 *
 * @hide
 */
@@ -57,20 +58,32 @@ public final class AppPredictionContext implements Parcelable {
        mExtras = parcel.readBundle();
    }

    /**
     * Returns the UI surface of the prediction context.
     */
    @NonNull
    public String getUiSurface() {
        return mUiSurface;
    }

    /**
     * Returns the predicted target count
     */
    public @IntRange(from = 0) int getPredictedTargetCount() {
        return mPredictedTargetCount;
    }

    /**
     * Returns the package name of the prediction context.
     */
    @NonNull
    public String getPackageName() {
        return mPackageName;
    }

    /**
     * Returns the extras of the prediction context.
     */
    @Nullable
    public Bundle getExtras() {
        return mExtras;
@@ -100,9 +113,6 @@ public final class AppPredictionContext implements Parcelable {
        dest.writeBundle(mExtras);
    }

    /**
     * @see Parcelable.Creator
     */
    public static final @android.annotation.NonNull Parcelable.Creator<AppPredictionContext> CREATOR =
            new Parcelable.Creator<AppPredictionContext>() {
                public AppPredictionContext createFromParcel(Parcel parcel) {
@@ -132,7 +142,7 @@ public final class AppPredictionContext implements Parcelable {
        private Bundle mExtras;

        /**
         * TODO(b/123591863): Add java docs
         * @param context The {@link Context} of the prediction client.
         *
         * @hide
         */
+2 −1
Original line number Diff line number Diff line
@@ -23,7 +23,8 @@ import android.content.Context;
import com.android.internal.util.Preconditions;

/**
 * TODO (b/111701043) : Add java doc
 * Class that provides methods to create prediction clients.
 *
 * @hide
 */
@SystemApi
+3 −5
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ import android.os.Parcel;
import android.os.Parcelable;

/**
 * TODO (b/111701043) : Add java doc
 * The id for an app prediction session. See {@link AppPredictor}.
 *
 * @hide
 */
@@ -33,6 +33,8 @@ public final class AppPredictionSessionId implements Parcelable {
    private final String mId;

    /**
     * Creates a new id for a prediction session.
     *
     * @hide
     */
    public AppPredictionSessionId(@NonNull String id) {
@@ -58,7 +60,6 @@ public final class AppPredictionSessionId implements Parcelable {

    @Override
    public int hashCode() {
        // Ensure that the id has a consistent hash
        return mId.hashCode();
    }

@@ -72,9 +73,6 @@ public final class AppPredictionSessionId implements Parcelable {
        dest.writeString(mId);
    }

    /**
     * @see Parcelable.Creator
     */
    public static final @android.annotation.NonNull Parcelable.Creator<AppPredictionSessionId> CREATOR =
            new Parcelable.Creator<AppPredictionSessionId>() {
                public AppPredictionSessionId createFromParcel(Parcel parcel) {
+31 −8
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;

/**
 * TODO (b/111701043) : Add java doc
 * Class that represents an App Prediction client.
 *
 * <p>
 * Usage: <pre> {@code
@@ -49,14 +49,20 @@ import java.util.function.Consumer;
 *
 *    void onCreate() {
 *         mClient = new AppPredictor(...)
 *         mClient.registerPredictionUpdates(...)
 *    }
 *
 *    void onStart() {
 *        mClient.requestPredictionUpdate();
 *        mClient.requestPredictionUpdate()
 *    }
 *
 *    void onClick(...) {
 *        mClient.notifyAppTargetEvent(...)
 *    }
 *
 *    void onDestroy() {
 *        mClient.close();
 *        mClient.unregisterPredictionUpdates()
 *        mClient.close()
 *    }
 *
 * }</pre>
@@ -83,7 +89,8 @@ public final class AppPredictor {
     * The caller should call {@link AppPredictor#destroy()} to dispose the client once it
     * no longer used.
     *
     * @param predictionContext The prediction context
     * @param context The {@link Context} of the user of this {@link AppPredictor}.
     * @param predictionContext The prediction context.
     */
    AppPredictor(@NonNull Context context, @NonNull AppPredictionContext predictionContext) {
        IBinder b = ServiceManager.getService(Context.APP_PREDICTION_SERVICE);
@@ -102,6 +109,8 @@ public final class AppPredictor {

    /**
     * Notifies the prediction service of an app target event.
     *
     * @param event The {@link AppTargetEvent} that represents the app target event.
     */
    public void notifyAppTargetEvent(@NonNull AppTargetEvent event) {
        if (mIsClosed.get()) {
@@ -118,6 +127,9 @@ public final class AppPredictor {

    /**
     * Notifies the prediction service when the targets in a launch location are shown to the user.
     *
     * @param launchLocation The launch location where the targets are shown to the user.
     * @param targetIds List of {@link AppTargetId}s that are shown to the user.
     */
    public void notifyLocationShown(@NonNull String launchLocation,
            @NonNull List<AppTargetId> targetIds) {
@@ -138,7 +150,10 @@ public final class AppPredictor {
     * Requests the prediction service provide continuous updates of App predictions via the
     * provided callback, until the given callback is unregistered.
     *
     * @see Callback#onTargetsAvailable(List)
     * @see Callback#onTargetsAvailable(List).
     *
     * @param callbackExecutor The callback executor to use when calling the callback.
     * @param callback The Callback to be called when updates of App predictions are available.
     */
    public void registerPredictionUpdates(@NonNull @CallbackExecutor Executor callbackExecutor,
            @NonNull AppPredictor.Callback callback) {
@@ -164,6 +179,10 @@ public final class AppPredictor {
    /**
     * Requests the prediction service to stop providing continuous updates to the provided
     * callback until the callback is re-registered.
     *
     * @see {@link AppPredictor#registerPredictionUpdates(Executor, Callback)}.
     *
     * @param callback The callback to be unregistered.
     */
    public void unregisterPredictionUpdates(@NonNull AppPredictor.Callback callback) {
        if (mIsClosed.get()) {
@@ -187,7 +206,7 @@ public final class AppPredictor {
     * Requests the prediction service to dispatch a new set of App predictions via the provided
     * callback.
     *
     * @see Callback#onTargetsAvailable(List)
     * @see Callback#onTargetsAvailable(List).
     */
    public void requestPredictionUpdate() {
        if (mIsClosed.get()) {
@@ -205,6 +224,10 @@ public final class AppPredictor {
    /**
     * Returns a new list of AppTargets sorted based on prediction rank or {@code null} if the
     * ranker is not available.
     *
     * @param targets List of app targets to be sorted.
     * @param callbackExecutor The callback executor to use when calling the callback.
     * @param callback The callback to return the sorted list of app targets.
     */
    @Nullable
    public void sortTargets(@NonNull List<AppTarget> targets,
@@ -255,7 +278,7 @@ public final class AppPredictor {
    }

    /**
     * TODO(b/123591863): Add java docs
     * Returns the id of this prediction session.
     *
     * @hide
     */
@@ -271,7 +294,7 @@ public final class AppPredictor {

        /**
         * Called when a new set of predicted app targets are available.
         * @param targets Sorted list of predicted targets
         * @param targets Sorted list of predicted targets.
         */
        void onTargetsAvailable(@NonNull List<AppTarget> targets);
    }
+12 −5
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.internal.util.Preconditions;

/**
 * A representation of a launchable target.
 *
 * @hide
 */
@SystemApi
@@ -45,7 +46,12 @@ public final class AppTarget implements Parcelable {
    private int mRank;

    /**
     * TODO(b/123591863): Add java docs
     * Creates an instance of AppTarget that represent a launchable component.
     *
     * @param id A unique id for this launchable target.
     * @param packageName Package name of the target.
     * @param className Class name of the target.
     * @param user The UserHandle of the user which this target belongs to.
     *
     * @hide
     */
@@ -62,7 +68,11 @@ public final class AppTarget implements Parcelable {
    }

    /**
     * TODO(b/123591863): Add java docs
     * Creates an instance of AppTarget that represent a launchable shortcut.
     *
     * @param id A unique id for this launchable target.
     * @param shortcutInfo The {@link ShortcutInfo} that is represented with this target.
     * @param className Class name fo the target.
     *
     * @hide
     */
@@ -186,9 +196,6 @@ public final class AppTarget implements Parcelable {
        dest.writeInt(mRank);
    }

    /**
     * @see Parcelable.Creator
     */
    public static final @android.annotation.NonNull Parcelable.Creator<AppTarget> CREATOR =
            new Parcelable.Creator<AppTarget>() {
                public AppTarget createFromParcel(Parcel parcel) {
Loading