diff options
author | Yo Chiang <yochiang@google.com> | 2020-08-20 19:43:28 +0800 |
---|---|---|
committer | Yo Chiang <yochiang@google.com> | 2020-08-25 07:48:16 +0000 |
commit | 55668c1a49fdb34b2ffee071da9d9ac7dd1a5a9e (patch) | |
tree | 3fc1d20230e717ce8d49d68ee1e96352e12ebfde | |
parent | f288999050900de6f640b4fd10a7211e644b494c (diff) |
Check error status after installing each DSU partition
Add DynamicSystemManager.closePartition() that closes a partition
installation and returns its error status.
InstallationAsyncTask may call this method to do error checking.
Bug: 165471299
Test: Observe the logcat of a failed DSU installation
Change-Id: I9d155c70c6e490899a4acfd35c8096549af005d4
4 files changed, 41 insertions, 0 deletions
diff --git a/core/java/android/os/image/DynamicSystemManager.java b/core/java/android/os/image/DynamicSystemManager.java index 17851adac51b..7f01cad940ec 100644 --- a/core/java/android/os/image/DynamicSystemManager.java +++ b/core/java/android/os/image/DynamicSystemManager.java @@ -155,6 +155,19 @@ public class DynamicSystemManager { } } /** + * Complete the current partition installation. + * + * @return true if the partition installation completes without error. + */ + @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_SYSTEM) + public boolean closePartition() { + try { + return mService.closePartition(); + } catch (RemoteException e) { + throw new RuntimeException(e.toString()); + } + } + /** * Finish a previously started installation. Installations without a cooresponding * finishInstallation() will be cleaned up during device boot. */ diff --git a/core/java/android/os/image/IDynamicSystemService.aidl b/core/java/android/os/image/IDynamicSystemService.aidl index a1f927266de3..df0a69b47225 100644 --- a/core/java/android/os/image/IDynamicSystemService.aidl +++ b/core/java/android/os/image/IDynamicSystemService.aidl @@ -39,6 +39,13 @@ interface IDynamicSystemService boolean createPartition(@utf8InCpp String name, long size, boolean readOnly); /** + * Complete the current partition installation. + * + * @return true if the partition installation completes without error. + */ + boolean closePartition(); + + /** * Finish a previously started installation. Installations without * a cooresponding finishInstallation() will be cleaned up during device boot. */ diff --git a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java index f8952ace3cb3..4d31ce97e8b7 100644 --- a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java +++ b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java @@ -334,6 +334,11 @@ class InstallationAsyncTask extends AsyncTask<String, InstallationAsyncTask.Prog throw new IOException( "Failed to start installation with requested size: " + mUserdataSize); } + // Reset installation session and verify that installation completes successfully. + mInstallationSession = null; + if (!mDynSystem.closePartition()) { + throw new IOException("Failed to complete partition installation: userdata"); + } } private void installImages() @@ -503,6 +508,12 @@ class InstallationAsyncTask extends AsyncTask<String, InstallationAsyncTask.Prog imageValidationThrowOrWarning(new KeyRevokedException(publicKey)); } } + + // Reset installation session and verify that installation completes successfully. + mInstallationSession = null; + if (!mDynSystem.closePartition()) { + throw new IOException("Failed to complete partition installation: " + partitionName); + } } private static String toHexString(byte[] bytes) { diff --git a/services/core/java/com/android/server/DynamicSystemService.java b/services/core/java/com/android/server/DynamicSystemService.java index 191a9bc7651d..776f25fc98b6 100644 --- a/services/core/java/com/android/server/DynamicSystemService.java +++ b/services/core/java/com/android/server/DynamicSystemService.java @@ -126,6 +126,16 @@ public class DynamicSystemService extends IDynamicSystemService.Stub { } @Override + public boolean closePartition() throws RemoteException { + IGsiService service = getGsiService(); + if (service.closePartition() != 0) { + Slog.i(TAG, "Partition installation completes with error"); + return false; + } + return true; + } + + @Override public boolean finishInstallation() throws RemoteException { IGsiService service = getGsiService(); if (service.closeInstall() != 0) { |