summaryrefslogtreecommitdiff
path: root/preopt2cachename
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2017-05-05 10:56:11 -0700
committerMathieu Chartier <mathieuc@google.com>2017-05-05 13:19:28 -0700
commit496f0213f35f681f90d503f8d45e5f29a3139b4f (patch)
treedd0daa8cae72be448bb00c9b72da83f03ec054ec /preopt2cachename
parent13143d67af0ea867f1b4ecc6019474090e04bb5b (diff)
downloadextras-496f0213f35f681f90d503f8d45e5f29a3139b4f.tar.gz
Add art files support to cppreopt copy
Preopted art files are now copied to classes.dex. Test: adb shell rm /data/system/packages.xml Test: adb shell rm -rf /data/dalvik-cache Test: adb reboot Test: adb shell ls -l /data/dalvik-cache/*/* | grep Calc Bug: 38033055 Change-Id: Ib7d1c65ff47cdb4ebb1829f6a87a885381aded15
Diffstat (limited to 'preopt2cachename')
-rw-r--r--preopt2cachename/preopt2cachename.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/preopt2cachename/preopt2cachename.cpp b/preopt2cachename/preopt2cachename.cpp
index f9a12ff4..3fb887be 100644
--- a/preopt2cachename/preopt2cachename.cpp
+++ b/preopt2cachename/preopt2cachename.cpp
@@ -26,6 +26,7 @@
static const char* kDalvikCacheDir = "/data/dalvik-cache/";
static const char* kOdexCacheSuffix = "@classes.dex";
static const char* kVdexCacheSuffix = "@classes.vdex";
+static const char* kArtCacheSuffix = "@classes.art";
// Returns the ISA extracted from the file_location.
// file_location is formatted like /system/app/<app_name>/oat/<isa>/<app_name>.{odex,vdex}
@@ -88,10 +89,17 @@ static bool SystemBFilenameToCacheFile(const std::string& file_location,
LOG(ERROR) << "Unable to determine apk name from file name '" << file_location << "'";
return false;
}
+ std::string::size_type pos = file_location.find_last_of(".");
+ if (pos == std::string::npos) {
+ LOG(ERROR) << "Invalid file location '" << file_location << "'";
+ return false;
+ }
cache_file += apk_name;
- if (file_location.size() >= 5 &&
- file_location.substr(file_location.size() - 5) == std::string(".vdex")) {
+ std::string extension(file_location.substr(pos));
+ if (extension == ".vdex") {
cache_file += kVdexCacheSuffix;
+ } else if (extension == ".art") {
+ cache_file += kArtCacheSuffix;
} else {
cache_file += kOdexCacheSuffix;
}