OtaDexopt: Ensure float format for progress command
The progress value will be forwarded to update_engine, which expects
a "."-based float representation. Use Locale.ROOT when printing.
Bug: 37760573
Test: m
Test: adb root && adb shell cmd otadexopt prepare && \
adb shell cmd otadexopt progress | grep 0.00
Test: Switch to German, reboot, \
adb root && adb shell cmd otadexopt prepare && \
adb shell cmd otadexopt progress | grep 0.00
Change-Id: I99ffdd3aefa77d77b73fb7b94accefc0f2eb3c0a
diff --git a/services/core/java/com/android/server/pm/OtaDexoptShellCommand.java b/services/core/java/com/android/server/pm/OtaDexoptShellCommand.java
index bbd4048..575e0f9 100644
--- a/services/core/java/com/android/server/pm/OtaDexoptShellCommand.java
+++ b/services/core/java/com/android/server/pm/OtaDexoptShellCommand.java
@@ -21,6 +21,7 @@
import android.os.ShellCommand;
import java.io.PrintWriter;
+import java.util.Locale;
class OtaDexoptShellCommand extends ShellCommand {
final IOtaDexopt mInterface;
@@ -93,7 +94,10 @@
private int runOtaProgress() throws RemoteException {
final float progress = mInterface.getProgress();
final PrintWriter pw = getOutPrintWriter();
- pw.format("%.2f", progress);
+ // Note: The float output is parsed by update_engine. It does needs to be non-localized,
+ // as it's always expected to be "0.xy," never "0,xy" or similar. So use the ROOT
+ // Locale for formatting. (b/37760573)
+ pw.format(Locale.ROOT, "%.2f", progress);
return 0;
}