Loading cmds/installd/InstalldNativeService.cpp +6 −3 Original line number Original line Diff line number Diff line Loading @@ -1100,11 +1100,14 @@ binder::Status InstalldNativeService::rmdex(const std::string& codePath, ALOGV("unlink %s\n", dex_path); ALOGV("unlink %s\n", dex_path); if (unlink(dex_path) < 0) { if (unlink(dex_path) < 0) { // 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 error(StringPrintf("Failed to unlink %s", dex_path)); } else { return ok(); } } } } return ok(); } struct stats { struct stats { int64_t codeSize; int64_t codeSize; Loading cmds/installd/tests/installd_service_test.cpp +14 −4 Original line number Original line Diff line number Diff line Loading @@ -54,10 +54,12 @@ bool calculate_odex_file_path(char path[PKG_PATH_MAX] ATTRIBUTE_UNUSED, return false; return false; } } bool create_cache_path(char path[PKG_PATH_MAX] ATTRIBUTE_UNUSED, bool create_cache_path(char path[PKG_PATH_MAX], const char *src ATTRIBUTE_UNUSED, const char *src, const char *instruction_set ATTRIBUTE_UNUSED) { const char *instruction_set) { return false; // 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) { static void mkdir(const char* path, uid_t owner, gid_t group, mode_t mode) { Loading Loading @@ -151,5 +153,13 @@ TEST_F(ServiceTest, FixupAppData_Moved) { EXPECT_EQ(10000, stat_gid("com.example/bar/file")); 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 installd } // namespace android } // namespace android Loading
cmds/installd/InstalldNativeService.cpp +6 −3 Original line number Original line Diff line number Diff line Loading @@ -1100,11 +1100,14 @@ binder::Status InstalldNativeService::rmdex(const std::string& codePath, ALOGV("unlink %s\n", dex_path); ALOGV("unlink %s\n", dex_path); if (unlink(dex_path) < 0) { if (unlink(dex_path) < 0) { // 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 error(StringPrintf("Failed to unlink %s", dex_path)); } else { return ok(); } } } } return ok(); } struct stats { struct stats { int64_t codeSize; int64_t codeSize; Loading
cmds/installd/tests/installd_service_test.cpp +14 −4 Original line number Original line Diff line number Diff line Loading @@ -54,10 +54,12 @@ bool calculate_odex_file_path(char path[PKG_PATH_MAX] ATTRIBUTE_UNUSED, return false; return false; } } bool create_cache_path(char path[PKG_PATH_MAX] ATTRIBUTE_UNUSED, bool create_cache_path(char path[PKG_PATH_MAX], const char *src ATTRIBUTE_UNUSED, const char *src, const char *instruction_set ATTRIBUTE_UNUSED) { const char *instruction_set) { return false; // 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) { static void mkdir(const char* path, uid_t owner, gid_t group, mode_t mode) { Loading Loading @@ -151,5 +153,13 @@ TEST_F(ServiceTest, FixupAppData_Moved) { EXPECT_EQ(10000, stat_gid("com.example/bar/file")); 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 installd } // namespace android } // namespace android