summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2017-05-08 23:20:12 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2017-05-08 23:20:13 +0000
commitd6ca10b76d2d00d2b60bb186f71b125f917825b0 (patch)
treeaf7a1bfeed6a23a437b53f088f6ba59bc86fdfca
parent663720b29f412756b8599897df9f8e32eb930be2 (diff)
parent249f2d3e018bd98eba74c3184b80bc91b04281cd (diff)
Merge "Do not return an error if the dalvik-cache odex is missing" into oc-dev
-rw-r--r--cmds/installd/InstalldNativeService.cpp9
-rw-r--r--cmds/installd/tests/installd_service_test.cpp18
2 files changed, 20 insertions, 7 deletions
diff --git a/cmds/installd/InstalldNativeService.cpp b/cmds/installd/InstalldNativeService.cpp
index 19dfb8789d..a0d987ded6 100644
--- a/cmds/installd/InstalldNativeService.cpp
+++ b/cmds/installd/InstalldNativeService.cpp
@@ -1100,10 +1100,13 @@ binder::Status InstalldNativeService::rmdex(const std::string& codePath,
ALOGV("unlink %s\n", dex_path);
if (unlink(dex_path) < 0) {
- return error(StringPrintf("Failed to unlink %s", dex_path));
- } else {
- return ok();
+ // It's ok if we don't have a dalvik cache path. Report error only when the path exists
+ // but could not be unlinked.
+ if (errno != ENOENT) {
+ return error(StringPrintf("Failed to unlink %s", dex_path));
+ }
}
+ return ok();
}
struct stats {
diff --git a/cmds/installd/tests/installd_service_test.cpp b/cmds/installd/tests/installd_service_test.cpp
index 4a1f333bae..34818f65aa 100644
--- a/cmds/installd/tests/installd_service_test.cpp
+++ b/cmds/installd/tests/installd_service_test.cpp
@@ -54,10 +54,12 @@ bool calculate_odex_file_path(char path[PKG_PATH_MAX] ATTRIBUTE_UNUSED,
return false;
}
-bool create_cache_path(char path[PKG_PATH_MAX] ATTRIBUTE_UNUSED,
- const char *src ATTRIBUTE_UNUSED,
- const char *instruction_set ATTRIBUTE_UNUSED) {
- return false;
+bool create_cache_path(char path[PKG_PATH_MAX],
+ const char *src,
+ const char *instruction_set) {
+ // Not really a valid path but it's good enough for testing.
+ sprintf(path,"/data/dalvik-cache/%s/%s", instruction_set, src);
+ return true;
}
static void mkdir(const char* path, uid_t owner, gid_t group, mode_t mode) {
@@ -151,5 +153,13 @@ TEST_F(ServiceTest, FixupAppData_Moved) {
EXPECT_EQ(10000, stat_gid("com.example/bar/file"));
}
+TEST_F(ServiceTest, RmDexNoDalvikCache) {
+ LOG(INFO) << "RmDexNoDalvikCache";
+
+ // Try to remove a non existing dalvik cache dex. The call should be
+ // successful because there's nothing to remove.
+ EXPECT_TRUE(service->rmdex("com.example", "arm").isOk());
+}
+
} // namespace installd
} // namespace android