summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Philip Cuadra <philipcuadra@google.com> 2016-07-12 17:29:38 -0700
committer Philip Cuadra <philipcuadra@google.com> 2016-07-13 15:14:43 -0700
commitd9bd884d731e5d9931842161f6777986e11434dd (patch)
tree6e8611b128b504503380b1c56d2ccf5cff304e88
parentbb6f52d06bcfb21ed25b3acb8aae6240a81eacf0 (diff)
Call into ART to get the location of the odex/oat file to pin
Get the location of the odex / oat file to pin from ART instead of trying to figure it out from location of the apk. Bug 28251566 Change-Id: Ia2921f6e8df412c4ac5073cd36e57807c655a81d
-rw-r--r--services/core/java/com/android/server/PinnerService.java22
1 files changed, 14 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/PinnerService.java b/services/core/java/com/android/server/PinnerService.java
index eaf317a46bc1..7ea8f1f4924d 100644
--- a/services/core/java/com/android/server/PinnerService.java
+++ b/services/core/java/com/android/server/PinnerService.java
@@ -41,6 +41,7 @@ import android.system.StructStat;
import com.android.internal.app.ResolverActivity;
import com.android.internal.os.BackgroundThread;
+import dalvik.system.DexFile;
import dalvik.system.VMRuntime;
import java.util.ArrayList;
@@ -240,12 +241,6 @@ public final class PinnerService extends SystemService {
}
mPinnedCameraFiles.add(pf);
- //find the location of the odex based on the location of the APK
- int lastPeriod = camAPK.lastIndexOf('.');
- int lastSlash = camAPK.lastIndexOf('/', lastPeriod);
- String base = camAPK.substring(0, lastSlash);
- String appName = camAPK.substring(lastSlash + 1, lastPeriod);
-
// determine the ABI from either ApplicationInfo or Build
String arch = "arm";
if (cameraInfo.primaryCpuAbi != null
@@ -256,8 +251,18 @@ public final class PinnerService extends SystemService {
arch = arch + "64";
}
}
- String odex = base + "/oat/" + arch + "/" + appName + ".odex";
- //not all apps have odex files, so not pinning the odex is not a fatal error
+
+ // get the path to the odex or oat file
+ String baseCodePath = cameraInfo.getBaseCodePath();
+ String odex = null;
+ try {
+ odex = DexFile.getDexFileOutputPath(baseCodePath, arch);
+ } catch (IOException ioe) {}
+ if (odex == null) {
+ return true;
+ }
+
+ //not pinning the oat/odex is not a fatal error
pf = pinFile(odex, 0, 0, MAX_CAMERA_PIN_SIZE);
if (pf != null) {
mPinnedCameraFiles.add(pf);
@@ -265,6 +270,7 @@ public final class PinnerService extends SystemService {
Slog.i(TAG, "Pinned " + pf.mFilename);
}
}
+
return true;
}