Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
126 commits
Select commit Hold shift + click to select a range
947e34c
[flutter_markdown] Replace deprecated API (#6134)
stuartmorgan-g Feb 20, 2024
8bba41b
Roll Flutter from 064c340baf0e to 5129806e6c63 (9 revisions) (#6164)
engine-flutter-autoroll Feb 20, 2024
b21dce5
[web] Updates package:web dependency to ^0.5.0. (#5791)
kevmoo Feb 20, 2024
48048f6
[google_sign_in_web] Updates package:web dependency to 0.5.0. (#6167)
ditman Feb 20, 2024
cd5d7d8
[local_auth] Switch iOS endorsement to `local_auth_darwin` (#6107)
stuartmorgan-g Feb 21, 2024
e88ca69
[camera_android_camerax] Fix typo in readme (#6143)
Bassiuz Feb 21, 2024
5f44e3d
[url_launcher] Remove `renderView` usage (#6137)
stuartmorgan-g Feb 21, 2024
9c15ec5
[ci] Run Windows Arm64 build tests post-submit (#6166)
loic-sharma Feb 21, 2024
ed046de
[flutter_markdown] Support wasm (#6168)
kevmoo Feb 21, 2024
ccb27be
[various] Commit Windows build migrations (#6175)
stuartmorgan-g Feb 21, 2024
83d7fc6
[camerax] Implements `setFocusPoint`, `setExposurePoint`, `setExposur…
camsim99 Feb 21, 2024
784190c
[camerax] Modifies initialized camera info to reflect default AF/AE m…
camsim99 Feb 21, 2024
1c11001
[in_app_purchase] Convert refreshReceipt(), startObservingPaymentQueu…
LouiseHsu Feb 21, 2024
291d9d9
Manual roll Flutter (stable) from bae5e49bc2a8 to abb292a07e20 (1 rev…
engine-flutter-autoroll Feb 22, 2024
078c2a3
Manual roll Flutter from 5129806e6c63 to efee280cfa93 (47 revisions) …
engine-flutter-autoroll Feb 22, 2024
ff587b7
Roll Flutter from efee280cfa93 to 41581c9a1b90 (1 revision) (#6181)
engine-flutter-autoroll Feb 22, 2024
67470fc
[two_dimensional_scrollables] Fix layout offset of merged pinned cell…
Piinks Feb 22, 2024
7df2085
[web] Removes a few deprecated API usages. (#6177)
ditman Feb 22, 2024
f191932
Bump github/codeql-action from 3.24.3 to 3.24.4 (#6184)
dependabot[bot] Feb 23, 2024
74eeb29
[camera] Document -1 return value for `getExposureOffsetStepSize` (#6…
camsim99 Feb 23, 2024
fe6111b
Roll Flutter from 41581c9a1b90 to 39585e66c11f (31 revisions) (#6194)
engine-flutter-autoroll Feb 23, 2024
41f5a16
Roll Flutter from 39585e66c11f to f6c10820fa30 (20 revisions) (#6200)
engine-flutter-autoroll Feb 24, 2024
7f7b715
Roll Flutter from f6c10820fa30 to 1e8dd1e4d6d7 (3 revisions) (#6203)
engine-flutter-autoroll Feb 25, 2024
25d9c9d
Bump github/codeql-action from 3.24.4 to 3.24.5 (#6204)
dependabot[bot] Feb 26, 2024
353086c
[google_map_flutter] Add style to widget - platform interface (#6197)
stuartmorgan-g Feb 26, 2024
f9171d1
Roll Flutter from 1e8dd1e4d6d7 to b77560e92a58 (8 revisions) (#6207)
engine-flutter-autoroll Feb 26, 2024
0aff69f
[tool] Ignore GeneratedPluginRegistrant.swift for `format` (#6195)
stuartmorgan-g Feb 26, 2024
6e83506
[pigeon] Fix tool hangs on verbose sub-processes (#6198)
loic-sharma Feb 26, 2024
5e03e0f
[url_launcher] Add explicit imports of UIKit (#6208)
ChristianEdwardPadilla Feb 26, 2024
91d11d6
Add `InkResponse`, `Material` and fix `Opacity` (#6199)
peixinli Feb 26, 2024
bc51dea
Roll Flutter from b77560e92a58 to c30f998eb5db (12 revisions) (#6211)
engine-flutter-autoroll Feb 27, 2024
e07eb50
[camerax] Implements `setExposureMode` (#6110)
camsim99 Feb 27, 2024
679bdd7
[pigeon] Allows kotlin generator to skip error class generation (#6183)
tarrinneal Feb 27, 2024
5ff00b2
[pigeon] Remove heap allocation in generated C++ code (#6196)
loic-sharma Feb 28, 2024
7cdcf30
[google_maps_flutter_web] Migrate to package:web (#5254)
navaronbracke Feb 28, 2024
3214a67
[google_map_flutter] Add style to widget - platform impls (#6205)
stuartmorgan-g Feb 28, 2024
ccec918
Add library annotations for js interop (#6216)
srujzs Feb 28, 2024
930318a
[google_maps_flutter] Add `style` to widget (#6192)
stuartmorgan-g Feb 28, 2024
6d02f03
Manual roll Flutter from c30f998eb5db to d00bfe820eef (32 revisions) …
engine-flutter-autoroll Feb 28, 2024
a1c5006
Roll Flutter from d00bfe820eef to e92bca3ff5d2 (15 revisions) (#6227)
engine-flutter-autoroll Feb 29, 2024
8e2202d
Roll Flutter (stable) from abb292a07e20 to 7482962148e8 (1 revision) …
engine-flutter-autoroll Feb 29, 2024
b3f10aa
[google_maps_flutter] Add support for marker clustering - platform in…
jokerttu Feb 29, 2024
268f7d5
[various] Standardize Obj-C doc comment style (#6232)
stuartmorgan-g Feb 29, 2024
a9c68b8
Bump github/codeql-action from 3.24.5 to 3.24.6 (#6234)
dependabot[bot] Mar 1, 2024
06c1fa4
[camera_avfoundation] Set highest available resolution for Resolution…
sergeidesenko Mar 1, 2024
8ccf7f6
Roll Flutter from e92bca3ff5d2 to ba719bc588ed (37 revisions) (#6235)
engine-flutter-autoroll Mar 1, 2024
0625827
Roll Flutter from ba719bc588ed to 65cd84b58885 (5 revisions) (#6239)
engine-flutter-autoroll Mar 2, 2024
05f97df
[webview_flutter] Make WebKitWebViewWidget unit tests stateless (#6228)
stuartmorgan-g Mar 4, 2024
5fed047
[flutter_markdown] Fix WidgetSpan Support in MarkdownElementBuilder (…
pzierahn Mar 5, 2024
4a9c4be
[pigeon] Separates message call code generation into separate methods…
bparrishMines Mar 5, 2024
4ece1dd
[video_player] Fix typo in readme (#6264)
Slowhand0309 Mar 5, 2024
2aa6e3f
[in_app_purchase_storekit] Fix type of error code returned from nativ…
blaugold Mar 5, 2024
4200177
Roll Flutter from 65cd84b58885 to 3b5a2ecf992d (26 revisions) (#6269)
engine-flutter-autoroll Mar 5, 2024
83b72ba
[web] Use TrustedTypes from pkg web. (#6273)
ditman Mar 5, 2024
6a4e2ff
[tool] Add features to support GCB auto-publish flow (#6218)
stuartmorgan-g Mar 5, 2024
b5fe05d
[in_app_purchase_storekit] backfill native tests for more complete te…
LouiseHsu Mar 5, 2024
10cd61c
[rfw] Change test coverage logic to enforce 100% coverage (#6272)
Hixie Mar 5, 2024
79faa24
[in_app_pur]: Bump org.json:json from 20240205 to 20240303 in /packag…
dependabot[bot] Mar 6, 2024
b097d99
[video_player_web] migrates to package:web (#5800)
balvinderz Mar 6, 2024
9b88dbc
[image_picker_for_web] migrates to package:web (#5799)
balvinderz Mar 6, 2024
cc3f2a3
Roll Flutter from 3b5a2ecf992d to 8f84f3f32ddc (18 revisions) (#6276)
engine-flutter-autoroll Mar 6, 2024
ceb3dfd
[in_app_purchase_storekit] Handle translation of errors nested in dic…
blaugold Mar 6, 2024
6701c9e
[rfw] Add support for widget builders (#5907)
tugorez Mar 6, 2024
903f03a
Roll Flutter from 8f84f3f32ddc to 471a82856d86 (27 revisions) (#6281)
engine-flutter-autoroll Mar 7, 2024
0badb43
[two_dimensional_scrollables] Fix another combo of pinned/unpinned me…
Piinks Mar 7, 2024
6860fdf
Roll Flutter (stable) from 7482962148e8 to ba3931984302 (2 revisions)…
engine-flutter-autoroll Mar 8, 2024
a10b360
Roll Flutter from 471a82856d86 to 7c89ec8bbc6d (15 revisions) (#6288)
engine-flutter-autoroll Mar 8, 2024
d489d84
[in_app_purchase_android] Add UserChoiceBilling mode. (#6162)
reidbaker Mar 8, 2024
3eb794b
Manual roll Flutter from 7c89ec8bbc6d to 3bb2e5948e7a (31 revisions) …
engine-flutter-autoroll Mar 11, 2024
1e46a6a
Roll Flutter from 7c89ec8bbc6d to 3bb2e5948e7a (31 revisions) (#6300)
engine-flutter-autoroll Mar 11, 2024
d1aeb26
Manual roll Flutter from 3bb2e5948e7a to 1ca88730a0c1 (11 revisions) …
engine-flutter-autoroll Mar 12, 2024
38711ac
Roll Flutter from 1ca88730a0c1 to 61812ca3eb13 (1 revision) (#6305)
engine-flutter-autoroll Mar 12, 2024
142a604
Bump github/codeql-action from 3.24.6 to 3.24.7 (#6310)
dependabot[bot] Mar 13, 2024
131033e
Replace deprecated UIGraphicsBeginImageContextWithOptions with UIGrap…
jmagman Mar 13, 2024
be216b6
Bump actions/checkout from 4.1.1 to 4.1.2 (#6309)
dependabot[bot] Mar 13, 2024
1601b4b
Manual roll Flutter from 61812ca3eb13 to 394269f9ea2e (6 revisions) (…
engine-flutter-autoroll Mar 13, 2024
b21c542
Support overriding `ErrorWidget.builder` (#6302)
peixinli Mar 14, 2024
2218300
[google_maps_flutter] Started dispatching platform messages from plat…
gaaclarke Mar 14, 2024
e8ab632
[image_picker_android] Fix deprecation warnings by branching based on…
gmackall Mar 14, 2024
92a8b7a
[webview_flutter_android][webview_flutter_wkwebview] Adds platform im…
bparrishMines Mar 14, 2024
0895119
[pigeon] Fixes double prefixes added to enum names for Objc HostApis …
bparrishMines Mar 14, 2024
6db47f4
[camera_web][google_maps_flutter] Fix tests throwing errors after tes…
bparrishMines Mar 15, 2024
756dcc1
[go_router] Use `leak_tracker_flutter_testing` (#6210)
ValentinVignal Mar 15, 2024
0a49d24
[pigeon]Add hellohuanlin to pigeon iOS for code reviews (#6333)
hellohuanlin Mar 15, 2024
9aa208a
[pointer_interceptor_web] Skip broken semantics tests and do a manual…
bparrishMines Mar 16, 2024
a757073
Roll Flutter from 71606af8d82e to 7c860ddf9705 (21 revisions) (#6345)
engine-flutter-autoroll Mar 17, 2024
1b9bab3
[flutter_markdown] Adds onSelectionChanged in Markdown (#6169)
leiatfly Mar 18, 2024
02128ee
Roll Flutter from 7c860ddf9705 to f217fc173918 (9 revisions) (#6350)
engine-flutter-autoroll Mar 18, 2024
a2f4ce0
[sign_in]: Bump com.google.android.gms:play-services-auth from 20.7.0…
dependabot[bot] Mar 18, 2024
52ed702
Roll Flutter from f217fc173918 to d31a85ba5c5e (23 revisions) (#6356)
engine-flutter-autoroll Mar 19, 2024
3be3ec1
[camerax] Implements `setFocusMode` (#6176)
camsim99 Mar 19, 2024
da16269
[pigeon] Adds Dart implementation of ProxyApi (#6043)
bparrishMines Mar 19, 2024
bb247f7
[flutter_markdown] Allow for custom block element (#5815)
dawidope Mar 19, 2024
23e56af
[camerax] Update README to encourage users to opt in (#6352)
camsim99 Mar 19, 2024
6975ba7
Roll Flutter from d31a85ba5c5e to b96c13d1e9ff (19 revisions) (#6359)
engine-flutter-autoroll Mar 20, 2024
8df9848
[camera_android] Update README to encourage users to use CameraX impl…
camsim99 Mar 20, 2024
b7fbe68
[adaptive_scaffold] : 🐛 #141938 - Drawer stays open even on destinati…
aliasgar4558 Mar 21, 2024
7cc7e31
[adaptive_scaffold] : 🐛 : #110902 : Assertion added when try with les…
aliasgar4558 Mar 21, 2024
352ddac
[flutter_adaptive_scaffold] Remove broken link from README (#6364)
stuartmorgan-g Mar 21, 2024
04b8ecc
Roll Flutter (stable) from ba3931984302 to 68bfaea22488 (2 revisions)…
engine-flutter-autoroll Mar 21, 2024
611aea1
Roll Flutter from b96c13d1e9ff to 18340ea16cee (26 revisions) (#6370)
engine-flutter-autoroll Mar 21, 2024
28d126c
Roll Flutter from 18340ea16cee to 14774b95c250 (20 revisions) (#6376)
engine-flutter-autoroll Mar 25, 2024
ab1630b
[pigeon] Adds @SwiftClass annotation (#6372)
tarrinneal Mar 26, 2024
333d43c
[in_app_pur]: Bump org.json:json from 20231013 to 20240303 in /packag…
dependabot[bot] Mar 26, 2024
c16c956
Roll Flutter from 14774b95c250 to dbdcead93225 (38 revisions) (#6399)
engine-flutter-autoroll Mar 26, 2024
014cf20
Bump github/codeql-action from 3.24.7 to 3.24.9 (#6386)
dependabot[bot] Mar 26, 2024
01d16a4
[flutter_lints] Updates various links (#6400)
goderbauer Mar 26, 2024
00d29b1
[google_maps_flutter] Fix ios tile overlay not loading when dealing w…
LouiseHsu Mar 27, 2024
e6b3e11
[camera]: Bump androidx.annotation:annotation from 1.7.0 to 1.7.1 in …
dependabot[bot] Mar 27, 2024
f61723b
[camerax] Use `AspectRatioStrategy` to help automatic selection of ex…
camsim99 Mar 27, 2024
72669d5
[interactive_media_ads] Creates and adds the `interactive_media_ads` …
bparrishMines Mar 27, 2024
974f284
Reverts "[interactive_media_ads] Creates and adds the `interactive_me…
auto-submit[bot] Mar 28, 2024
e234425
[ci] Temporarily allow-warnings in podspec_check_command.dart (#6416)
ditman Mar 28, 2024
924c7e6
Reverts "[ci] Temporarily allow-warnings in podspec_check_command.dar…
auto-submit[bot] Mar 28, 2024
88a02f0
[google_sign_in_ios] Pins GoogleSignIn to 7.0.0 in podspec. (#6430)
ditman Mar 28, 2024
ead738f
[interactive_media_ads] Reland "Creates and adds the interactive_medi…
bparrishMines Mar 28, 2024
c7d30e2
[go_router]: fix GoRouter.optionURLReflectsImperativeAPIs flag works …
anisovdev Mar 28, 2024
6d86800
[ci] Adds sleep 60s to release action. (#6405)
ditman Mar 28, 2024
fbf44e2
Manual roll Flutter from dbdcead93225 to 89ea49204b37 (54 revisions) …
engine-flutter-autoroll Mar 28, 2024
286c94e
[image_picker]: Bump androidx.exifinterface:exifinterface from 1.3.6 …
dependabot[bot] Mar 28, 2024
ad0274a
Manual roll Flutter (stable) from 68bfaea22488 to 300451adae58 (2 rev…
engine-flutter-autoroll Mar 29, 2024
51faaa1
[shared_preferences] Update mockito to the new version available 5.2.…
krupikivan Mar 29, 2024
302e73c
[two_dimensional_scrollables] Infinite TableView (#6411)
Piinks Mar 29, 2024
67d9025
Roll Flutter from 89ea49204b37 to 85288818b59e (11 revisions) (#6436)
engine-flutter-autoroll Mar 29, 2024
d5aff19
Roll Flutter from 85288818b59e to d12ba5c270d8 (21 revisions) (#6440)
engine-flutter-autoroll Mar 30, 2024
8fcffdd
Move integration_test dependency from regular dependencies to test de…
reidbaker Apr 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[camerax] Implements setFocusPoint, setExposurePoint, `setExposur…
…eOffset` (flutter#6059)

This PR implements `setFocusPoint`, `setExposurePoint`, `setExposureOffset` and makes some small fixes here and there, each of which I have left a comment about for context.

Part of flutter/flutter#120468 & flutter/flutter#120467.

~NOTE: Should land after flutter#6068 done :)
  • Loading branch information
camsim99 authored Feb 21, 2024
commit 83d7fc613e24a068261de934270cd1efd55d2c9e
4 changes: 4 additions & 0 deletions packages/camera/camera_android_camerax/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.0+34

* Implements `setFocusPoint`, `setExposurePoint`, and `setExposureOffset`.

## 0.5.0+33

* Fixes typo in `README.md`.
Expand Down
9 changes: 4 additions & 5 deletions packages/camera/camera_android_camerax/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,19 @@ dependencies:

## Missing features and limitations


### 240p resolution configuration for video recording

240p resolution configuration for video recording is unsupported by CameraX,
and thus, the plugin will fall back to 480p if configured with a
`ResolutionPreset`.

### Exposure mode, point, & offset configuration \[[Issue #120468][120468]\]
### Exposure mode configuration \[[Issue #120468][120468]\]

`setExposureMode`, `setExposurePoint`, & `setExposureOffset` are unimplemented.
`setExposureMode`is unimplemented.

### Focus mode & point configuration \[[Issue #120467][120467]\]
### Focus mode configuration \[[Issue #120467][120467]\]

`setFocusMode` & `setFocusPoint` are unimplemented.
`setFocusMode` is unimplemented.

### Setting maximum duration and stream options for video capture

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public final class CameraAndroidCameraxPlugin implements FlutterPlugin, Activity
@VisibleForTesting @Nullable public ImageCaptureHostApiImpl imageCaptureHostApiImpl;
@VisibleForTesting @Nullable public CameraControlHostApiImpl cameraControlHostApiImpl;
@VisibleForTesting @Nullable public SystemServicesHostApiImpl systemServicesHostApiImpl;
@VisibleForTesting @Nullable public MeteringPointHostApiImpl meteringPointHostApiImpl;

@VisibleForTesting
public @Nullable DeviceOrientationManagerHostApiImpl deviceOrientationManagerHostApiImpl;
Expand Down Expand Up @@ -119,6 +120,12 @@ public void setUp(
cameraControlHostApiImpl =
new CameraControlHostApiImpl(binaryMessenger, instanceManager, context);
GeneratedCameraXLibrary.CameraControlHostApi.setup(binaryMessenger, cameraControlHostApiImpl);
GeneratedCameraXLibrary.FocusMeteringActionHostApi.setup(
binaryMessenger, new FocusMeteringActionHostApiImpl(instanceManager));
GeneratedCameraXLibrary.FocusMeteringResultHostApi.setup(
binaryMessenger, new FocusMeteringResultHostApiImpl(instanceManager));
meteringPointHostApiImpl = new MeteringPointHostApiImpl(instanceManager);
GeneratedCameraXLibrary.MeteringPointHostApi.setup(binaryMessenger, meteringPointHostApiImpl);
}

@Override
Expand Down Expand Up @@ -238,5 +245,8 @@ public void updateActivity(@Nullable Activity activity) {
if (deviceOrientationManagerHostApiImpl != null) {
deviceOrientationManagerHostApiImpl.setActivity(activity);
}
if (meteringPointHostApiImpl != null) {
meteringPointHostApiImpl.setActivity(activity);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ public void onSuccess(Void voidResult) {
}

public void onFailure(Throwable t) {
if (t instanceof CameraControl.OperationCanceledException) {
// Operation was canceled due to camera being closed or a new request was submitted, which
// is not actionable and should not block a new value from potentially being submitted.
result.success(null);
return;
}
result.error(t);
}
},
Expand All @@ -94,6 +100,9 @@ public void onFailure(Throwable t) {
*
* <p>Will trigger an auto focus action and enable auto focus/auto exposure/auto white balance
* metering regions.
*
* <p>Will send a {@link GeneratedCameraXLibrary.Result} with a null result if operation was
* canceled.
*/
public void startFocusAndMetering(
@NonNull CameraControl cameraControl,
Expand All @@ -117,6 +126,12 @@ public void onSuccess(FocusMeteringResult focusMeteringResult) {
}

public void onFailure(Throwable t) {
if (t instanceof CameraControl.OperationCanceledException) {
// Operation was canceled due to camera being closed or a new request was submitted, which
// is not actionable and should not block a new value from potentially being submitted.
result.success(null);
return;
}
result.error(t);
}
},
Expand Down Expand Up @@ -152,6 +167,9 @@ public void onFailure(Throwable t) {
* <p>The exposure compensation value set on the camera must be within the range of {@code
* ExposureState#getExposureCompensationRange()} for the current {@code ExposureState} for the
* call to succeed.
*
* <p>Will send a {@link GeneratedCameraXLibrary.Result} with a null result if operation was
* canceled.
*/
public void setExposureCompensationIndex(
@NonNull CameraControl cameraControl, @NonNull Long index, @NonNull Result<Long> result) {
Expand All @@ -166,6 +184,12 @@ public void onSuccess(Integer integerResult) {
}

public void onFailure(Throwable t) {
if (t instanceof CameraControl.OperationCanceledException) {
// Operation was canceled due to camera being closed or a new request was submitted, which
// is not actionable and should not block a new value from potentially being submitted.
result.success(null);
return;
}
result.error(t);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ private CameraStateType(final int index) {
* <p>If you need to add another type to support a type S to use a LiveData<S> in this plugin,
* ensure the following is done on the Dart side:
*
* <p>* In `../lib/src/live_data.dart`, add new cases for S in
* <p>* In `camera_android_camerax/lib/src/live_data.dart`, add new cases for S in
* `_LiveDataHostApiImpl#getValueFromInstances` to get the current value of type S from a
* LiveData<S> instance and in `LiveDataFlutterApiImpl#create` to create the expected type of
* LiveData<S> when requested.
*
* <p>On the native side, ensure the following is done:
*
* <p>* Update `LiveDataHostApiImpl#getValue` is updated to properly return identifiers for
* <p>* Make sure `LiveDataHostApiImpl#getValue` is updated to properly return identifiers for
* instances of type S. * Update `ObserverFlutterApiWrapper#onChanged` to properly handle
* receiving calls with instances of type S if a LiveData<S> instance is observed.
*/
Expand Down Expand Up @@ -146,6 +146,24 @@ private VideoResolutionFallbackRule(final int index) {
}
}

/**
* The types of capture request options this plugin currently supports.
*
* <p>If you need to add another option to support, ensure the following is done on the Dart side:
*
* <p>* In `camera_android_camerax/lib/src/capture_request_options.dart`, add new cases for this
* option in `_CaptureRequestOptionsHostApiImpl#createFromInstances` to create the expected Map
* entry of option key index and value to send to the native side.
*
* <p>On the native side, ensure the following is done:
*
* <p>* Update `CaptureRequestOptionsHostApiImpl#create` to set the correct `CaptureRequest` key
* with a valid value type for this option.
*
* <p>See https://developer.android.com/reference/android/hardware/camera2/CaptureRequest for the
* sorts of capture request options that can be supported via CameraX's interoperability with
* Camera2.
*/
public enum CaptureRequestKeySupportedType {
CONTROL_AE_LOCK(0);

Expand Down Expand Up @@ -3899,7 +3917,11 @@ public void create(@NonNull Long identifierArg, @NonNull Reply<Void> callback) {
public interface MeteringPointHostApi {

void create(
@NonNull Long identifier, @NonNull Double x, @NonNull Double y, @Nullable Double size);
@NonNull Long identifier,
@NonNull Double x,
@NonNull Double y,
@Nullable Double size,
@NonNull Long cameraInfoId);

@NonNull
Double getDefaultPointSize();
Expand Down Expand Up @@ -3927,12 +3949,14 @@ static void setup(
Double xArg = (Double) args.get(1);
Double yArg = (Double) args.get(2);
Double sizeArg = (Double) args.get(3);
Number cameraInfoIdArg = (Number) args.get(4);
try {
api.create(
(identifierArg == null) ? null : identifierArg.longValue(),
xArg,
yArg,
sizeArg);
sizeArg,
(cameraInfoIdArg == null) ? null : cameraInfoIdArg.longValue());
wrapped.add(0, null);
} catch (Throwable exception) {
ArrayList<Object> wrappedError = wrapError(exception);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,20 @@

package io.flutter.plugins.camerax;

import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.view.Display;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.camera.core.CameraInfo;
import androidx.camera.core.DisplayOrientedMeteringPointFactory;
import androidx.camera.core.MeteringPoint;
import androidx.camera.core.MeteringPointFactory;
import androidx.camera.core.SurfaceOrientedMeteringPointFactory;
import io.flutter.plugins.camerax.GeneratedCameraXLibrary.MeteringPointHostApi;
import java.util.Objects;

/**
* Host API implementation for {@link MeteringPoint}.
Expand All @@ -25,29 +32,51 @@ public class MeteringPointHostApiImpl implements MeteringPointHostApi {
/** Proxy for constructor and static methods of {@link MeteringPoint}. */
@VisibleForTesting
public static class MeteringPointProxy {
Activity activity;

/**
* Creates a surface oriented {@link MeteringPoint} with the specified x, y, and size.
*
* <p>A {@link SurfaceOrientedMeteringPointFactory} is used to construct the {@link
* MeteringPoint} because underlying the camera preview that this plugin uses is a Flutter
* texture that is backed by a {@link Surface} created by the Flutter Android embedding.
* <p>A {@link DisplayOrientedMeteringPointFactory} is used to construct the {@link
* MeteringPoint} because this factory handles the transformation of specified coordinates based
* on camera information and the device orientation automatically.
*/
@NonNull
public MeteringPoint create(@NonNull Double x, @NonNull Double y, @Nullable Double size) {
SurfaceOrientedMeteringPointFactory factory = getSurfaceOrientedMeteringPointFactory(1f, 1f);
public MeteringPoint create(
@NonNull Double x,
@NonNull Double y,
@Nullable Double size,
@NonNull CameraInfo cameraInfo) {
Display display = null;

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
display = activity.getDisplay();
} else {
display = getDefaultDisplayForAndroidVersionBelowR(activity);
}

DisplayOrientedMeteringPointFactory factory =
getDisplayOrientedMeteringPointFactory(display, cameraInfo, 1f, 1f);

if (size == null) {
return factory.createPoint(x.floatValue(), y.floatValue());
} else {
return factory.createPoint(x.floatValue(), y.floatValue(), size.floatValue());
}
}

@NonNull
@SuppressWarnings("deprecation")
private Display getDefaultDisplayForAndroidVersionBelowR(@NonNull Activity activity) {
return ((WindowManager) activity.getSystemService(Context.WINDOW_SERVICE))
.getDefaultDisplay();
}

@VisibleForTesting
@NonNull
public SurfaceOrientedMeteringPointFactory getSurfaceOrientedMeteringPointFactory(
float width, float height) {
return new SurfaceOrientedMeteringPointFactory(width, height);
public DisplayOrientedMeteringPointFactory getDisplayOrientedMeteringPointFactory(
@NonNull Display display, @NonNull CameraInfo cameraInfo, float width, float height) {
return new DisplayOrientedMeteringPointFactory(display, cameraInfo, width, height);
}

/**
Expand Down Expand Up @@ -81,10 +110,23 @@ public MeteringPointHostApiImpl(@NonNull InstanceManager instanceManager) {
this.proxy = proxy;
}

public void setActivity(@NonNull Activity activity) {
this.proxy.activity = activity;
}

@Override
public void create(
@NonNull Long identifier, @NonNull Double x, @NonNull Double y, @Nullable Double size) {
MeteringPoint meteringPoint = proxy.create(x, y, size);
@NonNull Long identifier,
@NonNull Double x,
@NonNull Double y,
@Nullable Double size,
@NonNull Long cameraInfoId) {
MeteringPoint meteringPoint =
proxy.create(
x,
y,
size,
(CameraInfo) Objects.requireNonNull(instanceManager.getInstance(cameraInfoId)));
instanceManager.addDartCreatedInstance(meteringPoint, identifier);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public void onAttachedToActivity_setsActivityAsNeededAndPermissionsRegistry() {
mock(SystemServicesHostApiImpl.class);
final DeviceOrientationManagerHostApiImpl mockDeviceOrientationManagerHostApiImpl =
mock(DeviceOrientationManagerHostApiImpl.class);
final MeteringPointHostApiImpl mockMeteringPointHostApiImpl =
mock(MeteringPointHostApiImpl.class);
final ArgumentCaptor<PermissionsRegistry> permissionsRegistryCaptor =
ArgumentCaptor.forClass(PermissionsRegistry.class);

Expand All @@ -103,13 +105,15 @@ public void onAttachedToActivity_setsActivityAsNeededAndPermissionsRegistry() {
plugin.liveDataHostApiImpl = mock(LiveDataHostApiImpl.class);
plugin.systemServicesHostApiImpl = mockSystemServicesHostApiImpl;
plugin.deviceOrientationManagerHostApiImpl = mockDeviceOrientationManagerHostApiImpl;
plugin.meteringPointHostApiImpl = mockMeteringPointHostApiImpl;

plugin.onAttachedToEngine(flutterPluginBinding);
plugin.onAttachedToActivity(activityPluginBinding);

// Check Activity references are set.
verify(mockSystemServicesHostApiImpl).setActivity(mockActivity);
verify(mockDeviceOrientationManagerHostApiImpl).setActivity(mockActivity);
verify(mockMeteringPointHostApiImpl).setActivity(mockActivity);

// Check permissions registry reference is set.
verify(mockSystemServicesHostApiImpl)
Expand All @@ -129,11 +133,14 @@ public void onAttachedToActivity_setsActivityAsNeededAndPermissionsRegistry() {
mock(SystemServicesHostApiImpl.class);
final DeviceOrientationManagerHostApiImpl mockDeviceOrientationManagerHostApiImpl =
mock(DeviceOrientationManagerHostApiImpl.class);
final MeteringPointHostApiImpl mockMeteringPointHostApiImpl =
mock(MeteringPointHostApiImpl.class);

plugin.processCameraProviderHostApiImpl = mockProcessCameraProviderHostApiImpl;
plugin.liveDataHostApiImpl = mockLiveDataHostApiImpl;
plugin.systemServicesHostApiImpl = mockSystemServicesHostApiImpl;
plugin.deviceOrientationManagerHostApiImpl = mockDeviceOrientationManagerHostApiImpl;
plugin.meteringPointHostApiImpl = mockMeteringPointHostApiImpl;

plugin.onAttachedToEngine(flutterPluginBinding);
plugin.onDetachedFromActivityForConfigChanges();
Expand All @@ -142,6 +149,7 @@ public void onAttachedToActivity_setsActivityAsNeededAndPermissionsRegistry() {
verify(mockLiveDataHostApiImpl).setLifecycleOwner(null);
verify(mockSystemServicesHostApiImpl).setActivity(null);
verify(mockDeviceOrientationManagerHostApiImpl).setActivity(null);
verify(mockMeteringPointHostApiImpl).setActivity(null);
}

@Test
Expand Down Expand Up @@ -251,6 +259,8 @@ public void onReattachedToActivityForConfigChanges_setsActivityAndPermissionsReg
mock(CameraControlHostApiImpl.class);
final DeviceOrientationManagerHostApiImpl mockDeviceOrientationManagerHostApiImpl =
mock(DeviceOrientationManagerHostApiImpl.class);
final MeteringPointHostApiImpl mockMeteringPointHostApiImpl =
mock(MeteringPointHostApiImpl.class);
final ArgumentCaptor<PermissionsRegistry> permissionsRegistryCaptor =
ArgumentCaptor.forClass(PermissionsRegistry.class);

Expand All @@ -265,6 +275,7 @@ public void onReattachedToActivityForConfigChanges_setsActivityAndPermissionsReg
plugin.imageAnalysisHostApiImpl = mockImageAnalysisHostApiImpl;
plugin.cameraControlHostApiImpl = mockCameraControlHostApiImpl;
plugin.deviceOrientationManagerHostApiImpl = mockDeviceOrientationManagerHostApiImpl;
plugin.meteringPointHostApiImpl = mockMeteringPointHostApiImpl;
plugin.liveDataHostApiImpl = mock(LiveDataHostApiImpl.class);

plugin.onAttachedToEngine(flutterPluginBinding);
Expand All @@ -273,6 +284,7 @@ public void onReattachedToActivityForConfigChanges_setsActivityAndPermissionsReg
// Check Activity references are set.
verify(mockSystemServicesHostApiImpl).setActivity(mockActivity);
verify(mockDeviceOrientationManagerHostApiImpl).setActivity(mockActivity);
verify(mockMeteringPointHostApiImpl).setActivity(mockActivity);

// Check Activity as Context references are set.
verify(mockProcessCameraProviderHostApiImpl).setContext(mockActivity);
Expand Down Expand Up @@ -300,11 +312,14 @@ public void onDetachedFromActivity_removesReferencesToActivityPluginBindingAndAc
final LiveDataHostApiImpl mockLiveDataHostApiImpl = mock(LiveDataHostApiImpl.class);
final DeviceOrientationManagerHostApiImpl mockDeviceOrientationManagerHostApiImpl =
mock(DeviceOrientationManagerHostApiImpl.class);
final MeteringPointHostApiImpl mockMeteringPointHostApiImpl =
mock(MeteringPointHostApiImpl.class);

plugin.processCameraProviderHostApiImpl = mockProcessCameraProviderHostApiImpl;
plugin.liveDataHostApiImpl = mockLiveDataHostApiImpl;
plugin.systemServicesHostApiImpl = mockSystemServicesHostApiImpl;
plugin.deviceOrientationManagerHostApiImpl = mockDeviceOrientationManagerHostApiImpl;
plugin.meteringPointHostApiImpl = mockMeteringPointHostApiImpl;

plugin.onAttachedToEngine(flutterPluginBinding);
plugin.onDetachedFromActivityForConfigChanges();
Expand All @@ -313,6 +328,7 @@ public void onDetachedFromActivity_removesReferencesToActivityPluginBindingAndAc
verify(mockLiveDataHostApiImpl).setLifecycleOwner(null);
verify(mockSystemServicesHostApiImpl).setActivity(null);
verify(mockDeviceOrientationManagerHostApiImpl).setActivity(null);
verify(mockMeteringPointHostApiImpl).setActivity(null);
}

@Test
Expand Down
Loading