Merge changes I3f51e6ca,I8057ebb7,I63cfd666,I0580b9b6
* changes: DSU enhancement (4/N) DSU enhancement (3/N) DSU enhancement (2/N) DSU enhancement (1/N)
This commit is contained in:
@@ -202,6 +202,13 @@ public class DynamicSystemClient {
|
|||||||
public static final String ACTION_NOTIFY_IF_IN_USE =
|
public static final String ACTION_NOTIFY_IF_IN_USE =
|
||||||
"android.os.image.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
|
* Intent Keys
|
||||||
*/
|
*/
|
||||||
@@ -217,6 +224,19 @@ public class DynamicSystemClient {
|
|||||||
*/
|
*/
|
||||||
public static final String KEY_USERDATA_SIZE = "KEY_USERDATA_SIZE";
|
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 static class IncomingHandler extends Handler {
|
||||||
private final WeakReference<DynamicSystemClient> mWeakClient;
|
private final WeakReference<DynamicSystemClient> mWeakClient;
|
||||||
|
|||||||
@@ -39,6 +39,10 @@
|
|||||||
<data android:scheme="http" />
|
<data android:scheme="http" />
|
||||||
<data android:scheme="https" />
|
<data android:scheme="https" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.os.image.action.START_INSTALL" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<receiver
|
<receiver
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package com.android.dynsystem;
|
|||||||
import static android.os.AsyncTask.Status.FINISHED;
|
import static android.os.AsyncTask.Status.FINISHED;
|
||||||
import static android.os.AsyncTask.Status.PENDING;
|
import static android.os.AsyncTask.Status.PENDING;
|
||||||
import static android.os.AsyncTask.Status.RUNNING;
|
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_NOTIFY_IF_IN_USE;
|
||||||
import static android.os.image.DynamicSystemClient.ACTION_START_INSTALL;
|
import static android.os.image.DynamicSystemClient.ACTION_START_INSTALL;
|
||||||
import static android.os.image.DynamicSystemClient.CAUSE_ERROR_EXCEPTION;
|
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_CANCELLED;
|
||||||
import static android.os.image.DynamicSystemClient.CAUSE_INSTALL_COMPLETED;
|
import static android.os.image.DynamicSystemClient.CAUSE_INSTALL_COMPLETED;
|
||||||
import static android.os.image.DynamicSystemClient.CAUSE_NOT_SPECIFIED;
|
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_PROGRESS;
|
||||||
import static android.os.image.DynamicSystemClient.STATUS_IN_USE;
|
import static android.os.image.DynamicSystemClient.STATUS_IN_USE;
|
||||||
import static android.os.image.DynamicSystemClient.STATUS_NOT_STARTED;
|
import static android.os.image.DynamicSystemClient.STATUS_NOT_STARTED;
|
||||||
@@ -77,8 +80,6 @@ public class DynamicSystemInstallationService extends Service
|
|||||||
|
|
||||||
private static final String TAG = "DynamicSystemInstallationService";
|
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 KEY_DSU_SLOT = "KEY_DSU_SLOT";
|
||||||
static final String DEFAULT_DSU_SLOT = "dsu";
|
static final String DEFAULT_DSU_SLOT = "dsu";
|
||||||
static final String KEY_PUBKEY = "KEY_PUBKEY";
|
static final String KEY_PUBKEY = "KEY_PUBKEY";
|
||||||
@@ -172,6 +173,8 @@ public class DynamicSystemInstallationService extends Service
|
|||||||
|
|
||||||
// This is for testing only now
|
// This is for testing only now
|
||||||
private boolean mEnableWhenCompleted;
|
private boolean mEnableWhenCompleted;
|
||||||
|
private boolean mOneShot;
|
||||||
|
private boolean mHideNotification;
|
||||||
|
|
||||||
private InstallationAsyncTask.Progress mInstallTaskProgress;
|
private InstallationAsyncTask.Progress mInstallTaskProgress;
|
||||||
private InstallationAsyncTask mInstallTask;
|
private InstallationAsyncTask mInstallTask;
|
||||||
@@ -229,6 +232,8 @@ public class DynamicSystemInstallationService extends Service
|
|||||||
executeRebootToNormalCommand();
|
executeRebootToNormalCommand();
|
||||||
} else if (ACTION_NOTIFY_IF_IN_USE.equals(action)) {
|
} else if (ACTION_NOTIFY_IF_IN_USE.equals(action)) {
|
||||||
executeNotifyIfInUseCommand();
|
executeNotifyIfInUseCommand();
|
||||||
|
} else if (ACTION_HIDE_NOTIFICATION.equals(action)) {
|
||||||
|
executeHideNotificationCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Service.START_NOT_STICKY;
|
return Service.START_NOT_STICKY;
|
||||||
@@ -318,6 +323,7 @@ public class DynamicSystemInstallationService extends Service
|
|||||||
long systemSize = intent.getLongExtra(DynamicSystemClient.KEY_SYSTEM_SIZE, 0);
|
long systemSize = intent.getLongExtra(DynamicSystemClient.KEY_SYSTEM_SIZE, 0);
|
||||||
long userdataSize = intent.getLongExtra(DynamicSystemClient.KEY_USERDATA_SIZE, 0);
|
long userdataSize = intent.getLongExtra(DynamicSystemClient.KEY_USERDATA_SIZE, 0);
|
||||||
mEnableWhenCompleted = intent.getBooleanExtra(KEY_ENABLE_WHEN_COMPLETED, false);
|
mEnableWhenCompleted = intent.getBooleanExtra(KEY_ENABLE_WHEN_COMPLETED, false);
|
||||||
|
mOneShot = intent.getBooleanExtra(KEY_ONE_SHOT, true);
|
||||||
String dsuSlot = intent.getStringExtra(KEY_DSU_SLOT);
|
String dsuSlot = intent.getStringExtra(KEY_DSU_SLOT);
|
||||||
String publicKey = intent.getStringExtra(KEY_PUBKEY);
|
String publicKey = intent.getStringExtra(KEY_PUBKEY);
|
||||||
|
|
||||||
@@ -384,9 +390,9 @@ public class DynamicSystemInstallationService extends Service
|
|||||||
boolean enabled = false;
|
boolean enabled = false;
|
||||||
|
|
||||||
if (mInstallTask != null && mInstallTask.isCompleted()) {
|
if (mInstallTask != null && mInstallTask.isCompleted()) {
|
||||||
enabled = mInstallTask.commit();
|
enabled = mInstallTask.commit(mOneShot);
|
||||||
} else if (isDynamicSystemInstalled()) {
|
} else if (isDynamicSystemInstalled()) {
|
||||||
enabled = mDynSystem.setEnable(true, true);
|
enabled = mDynSystem.setEnable(true, mOneShot);
|
||||||
} else {
|
} else {
|
||||||
Log.e(TAG, "Trying to reboot to AOT while there is no complete installation");
|
Log.e(TAG, "Trying to reboot to AOT while there is no complete installation");
|
||||||
return;
|
return;
|
||||||
@@ -439,12 +445,16 @@ public class DynamicSystemInstallationService extends Service
|
|||||||
private void executeNotifyIfInUseCommand() {
|
private void executeNotifyIfInUseCommand() {
|
||||||
switch (getStatus()) {
|
switch (getStatus()) {
|
||||||
case STATUS_IN_USE:
|
case STATUS_IN_USE:
|
||||||
|
if (!mHideNotification) {
|
||||||
startForeground(NOTIFICATION_ID,
|
startForeground(NOTIFICATION_ID,
|
||||||
buildNotification(STATUS_IN_USE, CAUSE_NOT_SPECIFIED));
|
buildNotification(STATUS_IN_USE, CAUSE_NOT_SPECIFIED));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case STATUS_READY:
|
case STATUS_READY:
|
||||||
|
if (!mHideNotification) {
|
||||||
startForeground(NOTIFICATION_ID,
|
startForeground(NOTIFICATION_ID,
|
||||||
buildNotification(STATUS_READY, CAUSE_NOT_SPECIFIED));
|
buildNotification(STATUS_READY, CAUSE_NOT_SPECIFIED));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case STATUS_IN_PROGRESS:
|
case STATUS_IN_PROGRESS:
|
||||||
break;
|
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() {
|
private void resetTaskAndStop() {
|
||||||
resetTaskAndStop(/* removeNotification= */ false);
|
resetTaskAndStop(/* removeNotification= */ false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -803,7 +803,7 @@ class InstallationAsyncTask extends AsyncTask<String, Long, Throwable> {
|
|||||||
return mIsCompleted;
|
return mIsCompleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean commit() {
|
boolean commit(boolean oneShot) {
|
||||||
return mDynSystem.setEnable(true, true);
|
return mDynSystem.setEnable(true, oneShot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user