Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 318729c

Browse files
author
Emmanuel Garcia
committed
Merge branch 'master' into nnbd_update
2 parents 7bc1151 + f608743 commit 318729c

File tree

82 files changed

+2217
-765
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2217
-765
lines changed

packages/camera/CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## 0.5.8+11
2+
3+
* Fix rare nullptr exception on Android.
4+
* Updated README.md with information about handling App lifecycle changes.
5+
6+
## 0.5.8+10
7+
8+
* Suppress the `deprecated_member_use` warning in the example app for `ScaffoldMessenger.showSnackBar`.
9+
110
## 0.5.8+9
211

312
* Update android compileSdkVersion to 29.

packages/camera/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@ Change the minimum Android sdk version to 21 (or higher) in your `android/app/bu
4141
minSdkVersion 21
4242
```
4343

44+
### Handling Lifecycle states
45+
46+
As of version [0.5.0](https://github.com/flutter/plugins/blob/master/packages/camera/CHANGELOG.md#050) of the camera plugin, lifecycle changes are no longer handled by the plugin. This means developers are now responsible to control camera resources when the lifecycle state is updated. Failure to do so might lead to unexpected behavior (for example as described in issue [#39109](https://github.com/flutter/flutter/issues/39109)). Handling lifecycle changes can be done by overriding the `didChangeAppLifecycleState` method like so:
47+
48+
```dart
49+
@override
50+
void didChangeAppLifecycleState(AppLifecycleState state) {
51+
// App state changed before we got the chance to initialize.
52+
if (controller == null || !controller.value.isInitialized) {
53+
return;
54+
}
55+
if (state == AppLifecycleState.inactive) {
56+
controller?.dispose();
57+
} else if (state == AppLifecycleState.resumed) {
58+
if (controller != null) {
59+
onNewCameraSelected(controller.description);
60+
}
61+
}
62+
}
63+
```
64+
4465
### Example
4566

4667
Here is a small example flutter app displaying a full screen camera preview.

packages/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,8 @@ public void resumeVideoRecording(@NonNull final Result result) {
410410
}
411411

412412
public void startPreview() throws CameraAccessException {
413+
if (pictureImageReader == null || pictureImageReader.getSurface() == null) return;
414+
413415
createCaptureSession(CameraDevice.TEMPLATE_PREVIEW, pictureImageReader.getSurface());
414416
}
415417

packages/camera/example/lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ class _CameraExampleHomeState extends State<CameraExampleHome>
272272
String timestamp() => DateTime.now().millisecondsSinceEpoch.toString();
273273

274274
void showInSnackBar(String message) {
275+
// ignore: deprecated_member_use
275276
_scaffoldKey.currentState.showSnackBar(SnackBar(content: Text(message)));
276277
}
277278

packages/camera/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: camera
22
description: A Flutter plugin for getting information about and controlling the
33
camera on Android and iOS. Supports previewing the camera feed, capturing images, capturing video,
44
and streaming image buffers to dart.
5-
version: 0.5.8+9
5+
version: 0.5.8+11
66

77
homepage: https://github.com/flutter/plugins/tree/master/packages/camera
88

packages/connectivity/connectivity/CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
## 2.0.0
2+
3+
* [Breaking Change] The `getWifiName`, `getWifiBSSID` and `getWifiIP` are removed to [wifi_info_flutter](https://github.com/flutter/plugins/tree/master/packages/wifi_info_flutter)
4+
* Migration guide:
5+
6+
If you don't use any of the above APIs, your code should work as is. In addition, you can also remove `NSLocationAlwaysAndWhenInUseUsageDescription` and `NSLocationWhenInUseUsageDescription` in `ios/Runner/Info.plist`
7+
8+
If you use any of the above APIs, you can find the same APIs in the [wifi_info_flutter](https://github.com/flutter/plugins/tree/master/packages/wifi_info_flutter/wifi_info_flutter) plugin.
9+
For example, to migrate `getWifiName`, use the new plugin:
10+
```dart
11+
final WifiInfo _wifiInfo = WifiInfo();
12+
final String wifiName = await _wifiInfo.getWifiName();
13+
```
14+
15+
## 1.0.0
16+
17+
* Mark wifi related code deprecated.
18+
* Announce 1.0.0!
19+
120
## 0.4.9+5
221

322
* Update android compileSdkVersion to 29.

packages/connectivity/connectivity/README.md

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ This plugin works for iOS and Android.
77
> Note that on Android, this does not guarantee connection to Internet. For instance,
88
the app might have wifi access but it might be a VPN or a hotel WiFi with no access.
99

10-
**Please set your constraint to `connectivity: '>=0.4.y+x <2.0.0'`**
11-
12-
## Backward compatible 1.0.0 version is coming
13-
The plugin has reached a stable API, we guarantee that version `1.0.0` will be backward compatible with `0.4.y+z`.
14-
Please use `connectivity: '>=0.4.y+x <2.0.0'` as your dependency constraint to allow a smoother ecosystem migration.
15-
For more details see: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
16-
1710
## Usage
1811

1912
Sample usage to check current status:
@@ -59,58 +52,6 @@ dispose() {
5952

6053
Note that connectivity changes are no longer communicated to Android apps in the background starting with Android O. *You should always check for connectivity status when your app is resumed.* The broadcast is only useful when your application is in the foreground.
6154

62-
To successfully get WiFi Name or Wi-Fi BSSID starting with Android O, ensure all of the following conditions are met:
63-
64-
* If your app is targeting Android 10 (API level 29) SDK or higher, your app has the ACCESS_FINE_LOCATION permission.
65-
66-
* If your app is targeting SDK lower than Android 10 (API level 29), your app has the ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission.
67-
68-
* Location services are enabled on the device (under Settings > Location).
69-
70-
You can get wi-fi related information using:
71-
72-
```dart
73-
import 'package:connectivity/connectivity.dart';
74-
75-
var wifiBSSID = await (Connectivity().getWifiBSSID());
76-
var wifiIP = await (Connectivity().getWifiIP());network
77-
var wifiName = await (Connectivity().getWifiName());wifi network
78-
```
79-
80-
### iOS 12
81-
82-
To use `.getWifiBSSID()` and `.getWifiName()` on iOS >= 12, the `Access WiFi information capability` in XCode must be enabled. Otherwise, both methods will return null.
83-
84-
### iOS 13
85-
86-
The methods `.getWifiBSSID()` and `.getWifiName()` utilize the [`CNCopyCurrentNetworkInfo`](https://developer.apple.com/documentation/systemconfiguration/1614126-cncopycurrentnetworkinfo) function on iOS.
87-
88-
As of iOS 13, Apple announced that these APIs will no longer return valid information.
89-
An app linked against iOS 12 or earlier receives pseudo-values such as:
90-
91-
* SSID: "Wi-Fi" or "WLAN" ("WLAN" will be returned for the China SKU).
92-
93-
* BSSID: "00:00:00:00:00:00"
94-
95-
An app linked against iOS 13 or later receives `null`.
96-
97-
The `CNCopyCurrentNetworkInfo` will work for Apps that:
98-
99-
* The app uses Core Location, and has the user’s authorization to use location information.
100-
101-
* The app uses the NEHotspotConfiguration API to configure the current Wi-Fi network.
102-
103-
* The app has active VPN configurations installed.
104-
105-
If your app falls into the last two categories, it will work as it is. If your app doesn't fall into the last two categories,
106-
and you still need to access the wifi information, you should request user's authorization to use location information.
107-
108-
There is a helper method provided in this plugin to request the location authorization: `requestLocationServiceAuthorization`.
109-
To request location authorization, make sure to add the following keys to your _Info.plist_ file, located in `<project root>/ios/Runner/Info.plist`:
110-
111-
* `NSLocationAlwaysAndWhenInUseUsageDescription` - describe why the app needs access to the user’s location information all the time (foreground and background). This is called _Privacy - Location Always and When In Use Usage Description_ in the visual editor.
112-
* `NSLocationWhenInUseUsageDescription` - describe why the app needs access to the user’s location information when the app is running in the foreground. This is called _Privacy - Location When In Use Usage Description_ in the visual editor.
113-
11455
## Getting Started
11556

11657
For help getting started with Flutter, view our online
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/connectivity/android/src/main/java/io/flutter/plugins/connectivity/Connectivity.java

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@
77
import android.net.ConnectivityManager;
88
import android.net.Network;
99
import android.net.NetworkCapabilities;
10-
import android.net.wifi.WifiInfo;
11-
import android.net.wifi.WifiManager;
1210
import android.os.Build;
1311

1412
/** Reports connectivity related information such as connectivity type and wifi information. */
1513
class Connectivity {
1614
private ConnectivityManager connectivityManager;
17-
private WifiManager wifiManager;
1815

19-
Connectivity(ConnectivityManager connectivityManager, WifiManager wifiManager) {
16+
Connectivity(ConnectivityManager connectivityManager) {
2017
this.connectivityManager = connectivityManager;
21-
this.wifiManager = wifiManager;
2218
}
2319

2420
String getNetworkType() {
@@ -40,44 +36,6 @@ String getNetworkType() {
4036
return getNetworkTypeLegacy();
4137
}
4238

43-
String getWifiName() {
44-
WifiInfo wifiInfo = getWifiInfo();
45-
String ssid = null;
46-
if (wifiInfo != null) ssid = wifiInfo.getSSID();
47-
if (ssid != null) ssid = ssid.replaceAll("\"", ""); // Android returns "SSID"
48-
return ssid;
49-
}
50-
51-
String getWifiBSSID() {
52-
WifiInfo wifiInfo = getWifiInfo();
53-
String bssid = null;
54-
if (wifiInfo != null) {
55-
bssid = wifiInfo.getBSSID();
56-
}
57-
return bssid;
58-
}
59-
60-
String getWifiIPAddress() {
61-
WifiInfo wifiInfo = null;
62-
if (wifiManager != null) wifiInfo = wifiManager.getConnectionInfo();
63-
64-
String ip = null;
65-
int i_ip = 0;
66-
if (wifiInfo != null) i_ip = wifiInfo.getIpAddress();
67-
68-
if (i_ip != 0)
69-
ip =
70-
String.format(
71-
"%d.%d.%d.%d",
72-
(i_ip & 0xff), (i_ip >> 8 & 0xff), (i_ip >> 16 & 0xff), (i_ip >> 24 & 0xff));
73-
74-
return ip;
75-
}
76-
77-
private WifiInfo getWifiInfo() {
78-
return wifiManager == null ? null : wifiManager.getConnectionInfo();
79-
}
80-
8139
@SuppressWarnings("deprecation")
8240
private String getNetworkTypeLegacy() {
8341
// handle type for Android versions less than Android 9

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,6 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
3131
case "check":
3232
result.success(connectivity.getNetworkType());
3333
break;
34-
case "wifiName":
35-
result.success(connectivity.getWifiName());
36-
break;
37-
case "wifiBSSID":
38-
result.success(connectivity.getWifiBSSID());
39-
break;
40-
case "wifiIPAddress":
41-
result.success(connectivity.getWifiIPAddress());
42-
break;
4334
default:
4435
result.notImplemented();
4536
break;

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import android.content.Context;
88
import android.net.ConnectivityManager;
9-
import android.net.wifi.WifiManager;
109
import io.flutter.embedding.engine.plugins.FlutterPlugin;
1110
import io.flutter.plugin.common.BinaryMessenger;
1211
import io.flutter.plugin.common.EventChannel;
@@ -41,10 +40,8 @@ private void setupChannels(BinaryMessenger messenger, Context context) {
4140
eventChannel = new EventChannel(messenger, "plugins.flutter.io/connectivity_status");
4241
ConnectivityManager connectivityManager =
4342
(ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
44-
WifiManager wifiManager =
45-
(WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
4643

47-
Connectivity connectivity = new Connectivity(connectivityManager, wifiManager);
44+
Connectivity connectivity = new Connectivity(connectivityManager);
4845

4946
ConnectivityMethodChannelHandler methodChannelHandler =
5047
new ConnectivityMethodChannelHandler(connectivity);

0 commit comments

Comments
 (0)