Skip to content
Commit da0524f0 authored by Peter Collingbourne's avatar Peter Collingbourne
Browse files

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
parent 1ee3e70c
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment