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

Commit e20fcec6 authored by Adam Seaton's avatar Adam Seaton Committed by android-build-team Robot
Browse files

Revert "Add new constructors for mandatory fields in AppTarget.Builder"

This reverts commit 08c5083d.

Reason for revert: Creating revert to cherrypick into qt-release and fix daily build

Change-Id: I9a760c222e1b0dac9c9ec131cc14e7a3a689e939
(cherry picked from commit 1faaeaf560eed54163c67293e6accf9c4e61755e)
parent 9f7d5d81
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -1092,11 +1092,12 @@ package android.app.prediction {
  }
  public static final class AppTarget.Builder {
    ctor public AppTarget.Builder(@NonNull android.app.prediction.AppTargetId, @NonNull String, @NonNull android.os.UserHandle);
    ctor public AppTarget.Builder(@NonNull android.app.prediction.AppTargetId, @NonNull android.content.pm.ShortcutInfo);
    ctor public AppTarget.Builder(@NonNull android.app.prediction.AppTargetId);
    method @NonNull public android.app.prediction.AppTarget build();
    method @NonNull public android.app.prediction.AppTarget.Builder setClassName(@NonNull String);
    method @NonNull public android.app.prediction.AppTarget.Builder setRank(@IntRange(from=0) int);
    method @NonNull public android.app.prediction.AppTarget.Builder setTarget(@NonNull String, @NonNull android.os.UserHandle);
    method @NonNull public android.app.prediction.AppTarget.Builder setTarget(@NonNull android.content.pm.ShortcutInfo);
  }
  public final class AppTargetEvent implements android.os.Parcelable {
+3 −2
Original line number Diff line number Diff line
@@ -498,11 +498,12 @@ package android.app.prediction {
  }

  public static final class AppTarget.Builder {
    ctor public AppTarget.Builder(@NonNull android.app.prediction.AppTargetId, @NonNull String, @NonNull android.os.UserHandle);
    ctor public AppTarget.Builder(@NonNull android.app.prediction.AppTargetId, @NonNull android.content.pm.ShortcutInfo);
    ctor public AppTarget.Builder(@NonNull android.app.prediction.AppTargetId);
    method @NonNull public android.app.prediction.AppTarget build();
    method @NonNull public android.app.prediction.AppTarget.Builder setClassName(@NonNull String);
    method @NonNull public android.app.prediction.AppTarget.Builder setRank(@IntRange(from=0) int);
    method @NonNull public android.app.prediction.AppTarget.Builder setTarget(@NonNull String, @NonNull android.os.UserHandle);
    method @NonNull public android.app.prediction.AppTarget.Builder setTarget(@NonNull android.content.pm.ShortcutInfo);
  }

  public final class AppTargetEvent implements android.os.Parcelable {
+14 −39
Original line number Diff line number Diff line
@@ -203,50 +203,25 @@ public final class AppTarget implements Parcelable {
        private String mClassName;
        private int mRank;

        /**
         * @deprecated Use the other Builder constructors.
         * @hide
         */
        @Deprecated
        public Builder(@NonNull AppTargetId id) {
            mId = id;
        }

        /**
         * @param id A unique id for this launchable target.
         * @param packageName PackageName of the target.
         * @param user The UserHandle of the user which this target belongs to.
         * @hide
         */
        @SystemApi
        @TestApi
        public Builder(@NonNull AppTargetId id, @NonNull String packageName,
                @NonNull UserHandle user) {
            mId = Preconditions.checkNotNull(id);
            mPackageName = Preconditions.checkNotNull(packageName);
            mUser = Preconditions.checkNotNull(user);
        }

        /**
         * @param id A unique id for this launchable target.
         * @param info The ShortcutInfo that represents this launchable target.
         * @hide
         */
        @SystemApi
        @TestApi
        public Builder(@NonNull AppTargetId id, @NonNull ShortcutInfo info) {
            mId = Preconditions.checkNotNull(id);
            mShortcutInfo = Preconditions.checkNotNull(info);
            mPackageName = info.getPackage();
            mUser = info.getUserHandle();
        public Builder(@NonNull AppTargetId id) {
            mId = id;
        }

        /**
         * @deprecated Use the appropriate constructor.
         * @hide
         * Sets the target to be an app.
         *
         * @param packageName PackageName of the app
         * @param user The UserHandle of the user which this target belongs to.
         *
         * @throws IllegalArgumentException is the target is already set
         */
        @NonNull
        @Deprecated
        public Builder setTarget(@NonNull String packageName, @NonNull UserHandle user) {
            if (mPackageName != null) {
                throw new IllegalArgumentException("Target is already set");
@@ -257,11 +232,11 @@ public final class AppTarget implements Parcelable {
        }

        /**
         * @deprecated Use the appropriate constructor.
         * @hide
         * Sets the target to be a ShortcutInfo.
         *
         * @throws IllegalArgumentException is the target is already set
         */
        @NonNull
        @Deprecated
        public Builder setTarget(@NonNull ShortcutInfo info) {
            setTarget(info.getPackage(), info.getUserHandle());
            mShortcutInfo = Preconditions.checkNotNull(info);
@@ -269,7 +244,7 @@ public final class AppTarget implements Parcelable {
        }

        /**
         * Sets the className for the target.
         * Sets the className for the target
         */
        @NonNull
        public Builder setClassName(@NonNull String className) {
@@ -278,7 +253,7 @@ public final class AppTarget implements Parcelable {
        }

        /**
         * Sets the rank of the target.
         * Sets the rank of the for the target.
         */
        @NonNull
        public Builder setRank(@IntRange(from = 0) int rank) {
@@ -299,7 +274,7 @@ public final class AppTarget implements Parcelable {
        @NonNull
        public AppTarget build() {
            if (mPackageName == null) {
                throw new IllegalStateException("No target is set");
                throw new IllegalStateException("No target set");
            }
            return new AppTarget(mId, mPackageName, mUser, mShortcutInfo, mClassName, mRank);
        }
+5 −5
Original line number Diff line number Diff line
@@ -1349,12 +1349,12 @@ public class ChooserActivity extends ResolverActivity {
        appPredictor.notifyAppTargetEvent(
                new AppTargetEvent.Builder(
                    // TODO(b/124404997) Send full shortcut info, not just Id with AppTargetId.
                    new AppTarget.Builder(new AppTargetId(shortcutId),
                            componentName.getPackageName(), getUser())
                    new AppTarget.Builder(new AppTargetId(shortcutId))
                        .setTarget(componentName.getPackageName(), getUser())
                        .setClassName(componentName.getClassName())
                        .build(),
                    AppTargetEvent.ACTION_LAUNCH)
                    .setLaunchLocation(LAUNCH_LOCATON_DIRECT_SHARE)
                    AppTargetEvent.ACTION_LAUNCH
                ).setLaunchLocation(LAUNCH_LOCATON_DIRECT_SHARE)
                .build());
    }