Skip to content

Commit fadb2a6

Browse files
bwikbsswift-kim
authored andcommitted
[wifi_info_flutter] Add wifi_info_flutter_tizen package
1 parent c40bf67 commit fadb2a6

File tree

22 files changed

+655
-0
lines changed

22 files changed

+655
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
.dart_tool/
3+
4+
.packages
5+
.pub/
6+
7+
build/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0
2+
3+
* Initial release

packages/wifi_info_flutter/LICENSE

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Copyright (c) 2021 Samsung Electronics Co., Ltd. All rights reserved.
2+
Copyright (c) 2017 The Chromium Authors. All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following
11+
disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
* Neither the names of the copyright holders nor the names of the
14+
contributors may be used to endorse or promote products derived
15+
from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
21+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# wifi_info_flutter_tizen
2+
3+
The Tizen implementation of [`wifi_info_flutter`](https://github.com/flutter/plugins/tree/master/packages/wifi_info_flutter).
4+
5+
## Usage
6+
7+
This package is not an _endorsed_ implementation of `wifi_info_flutter`. Therefore, you have to include `wifi_info_flutter_tizen` alongside `wifi_info_flutter` as dependencies in your `pubspec.yaml` file.
8+
This package also requires `connectivity_tizen`. So it should be used like this:
9+
10+
```yaml
11+
dependencies:
12+
connectivity: 0.4.9+3
13+
connectivity_tizen:
14+
path: ../../../connectivity/connectivity_tizen/
15+
wifi_info_flutter: ^1.0.1
16+
wifi_info_flutter_tizen:
17+
path: ../```
18+
19+
Then you can import `wifi_info_flutter` in your Dart code:
20+
21+
```dart
22+
import 'package:wifi_info_flutter/wifi_info_flutter.dart';
23+
```
24+
25+
For detailed usage, see https://github.com/flutter/plugins/tree/master/packages/wifi_info_flutter/wifi_info_flutter#usage.
26+
27+
## Supported devices
28+
29+
This plugin is supported on these types of devices:
30+
31+
- Galaxy Watch (running Tizen 4.0 or later)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
12+
# IntelliJ related
13+
*.iml
14+
*.ipr
15+
*.iws
16+
.idea/
17+
18+
# The .vscode folder contains launch configuration and tasks you configure in
19+
# VS Code which you may wish to be included in version control, so this line
20+
# is commented out by default.
21+
#.vscode/
22+
23+
# Flutter/Dart/Pub related
24+
**/doc/api/
25+
**/ios/Flutter/.last_build_id
26+
.dart_tool/
27+
.flutter-plugins
28+
.flutter-plugins-dependencies
29+
.packages
30+
.pub-cache/
31+
.pub/
32+
/build/
33+
34+
# Web related
35+
lib/generated_plugin_registrant.dart
36+
37+
# Symbolication related
38+
app.*.symbols
39+
40+
# Obfuscation related
41+
app.*.map.json
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# wifi_info_flutter_example
2+
3+
Demonstrates how to use the wifi_info_flutter_tizen plugin.
4+
5+
## Getting Started
6+
7+
To run this app on your Tizen device, use [flutter-tizen](https://github.com/flutter-tizen/flutter-tizen).
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2020 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:io';
6+
import 'package:integration_test/integration_test.dart';
7+
import 'package:flutter_test/flutter_test.dart';
8+
import 'package:wifi_info_flutter/wifi_info_flutter.dart';
9+
10+
void main() {
11+
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
12+
13+
group('$WifiInfo test driver', () {
14+
WifiInfo _wifiInfo;
15+
16+
setUpAll(() async {
17+
_wifiInfo = WifiInfo();
18+
});
19+
20+
testWidgets('test location methods, iOS only', (WidgetTester tester) async {
21+
expect(
22+
(await _wifiInfo.getLocationServiceAuthorization()),
23+
LocationAuthorizationStatus.notDetermined,
24+
);
25+
}, skip: !Platform.isIOS);
26+
});
27+
}
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
// Copyright 2020 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// ignore_for_file: public_member_api_docs
6+
7+
import 'dart:async';
8+
import 'dart:io';
9+
10+
import 'package:connectivity/connectivity.dart'
11+
show Connectivity, ConnectivityResult;
12+
import 'package:flutter/foundation.dart';
13+
import 'package:flutter/material.dart';
14+
import 'package:flutter/services.dart';
15+
import 'package:wifi_info_flutter/wifi_info_flutter.dart';
16+
17+
// Sets a platform override for desktop to avoid exceptions. See
18+
// https://flutter.dev/desktop#target-platform-override for more info.
19+
void _enablePlatformOverrideForDesktop() {
20+
if (!kIsWeb && (Platform.isWindows || Platform.isLinux)) {
21+
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
22+
}
23+
}
24+
25+
void main() {
26+
_enablePlatformOverrideForDesktop();
27+
runApp(MyApp());
28+
}
29+
30+
class MyApp extends StatelessWidget {
31+
// This widget is the root of your application.
32+
@override
33+
Widget build(BuildContext context) {
34+
return MaterialApp(
35+
title: 'Flutter Demo',
36+
theme: ThemeData(
37+
primarySwatch: Colors.blue,
38+
),
39+
home: MyHomePage(title: 'Flutter Demo Home Page'),
40+
);
41+
}
42+
}
43+
44+
class MyHomePage extends StatefulWidget {
45+
MyHomePage({Key key, this.title}) : super(key: key);
46+
47+
final String title;
48+
49+
@override
50+
_MyHomePageState createState() => _MyHomePageState();
51+
}
52+
53+
class _MyHomePageState extends State<MyHomePage> {
54+
String _connectionStatus = 'Unknown';
55+
final Connectivity _connectivity = Connectivity();
56+
final WifiInfo _wifiInfo = WifiInfo();
57+
StreamSubscription<ConnectivityResult> _connectivitySubscription;
58+
59+
@override
60+
void initState() {
61+
super.initState();
62+
initConnectivity();
63+
_connectivitySubscription =
64+
_connectivity.onConnectivityChanged.listen(_updateConnectionStatus);
65+
}
66+
67+
@override
68+
void dispose() {
69+
_connectivitySubscription.cancel();
70+
super.dispose();
71+
}
72+
73+
// Platform messages are asynchronous, so we initialize in an async method.
74+
Future<void> initConnectivity() async {
75+
ConnectivityResult result;
76+
// Platform messages may fail, so we use a try/catch PlatformException.
77+
try {
78+
result = await _connectivity.checkConnectivity();
79+
} on PlatformException catch (e) {
80+
print(e.toString());
81+
}
82+
83+
// If the widget was removed from the tree while the asynchronous platform
84+
// message was in flight, we want to discard the reply rather than calling
85+
// setState to update our non-existent appearance.
86+
if (!mounted) {
87+
return Future.value(null);
88+
}
89+
90+
return _updateConnectionStatus(result);
91+
}
92+
93+
@override
94+
Widget build(BuildContext context) {
95+
return Scaffold(
96+
appBar: AppBar(
97+
title: const Text('Connectivity example app'),
98+
),
99+
body: Center(child: Text('Connection Status: $_connectionStatus')),
100+
);
101+
}
102+
103+
Future<void> _updateConnectionStatus(ConnectivityResult result) async {
104+
switch (result) {
105+
case ConnectivityResult.wifi:
106+
String wifiName, wifiBSSID, wifiIP;
107+
108+
try {
109+
if (!kIsWeb && Platform.isIOS) {
110+
LocationAuthorizationStatus status =
111+
await _wifiInfo.getLocationServiceAuthorization();
112+
if (status == LocationAuthorizationStatus.notDetermined) {
113+
status = await _wifiInfo.requestLocationServiceAuthorization();
114+
}
115+
if (status == LocationAuthorizationStatus.authorizedAlways ||
116+
status == LocationAuthorizationStatus.authorizedWhenInUse) {
117+
wifiName = await _connectivity.getWifiName();
118+
} else {
119+
wifiName = await _connectivity.getWifiName();
120+
}
121+
} else {
122+
wifiName = await _connectivity.getWifiName();
123+
}
124+
} on PlatformException catch (e) {
125+
print(e.toString());
126+
wifiName = "Failed to get Wifi Name";
127+
}
128+
129+
try {
130+
if (!kIsWeb && Platform.isIOS) {
131+
LocationAuthorizationStatus status =
132+
await _wifiInfo.getLocationServiceAuthorization();
133+
if (status == LocationAuthorizationStatus.notDetermined) {
134+
status = await _wifiInfo.requestLocationServiceAuthorization();
135+
}
136+
if (status == LocationAuthorizationStatus.authorizedAlways ||
137+
status == LocationAuthorizationStatus.authorizedWhenInUse) {
138+
wifiBSSID = await _connectivity.getWifiBSSID();
139+
} else {
140+
wifiBSSID = await _connectivity.getWifiBSSID();
141+
}
142+
} else {
143+
wifiBSSID = await _connectivity.getWifiBSSID();
144+
}
145+
} on PlatformException catch (e) {
146+
print(e.toString());
147+
wifiBSSID = "Failed to get Wifi BSSID";
148+
}
149+
150+
try {
151+
wifiIP = await _connectivity.getWifiIP();
152+
} on PlatformException catch (e) {
153+
print(e.toString());
154+
wifiIP = "Failed to get Wifi IP";
155+
}
156+
157+
setState(() {
158+
_connectionStatus = '$result\n'
159+
'Wifi Name: $wifiName\n'
160+
'Wifi BSSID: $wifiBSSID\n'
161+
'Wifi IP: $wifiIP\n';
162+
});
163+
break;
164+
case ConnectivityResult.mobile:
165+
case ConnectivityResult.none:
166+
setState(() => _connectionStatus = result.toString());
167+
break;
168+
default:
169+
setState(() => _connectionStatus = 'Failed to get connectivity.');
170+
break;
171+
}
172+
}
173+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: wifi_info_flutter_tizen_example
2+
description: Demonstrates how to use the wifi_info_flutter_tizen_example plugin.
3+
publish_to: 'none'
4+
5+
environment:
6+
sdk: ">=2.7.0 <3.0.0"
7+
8+
dependencies:
9+
connectivity: 0.4.9+3
10+
connectivity_tizen:
11+
path: ../../connectivity/
12+
flutter:
13+
sdk: flutter
14+
wifi_info_flutter: ^1.0.1
15+
wifi_info_flutter_tizen:
16+
path: ../
17+
integration_test: ^1.0.1
18+
integration_test_tizen:
19+
path: ../../integration_test/
20+
cupertino_icons: ^1.0.0
21+
22+
dev_dependencies:
23+
flutter_test:
24+
sdk: flutter
25+
26+
flutter:
27+
uses-material-design: true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import 'package:integration_test/integration_test_driver.dart';
2+
3+
Future<void> main() => integrationDriver();

0 commit comments

Comments
 (0)