From 22557fe696fcb234636cf39da1552d568445c6ba Mon Sep 17 00:00:00 2001 From: Kiyoung Kim Date: Thu, 28 Mar 2019 13:38:12 +0900 Subject: [PATCH] Check if product app is unbundled from property. Some of devices launched with old version of android (and maybe not treblized) can come with no /product/lib. However in current we are checking if product app is unbundled by checking /product/lib from search path, this can lead to wrong check of unbundled. To fix this, I created new property (ro.product.apps.unbundled) to decide if product app is unbundled. Bug: 129011845 Test: m -j && tested from crosshatch Change-Id: Id30595b3ca88ffe008ffe479406d59b840b19b44 --- core/java/android/app/LoadedApk.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/java/android/app/LoadedApk.java b/core/java/android/app/LoadedApk.java index 53849ba923393..3603b56c44c6f 100644 --- a/core/java/android/app/LoadedApk.java +++ b/core/java/android/app/LoadedApk.java @@ -46,6 +46,7 @@ import android.os.StrictMode; import android.os.SystemProperties; import android.os.Trace; import android.os.UserHandle; +import android.sysprop.ProductProperties; import android.text.TextUtils; import android.util.AndroidRuntimeException; import android.util.ArrayMap; @@ -761,10 +762,13 @@ public final class LoadedApk { } // Similar to vendor apks, we should add /product/lib for apks from product partition - // and not having /product/lib in the default search path - final boolean treatProductApkAsUnbundled = !defaultSearchPaths.contains("/product/lib"); + // when product apps are marked as unbundled. We cannot use the same way from vendor + // to check if lib path exists because there is possibility that /product/lib would not + // exist from legacy device while product apks are bundled. To make this clear, new + // property ("ro.product.apps.unbundled") is defined which should be true only when + // product apks are unbundled. if (mApplicationInfo.getCodePath() != null - && mApplicationInfo.isProduct() && treatProductApkAsUnbundled + && mApplicationInfo.isProduct() && ProductProperties.unbundled_apps().orElse(false) // TODO(b/128557860): Change target SDK version when version code R is available. && getTargetSdkVersion() == Build.VERSION_CODES.CUR_DEVELOPMENT) { isBundledApp = false;