OSDN Git Service

Unlink app image if copy fails for A/B OTA
authorMathieu Chartier <mathieuc@google.com>
Fri, 9 Sep 2016 23:15:52 +0000 (16:15 -0700)
committerMathieu Chartier <mathieuc@google.com>
Fri, 9 Sep 2016 23:19:24 +0000 (16:19 -0700)
Usually this happens when the app was recompiled with interpret-only.
In this case, move_ab_path will fail for the app image. If this
occurs, delete the existing app image to not have a stale one wasting
storage space.

Test: Make fake AB ota, delete the a/b generated app image, take the
OTA, ensure there is no stale app image after reboot. Also tested
that other apps with valid app images still had an image.

Bug: 31323617
Change-Id: I699b5eb3dc8f82759c284a1d299865b2c3a890d0

cmds/installd/commands.cpp

index 2014e99..31f9d7e 100644 (file)
@@ -2186,6 +2186,9 @@ int move_ab(const char* apk_path, const char* instruction_set, const char* oat_d
         bool art_success = true;
         if (!a_image_path.empty()) {
             art_success = move_ab_path(b_image_path, a_image_path);
+            if (!art_success) {
+                unlink(a_image_path.c_str());
+            }
         }
 
         success = art_success || kIgnoreAppImageFailure;