Search code examples
bootandroidwifiexception

Android hangs with fatal exceptions WifiStateMachine and JavaBinder during boot process


I am experiencing crashes of the app I am developping. The crashes lead to a reboot of the system.
The annoying part is that sometimes the system is not even starting anymore. It hangs with the animation forever, not making it to the home screen. So I have to restore the whole data partition.

Logcat throws the following when the system is stopping in the boot process:
.
.
--------- beginning of crash
03-08 16:42:33.431 1031 3168 E AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: WifiStateMachine
03-08 16:42:33.431 1031 3168 E AndroidRuntime: java.lang.StringIndexOutOfBoundsException: length=0; index=0
03-08 16:42:33.431 1031 3168 E AndroidRuntime: at java.lang.String.charAt(Native Method)
03-08 16:42:33.431 1031 3168 E AndroidRuntime: at com.android.server.wifi.WifiNetworkHistory.readNetworkHistory(WifiNetworkHistory.java:352)
.
.
03-08 16:42:34.011 3850 3850 E JavaBinder: !!! FAILED BINDER TRANSACTION !!! (parcel size = 4700)
03-08 16:42:34.013 3850 3850 E AndroidRuntime: FATAL EXCEPTION: main
03-08 16:42:34.013 3850 3850 E AndroidRuntime: Process: com.android.cellbroadcastreceiver, PID: 3850
03-08 16:42:34.013 3850 3850 E AndroidRuntime: DeadSystemException: The system died; earlier logs will point to the root cause
.
.
03-08 16:42:34.069 3623 3623 E AndroidRuntime: FATAL EXCEPTION: main
03-08 16:42:34.069 3623 3623 E AndroidRuntime: Process: com.android.phone, PID: 3623
03-08 16:42:34.069 3623 3623 E AndroidRuntime: DeadSystemException: The system died; earlier logs will point to the root cause
.
.

My app is not doing anything with WiFi at all. Binder is used for any kind of inter process communication in Android. But by all means this is not my app. In this state of the boot process my app is not involved.
Perhaps there are some system files corrupted due to the crash?
As the logcat output above states "earlier logs will point to the root cause". But there are so many errors which seem to be normal. Even on a healthy system there are about 800 lines with 'E' for error...

Does anyone have a clue what's going on?
Thanks


Solution

  • The readNetworkHistory() from the log posted above pointed me to the solution:
    The file /data/misc/wifi/networkHistory.txt sometimes gets corrupted when the phone crashes. It only contains zeros.
    The solution is to simply delete this file. This can be done with TWRP, Advanced, File Manager. Or with ADB.
    The file will automatically be restored. I think it is just a copy in readable form of WifiConfiguration (see WifiNetworkHistory.java).

    This seems to be a general problem. Some time ago I had another dead system. It crashed due to a drained battery, failed to boot afterwards
    I still have the TWRP backups of it. Also here the file networkHistory.txt is corrupted.

    Hope this helps someone, Zweikeks