From 69ec21ebff7ceb4aaadc032908691049a1fb6214 Mon Sep 17 00:00:00 2001 From: Songchun Fan Date: Fri, 5 Feb 2021 20:36:48 +0000 Subject: [PATCH] [pm] clarify error message and comments for app install with RenderScript Addressing comment in ag/13462380. See discussions in b/179072387. BUG: 179072387 Test: builds Change-Id: I891b2f678fb6e24c26f19e33aa23c29132c99066 --- .../android/server/pm/PackageAbiHelperImpl.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/pm/PackageAbiHelperImpl.java b/services/core/java/com/android/server/pm/PackageAbiHelperImpl.java index 6485c0c42ab76..d851e6ced91bf 100644 --- a/services/core/java/com/android/server/pm/PackageAbiHelperImpl.java +++ b/services/core/java/com/android/server/pm/PackageAbiHelperImpl.java @@ -401,11 +401,16 @@ final class PackageAbiHelperImpl implements PackageAbiHelper { String[] abiList = (cpuAbiOverride != null) ? new String[]{cpuAbiOverride} : Build.SUPPORTED_ABIS; - // Enable gross and lame hacks for apps that are built with old - // SDK tools. We must scan their APKs for renderscript bitcode and - // not launch them if it's present. Don't bother checking on devices - // that don't have 64 bit support. + // If an app that contains RenderScript has target API level < 21, it needs to run + // with 32-bit ABI, and its APK file will contain a ".bc" file. + // If an app that contains RenderScript has target API level >= 21, it can run with + // either 32-bit or 64-bit ABI, and its APK file will not contain a ".bc" file. + // Therefore, on a device that supports both 32-bit and 64-bit ABIs, we scan the app + // APK to see if it has a ".bc" file. If so, we will run it with 32-bit ABI. + // However, if the device only supports 64-bit ABI but does not support 32-bit ABI, + // we will fail the installation for such an app because it won't be able to run. boolean needsRenderScriptOverride = false; + // No need to check if the device only supports 32-bit if (Build.SUPPORTED_64_BIT_ABIS.length > 0 && cpuAbiOverride == null && NativeLibraryHelper.hasRenderscriptBitcode(handle)) { if (Build.SUPPORTED_32_BIT_ABIS.length > 0) { @@ -414,7 +419,8 @@ final class PackageAbiHelperImpl implements PackageAbiHelper { } else { throw new PackageManagerException( INSTALL_FAILED_CPU_ABI_INCOMPATIBLE, - "Apks with renderscript are not supported on 64-bit only devices"); + "Apps that contain RenderScript with target API level < 21 are not " + + "supported on 64-bit only platforms"); } }