Keep track of the installation status of AB updates

This allows to show the correct labels.

Change-Id: I52f42e042af0df2d091d786c03102cec352b3a5b
This commit is contained in:
Gabriele M
2017-11-30 23:41:00 +01:00
parent c5f36ee047
commit e66a8fa53a
6 changed files with 26 additions and 14 deletions

View File

@@ -79,7 +79,6 @@
<string name="list_build_version_date">LineageOS <xliff:g id="version" example="14.1">%1$s</xliff:g> - <xliff:g id="date" example="July 11, 2017">%2$s</xliff:g></string> <string name="list_build_version_date">LineageOS <xliff:g id="version" example="14.1">%1$s</xliff:g> - <xliff:g id="date" example="July 11, 2017">%2$s</xliff:g></string>
<string name="list_download_progress"><xliff:g id="filesize_without_unit" example="12.2">%1$s</xliff:g> of <xliff:g id="filesize_without_unit" example="310 MB">%2$s</xliff:g></string> <string name="list_download_progress"><xliff:g id="filesize_without_unit" example="12.2">%1$s</xliff:g> of <xliff:g id="filesize_without_unit" example="310 MB">%2$s</xliff:g></string>
<string name="list_download_progress_eta"><xliff:g id="filesize_without_unit" example="12.2">%1$s</xliff:g> of <xliff:g id="filesize_without_unit" example="310 MB">%2$s</xliff:g> - <xliff:g id="duration" example="3 minutes">%3$s</xliff:g> left</string> <string name="list_download_progress_eta"><xliff:g id="filesize_without_unit" example="12.2">%1$s</xliff:g> of <xliff:g id="filesize_without_unit" example="310 MB">%2$s</xliff:g> - <xliff:g id="duration" example="3 minutes">%3$s</xliff:g> left</string>
<string name="list_installing_update">Installing update</string>
<string name="list_verifying_update">Verifying update</string> <string name="list_verifying_update">Verifying update</string>
<string name="list_no_updates">No new updates found. To manually check for new updates, use the Refresh button.</string> <string name="list_no_updates">No new updates found. To manually check for new updates, use the Refresh button.</string>

View File

@@ -160,7 +160,10 @@ public class UpdatesListAdapter extends RecyclerView.Adapter<UpdatesListAdapter.
viewHolder.mProgressPercentage.setText(percentage); viewHolder.mProgressPercentage.setText(percentage);
} else if (mUpdaterController.isInstallingUpdate(downloadId)) { } else if (mUpdaterController.isInstallingUpdate(downloadId)) {
setButtonAction(viewHolder.mAction, Action.CANCEL_INSTALLATION, downloadId, true); setButtonAction(viewHolder.mAction, Action.CANCEL_INSTALLATION, downloadId, true);
viewHolder.mProgressText.setText(R.string.list_installing_update); viewHolder.mProgressText.setText(
update.getFinalizing() ?
R.string.finalizing_package :
R.string.preparing_ota_first_boot);
viewHolder.mProgressBar.setProgress(update.getInstallProgress()); viewHolder.mProgressBar.setProgress(update.getInstallProgress());
String percentage = NumberFormat.getPercentInstance().format( String percentage = NumberFormat.getPercentInstance().format(
update.getInstallProgress() / 100.f); update.getInstallProgress() / 100.f);

View File

@@ -67,6 +67,8 @@ class ABUpdateInstaller {
case UpdateEngine.UpdateStatusConstants.FINALIZING: { case UpdateEngine.UpdateStatusConstants.FINALIZING: {
int progress = Math.round(percent * 100); int progress = Math.round(percent * 100);
mUpdaterController.getActualUpdate(mDownloadId).setInstallProgress(progress); mUpdaterController.getActualUpdate(mDownloadId).setInstallProgress(progress);
boolean finalizing = status == UpdateEngine.UpdateStatusConstants.FINALIZING;
mUpdaterController.getActualUpdate(mDownloadId).setFinalizing(finalizing);
mUpdaterController.notifyInstallProgress(mDownloadId); mUpdaterController.notifyInstallProgress(mDownloadId);
} }
break; break;

View File

@@ -414,20 +414,15 @@ public class UpdaterService extends Service {
} }
private void handleInstallProgress(UpdateInfo update) { private void handleInstallProgress(UpdateInfo update) {
setNotificationTitle(update);
int progress = update.getInstallProgress(); int progress = update.getInstallProgress();
mNotificationBuilder.setProgress(100, progress, false); mNotificationBuilder.setProgress(100, progress, false);
String percent = NumberFormat.getPercentInstance().format(progress / 100.f);
setNotificationTitle(update); mNotificationStyle.setSummaryText(percent);
mNotificationStyle.bigText(
if (progress == 0) { update.getFinalizing() ?
mNotificationStyle.bigText(getString(R.string.finalizing_package)); getString(R.string.finalizing_package) :
mNotificationBuilder.setProgress(0, 0, true); getString(R.string.preparing_ota_first_boot));
} else {
String percent = NumberFormat.getPercentInstance().format(progress / 100.f);
mNotificationStyle.setSummaryText(percent);
mNotificationStyle.bigText(getString(R.string.preparing_ota_first_boot));
}
mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build()); mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build());
} }

View File

@@ -28,6 +28,7 @@ public class Update extends UpdateBase implements UpdateInfo {
private long mSpeed; private long mSpeed;
private int mInstallProgress; private int mInstallProgress;
private boolean mAvailableOnline; private boolean mAvailableOnline;
private boolean mIsFinalizing;
public Update() { public Update() {
} }
@@ -47,6 +48,7 @@ public class Update extends UpdateBase implements UpdateInfo {
mSpeed = update.getSpeed(); mSpeed = update.getSpeed();
mInstallProgress = update.getInstallProgress(); mInstallProgress = update.getInstallProgress();
mAvailableOnline = update.getAvailableOnline(); mAvailableOnline = update.getAvailableOnline();
mIsFinalizing = update.getFinalizing();
} }
@Override @Override
@@ -129,4 +131,13 @@ public class Update extends UpdateBase implements UpdateInfo {
public void setAvailableOnline(boolean availableOnline) { public void setAvailableOnline(boolean availableOnline) {
mAvailableOnline = availableOnline; mAvailableOnline = availableOnline;
} }
@Override
public boolean getFinalizing() {
return mIsFinalizing;
}
public void setFinalizing(boolean finalizing) {
mIsFinalizing = finalizing;
}
} }

View File

@@ -35,4 +35,6 @@ public interface UpdateInfo extends UpdateBaseInfo {
int getInstallProgress(); int getInstallProgress();
boolean getAvailableOnline(); boolean getAvailableOnline();
boolean getFinalizing();
} }