From 848bcdc42a694bdca561d9cdb6b2f8ae8b1618f5 Mon Sep 17 00:00:00 2001 From: Yo Chiang Date: Tue, 29 Dec 2020 18:03:05 +0800 Subject: DynamicSystemInstallationService: Support remount for DSU guest system DSU service would try to install a DSU scratch partition if host system is debuggable. If the scratch partition failed to install, then skip installing scratch, as remount support should be optional. Otherwise if the guest system is non-debuggable, then the scratch partition would be ignored by guest, which is harmless. Otherwise the guest system is debuggable, which means the guest system would be able to do adb remount. Relax partition allocation status polling rate from 10ms -> 100ms, because there's no point polling faster than the screen framerate. Bug: 165925766 Test: TH Test: Install a DSU system on a debuggable host, reboot into the guest system, and guest system can remount. Change-Id: I9a8255483cc963ebcf7a2909e68ac69371cb369f --- .../android/dynsystem/InstallationAsyncTask.java | 69 ++++++++++++++++++++-- 1 file changed, 64 insertions(+), 5 deletions(-) (limited to 'packages/DynamicSystemInstallationService') diff --git a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java index ac73f35517d6..4ef5e2b4f090 100644 --- a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java +++ b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java @@ -20,6 +20,7 @@ import android.content.Context; import android.gsi.AvbPublicKey; import android.net.Uri; import android.os.AsyncTask; +import android.os.Build; import android.os.MemoryFile; import android.os.ParcelFileDescriptor; import android.os.image.DynamicSystemManager; @@ -51,7 +52,8 @@ class InstallationAsyncTask extends AsyncTask UNSUPPORTED_PARTITIONS = - Arrays.asList("vbmeta", "boot", "userdata", "dtbo", "super_empty", "system_other"); + Arrays.asList( + "vbmeta", "boot", "userdata", "dtbo", "super_empty", "system_other", "scratch"); private class UnsupportedUrlException extends Exception { private UnsupportedUrlException(String message) { @@ -196,6 +198,22 @@ class InstallationAsyncTask extends AsyncTask progress.installedSize + MIN_PROGRESS_TO_PUBLISH) { + progress.installedSize = installedSize; + publishProgress(progress); + } + + Thread.sleep(100); + } + + if (mInstallationSession == null) { + throw new IOException( + "Failed to start installation with requested size: " + scratchSize); + } + // Reset installation session and verify that installation completes successfully. + mInstallationSession = null; + if (!mDynSystem.closePartition()) { + throw new IOException("Failed to complete partition installation: scratch"); + } + } + + private void installUserdata() throws IOException, InterruptedException { Thread thread = new Thread(() -> { mInstallationSession = mDynSystem.createPartition("userdata", mUserdataSize, false); }); - Log.d(TAG, "Creating partition: userdata"); + Log.d(TAG, "Creating partition: userdata, size = " + mUserdataSize); thread.start(); Progress progress = new Progress("userdata", mUserdataSize, mNumInstalledPartitions++); @@ -324,7 +383,7 @@ class InstallationAsyncTask extends AsyncTask