Merge "Deprecate pm.dexopt.priv-apps-oob{,-list}"

This commit is contained in:
Victor Hsieh
2022-08-31 21:13:57 +00:00
committed by Android (Google) Code Review
4 changed files with 2 additions and 105 deletions

View File

@@ -133,7 +133,6 @@ import com.android.server.SystemConfig;
import com.android.server.Watchdog;
import com.android.server.am.ActivityManagerService.ProcessChangeItem;
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.pkg.PackageStateInternal;
import com.android.server.wm.ActivityServiceConnectionsHolder;
@@ -1790,14 +1789,6 @@ public final class ProcessList {
if (app.info.isEmbeddedDexUsed()) {
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()) {

View File

@@ -74,7 +74,6 @@ import com.android.server.pm.Installer.InstallerException;
import com.android.server.pm.dex.ArtManagerService;
import com.android.server.pm.dex.ArtStatsLogUtils;
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.DexoptUtils;
import com.android.server.pm.dex.PackageDexUsage;
@@ -787,10 +786,7 @@ public class PackageDexOptimizer {
*/
private String getRealCompilerFilter(ApplicationInfo info, String targetCompilerFilter,
boolean isUsedByOtherApps) {
// When an app or priv app is configured to run out of box, only verify it.
if (info.isEmbeddedDexUsed()
|| (info.isPrivilegedApp()
&& DexManager.isPackageSelectedToRunOob(info.packageName))) {
if (info.isEmbeddedDexUsed()) {
return "verify";
}
@@ -827,10 +823,7 @@ public class PackageDexOptimizer {
* handling the case where the package code is used by other apps.
*/
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()
|| (pkg.isPrivileged()
&& DexManager.isPackageSelectedToRunOob(pkg.getPackageName()))) {
if (pkg.isUseEmbeddedDex()) {
return "verify";
}

View File

@@ -36,7 +36,6 @@ import android.os.FileUtils;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.storage.StorageManager;
import android.util.Log;
@@ -58,8 +57,6 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -81,10 +78,6 @@ public class DexManager {
private static final String TAG = "DexManager";
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.
// However it can load verification data - thus we pick the "verify" compiler filter.
private static final String SYSTEM_SERVER_COMPILER_FILTER = "verify";
@@ -909,45 +902,6 @@ public class DexManager {
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
* be direclty mapped.

View File

@@ -61,7 +61,6 @@ import org.mockito.quality.Strictness;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -1029,44 +1028,4 @@ public class DexManagerTests {
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));
}
}