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

Commit 1d27271b authored by Chun-Wei Wang's avatar Chun-Wei Wang Committed by Automerger Merge Worker
Browse files

Merge changes I3f51e6ca,I8057ebb7,I63cfd666,I0580b9b6 am: 36dc7b98 am: 9fffabf7 am: 5a0ec14b

parents 947b03a7 5a0ec14b
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -202,6 +202,13 @@ public class DynamicSystemClient {
    public static final String ACTION_NOTIFY_IF_IN_USE =
            "android.os.image.action.NOTIFY_IF_IN_USE";

    /**
     * Intent action: hide notifications about the status of {@code DynamicSystem}.
     * @hide
     */
    public static final String ACTION_HIDE_NOTIFICATION =
            "android.os.image.action.HIDE_NOTIFICATION";

    /*
     * Intent Keys
     */
@@ -217,6 +224,19 @@ public class DynamicSystemClient {
     */
    public static final String KEY_USERDATA_SIZE = "KEY_USERDATA_SIZE";

    /**
     * Intent key: Whether to enable DynamicSystem immediately after installation is done.
     *             Note this will reboot the device automatically.
     * @hide
     */
    public static final String KEY_ENABLE_WHEN_COMPLETED = "KEY_ENABLE_WHEN_COMPLETED";

    /**
     * Intent key: Whether to leave DynamicSystem on device reboot.
     *             False indicates a sticky mode where device stays in DynamicSystem across reboots.
     * @hide
     */
    public static final String KEY_ONE_SHOT = "KEY_ONE_SHOT";

    private static class IncomingHandler extends Handler {
        private final WeakReference<DynamicSystemClient> mWeakClient;
+4 −0
Original line number Diff line number Diff line
@@ -36,6 +36,10 @@
                <data android:scheme="http" />
                <data android:scheme="https" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.os.image.action.START_INSTALL" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <receiver
+28 −8
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.dynsystem;
import static android.os.AsyncTask.Status.FINISHED;
import static android.os.AsyncTask.Status.PENDING;
import static android.os.AsyncTask.Status.RUNNING;
import static android.os.image.DynamicSystemClient.ACTION_HIDE_NOTIFICATION;
import static android.os.image.DynamicSystemClient.ACTION_NOTIFY_IF_IN_USE;
import static android.os.image.DynamicSystemClient.ACTION_START_INSTALL;
import static android.os.image.DynamicSystemClient.CAUSE_ERROR_EXCEPTION;
@@ -27,6 +28,8 @@ import static android.os.image.DynamicSystemClient.CAUSE_ERROR_IO;
import static android.os.image.DynamicSystemClient.CAUSE_INSTALL_CANCELLED;
import static android.os.image.DynamicSystemClient.CAUSE_INSTALL_COMPLETED;
import static android.os.image.DynamicSystemClient.CAUSE_NOT_SPECIFIED;
import static android.os.image.DynamicSystemClient.KEY_ENABLE_WHEN_COMPLETED;
import static android.os.image.DynamicSystemClient.KEY_ONE_SHOT;
import static android.os.image.DynamicSystemClient.STATUS_IN_PROGRESS;
import static android.os.image.DynamicSystemClient.STATUS_IN_USE;
import static android.os.image.DynamicSystemClient.STATUS_NOT_STARTED;
@@ -77,8 +80,6 @@ public class DynamicSystemInstallationService extends Service

    private static final String TAG = "DynamicSystemInstallationService";

    // TODO (b/131866826): This is currently for test only. Will move this to System API.
    static final String KEY_ENABLE_WHEN_COMPLETED = "KEY_ENABLE_WHEN_COMPLETED";
    static final String KEY_DSU_SLOT = "KEY_DSU_SLOT";
    static final String DEFAULT_DSU_SLOT = "dsu";
    static final String KEY_PUBKEY = "KEY_PUBKEY";
@@ -172,6 +173,8 @@ public class DynamicSystemInstallationService extends Service

    // This is for testing only now
    private boolean mEnableWhenCompleted;
    private boolean mOneShot;
    private boolean mHideNotification;

    private InstallationAsyncTask.Progress mInstallTaskProgress;
    private InstallationAsyncTask mInstallTask;
@@ -229,6 +232,8 @@ public class DynamicSystemInstallationService extends Service
            executeRebootToNormalCommand();
        } else if (ACTION_NOTIFY_IF_IN_USE.equals(action)) {
            executeNotifyIfInUseCommand();
        } else if (ACTION_HIDE_NOTIFICATION.equals(action)) {
            executeHideNotificationCommand();
        }

        return Service.START_NOT_STICKY;
@@ -318,6 +323,7 @@ public class DynamicSystemInstallationService extends Service
        long systemSize = intent.getLongExtra(DynamicSystemClient.KEY_SYSTEM_SIZE, 0);
        long userdataSize = intent.getLongExtra(DynamicSystemClient.KEY_USERDATA_SIZE, 0);
        mEnableWhenCompleted = intent.getBooleanExtra(KEY_ENABLE_WHEN_COMPLETED, false);
        mOneShot = intent.getBooleanExtra(KEY_ONE_SHOT, true);
        String dsuSlot = intent.getStringExtra(KEY_DSU_SLOT);
        String publicKey = intent.getStringExtra(KEY_PUBKEY);

@@ -384,9 +390,9 @@ public class DynamicSystemInstallationService extends Service
        boolean enabled = false;

        if (mInstallTask != null && mInstallTask.isCompleted()) {
            enabled = mInstallTask.commit();
            enabled = mInstallTask.commit(mOneShot);
        } else if (isDynamicSystemInstalled()) {
            enabled = mDynSystem.setEnable(true, true);
            enabled = mDynSystem.setEnable(true, mOneShot);
        } else {
            Log.e(TAG, "Trying to reboot to AOT while there is no complete installation");
            return;
@@ -439,12 +445,16 @@ public class DynamicSystemInstallationService extends Service
    private void executeNotifyIfInUseCommand() {
        switch (getStatus()) {
            case STATUS_IN_USE:
                if (!mHideNotification) {
                    startForeground(NOTIFICATION_ID,
                            buildNotification(STATUS_IN_USE, CAUSE_NOT_SPECIFIED));
                }
                break;
            case STATUS_READY:
                if (!mHideNotification) {
                    startForeground(NOTIFICATION_ID,
                            buildNotification(STATUS_READY, CAUSE_NOT_SPECIFIED));
                }
                break;
            case STATUS_IN_PROGRESS:
                break;
@@ -454,6 +464,16 @@ public class DynamicSystemInstallationService extends Service
        }
    }

    private void executeHideNotificationCommand() {
        mHideNotification = true;
        switch (getStatus()) {
            case STATUS_IN_USE:
            case STATUS_READY:
                stopForeground(STOP_FOREGROUND_REMOVE);
                break;
        }
    }

    private void resetTaskAndStop() {
        resetTaskAndStop(/* removeNotification= */ false);
    }
+2 −2
Original line number Diff line number Diff line
@@ -803,7 +803,7 @@ class InstallationAsyncTask extends AsyncTask<String, Long, Throwable> {
        return mIsCompleted;
    }

    boolean commit() {
        return mDynSystem.setEnable(true, true);
    boolean commit(boolean oneShot) {
        return mDynSystem.setEnable(true, oneShot);
    }
}