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

Commit 567ee66

Browse files
committed
Merge branch 'upstream_master'
* upstream_master: (40 commits) [image_picker] Image picker fix camera device (flutter#3898) [flutter_plugin_tools] Improve license-check output (flutter#4154) [webview_flutter] Fix broken keyboard issue link (flutter#3266) [flutter_plugin_tools] Support format on Windows (flutter#4150) [flutter_plugin_tools] Make unit tests pass on Windows (flutter#4149) [image_picker_for_web] Migrate image_picker to package:cross_file (flutter#4083) [various] Prepare plugin repo for binding API improvements (flutter#4148) [quick_actions] Add const constructor (flutter#4131) [in_app_purchase] Add iOS currency symbol to ProductDetails (flutter#4144) [in_app_purchase] Added priceCurrencySymbol to SkuDetailsWrapper (flutter#4114) [image_picker_platform_interface] Add methods that return package:cross_file (flutter#4072) [flutter_plugin_tools] Improve and test 'format' (flutter#4145) [flutter_plugin_tools] Only check target packages in analyze (flutter#4146) [in_app_purchase] Fix crash when retrieveReceiptWithError gives an error. (flutter#4138) [video_player] Pause video when it completes (flutter#3727) [in_app_purchase] Add currencySymbol to ProductDetails (flutter#4115) [in_app_purchase] Add documentation for price change confirmations (flutter#4092) [camera] android-rework part 8: Supporting modules for final implementation (flutter#4054) [plugin_platform_interface] Fix README broken link (flutter#4143) [various] Prepare plugin repo for binding API improvements (flutter#4137) ...
2 parents 75d8b60 + cf80430 commit 567ee66

File tree

159 files changed

+7798
-2156
lines changed

Some content is hidden

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

159 files changed

+7798
-2156
lines changed

.cirrus.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ task:
168168
env:
169169
# Currently missing; see https://github.com/flutter/flutter/issues/81982
170170
# and https://github.com/flutter/flutter/issues/82211
171-
PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS: "file_selector,image_picker_for_web,shared_preferences_web"
171+
PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS: "file_selector,shared_preferences_web"
172172
matrix:
173173
CHANNEL: "master"
174174
CHANNEL: "stable"
@@ -220,7 +220,7 @@ task:
220220
- xcrun simctl list
221221
- xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-14-5 | xargs xcrun simctl boot
222222
build_script:
223-
- ./script/tool_runner.sh build-examples --ipa
223+
- ./script/tool_runner.sh build-examples --ios
224224
xctest_script:
225225
- ./script/tool_runner.sh xctest --ios --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=latest"
226226
drive_script:
@@ -248,7 +248,7 @@ task:
248248
PATH: $PATH:/usr/local/bin
249249
build_script:
250250
- flutter config --enable-macos-desktop
251-
- ./script/tool_runner.sh build-examples --macos --no-ipa
251+
- ./script/tool_runner.sh build-examples --macos
252252
xctest_script:
253253
- ./script/tool_runner.sh xctest --macos --exclude $PLUGINS_TO_EXCLUDE_MACOS_XCTESTS
254254
drive_script:

packages/battery/battery_platform_interface/test/method_channel_battery_test.dart

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ void main() {
3232
.setMockMethodCallHandler((MethodCall methodCall) async {
3333
switch (methodCall.method) {
3434
case 'listen':
35-
await ServicesBinding.instance!.defaultBinaryMessenger
35+
await _ambiguate(ServicesBinding.instance)!
36+
.defaultBinaryMessenger
3637
.handlePlatformMessage(
37-
methodChannelBattery.eventChannel.name,
38-
methodChannelBattery.eventChannel.codec
39-
.encodeSuccessEnvelope('full'),
40-
(_) {},
41-
);
38+
methodChannelBattery.eventChannel.name,
39+
methodChannelBattery.eventChannel.codec
40+
.encodeSuccessEnvelope('full'),
41+
(_) {},
42+
);
4243
break;
4344
case 'cancel':
4445
default:
@@ -61,3 +62,10 @@ void main() {
6162
});
6263
});
6364
}
65+
66+
/// This allows a value of type T or T? to be treated as a value of type T?.
67+
///
68+
/// We use this so that APIs that have become non-nullable can still be used
69+
/// with `!` and `?` on the stable branch.
70+
// TODO(ianh): Remove this once we roll stable in late 2021.
71+
T? _ambiguate<T>(T? value) => value;

