Skip to content

Commit 1e59632

Browse files
authored
Handle wifi info retrieve failure case (#274)
1 parent f986a25 commit 1e59632

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

packages/network_info_plus/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,7 @@
88
* Add gateway ip address information.
99
* Add broadcast information.
1010
* Add subnet mask information.
11+
12+
## 1.1.1
13+
14+
* Fix app crash when wifi info is not available.

packages/network_info_plus/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This package is not an _endorsed_ implementation of `network_info_plus`. Therefo
99
```yaml
1010
dependencies:
1111
network_info_plus: ^2.0.2
12-
network_info_plus_tizen: ^1.1.0
12+
network_info_plus_tizen: ^1.1.1
1313
```
1414
1515
Then you can import `network_info_plus` in your Dart code:

packages/network_info_plus/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: network_info_plus_tizen
22
description: Tizen implementation of the network_info_plus plugin
33
homepage: https://github.com/flutter-tizen/plugins
44
repository: https://github.com/flutter-tizen/plugins/tree/master/packages/network_info_plus
5-
version: 1.1.0
5+
version: 1.1.1
66

77
flutter:
88
plugin:

packages/network_info_plus/tizen/src/network_info_plus_tizen_plugin.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class NetworkInfoPlusTizenPlugin : public flutter::Plugin {
9292
result->Error("-1", "Initialization failed");
9393
return;
9494
}
95-
std::string reply = "";
95+
std::string reply;
9696
if (method_call.method_name().compare("wifiName") == 0) {
9797
reply = GetWifiInfo(WifiInfoType::ESSID);
9898
} else if (method_call.method_name().compare("wifiBSSID") == 0) {
@@ -108,14 +108,17 @@ class NetworkInfoPlusTizenPlugin : public flutter::Plugin {
108108
} else if (method_call.method_name().compare("wifiBroadcast") == 0) {
109109
std::string ipv4 = GetWifiInfo(WifiInfoType::IPV4);
110110
std::string subnet_mask = GetWifiInfo(WifiInfoType::SUBNET_MASK);
111-
reply = IntegerToDottedDecimal(DottedDecimalToInteger(ipv4) |
112-
~DottedDecimalToInteger(subnet_mask));
111+
if (!ipv4.empty() && !subnet_mask.empty()) {
112+
reply = IntegerToDottedDecimal(DottedDecimalToInteger(ipv4) |
113+
~DottedDecimalToInteger(subnet_mask));
114+
}
113115
} else {
114116
result->NotImplemented();
115117
return;
116118
}
117119
if (reply.length() == 0) {
118120
result->Error("-1", "Not valid result");
121+
LOG_ERROR("Could not retrieve %s.", method_call.method_name().c_str());
119122
return;
120123
}
121124
flutter::EncodableValue msg(reply);

0 commit comments

Comments
 (0)