Merge "Remove legacy-flow no-op variables: max, realMax and realProgress"
diff --git a/packages/Shell/src/com/android/shell/BugreportProgressService.java b/packages/Shell/src/com/android/shell/BugreportProgressService.java
index 30ad9c5..48d405a 100644
--- a/packages/Shell/src/com/android/shell/BugreportProgressService.java
+++ b/packages/Shell/src/com/android/shell/BugreportProgressService.java
@@ -156,7 +156,6 @@
static final String EXTRA_BUGREPORT_TYPE = "android.intent.extra.BUGREPORT_TYPE";
static final String EXTRA_SCREENSHOT = "android.intent.extra.SCREENSHOT";
static final String EXTRA_ID = "android.intent.extra.ID";
- static final String EXTRA_MAX = "android.intent.extra.MAX";
static final String EXTRA_NAME = "android.intent.extra.NAME";
static final String EXTRA_TITLE = "android.intent.extra.TITLE";
static final String EXTRA_DESCRIPTION = "android.intent.extra.DESCRIPTION";
@@ -173,7 +172,6 @@
// Maximum progress displayed in %.
private static final int CAPPED_PROGRESS = 99;
- private static final int CAPPED_MAX = 100;
/** Show the progress log every this percent. */
private static final int LOG_PROGRESS_STEP = 10;
@@ -528,12 +526,10 @@
}
final String action = intent.getAction();
final int id = intent.getIntExtra(EXTRA_ID, 0);
- final int max = intent.getIntExtra(EXTRA_MAX, -1);
final String name = intent.getStringExtra(EXTRA_NAME);
if (DEBUG)
- Log.v(TAG, "action: " + action + ", name: " + name + ", id: " + id
- + ", max: " + max);
+ Log.v(TAG, "action: " + action + ", name: " + name + ", id: " + id);
switch (action) {
case INTENT_BUGREPORT_REQUESTED:
startBugreportAPI(intent);
@@ -608,7 +604,7 @@
String name = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date());
BugreportInfo info = new BugreportInfo(mContext, baseName, name,
- 100 /* max progress*/, shareTitle, shareDescription, bugreportType);
+ shareTitle, shareDescription, bugreportType);
ParcelFileDescriptor bugreportFd = info.createBugreportFd();
if (bugreportFd == null) {
@@ -662,8 +658,8 @@
* Updates the system notification for a given bugreport.
*/
private void updateProgress(BugreportInfo info) {
- if (info.max <= 0 || info.progress < 0) {
- Log.e(TAG, "Invalid progress values for " + info);
+ if (info.progress < 0) {
+ Log.e(TAG, "Invalid progress value for " + info);
return;
}
@@ -676,7 +672,7 @@
final NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMinimumFractionDigits(2);
nf.setMaximumFractionDigits(2);
- final String percentageText = nf.format((double) info.progress / info.max);
+ final String percentageText = nf.format((double) info.progress / 100);
String title = mContext.getString(R.string.bugreport_in_progress_title, info.id);
@@ -684,7 +680,7 @@
if (mIsWatch) {
nf.setMinimumFractionDigits(0);
nf.setMaximumFractionDigits(0);
- final String watchPercentageText = nf.format((double) info.progress / info.max);
+ final String watchPercentageText = nf.format((double) info.progress / 100);
title = title + "\n" + watchPercentageText;
}
@@ -695,7 +691,7 @@
.setContentTitle(title)
.setTicker(title)
.setContentText(name)
- .setProgress(info.max, info.progress, false)
+ .setProgress(100 /* max value of progress percentage */, info.progress, false)
.setOngoing(true);
// Wear and ATV bugreport doesn't need the bug info dialog, screenshot and cancel action.
@@ -724,7 +720,7 @@
.setActions(infoAction, screenshotAction, cancelAction);
}
// Show a debug log, every LOG_PROGRESS_STEP percent.
- final int progress = (info.progress * 100) / info.max;
+ final int progress = info.progress;
if ((info.progress == 0) || (info.progress >= 100) ||
((progress / LOG_PROGRESS_STEP) != (mLastProgressPercent / LOG_PROGRESS_STEP))) {
@@ -1457,7 +1453,6 @@
}
final StringBuilder buffer = new StringBuilder(action).append(" extras: ");
addExtra(buffer, intent, EXTRA_ID);
- addExtra(buffer, intent, EXTRA_MAX);
addExtra(buffer, intent, EXTRA_NAME);
addExtra(buffer, intent, EXTRA_DESCRIPTION);
addExtra(buffer, intent, EXTRA_BUGREPORT);
@@ -1761,26 +1756,11 @@
String description;
/**
- * Maximum progress of the bugreport generation as displayed by the UI.
- */
- int max;
-
- /**
- * Current progress of the bugreport generation as displayed by the UI.
+ * Current progress (in percentage) of the bugreport generation as displayed by the UI.
*/
int progress;
/**
- * Maximum progress of the bugreport generation as reported by dumpstate.
- */
- int realMax;
-
- /**
- * Current progress of the bugreport generation as reported by dumpstate.
- */
- int realProgress;
-
- /**
* Time of the last progress update.
*/
long lastUpdate = System.currentTimeMillis();
@@ -1831,12 +1811,11 @@
/**
* Constructor for tracked bugreports - typically called upon receiving BUGREPORT_REQUESTED.
*/
- BugreportInfo(Context context, String baseName, String name, int max,
+ BugreportInfo(Context context, String baseName, String name,
@Nullable String shareTitle, @Nullable String shareDescription,
@BugreportParams.BugreportMode int type) {
this.context = context;
this.name = this.initialName = name;
- this.max = this.realMax = max;
this.shareTitle = shareTitle == null ? "" : shareTitle;
this.shareDescription = shareDescription == null ? "" : shareDescription;
this.type = type;
@@ -1930,8 +1909,6 @@
@Override
public String toString() {
- final float percent = ((float) progress * 100 / max);
- final float realPercent = ((float) realProgress * 100 / realMax);
final StringBuilder builder = new StringBuilder()
.append("\tid: ").append(id)
@@ -1953,10 +1930,7 @@
return builder
.append("\n\tfile: ").append(bugreportFile)
.append("\n\tscreenshots: ").append(screenshotFiles)
- .append("\n\tprogress: ").append(progress).append("/").append(max)
- .append(" (").append(percent).append(")")
- .append("\n\treal progress: ").append(realProgress).append("/").append(realMax)
- .append(" (").append(realPercent).append(")")
+ .append("\n\tprogress: ").append(progress)
.append("\n\tlast_update: ").append(getFormattedLastUpdate())
.append("\n\taddingDetailsToZip: ").append(addingDetailsToZip)
.append(" addedDetailsToZip: ").append(addedDetailsToZip)
@@ -1974,10 +1948,7 @@
initialName = in.readString();
title = in.readString();
description = in.readString();
- max = in.readInt();
progress = in.readInt();
- realMax = in.readInt();
- realProgress = in.readInt();
lastUpdate = in.readLong();
formattedLastUpdate = in.readString();
bugreportFile = readFile(in);
@@ -2001,10 +1972,7 @@
dest.writeString(initialName);
dest.writeString(title);
dest.writeString(description);
- dest.writeInt(max);
dest.writeInt(progress);
- dest.writeInt(realMax);
- dest.writeInt(realProgress);
dest.writeLong(lastUpdate);
dest.writeString(getFormattedLastUpdate());
writeFile(dest, bugreportFile);
@@ -2055,22 +2023,13 @@
if (progress > CAPPED_PROGRESS) {
progress = CAPPED_PROGRESS;
}
- updateProgressInfo(info, progress, CAPPED_MAX);
- }
-
- private void updateProgressInfo(BugreportInfo info, int progress, int max) {
if (DEBUG) {
if (progress != info.progress) {
Log.v(TAG, "Updating progress for name " + info.name + "(id: " + info.id
+ ") from " + info.progress + " to " + progress);
}
- if (max != info.max) {
- Log.v(TAG, "Updating max progress for name " + info.name + "(id: " + info.id
- + ") from " + info.max + " to " + max);
- }
}
info.progress = progress;
- info.max = max;
info.lastUpdate = System.currentTimeMillis();
updateProgress(info);
diff --git a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
index bb298e9..b95092a 100644
--- a/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
+++ b/packages/Shell/tests/src/com/android/shell/BugreportReceiverTest.java
@@ -27,7 +27,6 @@
import static com.android.shell.BugreportPrefs.setWarningState;
import static com.android.shell.BugreportProgressService.EXTRA_BUGREPORT;
import static com.android.shell.BugreportProgressService.EXTRA_ID;
-import static com.android.shell.BugreportProgressService.EXTRA_MAX;
import static com.android.shell.BugreportProgressService.EXTRA_NAME;
import static com.android.shell.BugreportProgressService.EXTRA_SCREENSHOT;
import static com.android.shell.BugreportProgressService.INTENT_BUGREPORT_FINISHED;
@@ -144,6 +143,7 @@
private static final String DESCRIPTION = "One's description...";
private static final String DESCRIPTION2 = "...is another's treasure.";
// TODO(b/143130523): Fix (update) tests and add to presubmit
+ private static final String EXTRA_MAX = "android.intent.extra.MAX";
private static final String EXTRA_PID = "android.intent.extra.PID";
private static final String INTENT_BUGREPORT_STARTED =
"com.android.internal.intent.action.BUGREPORT_STARTED";