Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7898d33e authored by Howard Chen's avatar Howard Chen Committed by Gerrit Code Review
Browse files

Merge "Use new GsiInstallParams struct"

parents 634c6a51 e176c56f
Loading
Loading
Loading
Loading
+5 −4
Original line number Original line Diff line number Diff line
@@ -104,16 +104,17 @@ public class DynamicSystemManager {
     * Start DynamicSystem installation. This call may take an unbounded amount of time. The caller
     * 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.
     * may use another thread to call the getStartProgress() to get the progress.
     *
     *
     * @param systemSize system size in bytes
     * @param name The DSU partition name
     * @param userdataSize userdata size in bytes
     * @param size Size of the DSU image in bytes
     * @param readOnly True if the partition is read only, e.g. system.
     * @return {@code true} if the call succeeds. {@code false} either the device does not contain
     * @return {@code true} if the call succeeds. {@code false} either the device does not contain
     *     enough space or a DynamicSystem is currently in use where the {@link #isInUse} would be
     *     enough space or a DynamicSystem is currently in use where the {@link #isInUse} would be
     *     true.
     *     true.
     */
     */
    @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_SYSTEM)
    @RequiresPermission(android.Manifest.permission.MANAGE_DYNAMIC_SYSTEM)
    public Session startInstallation(long systemSize, long userdataSize) {
    public Session startInstallation(String name, long size, boolean readOnly) {
        try {
        try {
            if (mService.startInstallation(systemSize, userdataSize)) {
            if (mService.startInstallation(name, size, readOnly)) {
                return new Session();
                return new Session();
            } else {
            } else {
                return null;
                return null;
+4 −3
Original line number Original line Diff line number Diff line
@@ -24,11 +24,12 @@ interface IDynamicSystemService
     * Start DynamicSystem installation. This call may take 60~90 seconds. The caller
     * Start DynamicSystem installation. This call may take 60~90 seconds. The caller
     * may use another thread to call the getStartProgress() to get the progress.
     * may use another thread to call the getStartProgress() to get the progress.
     *
     *
     * @param systemSize system size in bytes
     * @param name The DSU partition name
     * @param userdataSize userdata size in bytes
     * @param size Size of the DSU image in bytes
     * @param readOnly True if this partition is readOnly
     * @return true if the call succeeds
     * @return true if the call succeeds
     */
     */
    boolean startInstallation(long systemSize, long userdataSize);
    boolean startInstallation(@utf8InCpp String name, long size, boolean readOnly);


    /**
    /**
     * Query the progress of the current installation operation. This can be called while
     * Query the progress of the current installation operation. This can be called while
+7 −5
Original line number Original line Diff line number Diff line
@@ -99,12 +99,14 @@ class InstallationAsyncTask extends AsyncTask<String, Long, Throwable> {
            // init input stream before calling startInstallation(), which takes 90 seconds.
            // init input stream before calling startInstallation(), which takes 90 seconds.
            initInputStream();
            initInputStream();


            Thread thread = new Thread(() -> {
            Thread thread =
                    new Thread(
                            () -> {
                                mDynSystem.startInstallation("userdata", mUserdataSize, false);
                                mInstallationSession =
                                mInstallationSession =
                        mDynSystem.startInstallation(mSystemSize, mUserdataSize);
                                        mDynSystem.startInstallation("system", mSystemSize, true);
                            });
                            });



            thread.start();
            thread.start();


            while (thread.isAlive()) {
            while (thread.isAlive()) {
+12 −4
Original line number Original line Diff line number Diff line
@@ -115,7 +115,8 @@ public class DynamicSystemService extends IDynamicSystemService.Stub implements
    }
    }


    @Override
    @Override
    public boolean startInstallation(long systemSize, long userdataSize) throws RemoteException {
    public boolean startInstallation(String name, long size, boolean readOnly)
            throws RemoteException {
        // priority from high to low: sysprop -> sdcard -> /data
        // priority from high to low: sysprop -> sdcard -> /data
        String path = SystemProperties.get("os.aot.path");
        String path = SystemProperties.get("os.aot.path");
        if (path.isEmpty()) {
        if (path.isEmpty()) {
@@ -137,11 +138,18 @@ public class DynamicSystemService extends IDynamicSystemService.Stub implements
            }
            }
            Slog.i(TAG, "startInstallation -> " + path);
            Slog.i(TAG, "startInstallation -> " + path);
        }
        }
        IGsiService service = getGsiService();
        GsiInstallParams installParams = new GsiInstallParams();
        GsiInstallParams installParams = new GsiInstallParams();
        installParams.installDir = path;
        installParams.installDir = path;
        installParams.gsiSize = systemSize;
        installParams.name = name;
        installParams.userdataSize = userdataSize;
        installParams.size = size;
        return getGsiService().beginGsiInstall(installParams) == 0;
        installParams.wipe = readOnly;
        installParams.readOnly = readOnly;
        if (service.beginGsiInstall(installParams) != 0) {
            Slog.i(TAG, "Failed to install " + name);
            return false;
        }
        return true;
    }
    }


    @Override
    @Override
+1 −1
Original line number Original line Diff line number Diff line
@@ -36,7 +36,7 @@ public class DynamicSystemServiceTest extends AndroidTestCase {
    public void test1() {
    public void test1() {
        assertTrue("dynamic_system service available", mService != null);
        assertTrue("dynamic_system service available", mService != null);
        try {
        try {
            mService.startInstallation(1 << 20, 8 << 30);
            mService.startInstallation("userdata", 8L << 30, false);
            fail("DynamicSystemService did not throw SecurityException as expected");
            fail("DynamicSystemService did not throw SecurityException as expected");
        } catch (SecurityException e) {
        } catch (SecurityException e) {
            // expected
            // expected