Merge "Addresses setRequireUserAction API feedback" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0b99af47c5
@@ -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_NO_ERROR = 0; // 0x0
|
||||||
field public static final int STAGED_SESSION_UNKNOWN = 3; // 0x3
|
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 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 {
|
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 setOriginatingUid(int);
|
||||||
method public void setOriginatingUri(@Nullable android.net.Uri);
|
method public void setOriginatingUri(@Nullable android.net.Uri);
|
||||||
method public void setReferrerUri(@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 setSize(long);
|
||||||
method public void setWhitelistedRestrictedPermissions(@Nullable java.util.Set<java.lang.String>);
|
method public void setWhitelistedRestrictedPermissions(@Nullable java.util.Set<java.lang.String>);
|
||||||
method public void writeToParcel(android.os.Parcel, int);
|
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_FULL_INSTALL = 1; // 0x1
|
||||||
field public static final int MODE_INHERIT_EXISTING = 2; // 0x2
|
field public static final int MODE_INHERIT_EXISTING = 2; // 0x2
|
||||||
field @NonNull public static final java.util.Set<java.lang.String> RESTRICTED_PERMISSIONS_ALL;
|
field @NonNull public static final java.util.Set<java.lang.String> 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 {
|
public class PackageItemInfo {
|
||||||
|
|||||||
@@ -1529,6 +1529,33 @@ public class PackageInstaller {
|
|||||||
*/
|
*/
|
||||||
public static final int MAX_PACKAGE_NAME_LENGTH = 255;
|
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} */
|
/** {@hide} */
|
||||||
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
|
||||||
public int mode = MODE_INVALID;
|
public int mode = MODE_INVALID;
|
||||||
@@ -1593,7 +1620,7 @@ public class PackageInstaller {
|
|||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
public boolean forceQueryableOverride;
|
public boolean forceQueryableOverride;
|
||||||
/** {@hide} */
|
/** {@hide} */
|
||||||
public int requireUserAction = SessionInfo.USER_ACTION_UNSPECIFIED;
|
public int requireUserAction = USER_ACTION_UNSPECIFIED;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct parameters for a new package install session.
|
* 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
|
* Optionally indicate whether user action should be required when the session is
|
||||||
* committed.
|
* committed.
|
||||||
* <p>
|
* <p>
|
||||||
* 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
|
* {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES android.permission
|
||||||
* #REQUEST_INSTALL_PACKAGES} permission, and {@code false} otherwise. When {@code true},
|
* #REQUEST_INSTALL_PACKAGES} permission will behave as if set to
|
||||||
* installers will receive a {@link #STATUS_PENDING_USER_ACTION} callback once the
|
* {@link #USER_ACTION_REQUIRED}, and {@link #USER_ACTION_NOT_REQUIRED} otherwise.
|
||||||
* session is committed, indicating that user action is required for the install to proceed.
|
* 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.
|
||||||
* <p>
|
* <p>
|
||||||
* For installers that have been granted the
|
* For installers that have been granted the
|
||||||
* {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES android.permission
|
* {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES android.permission
|
||||||
@@ -2094,7 +2124,7 @@ public class PackageInstaller {
|
|||||||
* the following conditions are met:
|
* the following conditions are met:
|
||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>{@code requireUserAction} is set to {@code false}.</li>
|
* <li>{@code requireUserAction} is set to {@link #USER_ACTION_NOT_REQUIRED}.</li>
|
||||||
* <li>The app being installed targets {@link android.os.Build.VERSION_CODES#Q API 29}
|
* <li>The app being installed targets {@link android.os.Build.VERSION_CODES#Q API 29}
|
||||||
* or higher.</li>
|
* or higher.</li>
|
||||||
* <li>The installer is the {@link InstallSourceInfo#getInstallingPackageName()
|
* <li>The installer is the {@link InstallSourceInfo#getInstallingPackageName()
|
||||||
@@ -2110,10 +2140,17 @@ public class PackageInstaller {
|
|||||||
*
|
*
|
||||||
* @param requireUserAction whether user action should be required.
|
* @param requireUserAction whether user action should be required.
|
||||||
*/
|
*/
|
||||||
public void setRequireUserAction(boolean requireUserAction) {
|
public void setRequireUserAction(
|
||||||
this.requireUserAction = requireUserAction
|
@SessionParams.UserActionRequirement int requireUserAction) {
|
||||||
? SessionInfo.USER_ACTION_REQUIRED
|
if (requireUserAction != USER_ACTION_UNSPECIFIED
|
||||||
: SessionInfo.USER_ACTION_NOT_REQUIRED;
|
&& requireUserAction != USER_ACTION_REQUIRED
|
||||||
|
&& requireUserAction != USER_ACTION_NOT_REQUIRED) {
|
||||||
|
throw new IllegalArgumentException("requireUserAction set as invalid value of "
|
||||||
|
+ requireUserAction + ", but must be one of ["
|
||||||
|
+ "USER_ACTION_UNSPECIFIED, USER_ACTION_REQUIRED, USER_ACTION_NOT_REQUIRED"
|
||||||
|
+ "]");
|
||||||
|
}
|
||||||
|
this.requireUserAction = requireUserAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2255,36 +2292,11 @@ public class PackageInstaller {
|
|||||||
*/
|
*/
|
||||||
public static final int STAGED_SESSION_CONFLICT = 4;
|
public static final int STAGED_SESSION_CONFLICT = 4;
|
||||||
|
|
||||||
/** @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(boolean)} 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(boolean)} 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(boolean)} with
|
|
||||||
* {@code false} to request that user action not be required for this install.
|
|
||||||
*/
|
|
||||||
public static final int USER_ACTION_NOT_REQUIRED = 2;
|
|
||||||
|
|
||||||
private static String userActionToString(int requireUserAction) {
|
private static String userActionToString(int requireUserAction) {
|
||||||
switch(requireUserAction) {
|
switch(requireUserAction) {
|
||||||
case SessionInfo.USER_ACTION_REQUIRED:
|
case SessionParams.USER_ACTION_REQUIRED:
|
||||||
return "REQUIRED";
|
return "REQUIRED";
|
||||||
case SessionInfo.USER_ACTION_NOT_REQUIRED:
|
case SessionParams.USER_ACTION_NOT_REQUIRED:
|
||||||
return "NOT_REQUIRED";
|
return "NOT_REQUIRED";
|
||||||
default:
|
default:
|
||||||
return "UNSPECIFIED";
|
return "UNSPECIFIED";
|
||||||
@@ -2941,10 +2953,11 @@ public class PackageInstaller {
|
|||||||
* Note: a return value of {@code USER_ACTION_NOT_REQUIRED} does not guarantee that the
|
* Note: a return value of {@code USER_ACTION_NOT_REQUIRED} does not guarantee that the
|
||||||
* install will not result in user action.
|
* install will not result in user action.
|
||||||
*
|
*
|
||||||
* @return {@link #USER_ACTION_NOT_REQUIRED}, {@link #USER_ACTION_REQUIRED} or
|
* @return {@link SessionParams#USER_ACTION_NOT_REQUIRED},
|
||||||
* {@link #USER_ACTION_UNSPECIFIED}
|
* {@link SessionParams#USER_ACTION_REQUIRED} or
|
||||||
|
* {@link SessionParams#USER_ACTION_UNSPECIFIED}
|
||||||
*/
|
*/
|
||||||
@UserActionRequirement
|
@SessionParams.UserActionRequirement
|
||||||
public int getRequireUserAction() {
|
public int getRequireUserAction() {
|
||||||
return requireUserAction;
|
return requireUserAction;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5751,7 +5751,7 @@
|
|||||||
android:protectionLevel="signature|privileged|vendorPrivileged" />
|
android:protectionLevel="signature|privileged|vendorPrivileged" />
|
||||||
|
|
||||||
<!-- Allows an application to indicate via
|
<!-- Allows an application to indicate via
|
||||||
{@link android.content.pm.PackageInstaller.SessionParams#setRequireUserAction(boolean)}
|
{@link android.content.pm.PackageInstaller.SessionParams#setRequireUserAction(int)}
|
||||||
that user action should not be required for an app update.
|
that user action should not be required for an app update.
|
||||||
<p>Protection level: normal
|
<p>Protection level: normal
|
||||||
-->
|
-->
|
||||||
|
|||||||
@@ -928,7 +928,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
|||||||
|
|
||||||
final boolean forcePermissionPrompt =
|
final boolean forcePermissionPrompt =
|
||||||
(params.installFlags & PackageManager.INSTALL_FORCE_PERMISSION_PROMPT) != 0
|
(params.installFlags & PackageManager.INSTALL_FORCE_PERMISSION_PROMPT) != 0
|
||||||
|| params.requireUserAction == SessionInfo.USER_ACTION_REQUIRED;
|
|| params.requireUserAction == SessionParams.USER_ACTION_REQUIRED;
|
||||||
if (forcePermissionPrompt) {
|
if (forcePermissionPrompt) {
|
||||||
return USER_ACTION_REQUIRED;
|
return USER_ACTION_REQUIRED;
|
||||||
}
|
}
|
||||||
@@ -977,7 +977,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
|
|||||||
return USER_ACTION_REQUIRED;
|
return USER_ACTION_REQUIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.requireUserAction == SessionInfo.USER_ACTION_NOT_REQUIRED
|
if (params.requireUserAction == SessionParams.USER_ACTION_NOT_REQUIRED
|
||||||
&& isUpdateWithoutUserActionPermissionGranted
|
&& isUpdateWithoutUserActionPermissionGranted
|
||||||
&& (isInstallerOfRecord || isSelfUpdate)) {
|
&& (isInstallerOfRecord || isSelfUpdate)) {
|
||||||
return USER_ACTION_PENDING_APK_PARSING;
|
return USER_ACTION_PENDING_APK_PARSING;
|
||||||
|
|||||||
Reference in New Issue
Block a user