From d143808365c06be7e64837d005d07e91ebfad745 Mon Sep 17 00:00:00 2001 From: Chad Brubaker Date: Mon, 6 Feb 2017 13:25:05 -0800 Subject: [PATCH] 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 --- .../server/pm/PackageManagerService.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java index fe2fb66822f15..50deccab527e4 100644 --- a/services/core/java/com/android/server/pm/PackageManagerService.java +++ b/services/core/java/com/android/server/pm/PackageManagerService.java @@ -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