packages/camera/camera/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.8.1+4
2+
3+
* Silenced warnings that may occur during build when using a very
4+
recent version of Flutter relating to null safety.
5+
16
## 0.8.1+3
27

38
* Do not change camera orientation when iOS device is flat.
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
// Copyright 2013 The Flutter 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+
package io.flutter.plugins.camera;
6+
7+
import android.hardware.camera2.CameraCaptureSession;
8+
import android.hardware.camera2.CameraCaptureSession.CaptureCallback;
9+
import android.hardware.camera2.CaptureRequest;
10+
import android.hardware.camera2.CaptureResult;
11+
import android.hardware.camera2.TotalCaptureResult;
12+
import android.util.Log;
13+
import androidx.annotation.NonNull;
14+
import io.flutter.plugins.camera.types.CaptureTimeoutsWrapper;
15+
16+
/**
17+
* A callback object for tracking the progress of a {@link android.hardware.camera2.CaptureRequest}
18+
* submitted to the camera device.
19+
*/
20+
class CameraCaptureCallback extends CaptureCallback {
21+
private static final String TAG = "CameraCaptureCallback";
22+
private final CameraCaptureStateListener cameraStateListener;
23+
private CameraState cameraState;
24+
private final CaptureTimeoutsWrapper captureTimeouts;
25+
26+
private CameraCaptureCallback(
27+
@NonNull CameraCaptureStateListener cameraStateListener,
28+
@NonNull CaptureTimeoutsWrapper captureTimeouts) {
29+
cameraState = CameraState.STATE_PREVIEW;
30+
this.cameraStateListener = cameraStateListener;
31+
this.captureTimeouts = captureTimeouts;
32+
}
33+
34+
/**
35+
* Creates a new instance of the {@link CameraCaptureCallback} class.
36+
*
37+
* @param cameraStateListener instance which will be called when the camera state changes.
38+
* @param captureTimeouts specifying the different timeout counters that should be taken into
39+
* account.
40+
* @return a configured instance of the {@link CameraCaptureCallback} class.
41+
*/
42+
public static CameraCaptureCallback create(
43+
@NonNull CameraCaptureStateListener cameraStateListener,
44+
@NonNull CaptureTimeoutsWrapper captureTimeouts) {
45+
return new CameraCaptureCallback(cameraStateListener, captureTimeouts);
46+
}
47+
48+
/**
49+
* Gets the current {@link CameraState}.
50+
*
51+
* @return the current {@link CameraState}.
52+
*/
53+
public CameraState getCameraState() {
54+
return cameraState;
55+
}
56+
57+
/**
58+
* Sets the {@link CameraState}.
59+
*
60+
* @param state the camera is currently in.
61+
*/
62+
public void setCameraState(@NonNull CameraState state) {
63+
cameraState = state;
64+
}
65+
66+
private void process(CaptureResult result) {
67+
Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
68+
Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);
69+
70+
if (cameraState != CameraState.STATE_PREVIEW) {
71+
Log.d(
72+
TAG,
73+
"CameraCaptureCallback | state: "
74+
+ cameraState
75+
+ " | afState: "
76+
+ afState
77+
+ " | aeState: "
78+
+ aeState);
79+
}
80+
81+
switch (cameraState) {
82+
case STATE_PREVIEW:
83+
{
84+
// We have nothing to do when the camera preview is working normally.
85+
break;
86+
}
87+
case STATE_WAITING_FOCUS:
88+
{
89+
if (afState == null) {
90+
return;
91+
} else if (afState == CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED
92+
|| afState == CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED) {
93+
handleWaitingFocusState(aeState);
94+
} else if (captureTimeouts.getPreCaptureFocusing().getIsExpired()) {
95+
Log.w(TAG, "Focus timeout, moving on with capture");
96+
handleWaitingFocusState(aeState);
97+
}
98+
99+
break;
100+
}
101+
case STATE_WAITING_PRECAPTURE_START:
102+
{
103+
// CONTROL_AE_STATE can be null on some devices
104+
if (aeState == null
105+
|| aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED
106+
|| aeState == CaptureResult.CONTROL_AE_STATE_PRECAPTURE
107+
|| aeState == CaptureResult.CONTROL_AE_STATE_FLASH_REQUIRED) {
108+
setCameraState(CameraState.STATE_WAITING_PRECAPTURE_DONE);
109+
} else if (captureTimeouts.getPreCaptureMetering().getIsExpired()) {
110+
Log.w(TAG, "Metering timeout waiting for pre-capture to start, moving on with capture");
111+
112+
setCameraState(CameraState.STATE_WAITING_PRECAPTURE_DONE);
113+
}
114+
break;
115+
}
116+
case STATE_WAITING_PRECAPTURE_DONE:
117+
{
118+
// CONTROL_AE_STATE can be null on some devices
119+
if (aeState == null || aeState != CaptureResult.CONTROL_AE_STATE_PRECAPTURE) {
120+
cameraStateListener.onConverged();
121+
} else if (captureTimeouts.getPreCaptureMetering().getIsExpired()) {
122+
Log.w(
123+
TAG, "Metering timeout waiting for pre-capture to finish, moving on with capture");
124+
cameraStateListener.onConverged();
125+
}
126+
127+
break;
128+
}
129+
}
130+
}
131+
132+
private void handleWaitingFocusState(Integer aeState) {
133+
// CONTROL_AE_STATE can be null on some devices
134+
if (aeState == null || aeState == CaptureRequest.CONTROL_AE_STATE_CONVERGED) {
135+
cameraStateListener.onConverged();
136+
} else {
137+
cameraStateListener.onPrecapture();
138+
}
139+
}
140+
141+
@Override
142+
public void onCaptureProgressed(
143+
@NonNull CameraCaptureSession session,
144+
@NonNull CaptureRequest request,
145+
@NonNull CaptureResult partialResult) {
146+
process(partialResult);
147+
}
148+
149+
@Override
150+
public void onCaptureCompleted(
151+
@NonNull CameraCaptureSession session,
152+
@NonNull CaptureRequest request,
153+
@NonNull TotalCaptureResult result) {
154+
process(result);
155+
}
156+
157+
/** An interface that describes the different state changes implementers can be informed about. */
158+
interface CameraCaptureStateListener {
159+
160+
/** Called when the {@link android.hardware.camera2.CaptureRequest} has been converged. */
161+
void onConverged();
162+
163+
/**
164+
* Called when the {@link android.hardware.camera2.CaptureRequest} enters the pre-capture state.
165+
*/
166+
void onPrecapture();
167+
}
168+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public interface CameraProperties {
124124
* <li>@see android.hardware.camera2.CameraMetadata.LENS_FACING_EXTERNAL
125125
* </ul>
126126
*
127-
* By default maps to the @see android.hardware.camera2.CameraCharacteristics.LENS_FACING key.
127+
* <p>By default maps to the @see android.hardware.camera2.CameraCharacteristics.LENS_FACING key.
128128
*
129129
* @return int Direction the camera faces relative to device screen.
130130
*/
@@ -216,7 +216,7 @@ public interface CameraProperties {
216216
* <li>@see android.hardware.camera2.CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL
217217
* </ul>
218218
*
219-
* By default maps to the @see
219+
* <p>By default maps to the @see
220220
* android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL key.
221221
*
222222
* @return int Level which generally classifies the overall set of the camera device
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2013 The Flutter 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+
package io.flutter.plugins.camera;
6+
7+
/**
8+
* These are the states that the camera can be in. The camera can only take one photo at a time so
9+
* this state describes the state of the camera itself. The camera works like a pipeline where we
10+
* feed it requests through. It can only process one tasks at a time.
11+
*/
12+
public enum CameraState {
13+
/** Idle, showing preview and not capturing anything. */
14+
STATE_PREVIEW,
15+
16+
/** Starting and waiting for autofocus to complete. */
17+
STATE_WAITING_FOCUS,
18+
19+
/** Start performing autoexposure. */
20+
STATE_WAITING_PRECAPTURE_START,
21+
22+
/** waiting for autoexposure to complete. */
23+
STATE_WAITING_PRECAPTURE_DONE,
24+
25+
/** Capturing an image. */
26+
STATE_CAPTURING,
27+
}

0 commit comments

Comments
 (0)