diff --git a/core/api/current.txt b/core/api/current.txt index d488220b92e33..71c8f161fb7a3 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -12415,9 +12415,6 @@ package android.content.pm { field public static final int STAGED_SESSION_NO_ERROR = 0; // 0x0 field public static final int STAGED_SESSION_UNKNOWN = 3; // 0x3 field public static final int STAGED_SESSION_VERIFICATION_FAILED = 1; // 0x1 - field public static final int USER_ACTION_NOT_REQUIRED = 2; // 0x2 - field public static final int USER_ACTION_REQUIRED = 1; // 0x1 - field public static final int USER_ACTION_UNSPECIFIED = 0; // 0x0 } public static class PackageInstaller.SessionParams implements android.os.Parcelable { @@ -12434,7 +12431,7 @@ package android.content.pm { method public void setOriginatingUid(int); method public void setOriginatingUri(@Nullable android.net.Uri); method public void setReferrerUri(@Nullable android.net.Uri); - method public void setRequireUserAction(boolean); + method public void setRequireUserAction(int); method public void setSize(long); method public void setWhitelistedRestrictedPermissions(@Nullable java.util.Set); method public void writeToParcel(android.os.Parcel, int); @@ -12442,6 +12439,9 @@ package android.content.pm { field public static final int MODE_FULL_INSTALL = 1; // 0x1 field public static final int MODE_INHERIT_EXISTING = 2; // 0x2 field @NonNull public static final java.util.Set RESTRICTED_PERMISSIONS_ALL; + field public static final int USER_ACTION_NOT_REQUIRED = 2; // 0x2 + field public static final int USER_ACTION_REQUIRED = 1; // 0x1 + field public static final int USER_ACTION_UNSPECIFIED = 0; // 0x0 } public class PackageItemInfo { diff --git a/core/java/android/content/pm/PackageInstaller.java b/core/java/android/content/pm/PackageInstaller.java index 85830ed125c08..75dd9fb24e358 100644 --- a/core/java/android/content/pm/PackageInstaller.java +++ b/core/java/android/content/pm/PackageInstaller.java @@ -1529,6 +1529,33 @@ public class PackageInstaller { */ public static final int MAX_PACKAGE_NAME_LENGTH = 255; + /** @hide */ + @IntDef(prefix = {"USER_ACTION_"}, value = { + USER_ACTION_UNSPECIFIED, + USER_ACTION_REQUIRED, + USER_ACTION_NOT_REQUIRED + }) + @Retention(RetentionPolicy.SOURCE) + public @interface UserActionRequirement {} + + /** + * The installer did not call {@link SessionParams#setRequireUserAction(int)} to + * specify whether user action should be required for the install. + */ + public static final int USER_ACTION_UNSPECIFIED = 0; + + /** + * The installer called {@link SessionParams#setRequireUserAction(int)} with + * {@code true} to require user action for the install to complete. + */ + public static final int USER_ACTION_REQUIRED = 1; + + /** + * The installer called {@link SessionParams#setRequireUserAction(int)} with + * {@code false} to request that user action not be required for this install. + */ + public static final int USER_ACTION_NOT_REQUIRED = 2; + /** {@hide} */ @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) public int mode = MODE_INVALID; @@ -1593,7 +1620,7 @@ public class PackageInstaller { /** {@hide} */ public boolean forceQueryableOverride; /** {@hide} */ - public int requireUserAction = SessionInfo.USER_ACTION_UNSPECIFIED; + public int requireUserAction = USER_ACTION_UNSPECIFIED; /** * Construct parameters for a new package install session. @@ -2082,11 +2109,14 @@ public class PackageInstaller { * Optionally indicate whether user action should be required when the session is * committed. *

- * Defaults to {@code true} for installers using the + * Defaults to {@link #USER_ACTION_UNSPECIFIED} unless otherwise set. When unspecified for + * installers using the * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES android.permission - * #REQUEST_INSTALL_PACKAGES} permission, and {@code false} otherwise. When {@code true}, - * installers will receive a {@link #STATUS_PENDING_USER_ACTION} callback once the - * session is committed, indicating that user action is required for the install to proceed. + * #REQUEST_INSTALL_PACKAGES} permission will behave as if set to + * {@link #USER_ACTION_REQUIRED}, and {@link #USER_ACTION_NOT_REQUIRED} otherwise. + * When {@code requireUserAction} is set to {@link #USER_ACTION_REQUIRED}, installers will + * receive a {@link #STATUS_PENDING_USER_ACTION} callback once the session is committed, + * indicating that user action is required for the install to proceed. *

* For installers that have been granted the * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES android.permission @@ -2094,7 +2124,7 @@ public class PackageInstaller { * the following conditions are met: * *