Merge "Allow createOatDir for partial installation." into udc-dev

This commit is contained in:
Jiakai Zhang
2023-03-21 21:44:16 +00:00
committed by Android (Google) Code Review
2 changed files with 8 additions and 14 deletions

View File

@@ -821,8 +821,10 @@ public class Installer extends SystemService {
* Creates an oat dir for given package and instruction set.
*/
public void createOatDir(String packageName, String oatDir, String dexInstructionSet)
throws InstallerException, LegacyDexoptDisabledException {
checkLegacyDexoptDisabled();
throws InstallerException {
// This method should be allowed even if ART Service is enabled, because it's used for
// creating oat dirs before creating hard links for partial installation.
// TODO(b/274658735): Add an ART Service API to support hard linking.
if (!checkBeforeRemote()) return;
try {
mInstalld.createOatDir(packageName, oatDir, dexInstructionSet);

View File

@@ -49,7 +49,6 @@ import static com.android.internal.util.XmlUtils.writeBooleanAttribute;
import static com.android.internal.util.XmlUtils.writeByteArrayAttribute;
import static com.android.internal.util.XmlUtils.writeStringAttribute;
import static com.android.internal.util.XmlUtils.writeUriAttribute;
import static com.android.server.pm.DexOptHelper.useArtService;
import static com.android.server.pm.PackageInstallerService.prepareStageDir;
import static com.android.server.pm.PackageManagerService.APP_METADATA_FILE_NAME;
@@ -173,7 +172,6 @@ import com.android.modules.utils.TypedXmlPullParser;
import com.android.modules.utils.TypedXmlSerializer;
import com.android.server.LocalServices;
import com.android.server.pm.Installer.InstallerException;
import com.android.server.pm.Installer.LegacyDexoptDisabledException;
import com.android.server.pm.dex.DexManager;
import com.android.server.pm.pkg.AndroidPackage;
import com.android.server.pm.pkg.PackageStateInternal;
@@ -2560,15 +2558,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
}
if (isLinkPossible(fromFiles, toDir)) {
if (!useArtService()) { // ART Service creates oat dirs on demand instead.
if (!mResolvedInstructionSets.isEmpty()) {
final File oatDir = new File(toDir, "oat");
try {
createOatDirs(tempPackageName, mResolvedInstructionSets, oatDir);
} catch (LegacyDexoptDisabledException e) {
throw new RuntimeException(e);
}
}
if (!mResolvedInstructionSets.isEmpty()) {
final File oatDir = new File(toDir, "oat");
createOatDirs(tempPackageName, mResolvedInstructionSets, oatDir);
}
// pre-create lib dirs for linking if necessary
if (!mResolvedNativeLibPaths.isEmpty()) {
@@ -3829,7 +3821,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
}
private void createOatDirs(String packageName, List<String> instructionSets, File fromDir)
throws PackageManagerException, LegacyDexoptDisabledException {
throws PackageManagerException {
for (String instructionSet : instructionSets) {
try {
mInstaller.createOatDir(packageName, fromDir.getAbsolutePath(), instructionSet);