Force ephemeral apps to have correct targetSdk/targetSandbox temporarily

There is a bit of a chicken and egg problem with Instant Apps and the
requirement to have targerSdk >= O and targetSandboxVersion >= 2 with
the sdk not being locked down yet. To work around this for now the
targetSdk and targetSandboxVersion will be made correct instead of
causing the install to fail. This work around must be removed before O
ships.

Test: adb install --ephemeral updates the targetSdk and targetSandbox
accordingly.

Change-Id: I283e71e459f0f69ef4053591b6647991746f54da
This commit is contained in:
Chad Brubaker
2017-02-06 13:25:05 -08:00
parent 339dc75d46
commit d143808365

View File

@@ -16638,13 +16638,19 @@ public class PackageManagerService extends IPackageManager.Stub {
Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
}
// // Ephemeral apps must have target SDK >= O.
// // TODO: Update conditional and error message when O gets locked down
// if (instantApp && pkg.applicationInfo.targetSdkVersion <= Build.VERSION_CODES.N_MR1) {
// res.setError(PackageManager.INSTALL_FAILED_EPHEMERAL_INVALID,
// "Ephemeral apps must have target SDK version of at least O");
// return;
// }
// Instant apps must have target SDK >= O and have targetSanboxVersion >= 2
if (instantApp && pkg.applicationInfo.targetSdkVersion <= Build.VERSION_CODES.N_MR1) {
Slog.w(TAG, "Instant app package " + pkg.packageName
+ " does not target O, this will be a fatal error.");
// STOPSHIP: Make this a fatal error
pkg.applicationInfo.targetSdkVersion = Build.VERSION_CODES.O;
}
if (instantApp && pkg.applicationInfo.targetSandboxVersion != 2) {
Slog.w(TAG, "Instant app package " + pkg.packageName
+ " does not target targetSandboxVersion 2, this will be a fatal error.");
// STOPSHIP: Make this a fatal error
pkg.applicationInfo.targetSandboxVersion = 2;
}
if (pkg.applicationInfo.isStaticSharedLibrary()) {
// Static shared libraries have synthetic package names