Merge "Move code around for deleting oat artifacts." am: a7bf2a21d9
am: 69fbdcae71
Change-Id: If5e92c3b0499f3d2f69975596678581dfc090733
This commit is contained in:
@@ -152,7 +152,7 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
|
||||
Log.i(TAG, "Low on space, deleting oat files in an attempt to free up space: "
|
||||
+ PackageManagerServiceUtils.packagesToString(others));
|
||||
for (PackageParser.Package pkg : others) {
|
||||
deleteOatArtifactsOfPackage(pkg);
|
||||
mPackageManagerService.deleteOatArtifactsOfPackage(pkg.packageName);
|
||||
}
|
||||
}
|
||||
long spaceAvailableNow = getAvailableSpace();
|
||||
@@ -242,30 +242,6 @@ public class OtaDexoptService extends IOtaDexopt.Stub {
|
||||
return usableSpace - lowThreshold;
|
||||
}
|
||||
|
||||
private static String getOatDir(PackageParser.Package pkg) {
|
||||
if (!pkg.canHaveOatDir()) {
|
||||
return null;
|
||||
}
|
||||
File codePath = new File(pkg.codePath);
|
||||
if (codePath.isDirectory()) {
|
||||
return PackageDexOptimizer.getOatDir(codePath).getAbsolutePath();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void deleteOatArtifactsOfPackage(PackageParser.Package pkg) {
|
||||
String[] instructionSets = getAppDexInstructionSets(pkg.applicationInfo);
|
||||
for (String codePath : pkg.getAllCodePaths()) {
|
||||
for (String isa : instructionSets) {
|
||||
try {
|
||||
mPackageManagerService.mInstaller.deleteOdex(codePath, isa, getOatDir(pkg));
|
||||
} catch (InstallerException e) {
|
||||
Log.e(TAG, "Failed deleting oat files for " + codePath, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate all dexopt commands for the given package.
|
||||
*/
|
||||
|
||||
@@ -24988,6 +24988,50 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
|
||||
return mInstantAppRegistry.getInstantAppAndroidIdLPw(packageName, userId);
|
||||
}
|
||||
}
|
||||
|
||||
boolean canHaveOatDir(String packageName) {
|
||||
synchronized (mPackages) {
|
||||
PackageParser.Package p = mPackages.get(packageName);
|
||||
if (p == null) {
|
||||
return false;
|
||||
}
|
||||
return p.canHaveOatDir();
|
||||
}
|
||||
}
|
||||
|
||||
private String getOatDir(PackageParser.Package pkg) {
|
||||
if (!pkg.canHaveOatDir()) {
|
||||
return null;
|
||||
}
|
||||
File codePath = new File(pkg.codePath);
|
||||
if (codePath.isDirectory()) {
|
||||
return PackageDexOptimizer.getOatDir(codePath).getAbsolutePath();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void deleteOatArtifactsOfPackage(String packageName) {
|
||||
final String[] instructionSets;
|
||||
final List<String> codePaths;
|
||||
final String oatDir;
|
||||
final PackageParser.Package pkg;
|
||||
synchronized (mPackages) {
|
||||
pkg = mPackages.get(packageName);
|
||||
}
|
||||
instructionSets = getAppDexInstructionSets(pkg.applicationInfo);
|
||||
codePaths = pkg.getAllCodePaths();
|
||||
oatDir = getOatDir(pkg);
|
||||
|
||||
for (String codePath : codePaths) {
|
||||
for (String isa : instructionSets) {
|
||||
try {
|
||||
mInstaller.deleteOdex(codePath, isa, oatDir);
|
||||
} catch (InstallerException e) {
|
||||
Log.e(TAG, "Failed deleting oat files for " + codePath, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface PackageSender {
|
||||
|
||||
Reference in New Issue
Block a user