Add install flag --bypass-low-target-sdk-block

Added a PM shell install flag to bypass the low target sdk block for
installing apps that are using low targetSdkVersion.

When set, this flag will bypass the install block and
allow the app to be installed.

Bug: 237321649
Test: adb install --bypass-low-target-sdk-block
~/install_target_sdk_22.apk

Change-Id: If6d47d60c4768f704b8ba6d4f5f07b5127b44cf7
Merged-In: Ie6d44b5f16bf7dd35d3c75f51a9c94fd4ef9dcb6
Merged-In: I42b003f8c42a7f8c45a581bd9383c78090462d0f
This commit is contained in:
Nick Kovacs
2023-01-24 23:56:16 +00:00
parent 849320e814
commit ffa1a73c53
2 changed files with 12 additions and 0 deletions

View File

@@ -1530,6 +1530,14 @@ public abstract class PackageManager {
*/
public static final int INSTALL_DISABLE_ALLOWED_APEX_UPDATE_CHECK = 0x00400000;
/**
* Flag parameter for {@link #installPackage} to bypass the low target sdk version block
* for this install.
*
* @hide
*/
public static final int INSTALL_BYPASS_LOW_TARGET_SDK_BLOCK = 0x01000000;
/** @hide */
@IntDef(flag = true, value = {
DONT_KILL_APP,

View File

@@ -3184,6 +3184,10 @@ class PackageManagerShellCommand extends ShellCommand {
case "--skip-verification":
sessionParams.installFlags |= PackageManager.INSTALL_DISABLE_VERIFICATION;
break;
case "--bypass-low-target-sdk-block":
sessionParams.installFlags |=
PackageManager.INSTALL_BYPASS_LOW_TARGET_SDK_BLOCK;
break;
default:
throw new IllegalArgumentException("Unknown option " + opt);
}