Fix force close in WiFi API test code
Enable WiFi network with empty net id, force close will occur. Add number format exception catch when parsing net id. Bug: 402260924 Change-Id: I540fdeddc7072e7a9414ac7f9d7aca348d06cd30
This commit is contained in:
@@ -164,7 +164,13 @@ public class WifiAPITest extends SettingsPreferenceFragment implements
|
|||||||
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int whichButton) {
|
public void onClick(DialogInterface dialog, int whichButton) {
|
||||||
Editable value = input.getText();
|
Editable value = input.getText();
|
||||||
|
try {
|
||||||
netid = Integer.parseInt(value.toString());
|
netid = Integer.parseInt(value.toString());
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// Invalid netid
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
mWifiManager.enableNetwork(netid, false);
|
mWifiManager.enableNetwork(netid, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user