Tethering: Don't crash if wifi unavailable.
r.android.com/1213016 seems to have caused the following crash on devices without wifi: FATAL EXCEPTION: main Process: com.android.networkstack.process, PID: 1041 java.lang.RuntimeException: Unable to create service com.android.server.connectivity.tethering.TetheringService: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.net.wifi.WifiManager.registerSoftApCallback(java.util.concurrent.Executor, android.net.wifi.WifiManager$SoftApCallback)' on a null object reference at android.app.ActivityThread.handleCreateService(ActivityThread.java:4005) at android.app.ActivityThread.access$1500(ActivityThread.java:220) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1891) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:216) at android.app.ActivityThread.main(ActivityThread.java:7396) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:949) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.net.wifi.WifiManager.registerSoftApCallback(java.util.concurrent.Executor, android.net.wifi.WifiManager$SoftApCallback)' on a null object reference at com.android.server.connectivity.tethering.Tethering.<init>(Tethering.java:317) at com.android.server.connectivity.tethering.TetheringService.makeTethering(TetheringService.java:90) at com.android.server.connectivity.tethering.TetheringService.onCreate(TetheringService.java:81) at android.app.ActivityThread.handleCreateService(ActivityThread.java:3993) Fix it by null checking wifiManager before calling a method on it. Bug: 142352330 Change-Id: I46e2f3053a59d3dba6a186a9eed34fa63b45d03e
Loading
Please register or sign in to comment