Resolved Security App crashes when setting mobile data usage for apps


Jan 8, 2019
9
15
Xiaomi.eu 9.2.28
Device - Vince (Redmi 5 Plus)
Security App crashes when setting mobile data usage for apps


java.lang.NumberFormatException: For input string: "0,0"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
at java.lang.Float.parseFloat(Float.java:452)
at com.miui.networkassistant.ui.view.AppDetailTrafficView.dividerX(Unknown Source:24)
at com.miui.networkassistant.ui.view.AppDetailTrafficView.setData(Unknown Source:31)
at com.miui.networkassistant.ui.fragment.ShowAppDetailFragment.applyTrafficData(Unknown Source:179)
at com.miui.networkassistant.ui.fragment.ShowAppDetailFragment.-wrap2(Unknown Source:0)
at com.miui.networkassistant.ui.fragment.ShowAppDetailFragment$7.onPostExecute(Unknown Source:18)
at com.miui.networkassistant.ui.fragment.ShowAppDetailFragment$7.onPostExecute(Unknown Source:2)
at android.os.AsyncTask.finish(Unknown Source:14)
at android.os.AsyncTask.-wrap1(Unknown Source:0)
at android.os.AsyncTask$InternalHandler.handleMessage(Unknown Source:17)
at android.os.Handler.dispatchMessage(Unknown Source:21)
at android.os.Looper.loop(Unknown Source:155)
at android.app.ActivityThread.main(Unknown Source:65)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(Unknown Source:11)
at com.android.internal.os.ZygoteInit.main(Unknown Source:345)
 
Mention the display language you are using, and a video recording of the exact place of the problem would be helpful.
 
Confirmed this issue on many language, included my language. Except English. Finding translation error

Step in English (of course no issue for english):
Security -> Data usage -> Restrict data usage -> Click on any app
 
I found it crash on this value, but didnt found the string. Could you tell me what to do next @Igor Eisberg, thanks
When I'm using my language, it throw
java.lang.NumberFormatException: For input string: "2,5" (comma)
But in English it show 2.5 (dot)
 

Attachments

  • bug.png
    bug.png
    98.8 KB · Views: 411
I found it crash on this value, but didnt found the string. Could you tell me what to do next @Igor Eisberg, thanks
When I'm using my language, it throw
java.lang.NumberFormatException: For input string: "2,5" (comma)
But in English it show 2.5 (dot)
I tried Turkish, Polish and Vietnamese and couldn't make it crash...
Screenshot_2019-03-02-11-38-13-048_com.miui.securitycenter.png
 
Hi @Igor Eisberg, I've found something:

On my Mi8SE, method com.miui.networkassistant.ui.view.AppDetailTrafficView.dividerX has changed from 9.1.24 (I didnt compare with 9.2.21 or 9.2.15, too lazy to download again, sorry)
New method parse float from string to do some math, but in some language, float number is divide by comma(,), so it crash

When I replace this method from 9.1.24 to 9.3.1, no more crash

On Mi6 9.2.28, this method is the same with Mi8SE 9.1.24, so Mi6 didn't crash

I think this issue related to Xiaomi, on some device
 
Hi @Igor Eisberg, I've found something:

On my Mi8SE, method com.miui.networkassistant.ui.view.AppDetailTrafficView.dividerX has changed from 9.1.24 (I didnt compare with 9.2.21 or 9.2.15, too lazy to download again, sorry)
New method parse float from string to do some math, but in some language, float number is divide by comma(,), so it crash

When I replace this method from 9.1.24 to 9.3.1, no more crash

On Mi6 9.2.28, this method is the same with Mi8SE 9.1.24, so Mi6 didn't crash

I think this issue related to Xiaomi, on some device
We'll see what we can do, shouldn't be hard to fix. Thanks for the report and investigation.
 
The issue actually originates in method "textFormat" in FormatBytesUtil class.
They used String.format, without specifying a locale, so the method uses the user-selected Locale and placing a comma when applicable.
However, Float.parseFloat recognizes only a period as a decimal separator.
The solution is simple: Instead of Float.parseFloat(string), I used the locale-aware NumberFormat class like so: NumberFormat.getInstance().parse(string).floatValue().
Crash solved, and you will still see your locale-specific decimal separator in the data usage graphs like before.