Skip to content

Commit 740e098

Browse files
Lo_patLo_pat
Lo_pat
authored and
Lo_pat
committed
Merge branch 'master' into notta
* master: (153 commits) Roll Flutter from fd360c4 to ef5a6da (1 revision) (flutter#5298) [video_player_avfoundation] Applies the standardized transform for videos with different orientations (flutter#5069) Roll Flutter from 3752fb7 to fd360c4 (2 revisions) (flutter#5295) Roll Flutter from 3c4d7a1 to 3752fb7 (11 revisions) (flutter#5294) Add owners for Android implementations (flutter#5293) Roll Flutter from f4875ae to 3c4d7a1 (2 revisions) (flutter#5292) [video_player_web] Stop buffering when browser canPlayThrough. (flutter#5068) Roll Flutter from aa5d7b6 to f4875ae (1 revision) (flutter#5289) Roll Flutter from 44be0b8 to aa5d7b6 (12 revisions) (flutter#5286) Roll Flutter from ec8289c to 44be0b8 (2 revisions) (flutter#5284) Roll Flutter from 329ceae to ec8289c (26 revisions) (flutter#5283) [flutter_plugin_tools] Preserve Dart SDK version in all-plugins-app (flutter#5281) [webview_flutter_wkwebview] Implements the `HostApis` and methods for the `CookieManager`. (flutter#5244) [webview_flutter_wkwebview] Implement `WKNavigationDelegate.didFinishNavigation` as a proof of concept for callback methods (flutter#5199) Roll Flutter from 08e467d to 2b83332 (5 revisions) (flutter#5270) Roll Flutter from e2d1206 to 08e467d (1 revision) (flutter#5268) Roll Flutter from ff9d6e5 to e2d1206 (2 revisions) (flutter#5266) Roll Flutter from 0575932 to ff9d6e5 (1 revision) (flutter#5265) [local_auth] Refactor package to make use of new platform interface and native implementations (flutter#4701) Roll Flutter from cb968c5 to 0575932 (1 revision) (flutter#5263) ...
2 parents 4a0fd58 + 8084ac1 commit 740e098

File tree

575 files changed

+23399
-2956
lines changed

Some content is hidden

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

575 files changed

+23399
-2956
lines changed

.ci/flutter_master.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a491a81f78739dc1c801529b98239adc6a2dd361
1+
ef5a6da35a72dcd89cabb06f4e075801ea260224

.cirrus.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ flutter_upgrade_template: &FLUTTER_UPGRADE_TEMPLATE
2828
- git fetch origin
2929
# Switch to the requested channel.
3030
- git checkout $TARGET_TREEISH
31-
# When using a branch rather than a hash, reset to the upstream branch
32-
# rather than using pull, since the base image can sometimes be in a state
33-
# where it has diverged from upstream (!).
34-
- if [[ "$TARGET_TREEISH" == "$CHANNEL" ]]; then
31+
# When using a branch rather than a hash or version tag, reset to the
32+
# upstream branch rather than using pull, since the base image can sometimes
33+
# be in a state where it has diverged from upstream (!).
34+
- if [[ "$TARGET_TREEISH" == "$CHANNEL" ]] && [[ "$CHANNEL" != *"."* ]]; then
3535
- git reset --hard @{u}
3636
- fi
3737
# Run doctor to allow auditing of what version of Flutter the run is using.
@@ -101,6 +101,7 @@ task:
101101
always:
102102
format_script: ./script/tool_runner.sh format --fail-on-change
103103
pubspec_script: ./script/tool_runner.sh pubspec-check
104+
readme_script: ./script/tool_runner.sh readme-check
104105
license_script: dart $PLUGIN_TOOL license-check
105106
- name: federated_safety
106107
# This check is only meaningful for PRs, as it validates changes
@@ -138,6 +139,22 @@ task:
138139
# Restore the tree to a clean state, to avoid accidental issues if
139140
# other script steps are added to this task.
140141
- git checkout .
142+
# Does a sanity check that plugins at least pass analysis on the N-1 and N-2
143+
# versions of Flutter stable if the plugin claims to support that version.
144+
# This is to minimize accidentally making changes that break old versions
145+
# (which we don't commit to supporting, but don't want to actively break)
146+
# without updating the constraints.
147+
# Note: The versions below should be manually updated after a new stable
148+
# version comes out.
149+
- name: legacy-version-analyze
150+
depends_on: analyze
151+
env:
152+
matrix:
153+
CHANNEL: "2.5.3"
154+
CHANNEL: "2.8.1"
155+
analyze_script:
156+
- ./script/tool_runner.sh analyze --skip-if-not-supporting-flutter-version="$CHANNEL" --custom-analysis=script/configs/custom_analysis.yaml
157+
- echo "If this test fails, the minumum Flutter version should be updated"
141158
### Web tasks ###
142159
- name: web-build_all_plugins
143160
env:

.github/workflows/scorecards-analysis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ jobs:
2020

2121
steps:
2222
- name: "Checkout code"
23-
uses: actions/checkout@ec3a7ce113134d7a93b817d10a8272cb61118579 # v2.4.0
23+
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846
2424
with:
2525
persist-credentials: false
2626

2727
- name: "Run analysis"
28-
uses: ossf/scorecard-action@b614d455ee90608b5e36e3299cd50d457eb37d5f # v1.0.3
28+
uses: ossf/scorecard-action@c1aec4ac820532bab364f02a81873c555a0ba3a1
2929
with:
3030
results_file: results.sarif
3131
results_format: sarif
@@ -40,14 +40,14 @@ jobs:
4040

4141
# Upload the results as artifacts (optional).
4242
- name: "Upload artifact"
43-
uses: actions/upload-artifact@82c141cc518b40d92cc801eee768e7aafc9c2fa2 # v2.3.1
43+
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
4444
with:
4545
name: SARIF file
4646
path: results.sarif
4747
retention-days: 5
4848

4949
# Upload the results to GitHub's code scanning dashboard.
5050
- name: "Upload to code-scanning"
51-
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
51+
uses: github/codeql-action/upload-sarif@f5d822707ee6e8fb81b04a5c0040b736da22e587
5252
with:
5353
sarif_file: results.sarif

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@ Alex Li <[email protected]>
6666
Rahul Raj <[email protected]>
6767
Daniel Roek <[email protected]>
6868
TheOneWithTheBraid <[email protected]>
69+
Rulong Chen(陈汝龙) <[email protected]>

CODEOWNERS

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,18 @@ packages/webview_flutter/** @bparrishMines
99

1010
# Sub-package-level rules. These should stay last, since the last matching
1111
# entry takes precedence.
12-
packages/**/*_web/** @ditman
12+
13+
# - Web
14+
packages/**/*_web/** @ditman
15+
16+
# - Android
17+
packages/camera/android/** @camsim99
18+
packages/google_maps_flutter/android/** @GaryQian
19+
packages/google_sign_in/google_sign_in_android/** @camsim99
20+
packages/image_picker/image_picker_android/** @GaryQian
21+
packages/in_app_purchase/in_app_purchase_android/** @blasten
22+
packages/local_auth/local_auth_android/** @blasten
23+
packages/path_provider/path_provider_android/** @camsim99
24+
packages/quick_actions/quick_actions_android/** @camsim99
25+
packages/url_launcher/url_launcher_android/** @GaryQian
26+
packages/video_player/video_player_android/** @blasten

packages/camera/camera/CHANGELOG.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1-
## NEXT
1+
## 0.9.4+19
22

3-
* Minor iOS internal code cleanup related to queue helper functions.
3+
* Migrate deprecated Scaffold SnackBar methods to ScaffoldMessenger.
4+
5+
## 0.9.4+18
6+
7+
* Fixes a crash in iOS when streaming on low-performance devices.
8+
9+
## 0.9.4+17
10+
11+
* Removes obsolete information from README, and adds OS support table.
12+
13+
## 0.9.4+16
14+
15+
* Fixes a bug resulting in a `CameraAccessException` that prevents image
16+
capture on some Android devices.
17+
18+
## 0.9.4+15
19+
20+
* Uses dispatch queue for pixel buffer synchronization on iOS.
21+
* Minor iOS internal code cleanup related to queue helper functions.
422

523
## 0.9.4+14
624

packages/camera/camera/README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
A Flutter plugin for iOS, Android and Web allowing access to the device cameras.
66

7-
*Note*: This plugin is still under development, and some APIs might not be available yet. We are working on a refactor which can be followed here: [issue](https://github.com/flutter/flutter/issues/31225)
7+
| | Android | iOS | Web |
8+
|----------------|---------|----------|------------------------|
9+
| **Support** | SDK 21+ | iOS 10+* | [See `camera_web `][1] |
810

911
## Features
1012

@@ -19,22 +21,23 @@ First, add `camera` as a [dependency in your pubspec.yaml file](https://flutter.
1921

2022
### iOS
2123

22-
The camera plugin functionality works on iOS 10.0 or higher. If compiling for any version lower than 10.0,
23-
make sure to programmatically check the version of iOS running on the device before using any camera plugin features.
24+
\* The camera plugin compiles for any version of iOS, but its functionality
25+
requires iOS 10 or higher. If compiling for iOS 9, make sure to programmatically
26+
check the version of iOS running on the device before using any camera plugin features.
2427
The [device_info_plus](https://pub.dev/packages/device_info_plus) plugin, for example, can be used to check the iOS version.
2528

2629
Add two rows to the `ios/Runner/Info.plist`:
2730

2831
* one with the key `Privacy - Camera Usage Description` and a usage description.
2932
* and one with the key `Privacy - Microphone Usage Description` and a usage description.
3033

31-
Or in text format add the key:
34+
If editing `Info.plist` as text, add:
3235

3336
```xml
3437
<key>NSCameraUsageDescription</key>
35-
<string>Can I use the camera please?</string>
38+
<string>your usage description here</string>
3639
<key>NSMicrophoneUsageDescription</key>
37-
<string>Can I use the mic please?</string>
40+
<string>your usage description here</string>
3841
```
3942

4043
### Android
@@ -132,6 +135,4 @@ class _CameraAppState extends State<CameraApp> {
132135

133136
For a more elaborate usage example see [here](https://github.com/flutter/plugins/tree/main/packages/camera/camera/example).
134137

135-
*Note*: This plugin is still under development, and some APIs might not be available yet.
136-
[Feedback welcome](https://github.com/flutter/flutter/issues) and
137-
[Pull Requests](https://github.com/flutter/plugins/pulls) are most welcome!
138+
[1]: https://pub.dev/packages/camera_web#limitations-on-the-web-platform

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

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,24 @@ interface ErrorCallback {
7979
void onError(String errorCode, String errorMessage);
8080
}
8181

82+
/** A mockable wrapper for CameraDevice calls. */
83+
interface CameraDeviceWrapper {
84+
@NonNull
85+
CaptureRequest.Builder createCaptureRequest(int templateType) throws CameraAccessException;
86+
87+
@TargetApi(VERSION_CODES.P)
88+
void createCaptureSession(SessionConfiguration config) throws CameraAccessException;
89+
90+
@TargetApi(VERSION_CODES.LOLLIPOP)
91+
void createCaptureSession(
92+
@NonNull List<Surface> outputs,
93+
@NonNull CameraCaptureSession.StateCallback callback,
94+
@Nullable Handler handler)
95+
throws CameraAccessException;
96+
97+
void close();
98+
}
99+
82100
class Camera
83101
implements CameraCaptureCallback.CameraCaptureStateListener,
84102
ImageReader.OnImageAvailableListener {
@@ -114,7 +132,7 @@ class Camera
114132
/** An additional thread for running tasks that shouldn't block the UI. */
115133
private HandlerThread backgroundHandlerThread;
116134

117-
private CameraDevice cameraDevice;
135+
private CameraDeviceWrapper cameraDevice;
118136
private CameraCaptureSession captureSession;
119137
private ImageReader pictureImageReader;
120138
private ImageReader imageStreamReader;
@@ -136,6 +154,44 @@ class Camera
136154

137155
private MethodChannel.Result flutterResult;
138156

157+
/** A CameraDeviceWrapper implementation that forwards calls to a CameraDevice. */
158+
private class DefaultCameraDeviceWrapper implements CameraDeviceWrapper {
159+
private final CameraDevice cameraDevice;
160+
161+
private DefaultCameraDeviceWrapper(CameraDevice cameraDevice) {
162+
this.cameraDevice = cameraDevice;
163+
}
164+
165+
@NonNull
166+
@Override
167+
public CaptureRequest.Builder createCaptureRequest(int templateType)
168+
throws CameraAccessException {
169+
return cameraDevice.createCaptureRequest(templateType);
170+
}
171+
172+
@TargetApi(VERSION_CODES.P)
173+
@Override
174+
public void createCaptureSession(SessionConfiguration config) throws CameraAccessException {
175+
cameraDevice.createCaptureSession(config);
176+
}
177+
178+
@TargetApi(VERSION_CODES.LOLLIPOP)
179+
@SuppressWarnings("deprecation")
180+
@Override
181+
public void createCaptureSession(
182+
@NonNull List<Surface> outputs,
183+
@NonNull CameraCaptureSession.StateCallback callback,
184+
@Nullable Handler handler)
185+
throws CameraAccessException {
186+
cameraDevice.createCaptureSession(outputs, callback, backgroundHandler);
187+
}
188+
189+
@Override
190+
public void close() {
191+
cameraDevice.close();
192+
}
193+
}
194+
139195
public Camera(
140196
final Activity activity,
141197
final SurfaceTextureEntry flutterTexture,
@@ -261,7 +317,7 @@ public void open(String imageFormatGroup) throws CameraAccessException {
261317
new CameraDevice.StateCallback() {
262318
@Override
263319
public void onOpened(@NonNull CameraDevice device) {
264-
cameraDevice = device;
320+
cameraDevice = new DefaultCameraDeviceWrapper(device);
265321
try {
266322
startPreview();
267323
dartMessenger.sendCameraInitializedEvent(
@@ -584,7 +640,6 @@ public void onCaptureCompleted(
584640

585641
try {
586642
captureSession.stopRepeating();
587-
captureSession.abortCaptures();
588643
Log.i(TAG, "sending capture request");
589644
captureSession.capture(stillBuilder.build(), captureCallback, backgroundHandler);
590645
} catch (CameraAccessException e) {

packages/camera/camera/android/src/test/java/io/flutter/plugins/camera/CameraTest.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@
2222
import android.hardware.camera2.CameraCaptureSession;
2323
import android.hardware.camera2.CameraMetadata;
2424
import android.hardware.camera2.CaptureRequest;
25+
import android.hardware.camera2.params.SessionConfiguration;
26+
import android.media.ImageReader;
2527
import android.media.MediaRecorder;
2628
import android.os.Build;
2729
import android.os.Handler;
2830
import android.os.HandlerThread;
31+
import android.view.Surface;
2932
import androidx.annotation.NonNull;
33+
import androidx.annotation.Nullable;
3034
import androidx.lifecycle.LifecycleObserver;
3135
import io.flutter.embedding.engine.systemchannels.PlatformChannel;
3236
import io.flutter.plugin.common.MethodChannel;
@@ -50,11 +54,39 @@
5054
import io.flutter.plugins.camera.features.zoomlevel.ZoomLevelFeature;
5155
import io.flutter.plugins.camera.utils.TestUtils;
5256
import io.flutter.view.TextureRegistry;
57+
import java.util.ArrayList;
58+
import java.util.List;
5359
import org.junit.After;
5460
import org.junit.Before;
5561
import org.junit.Test;
5662
import org.mockito.MockedStatic;
5763

64+
class FakeCameraDeviceWrapper implements CameraDeviceWrapper {
65+
final List<CaptureRequest.Builder> captureRequests;
66+
67+
FakeCameraDeviceWrapper(List<CaptureRequest.Builder> captureRequests) {
68+
this.captureRequests = captureRequests;
69+
}
70+
71+
@NonNull
72+
@Override
73+
public CaptureRequest.Builder createCaptureRequest(int var1) {
74+
return captureRequests.remove(0);
75+
}
76+
77+
@Override
78+
public void createCaptureSession(SessionConfiguration config) {}
79+
80+
@Override
81+
public void createCaptureSession(
82+
@NonNull List<Surface> outputs,
83+
@NonNull CameraCaptureSession.StateCallback callback,
84+
@Nullable Handler handler) {}
85+
86+
@Override
87+
public void close() {}
88+
}
89+
5890
public class CameraTest {
5991
private CameraProperties mockCameraProperties;
6092
private CameraFeatureFactory mockCameraFeatureFactory;
@@ -801,6 +833,29 @@ public void startBackgroundThread_shouldNotStartNewThreadWhenAlreadyCreated() {
801833
verify(mockHandlerThread, times(1)).start();
802834
}
803835

836+
@Test
837+
public void onConverge_shouldTakePictureWithoutAbortingSession() throws CameraAccessException {
838+
ArrayList<CaptureRequest.Builder> mockRequestBuilders = new ArrayList<>();
839+
mockRequestBuilders.add(mock(CaptureRequest.Builder.class));
840+
CameraDeviceWrapper fakeCamera = new FakeCameraDeviceWrapper(mockRequestBuilders);
841+
// Stub out other features used by the flow.
842+
TestUtils.setPrivateField(camera, "cameraDevice", fakeCamera);
843+
TestUtils.setPrivateField(camera, "pictureImageReader", mock(ImageReader.class));
844+
SensorOrientationFeature mockSensorOrientationFeature =
845+
mockCameraFeatureFactory.createSensorOrientationFeature(mockCameraProperties, null, null);
846+
DeviceOrientationManager mockDeviceOrientationManager = mock(DeviceOrientationManager.class);
847+
when(mockSensorOrientationFeature.getDeviceOrientationManager())
848+
.thenReturn(mockDeviceOrientationManager);
849+
850+
// Simulate a post-precapture flow.
851+
camera.onConverged();
852+
// A picture should be taken.
853+
verify(mockCaptureSession, times(1)).capture(any(), any(), any());
854+
// The session shuold not be aborted as part of this flow, as this breaks capture on some
855+
// devices, and causes delays on others.
856+
verify(mockCaptureSession, never()).abortCaptures();
857+
}
858+
804859
private static class TestCameraFeatureFactory implements CameraFeatureFactory {
805860
private final AutoFocusFeature mockAutoFocusFeature;
806861
private final ExposureLockFeature mockExposureLockFeature;

0 commit comments

Comments
 (0)