Fix NPE when connect timeout

If user click connect button and then receive timeout event after leave
detail page, the NPE happened. Ignore the timeout event if activity
already gone.

Bug: 131141866
Test: manual test
Test: make RunSettingsRoboTests -j32 ROBOTEST_FILTER=com.android.settings.wifi.details.WifiDetailPreferenceControllerTest
Change-Id: Ic22c22027386d4a6de5d693eafcd9cd463ed3415
This commit is contained in:
clownshen
2019-04-24 13:52:06 +08:00
committed by Clown SHEN
parent b70f2b58e0
commit dd4764b7f4
2 changed files with 37 additions and 0 deletions

View File

@@ -1109,6 +1109,10 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
}
@Override
public void onFinish() {
if (mFragment == null || mFragment.getActivity() == null) {
Log.d(TAG, "Ignore timeout since activity not exist!");
return;
}
Log.e(TAG, "Timeout for state:" + mConnectingState);
if (mConnectingState == STATE_ENABLE_WIFI) {
updateConnectingState(STATE_ENABLE_WIFI_FAILED);