OSDN Git Service

Catch exceptions thrown from UpdateEngine#applyPayload.
authorAlex Kershaw <alexkershaw@google.com>
Fri, 12 Apr 2019 15:59:29 +0000 (16:59 +0100)
committerAlex Kershaw <alexkershaw@google.com>
Fri, 12 Apr 2019 17:19:34 +0000 (17:19 +0000)
Note: we can't add a CTS test for this behaviour since the UpdateEngine
is an implementation detail.

Fixes: 124106342
Test: Manually tested
Change-Id: Ib8e6895211b5d39a4d037d383c115011084ea257

services/devicepolicy/java/com/android/server/devicepolicy/AbUpdateInstaller.java

index d5cfab9..5acf83a 100644 (file)
@@ -194,8 +194,17 @@ class AbUpdateInstaller extends UpdateInstaller {
         }
 
         UpdateEngine updateEngine = buildBoundUpdateEngine();
-        updateEngine.applyPayload(
-                updatePath, mOffsetForUpdate, mSizeForUpdate, headerKeyValuePairs);
+        try {
+            updateEngine.applyPayload(
+                    updatePath, mOffsetForUpdate, mSizeForUpdate, headerKeyValuePairs);
+        } catch (Exception e) {
+            // Prevent an automatic restart when an update is already being processed
+            // (http://b/124106342).
+            Log.w(UpdateInstaller.TAG, "Failed to install update from file.", e);
+            notifyCallbackOnError(
+                    InstallSystemUpdateCallback.UPDATE_ERROR_UNKNOWN,
+                    "Failed to install update from file.");
+        }
     }
 
     private boolean updateStateForPayload() throws IOException {