DSU service: Show which partition is being installed in notification

Instead of showing "Install in progress", show which partition is being
installed and the total number of partitions, for example:
"Install in progress: system partition [2/3]"

Bug: 169036106
Test: Start a DSU installation and observe the system notification
Change-Id: I81b414606b1e18109ade5a3480931b162bd2a01f
This commit is contained in:
Yi-Yo Chiang
2022-03-25 19:21:58 +08:00
parent 3a9690c357
commit 9c074f0f78

View File

@@ -486,16 +486,31 @@ public class DynamicSystemInstallationService extends Service
switch (status) {
case STATUS_IN_PROGRESS:
builder.setContentText(getString(R.string.notification_install_inprogress));
String msgInProgress = getString(R.string.notification_install_inprogress);
if (mInstallTaskProgress != null) {
if (mInstallTaskProgress == null) {
builder.setContentText(msgInProgress);
} else {
if (mInstallTaskProgress.totalPartitionNumber > 0) {
builder.setContentText(
String.format(
"%s: %s partition [%d/%d]",
msgInProgress,
mInstallTaskProgress.partitionName,
mInstallTaskProgress.partitionNumber,
mInstallTaskProgress.totalPartitionNumber));
// totalProgressPercentage is defined iff totalPartitionNumber is defined
builder.setProgress(
100,
mInstallTaskProgress.totalProgressPercentage,
/* indeterminate = */ false);
} else {
builder.setContentText(
String.format(
"%s: %s partition",
msgInProgress, mInstallTaskProgress.partitionName));
int max = 1024;
int progress = 0;