Skip to content

Commit 428809a

Browse files
Revert "Adding getWifiName to connectivity plugin (flutter#685)"
This reverts commit b5dbd8d.
1 parent 1c842fe commit 428809a

6 files changed

Lines changed: 9 additions & 73 deletions

File tree

packages/connectivity/CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
## 0.3.2
2-
3-
* Adding getWifiName() to obtain current wifi network's SSID.
4-
51
## 0.3.1
62

73
* Updated Gradle tooling to match Android Studio 3.1.2.
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
22
package="io.flutter.plugins.connectivity">
33
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
4-
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
54
</manifest>

packages/connectivity/android/src/main/java/io/flutter/plugins/connectivity/ConnectivityPlugin.java

Lines changed: 8 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
import android.content.IntentFilter;
1111
import android.net.ConnectivityManager;
1212
import android.net.NetworkInfo;
13-
import android.net.wifi.WifiInfo;
14-
import android.net.wifi.WifiManager;
1513
import io.flutter.plugin.common.EventChannel;
1614
import io.flutter.plugin.common.EventChannel.EventSink;
1715
import io.flutter.plugin.common.EventChannel.StreamHandler;
@@ -74,43 +72,18 @@ private static String getNetworkType(int type) {
7472

7573
@Override
7674
public void onMethodCall(MethodCall call, Result result) {
77-
switch (call.method) {
78-
case "check":
79-
handleCheck(call, result);
80-
break;
81-
case "wifiName":
82-
handleWifiName(call, result);
83-
break;
84-
default:
85-
result.notImplemented();
86-
break;
87-
}
88-
}
89-
90-
private void handleCheck(MethodCall call, final Result result) {
91-
NetworkInfo info = manager.getActiveNetworkInfo();
92-
if (info != null && info.isConnected()) {
93-
result.success(getNetworkType(info.getType()));
75+
if (call.method.equals("check")) {
76+
NetworkInfo info = manager.getActiveNetworkInfo();
77+
if (info != null && info.isConnected()) {
78+
result.success(getNetworkType(info.getType()));
79+
} else {
80+
result.success("none");
81+
}
9482
} else {
95-
result.success("none");
83+
result.notImplemented();
9684
}
9785
}
9886

99-
private void handleWifiName(MethodCall call, final Result result) {
100-
WifiManager wifiManager =
101-
(WifiManager) registrar.context().getSystemService(Context.WIFI_SERVICE);
102-
103-
WifiInfo wifiInfo = null;
104-
if (wifiManager != null) wifiInfo = wifiManager.getConnectionInfo();
105-
106-
String ssid = null;
107-
if (wifiInfo != null) ssid = wifiInfo.getSSID();
108-
109-
if (ssid != null) ssid = ssid.replaceAll("\"", ""); // Android returns "SSID"
110-
111-
result.success(ssid);
112-
}
113-
11487
private BroadcastReceiver createReceiver(final EventSink events) {
11588
return new BroadcastReceiver() {
11689
@Override

packages/connectivity/ios/Classes/ConnectivityPlugin.m

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66

77
#import "Reachability/Reachability.h"
88

9-
#import "SystemConfiguration/CaptiveNetwork.h"
10-
119
@interface FLTConnectivityPlugin ()<FlutterStreamHandler>
1210
@end
1311

@@ -29,20 +27,6 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
2927
[streamChannel setStreamHandler:instance];
3028
}
3129

32-
- (NSString*)getWifiName {
33-
NSString* wifiName = nil;
34-
NSArray* interFaceNames = (__bridge_transfer id)CNCopySupportedInterfaces();
35-
36-
for (NSString* name in interFaceNames) {
37-
NSDictionary* info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)name);
38-
if (info[@"SSID"]) {
39-
wifiName = info[@"SSID"];
40-
}
41-
}
42-
43-
return wifiName;
44-
}
45-
4630
- (NSString*)statusFromReachability:(Reachability*)reachability {
4731
NetworkStatus status = [reachability currentReachabilityStatus];
4832
switch (status) {
@@ -63,8 +47,6 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
6347
// and the code
6448
// gets more involved. So for now, this will do.
6549
result([self statusFromReachability:[Reachability reachabilityForInternetConnection]]);
66-
} else if ([call.method isEqualToString:@"wifiName"]) {
67-
result([self getWifiName]);
6850
} else {
6951
result(FlutterMethodNotImplemented);
7052
}

packages/connectivity/lib/connectivity.dart

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,6 @@ class Connectivity {
4242
final String result = await _methodChannel.invokeMethod('check');
4343
return _parseConnectivityResult(result);
4444
}
45-
46-
/// Obtains the wifi name (SSID) of the connected network
47-
///
48-
/// Please note that it DOESN'T WORK on emulators (returns null).
49-
///
50-
/// From android 8.0 onwards the GPS must be ON (high accuracy)
51-
/// in order to be able to obtain the SSID.
52-
Future<String> getWifiName() async {
53-
String wifiName = await _methodChannel.invokeMethod('wifiName');
54-
// as Android might return <unknown ssid>, uniforming result
55-
// our iOS implementation will return null
56-
if (wifiName == '<unknown ssid>') wifiName = null;
57-
return wifiName;
58-
}
5945
}
6046

6147
ConnectivityResult _parseConnectivityResult(String state) {

packages/connectivity/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for discovering the state of the network (WiFi &
33
mobile/cellular) connectivity on Android and iOS.
44
author: Flutter Team <[email protected]>
55
homepage: https://github.com/flutter/plugins/tree/master/packages/connectivity
6-
version: 0.3.2
6+
version: 0.3.1
77

88
flutter:
99
plugin:

0 commit comments

Comments
 (0)