Merge "Publish system update info when updates are in progress" into main

This commit is contained in:
Pawan Wagh
2024-01-30 21:28:58 +00:00
committed by Gerrit Code Review

View File

@@ -176,6 +176,7 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen
public void on16kPagesDialogDismissed() {} public void on16kPagesDialogDismissed() {}
private void installUpdate() { private void installUpdate() {
// Check if there is any pending system update
SystemUpdateManager manager = mContext.getSystemService(SystemUpdateManager.class); SystemUpdateManager manager = mContext.getSystemService(SystemUpdateManager.class);
Bundle data = manager.retrieveSystemUpdateInfo(); Bundle data = manager.retrieveSystemUpdateInfo();
int status = data.getInt(SystemUpdateManager.KEY_STATUS); int status = data.getInt(SystemUpdateManager.KEY_STATUS);
@@ -184,6 +185,10 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen
throw new RuntimeException("System has pending update!"); throw new RuntimeException("System has pending update!");
} }
// Publish system update info
PersistableBundle info = createUpdateInfo(SystemUpdateManager.STATUS_IN_PROGRESS);
manager.updateSystemUpdateInfo(info);
String updateFilePath = mEnable16k ? OTA_16K_PATH : OTA_4K_PATH; String updateFilePath = mEnable16k ? OTA_16K_PATH : OTA_4K_PATH;
try { try {
File updateFile = new File(updateFilePath); File updateFile = new File(updateFilePath);
@@ -315,10 +320,10 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen
mEnable16k ? ENABLE_16K_PAGE_SIZE : ENABLE_4K_PAGE_SIZE); mEnable16k ? ENABLE_16K_PAGE_SIZE : ENABLE_4K_PAGE_SIZE);
// Publish system update info // Publish system update info
SystemUpdateManager manager = SystemUpdateManager manager = mContext.getSystemService(SystemUpdateManager.class);
(SystemUpdateManager) PersistableBundle info =
mContext.getSystemService(Context.SYSTEM_UPDATE_SERVICE); createUpdateInfo(SystemUpdateManager.STATUS_WAITING_REBOOT);
manager.updateSystemUpdateInfo(getUpdateInfo()); manager.updateSystemUpdateInfo(info);
// Restart device to complete update // Restart device to complete update
PowerManager pm = mContext.getSystemService(PowerManager.class); PowerManager pm = mContext.getSystemService(PowerManager.class);
@@ -345,10 +350,9 @@ public class Enable16kPagesPreferenceController extends DeveloperOptionsPreferen
return builder.create(); return builder.create();
} }
private PersistableBundle getUpdateInfo() { private PersistableBundle createUpdateInfo(int status) {
PersistableBundle infoBundle = new PersistableBundle(); PersistableBundle infoBundle = new PersistableBundle();
infoBundle.putInt( infoBundle.putInt(SystemUpdateManager.KEY_STATUS, status);
SystemUpdateManager.KEY_STATUS, SystemUpdateManager.STATUS_WAITING_REBOOT);
infoBundle.putBoolean(SystemUpdateManager.KEY_IS_SECURITY_UPDATE, false); infoBundle.putBoolean(SystemUpdateManager.KEY_IS_SECURITY_UPDATE, false);
infoBundle.putString(SystemUpdateManager.KEY_TITLE, EXPERIMENTAL_UPDATE_TITLE); infoBundle.putString(SystemUpdateManager.KEY_TITLE, EXPERIMENTAL_UPDATE_TITLE);
return infoBundle; return infoBundle;