Loading core/java/android/os/image/DynamicSystemClient.java +20 −0 Original line number Diff line number Diff line Loading @@ -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 */ Loading @@ -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; Loading packages/DynamicSystemInstallationService/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,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 Loading packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java +28 −8 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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"; Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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; Loading @@ -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); } Loading packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java +2 −2 Original line number Diff line number Diff line Loading @@ -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); } } Loading
core/java/android/os/image/DynamicSystemClient.java +20 −0 Original line number Diff line number Diff line Loading @@ -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 */ Loading @@ -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; Loading
packages/DynamicSystemInstallationService/AndroidManifest.xml +4 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,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 Loading
packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java +28 −8 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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"; Loading Loading @@ -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; Loading Loading @@ -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; Loading Loading @@ -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); Loading Loading @@ -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; Loading Loading @@ -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; Loading @@ -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); } Loading
packages/DynamicSystemInstallationService/src/com/android/dynsystem/InstallationAsyncTask.java +2 −2 Original line number Diff line number Diff line Loading @@ -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); } }