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

This reverts commit 08c5083da30ae36b093113a839321853956af443.

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

Change-Id: I9a760c222e1b0dac9c9ec131cc14e7a3a689e939
(cherry picked from commit 1faaeaf560eed54163c67293e6accf9c4e61755e)
diff --git a/api/system-current.txt b/api/system-current.txt
index d15d006..da7b452 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -1092,11 +1092,12 @@
   }
 
   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 {
diff --git a/api/test-current.txt b/api/test-current.txt
index 811ad43..13e97e3 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -498,11 +498,12 @@
   }
 
   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 {
diff --git a/core/java/android/app/prediction/AppTarget.java b/core/java/android/app/prediction/AppTarget.java
index 4704661..ed45b2f 100644
--- a/core/java/android/app/prediction/AppTarget.java
+++ b/core/java/android/app/prediction/AppTarget.java
@@ -204,49 +204,24 @@
         private int mRank;
 
         /**
-         * @deprecated Use the other Builder constructors.
+         * @param id A unique id for this launchable target.
          * @hide
          */
-        @Deprecated
+        @SystemApi
+        @TestApi
         public Builder(@NonNull AppTargetId id) {
             mId = id;
         }
 
         /**
-         * @param id A unique id for this launchable target.
-         * @param packageName PackageName of the target.
+         * 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.
-         * @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();
-        }
-
-        /**
-         * @deprecated Use the appropriate constructor.
-         * @hide
+         *
+         * @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 @@
         }
 
         /**
-         * @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 @@
         }
 
         /**
-         * Sets the className for the target.
+         * Sets the className for the target
          */
         @NonNull
         public Builder setClassName(@NonNull String className) {
@@ -278,7 +253,7 @@
         }
 
         /**
-         * 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 @@
         @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);
         }
diff --git a/core/java/com/android/internal/app/ChooserActivity.java b/core/java/com/android/internal/app/ChooserActivity.java
index 1597ab7..b8ac6dc 100644
--- a/core/java/com/android/internal/app/ChooserActivity.java
+++ b/core/java/com/android/internal/app/ChooserActivity.java
@@ -1349,13 +1349,13 @@
         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)
-                    .build());
+                    AppTargetEvent.ACTION_LAUNCH
+                ).setLaunchLocation(LAUNCH_LOCATON_DIRECT_SHARE)
+                .build());
     }
 
     @Nullable