Loading services/core/java/com/android/server/am/ProcessList.java +0 −9 Original line number Original line Diff line number Diff line Loading @@ -133,7 +133,6 @@ import com.android.server.SystemConfig; import com.android.server.Watchdog; import com.android.server.Watchdog; import com.android.server.am.ActivityManagerService.ProcessChangeItem; import com.android.server.am.ActivityManagerService.ProcessChangeItem; import com.android.server.compat.PlatformCompat; import com.android.server.compat.PlatformCompat; import com.android.server.pm.dex.DexManager; import com.android.server.pm.parsing.pkg.AndroidPackage; import com.android.server.pm.parsing.pkg.AndroidPackage; import com.android.server.pm.pkg.PackageStateInternal; import com.android.server.pm.pkg.PackageStateInternal; import com.android.server.wm.ActivityServiceConnectionsHolder; import com.android.server.wm.ActivityServiceConnectionsHolder; Loading Loading @@ -1790,14 +1789,6 @@ public final class ProcessList { if (app.info.isEmbeddedDexUsed()) { if (app.info.isEmbeddedDexUsed()) { runtimeFlags |= Zygote.ONLY_USE_SYSTEM_OAT_FILES; runtimeFlags |= Zygote.ONLY_USE_SYSTEM_OAT_FILES; } else if (app.info.isPrivilegedApp()) { final PackageList pkgList = app.getPkgList(); synchronized (pkgList) { if (DexManager.isPackageSelectedToRunOob( pkgList.getPackageListLocked().keySet())) { runtimeFlags |= Zygote.ONLY_USE_SYSTEM_OAT_FILES; } } } } if (!disableHiddenApiChecks && !mService.mHiddenApiBlacklist.isDisabled()) { if (!disableHiddenApiChecks && !mService.mHiddenApiBlacklist.isDisabled()) { Loading services/core/java/com/android/server/pm/PackageDexOptimizer.java +2 −9 Original line number Original line Diff line number Diff line Loading @@ -74,7 +74,6 @@ import com.android.server.pm.Installer.InstallerException; import com.android.server.pm.dex.ArtManagerService; import com.android.server.pm.dex.ArtManagerService; import com.android.server.pm.dex.ArtStatsLogUtils; import com.android.server.pm.dex.ArtStatsLogUtils; import com.android.server.pm.dex.ArtStatsLogUtils.ArtStatsLogger; import com.android.server.pm.dex.ArtStatsLogUtils.ArtStatsLogger; import com.android.server.pm.dex.DexManager; import com.android.server.pm.dex.DexoptOptions; import com.android.server.pm.dex.DexoptOptions; import com.android.server.pm.dex.DexoptUtils; import com.android.server.pm.dex.DexoptUtils; import com.android.server.pm.dex.PackageDexUsage; import com.android.server.pm.dex.PackageDexUsage; Loading Loading @@ -787,10 +786,7 @@ public class PackageDexOptimizer { */ */ private String getRealCompilerFilter(ApplicationInfo info, String targetCompilerFilter, private String getRealCompilerFilter(ApplicationInfo info, String targetCompilerFilter, boolean isUsedByOtherApps) { boolean isUsedByOtherApps) { // When an app or priv app is configured to run out of box, only verify it. if (info.isEmbeddedDexUsed()) { if (info.isEmbeddedDexUsed() || (info.isPrivilegedApp() && DexManager.isPackageSelectedToRunOob(info.packageName))) { return "verify"; return "verify"; } } Loading Loading @@ -827,10 +823,7 @@ public class PackageDexOptimizer { * handling the case where the package code is used by other apps. * handling the case where the package code is used by other apps. */ */ private String getRealCompilerFilter(AndroidPackage pkg, String targetCompilerFilter) { private String getRealCompilerFilter(AndroidPackage pkg, String targetCompilerFilter) { // When an app or priv app is configured to run out of box, only verify it. if (pkg.isUseEmbeddedDex()) { if (pkg.isUseEmbeddedDex() || (pkg.isPrivileged() && DexManager.isPackageSelectedToRunOob(pkg.getPackageName()))) { return "verify"; return "verify"; } } Loading services/core/java/com/android/server/pm/dex/DexManager.java +0 −46 Original line number Original line Diff line number Diff line Loading @@ -36,7 +36,6 @@ import android.os.FileUtils; import android.os.PowerManager; import android.os.PowerManager; import android.os.RemoteException; import android.os.RemoteException; import android.os.ServiceManager; import android.os.ServiceManager; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserHandle; import android.os.storage.StorageManager; import android.os.storage.StorageManager; import android.util.Log; import android.util.Log; Loading @@ -58,8 +57,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.Paths; import java.util.ArrayList; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Collections; import java.util.HashMap; import java.util.HashMap; import java.util.HashSet; import java.util.HashSet; Loading @@ -81,10 +78,6 @@ public class DexManager { private static final String TAG = "DexManager"; private static final String TAG = "DexManager"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final String PROPERTY_NAME_PM_DEXOPT_PRIV_APPS_OOB = "pm.dexopt.priv-apps-oob"; private static final String PROPERTY_NAME_PM_DEXOPT_PRIV_APPS_OOB_LIST = "pm.dexopt.priv-apps-oob-list"; // System server cannot load executable code outside system partitions. // System server cannot load executable code outside system partitions. // However it can load verification data - thus we pick the "verify" compiler filter. // However it can load verification data - thus we pick the "verify" compiler filter. private static final String SYSTEM_SERVER_COMPILER_FILTER = "verify"; private static final String SYSTEM_SERVER_COMPILER_FILTER = "verify"; Loading Loading @@ -909,45 +902,6 @@ public class DexManager { mDynamicCodeLogger.writeNow(); mDynamicCodeLogger.writeNow(); } } /** * Returns whether the given package is in the list of privilaged apps that should run out of * box. This only makes sense if the feature is enabled. Note that when the the OOB list is * empty, all priv apps will run in OOB mode. */ public static boolean isPackageSelectedToRunOob(String packageName) { return isPackageSelectedToRunOob(Arrays.asList(packageName)); } /** * Returns whether any of the given packages are in the list of privilaged apps that should run * out of box. This only makes sense if the feature is enabled. Note that when the the OOB list * is empty, all priv apps will run in OOB mode. */ public static boolean isPackageSelectedToRunOob(Collection<String> packageNamesInSameProcess) { return isPackageSelectedToRunOobInternal( SystemProperties.getBoolean(PROPERTY_NAME_PM_DEXOPT_PRIV_APPS_OOB, false), SystemProperties.get(PROPERTY_NAME_PM_DEXOPT_PRIV_APPS_OOB_LIST, "ALL"), packageNamesInSameProcess); } @VisibleForTesting /* package */ static boolean isPackageSelectedToRunOobInternal(boolean isEnabled, String whitelist, Collection<String> packageNamesInSameProcess) { if (!isEnabled) { return false; } if ("ALL".equals(whitelist)) { return true; } for (String oobPkgName : whitelist.split(",")) { if (packageNamesInSameProcess.contains(oobPkgName)) { return true; } } return false; } /** /** * Generates log if the archive located at {@code fileName} has uncompressed dex file that can * Generates log if the archive located at {@code fileName} has uncompressed dex file that can * be direclty mapped. * be direclty mapped. Loading services/tests/mockingservicestests/src/com/android/server/pm/dex/DexManagerTests.java +0 −41 Original line number Original line Diff line number Diff line Loading @@ -61,7 +61,6 @@ import org.mockito.quality.Strictness; import java.io.File; import java.io.File; import java.util.ArrayList; import java.util.ArrayList; import java.util.Arrays; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Collections; import java.util.HashMap; import java.util.HashMap; import java.util.List; import java.util.List; Loading Loading @@ -1029,44 +1028,4 @@ public class DexManagerTests { return mPackageInfo.applicationInfo.splitSourceDirs[length - 1]; return mPackageInfo.applicationInfo.splitSourceDirs[length - 1]; } } } } private boolean shouldPackageRunOob(boolean isDefaultEnabled, String whitelist, Collection<String> packageNamesInSameProcess) { return DexManager.isPackageSelectedToRunOobInternal( isDefaultEnabled, whitelist, packageNamesInSameProcess); } @Test public void testOobPackageSelectionDefault() { // Feature is off by default, not overriden assertFalse(shouldPackageRunOob(false, "ALL", null)); } @Test public void testOobPackageSelectionWhitelist() { // Various allowlist of apps to run in OOB mode. final String kWhitelistApp0 = "com.priv.app0"; final String kWhitelistApp1 = "com.priv.app1"; final String kWhitelistApp2 = "com.priv.app2"; final String kWhitelistApp1AndApp2 = "com.priv.app1,com.priv.app2"; // Packages that shares the targeting process. final Collection<String> runningPackages = Arrays.asList("com.priv.app1", "com.priv.app2"); // Feature is off, allowlist does not matter assertFalse(shouldPackageRunOob(false, kWhitelistApp0, runningPackages)); assertFalse(shouldPackageRunOob(false, kWhitelistApp1, runningPackages)); assertFalse(shouldPackageRunOob(false, "", runningPackages)); assertFalse(shouldPackageRunOob(false, "ALL", runningPackages)); // Feature is on, app not in allowlist assertFalse(shouldPackageRunOob(true, kWhitelistApp0, runningPackages)); assertFalse(shouldPackageRunOob(true, "", runningPackages)); // Feature is on, app in allowlist assertTrue(shouldPackageRunOob(true, kWhitelistApp1, runningPackages)); assertTrue(shouldPackageRunOob(true, kWhitelistApp2, runningPackages)); assertTrue(shouldPackageRunOob(true, kWhitelistApp1AndApp2, runningPackages)); assertTrue(shouldPackageRunOob(true, "ALL", runningPackages)); } } } Loading
services/core/java/com/android/server/am/ProcessList.java +0 −9 Original line number Original line Diff line number Diff line Loading @@ -133,7 +133,6 @@ import com.android.server.SystemConfig; import com.android.server.Watchdog; import com.android.server.Watchdog; import com.android.server.am.ActivityManagerService.ProcessChangeItem; import com.android.server.am.ActivityManagerService.ProcessChangeItem; import com.android.server.compat.PlatformCompat; import com.android.server.compat.PlatformCompat; import com.android.server.pm.dex.DexManager; import com.android.server.pm.parsing.pkg.AndroidPackage; import com.android.server.pm.parsing.pkg.AndroidPackage; import com.android.server.pm.pkg.PackageStateInternal; import com.android.server.pm.pkg.PackageStateInternal; import com.android.server.wm.ActivityServiceConnectionsHolder; import com.android.server.wm.ActivityServiceConnectionsHolder; Loading Loading @@ -1790,14 +1789,6 @@ public final class ProcessList { if (app.info.isEmbeddedDexUsed()) { if (app.info.isEmbeddedDexUsed()) { runtimeFlags |= Zygote.ONLY_USE_SYSTEM_OAT_FILES; runtimeFlags |= Zygote.ONLY_USE_SYSTEM_OAT_FILES; } else if (app.info.isPrivilegedApp()) { final PackageList pkgList = app.getPkgList(); synchronized (pkgList) { if (DexManager.isPackageSelectedToRunOob( pkgList.getPackageListLocked().keySet())) { runtimeFlags |= Zygote.ONLY_USE_SYSTEM_OAT_FILES; } } } } if (!disableHiddenApiChecks && !mService.mHiddenApiBlacklist.isDisabled()) { if (!disableHiddenApiChecks && !mService.mHiddenApiBlacklist.isDisabled()) { Loading
services/core/java/com/android/server/pm/PackageDexOptimizer.java +2 −9 Original line number Original line Diff line number Diff line Loading @@ -74,7 +74,6 @@ import com.android.server.pm.Installer.InstallerException; import com.android.server.pm.dex.ArtManagerService; import com.android.server.pm.dex.ArtManagerService; import com.android.server.pm.dex.ArtStatsLogUtils; import com.android.server.pm.dex.ArtStatsLogUtils; import com.android.server.pm.dex.ArtStatsLogUtils.ArtStatsLogger; import com.android.server.pm.dex.ArtStatsLogUtils.ArtStatsLogger; import com.android.server.pm.dex.DexManager; import com.android.server.pm.dex.DexoptOptions; import com.android.server.pm.dex.DexoptOptions; import com.android.server.pm.dex.DexoptUtils; import com.android.server.pm.dex.DexoptUtils; import com.android.server.pm.dex.PackageDexUsage; import com.android.server.pm.dex.PackageDexUsage; Loading Loading @@ -787,10 +786,7 @@ public class PackageDexOptimizer { */ */ private String getRealCompilerFilter(ApplicationInfo info, String targetCompilerFilter, private String getRealCompilerFilter(ApplicationInfo info, String targetCompilerFilter, boolean isUsedByOtherApps) { boolean isUsedByOtherApps) { // When an app or priv app is configured to run out of box, only verify it. if (info.isEmbeddedDexUsed()) { if (info.isEmbeddedDexUsed() || (info.isPrivilegedApp() && DexManager.isPackageSelectedToRunOob(info.packageName))) { return "verify"; return "verify"; } } Loading Loading @@ -827,10 +823,7 @@ public class PackageDexOptimizer { * handling the case where the package code is used by other apps. * handling the case where the package code is used by other apps. */ */ private String getRealCompilerFilter(AndroidPackage pkg, String targetCompilerFilter) { private String getRealCompilerFilter(AndroidPackage pkg, String targetCompilerFilter) { // When an app or priv app is configured to run out of box, only verify it. if (pkg.isUseEmbeddedDex()) { if (pkg.isUseEmbeddedDex() || (pkg.isPrivileged() && DexManager.isPackageSelectedToRunOob(pkg.getPackageName()))) { return "verify"; return "verify"; } } Loading
services/core/java/com/android/server/pm/dex/DexManager.java +0 −46 Original line number Original line Diff line number Diff line Loading @@ -36,7 +36,6 @@ import android.os.FileUtils; import android.os.PowerManager; import android.os.PowerManager; import android.os.RemoteException; import android.os.RemoteException; import android.os.ServiceManager; import android.os.ServiceManager; import android.os.SystemProperties; import android.os.UserHandle; import android.os.UserHandle; import android.os.storage.StorageManager; import android.os.storage.StorageManager; import android.util.Log; import android.util.Log; Loading @@ -58,8 +57,6 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.Paths; import java.util.ArrayList; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Collections; import java.util.HashMap; import java.util.HashMap; import java.util.HashSet; import java.util.HashSet; Loading @@ -81,10 +78,6 @@ public class DexManager { private static final String TAG = "DexManager"; private static final String TAG = "DexManager"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); private static final String PROPERTY_NAME_PM_DEXOPT_PRIV_APPS_OOB = "pm.dexopt.priv-apps-oob"; private static final String PROPERTY_NAME_PM_DEXOPT_PRIV_APPS_OOB_LIST = "pm.dexopt.priv-apps-oob-list"; // System server cannot load executable code outside system partitions. // System server cannot load executable code outside system partitions. // However it can load verification data - thus we pick the "verify" compiler filter. // However it can load verification data - thus we pick the "verify" compiler filter. private static final String SYSTEM_SERVER_COMPILER_FILTER = "verify"; private static final String SYSTEM_SERVER_COMPILER_FILTER = "verify"; Loading Loading @@ -909,45 +902,6 @@ public class DexManager { mDynamicCodeLogger.writeNow(); mDynamicCodeLogger.writeNow(); } } /** * Returns whether the given package is in the list of privilaged apps that should run out of * box. This only makes sense if the feature is enabled. Note that when the the OOB list is * empty, all priv apps will run in OOB mode. */ public static boolean isPackageSelectedToRunOob(String packageName) { return isPackageSelectedToRunOob(Arrays.asList(packageName)); } /** * Returns whether any of the given packages are in the list of privilaged apps that should run * out of box. This only makes sense if the feature is enabled. Note that when the the OOB list * is empty, all priv apps will run in OOB mode. */ public static boolean isPackageSelectedToRunOob(Collection<String> packageNamesInSameProcess) { return isPackageSelectedToRunOobInternal( SystemProperties.getBoolean(PROPERTY_NAME_PM_DEXOPT_PRIV_APPS_OOB, false), SystemProperties.get(PROPERTY_NAME_PM_DEXOPT_PRIV_APPS_OOB_LIST, "ALL"), packageNamesInSameProcess); } @VisibleForTesting /* package */ static boolean isPackageSelectedToRunOobInternal(boolean isEnabled, String whitelist, Collection<String> packageNamesInSameProcess) { if (!isEnabled) { return false; } if ("ALL".equals(whitelist)) { return true; } for (String oobPkgName : whitelist.split(",")) { if (packageNamesInSameProcess.contains(oobPkgName)) { return true; } } return false; } /** /** * Generates log if the archive located at {@code fileName} has uncompressed dex file that can * Generates log if the archive located at {@code fileName} has uncompressed dex file that can * be direclty mapped. * be direclty mapped. Loading
services/tests/mockingservicestests/src/com/android/server/pm/dex/DexManagerTests.java +0 −41 Original line number Original line Diff line number Diff line Loading @@ -61,7 +61,6 @@ import org.mockito.quality.Strictness; import java.io.File; import java.io.File; import java.util.ArrayList; import java.util.ArrayList; import java.util.Arrays; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Collections; import java.util.HashMap; import java.util.HashMap; import java.util.List; import java.util.List; Loading Loading @@ -1029,44 +1028,4 @@ public class DexManagerTests { return mPackageInfo.applicationInfo.splitSourceDirs[length - 1]; return mPackageInfo.applicationInfo.splitSourceDirs[length - 1]; } } } } private boolean shouldPackageRunOob(boolean isDefaultEnabled, String whitelist, Collection<String> packageNamesInSameProcess) { return DexManager.isPackageSelectedToRunOobInternal( isDefaultEnabled, whitelist, packageNamesInSameProcess); } @Test public void testOobPackageSelectionDefault() { // Feature is off by default, not overriden assertFalse(shouldPackageRunOob(false, "ALL", null)); } @Test public void testOobPackageSelectionWhitelist() { // Various allowlist of apps to run in OOB mode. final String kWhitelistApp0 = "com.priv.app0"; final String kWhitelistApp1 = "com.priv.app1"; final String kWhitelistApp2 = "com.priv.app2"; final String kWhitelistApp1AndApp2 = "com.priv.app1,com.priv.app2"; // Packages that shares the targeting process. final Collection<String> runningPackages = Arrays.asList("com.priv.app1", "com.priv.app2"); // Feature is off, allowlist does not matter assertFalse(shouldPackageRunOob(false, kWhitelistApp0, runningPackages)); assertFalse(shouldPackageRunOob(false, kWhitelistApp1, runningPackages)); assertFalse(shouldPackageRunOob(false, "", runningPackages)); assertFalse(shouldPackageRunOob(false, "ALL", runningPackages)); // Feature is on, app not in allowlist assertFalse(shouldPackageRunOob(true, kWhitelistApp0, runningPackages)); assertFalse(shouldPackageRunOob(true, "", runningPackages)); // Feature is on, app in allowlist assertTrue(shouldPackageRunOob(true, kWhitelistApp1, runningPackages)); assertTrue(shouldPackageRunOob(true, kWhitelistApp2, runningPackages)); assertTrue(shouldPackageRunOob(true, kWhitelistApp1AndApp2, runningPackages)); assertTrue(shouldPackageRunOob(true, "ALL", runningPackages)); } } }