summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Howard Chen <howardsoc@google.com> 2019-11-15 11:05:16 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2019-11-15 11:05:16 +0000
commitc68c069db756d549922c0a08a73556ff9c97a3a6 (patch)
treeae537d8d4acf0d8a5cd90182d06a3eb76391b8e0
parentdbdaa06d90a8afd2e96ab7fe50a573e4988084f8 (diff)
parent6ea5beddd975c78371c6acd984667bd64193b944 (diff)
Merge "Use the new gsid interface"
-rw-r--r--core/java/android/os/image/DynamicSystemManager.java30
-rw-r--r--core/java/android/os/image/IDynamicSystemService.aidl17
-rw-r--r--packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java6
-rw-r--r--services/core/java/com/android/server/DynamicSystemService.java37
-rw-r--r--services/tests/servicestests/src/com/android/server/DynamicSystemServiceTest.java2
5 files changed, 73 insertions, 19 deletions
diff --git a/core/java/android/os/image/DynamicSystemManager.java b/core/java/android/os/image/DynamicSystemManager.java
index 0e00d5e9b7bf..4c92c28c1bfa 100644
--- a/core/java/android/os/image/DynamicSystemManager.java
+++ b/core/java/android/os/image/DynamicSystemManager.java
@@ -101,6 +101,19 @@ public class DynamicSystemManager {
}
}
/**
+ * Start DynamicSystem installation.
+ *
+ * @return true if the call succeeds
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_SYSTEM)
+ public boolean startInstallation() {
+ try {
+ return mService.startInstallation();
+ } catch (RemoteException e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
+ /**
* Start DynamicSystem installation. This call may take an unbounded amount of time. The caller
* may use another thread to call the getStartProgress() to get the progress.
*
@@ -112,9 +125,9 @@ public class DynamicSystemManager {
* true.
*/
@RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_SYSTEM)
- public Session startInstallation(String name, long size, boolean readOnly) {
+ public Session createPartition(String name, long size, boolean readOnly) {
try {
- if (mService.startInstallation(name, size, readOnly)) {
+ if (mService.createPartition(name, size, readOnly)) {
return new Session();
} else {
return null;
@@ -123,7 +136,18 @@ public class DynamicSystemManager {
throw new RuntimeException(e.toString());
}
}
-
+ /**
+ * Finish a previously started installation. Installations without a cooresponding
+ * finishInstallation() will be cleaned up during device boot.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_SYSTEM)
+ public boolean finishInstallation() {
+ try {
+ return mService.finishInstallation();
+ } catch (RemoteException e) {
+ throw new RuntimeException(e.toString());
+ }
+ }
/**
* Query the progress of the current installation operation. This can be called while the
* installation is in progress.
diff --git a/core/java/android/os/image/IDynamicSystemService.aidl b/core/java/android/os/image/IDynamicSystemService.aidl
index 75f67854743f..69cbab2c68ad 100644
--- a/core/java/android/os/image/IDynamicSystemService.aidl
+++ b/core/java/android/os/image/IDynamicSystemService.aidl
@@ -21,15 +21,26 @@ import android.gsi.GsiProgress;
interface IDynamicSystemService
{
/**
- * Start DynamicSystem installation. This call may take 60~90 seconds. The caller
+ * Start DynamicSystem installation.
+ * @return true if the call succeeds
+ */
+ boolean startInstallation();
+
+ /**
+ * Create a DSU partition. This call may take 60~90 seconds. The caller
* may use another thread to call the getStartProgress() to get the progress.
- *
* @param name The DSU partition name
* @param size Size of the DSU image in bytes
* @param readOnly True if this partition is readOnly
* @return true if the call succeeds
*/
- boolean startInstallation(@utf8InCpp String name, long size, boolean readOnly);
+ boolean createPartition(@utf8InCpp String name, long size, boolean readOnly);
+
+ /**
+ * Finish a previously started installation. Installations without
+ * a cooresponding finishInstallation() will be cleaned up during device boot.
+ */
+ boolean finishInstallation();
/**
* Query the progress of the current installation operation. This can be called while
diff --git a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java
index 738c4257d2c5..19ae97070188 100644
--- a/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java
+++ b/packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java
@@ -102,9 +102,10 @@ class InstallationAsyncTask extends AsyncTask<String, Long, Throwable> {
Thread thread =
new Thread(
() -> {
- mDynSystem.startInstallation("userdata", mUserdataSize, false);
+ mDynSystem.startInstallation();
+ mDynSystem.createPartition("userdata", mUserdataSize, false);
mInstallationSession =
- mDynSystem.startInstallation("system", mSystemSize, true);
+ mDynSystem.createPartition("system", mSystemSize, true);
});
thread.start();
@@ -157,6 +158,7 @@ class InstallationAsyncTask extends AsyncTask<String, Long, Throwable> {
reportedInstalledSize = installedSize;
}
}
+ mDynSystem.finishInstallation();
return null;
} catch (Exception e) {
diff --git a/services/core/java/com/android/server/DynamicSystemService.java b/services/core/java/com/android/server/DynamicSystemService.java
index 190e6cf2d35c..7b02b6e0ac11 100644
--- a/services/core/java/com/android/server/DynamicSystemService.java
+++ b/services/core/java/com/android/server/DynamicSystemService.java
@@ -18,7 +18,6 @@ package com.android.server;
import android.content.Context;
import android.content.pm.PackageManager;
-import android.gsi.GsiInstallParams;
import android.gsi.GsiProgress;
import android.gsi.IGsiService;
import android.gsi.IGsid;
@@ -47,6 +46,7 @@ public class DynamicSystemService extends IDynamicSystemService.Stub implements
private static final int GSID_ROUGH_TIMEOUT_MS = 8192;
private static final String PATH_DEFAULT = "/data/gsi";
private Context mContext;
+ private String mInstallPath;
private volatile IGsiService mGsiService;
DynamicSystemService(Context context) {
@@ -115,8 +115,8 @@ public class DynamicSystemService extends IDynamicSystemService.Stub implements
}
@Override
- public boolean startInstallation(String name, long size, boolean readOnly)
- throws RemoteException {
+ public boolean startInstallation() throws RemoteException {
+ IGsiService service = getGsiService();
// priority from high to low: sysprop -> sdcard -> /data
String path = SystemProperties.get("os.aot.path");
if (path.isEmpty()) {
@@ -138,14 +138,19 @@ public class DynamicSystemService extends IDynamicSystemService.Stub implements
}
Slog.i(TAG, "startInstallation -> " + path);
}
+ mInstallPath = path;
+ if (service.openInstall(path) != 0) {
+ Slog.i(TAG, "Failed to open " + path);
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean createPartition(String name, long size, boolean readOnly)
+ throws RemoteException {
IGsiService service = getGsiService();
- GsiInstallParams installParams = new GsiInstallParams();
- installParams.installDir = path;
- installParams.name = name;
- installParams.size = size;
- installParams.wipe = readOnly;
- installParams.readOnly = readOnly;
- if (service.beginGsiInstall(installParams) != 0) {
+ if (service.createPartition(name, size, readOnly) != 0) {
Slog.i(TAG, "Failed to install " + name);
return false;
}
@@ -153,6 +158,16 @@ public class DynamicSystemService extends IDynamicSystemService.Stub implements
}
@Override
+ public boolean finishInstallation() throws RemoteException {
+ IGsiService service = getGsiService();
+ if (service.closeInstall() != 0) {
+ Slog.i(TAG, "Failed to finish installation");
+ return false;
+ }
+ return true;
+ }
+
+ @Override
public GsiProgress getInstallationProgress() throws RemoteException {
return getGsiService().getInstallProgress();
}
@@ -190,6 +205,8 @@ public class DynamicSystemService extends IDynamicSystemService.Stub implements
@Override
public boolean remove() throws RemoteException {
+ IGsiService gsiService = getGsiService();
+ String install_dir = gsiService.getInstalledGsiImageDir();
return getGsiService().removeGsi();
}
diff --git a/services/tests/servicestests/src/com/android/server/DynamicSystemServiceTest.java b/services/tests/servicestests/src/com/android/server/DynamicSystemServiceTest.java
index 0605d9e18069..50437b4d5f3e 100644
--- a/services/tests/servicestests/src/com/android/server/DynamicSystemServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/DynamicSystemServiceTest.java
@@ -36,7 +36,7 @@ public class DynamicSystemServiceTest extends AndroidTestCase {
public void test1() {
assertTrue("dynamic_system service available", mService != null);
try {
- mService.startInstallation("userdata", 8L << 30, false);
+ mService.startInstallation();
fail("DynamicSystemService did not throw SecurityException as expected");
} catch (SecurityException e) {
// expected