[Wi-Fi] Fix exception when WifiTracker2 callbacks to Wi-Fi Settings
When WifiTracker2 callbacks to Wi-Fi Settings, should check if the activity is finishing at first. Bug: 151677440 Test: make RunSettingsRoboTests -j ROBOTEST_FILTER=WifiSettings2Test Change-Id: I95737eae3f67e6471c75ba845b57af2d721d5d37
This commit is contained in:
@@ -674,11 +674,17 @@ public class WifiSettings2 extends RestrictedSettingsFragment
|
||||
|
||||
@Override
|
||||
public void onNumSavedNetworksChanged() {
|
||||
if (isFinishingOrDestroyed()) {
|
||||
return;
|
||||
}
|
||||
setAdditionalSettingsSummaries();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNumSavedSubscriptionsChanged() {
|
||||
if (isFinishingOrDestroyed()) {
|
||||
return;
|
||||
}
|
||||
setAdditionalSettingsSummaries();
|
||||
}
|
||||
|
||||
@@ -993,12 +999,10 @@ public class WifiSettings2 extends RestrictedSettingsFragment
|
||||
|
||||
@Override
|
||||
public void onFailure(int reason) {
|
||||
final Activity activity = getActivity();
|
||||
if (isFisishingOrDestroyed(activity)) {
|
||||
if (isFinishingOrDestroyed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Toast.makeText(activity, R.string.wifi_failed_connect_message, Toast.LENGTH_SHORT)
|
||||
Toast.makeText(getContext(), R.string.wifi_failed_connect_message, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
};
|
||||
@@ -1020,8 +1024,7 @@ public class WifiSettings2 extends RestrictedSettingsFragment
|
||||
|
||||
@Override
|
||||
public void onConnectResult(@ConnectStatus int status) {
|
||||
final Activity activity = getActivity();
|
||||
if (isFisishingOrDestroyed(activity)) {
|
||||
if (isFinishingOrDestroyed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1041,10 +1044,6 @@ public class WifiSettings2 extends RestrictedSettingsFragment
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isFisishingOrDestroyed(Activity activity) {
|
||||
return activity == null || activity.isFinishing() || activity.isDestroyed();
|
||||
}
|
||||
|
||||
private void launchConfigNewNetworkFragment(WifiEntry wifiEntry) {
|
||||
final Bundle bundle = new Bundle();
|
||||
bundle.putString(WifiNetworkDetailsFragment2.KEY_CHOSEN_WIFIENTRY_KEY,
|
||||
|
Reference in New Issue
Block a user