From dec3d697b4622d0edc5f7665215bda6f06706258 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Mon, 1 May 2023 16:34:43 -0700 Subject: [PATCH 01/15] Merge remote-tracking branch 'upstream/main' into camx_occ --- .../camera_android_camerax/CHANGELOG.md | 1 + .../camerax/CameraInfoHostApiImpl.java | 38 ++ .../camerax/GeneratedCameraXLibrary.java | 627 ++++++++++-------- .../plugins/camerax/CameraInfoTest.java | 1 + .../lib/src/android_camera_camerax.dart | 55 ++ ...roid_camera_camerax_flutter_api_impls.dart | 70 +- .../lib/src/camera_info.dart | 22 + .../lib/src/camerax_library.g.dart | 327 ++++++--- .../pigeons/camerax_library.dart | 25 + .../test/android_camera_camerax_test.dart | 65 +- .../android_camera_camerax_test.mocks.dart | 9 + .../test/camera_info_test.dart | 1 + .../test/camera_info_test.mocks.dart | 8 + .../test/camera_test.dart | 4 +- .../test/test_camerax_library.g.dart | 431 +++++------- 15 files changed, 977 insertions(+), 707 deletions(-) diff --git a/packages/camera/camera_android_camerax/CHANGELOG.md b/packages/camera/camera_android_camerax/CHANGELOG.md index 1c901a82bfac..24fbec47e8b7 100644 --- a/packages/camera/camera_android_camerax/CHANGELOG.md +++ b/packages/camera/camera_android_camerax/CHANGELOG.md @@ -21,3 +21,4 @@ * Implements image streaming. * Provides LifecycleOwner implementation for Activities that use the plugin that do not implement it themselves. * Implements retrieval of camera information. +* Implements onCameraClosing callback method for indicating the camera is closing and bumps CameraX version to 1.3.0-alpha05. diff --git a/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/CameraInfoHostApiImpl.java b/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/CameraInfoHostApiImpl.java index f9fd7722fc87..973e2928d789 100644 --- a/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/CameraInfoHostApiImpl.java +++ b/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/CameraInfoHostApiImpl.java @@ -6,8 +6,10 @@ import androidx.annotation.NonNull; import androidx.camera.core.CameraInfo; +import androidx.camera.core.CameraState; import androidx.camera.core.ExposureState; import androidx.camera.core.ZoomState; +import androidx.lifecycle.LiveData; import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugins.camerax.GeneratedCameraXLibrary.CameraInfoHostApi; import java.util.Objects; @@ -66,4 +68,40 @@ public Long getZoomState(@NonNull Long identifier) { return instanceManager.getIdentifierForStrongReference(zoomState); } + + /** + * Retrieves the {@link ExposureState} of the {@link CameraInfo} with the specified identifier. + */ + @Override + @NonNull + public Long getExposureState(@NonNull Long identifier) { + CameraInfo cameraInfo = + (CameraInfo) Objects.requireNonNull(instanceManager.getInstance(identifier)); + ExposureState exposureState = cameraInfo.getExposureState(); + + ExposureStateFlutterApiImpl exposureStateFlutterApiImpl = + new ExposureStateFlutterApiImpl(binaryMessenger, instanceManager); + exposureStateFlutterApiImpl.create(exposureState, result -> {}); + + return instanceManager.getIdentifierForStrongReference(exposureState); + } + + /** + * Retrieves the current {@link ZoomState} value of the {@link CameraInfo} with the specified + * identifier. + */ + @NonNull + @Override + public Long getZoomState(@NonNull Long identifier) { + CameraInfo cameraInfo = + (CameraInfo) Objects.requireNonNull(instanceManager.getInstance(identifier)); + // TODO(camsim99): Create/return LiveData once https://github.com/flutter/packages/pull/3419 lands. + ZoomState zoomState = cameraInfo.getZoomState().getValue(); + + ZoomStateFlutterApiImpl zoomStateFlutterApiImpl = + new ZoomStateFlutterApiImpl(binaryMessenger, instanceManager); + zoomStateFlutterApiImpl.create(zoomState, result -> {}); + + return instanceManager.getIdentifierForStrongReference(zoomState); + } } diff --git a/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/GeneratedCameraXLibrary.java b/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/GeneratedCameraXLibrary.java index 882c1d146323..d48feb044a36 100644 --- a/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/GeneratedCameraXLibrary.java +++ b/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/GeneratedCameraXLibrary.java @@ -18,7 +18,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** Generated class from Pigeon. */ @SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression", "serial"}) @@ -33,7 +35,8 @@ public static class FlutterError extends RuntimeException { /** The error details. Must be a datatype supported by the api codec. */ public final Object details; - public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) { + public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) + { super(message); this.code = code; this.details = details; @@ -52,7 +55,7 @@ protected static ArrayList wrapError(@NonNull Throwable exception) { errorList.add(exception.toString()); errorList.add(exception.getClass().getSimpleName()); errorList.add( - "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); } return errorList; } @@ -123,13 +126,9 @@ ArrayList toList() { static @NonNull ResolutionInfo fromList(@NonNull ArrayList list) { ResolutionInfo pigeonResult = new ResolutionInfo(); Object width = list.get(0); - pigeonResult.setWidth( - (width == null) ? null : ((width instanceof Integer) ? (Integer) width : (Long) width)); + pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer) width : (Long) width)); Object height = list.get(1); - pigeonResult.setHeight( - (height == null) - ? null - : ((height instanceof Integer) ? (Integer) height : (Long) height)); + pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer) height : (Long) height)); return pigeonResult; } } @@ -273,19 +272,82 @@ ArrayList toList() { static @NonNull ExposureCompensationRange fromList(@NonNull ArrayList list) { ExposureCompensationRange pigeonResult = new ExposureCompensationRange(); Object minCompensation = list.get(0); - pigeonResult.setMinCompensation( - (minCompensation == null) - ? null - : ((minCompensation instanceof Integer) - ? (Integer) minCompensation - : (Long) minCompensation)); + pigeonResult.setMinCompensation((minCompensation == null) ? null : ((minCompensation instanceof Integer) ? (Integer) minCompensation : (Long) minCompensation)); Object maxCompensation = list.get(1); - pigeonResult.setMaxCompensation( - (maxCompensation == null) - ? null - : ((maxCompensation instanceof Integer) - ? (Integer) maxCompensation - : (Long) maxCompensation)); + pigeonResult.setMaxCompensation((maxCompensation == null) ? null : ((maxCompensation instanceof Integer) ? (Integer) maxCompensation : (Long) maxCompensation)); + return pigeonResult; + } + } + + /** Generated class from Pigeon that represents data sent in messages. */ + public static final class ExposureCompensationRange { + private @NonNull Long minCompensation; + + public @NonNull Long getMinCompensation() { + return minCompensation; + } + + public void setMinCompensation(@NonNull Long setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"minCompensation\" is null."); + } + this.minCompensation = setterArg; + } + + private @NonNull Long maxCompensation; + + public @NonNull Long getMaxCompensation() { + return maxCompensation; + } + + public void setMaxCompensation(@NonNull Long setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"maxCompensation\" is null."); + } + this.maxCompensation = setterArg; + } + + /** Constructor is non-public to enforce null safety; use Builder. */ + ExposureCompensationRange() {} + + public static final class Builder { + + private @Nullable Long minCompensation; + + public @NonNull Builder setMinCompensation(@NonNull Long setterArg) { + this.minCompensation = setterArg; + return this; + } + + private @Nullable Long maxCompensation; + + public @NonNull Builder setMaxCompensation(@NonNull Long setterArg) { + this.maxCompensation = setterArg; + return this; + } + + public @NonNull ExposureCompensationRange build() { + ExposureCompensationRange pigeonReturn = new ExposureCompensationRange(); + pigeonReturn.setMinCompensation(minCompensation); + pigeonReturn.setMaxCompensation(maxCompensation); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList(2); + toListResult.add(minCompensation); + toListResult.add(maxCompensation); + return toListResult; + } + + static @NonNull ExposureCompensationRange fromList(@NonNull ArrayList list) { + ExposureCompensationRange pigeonResult = new ExposureCompensationRange(); + Object minCompensation = list.get(0); + pigeonResult.setMinCompensation((minCompensation == null) ? null : ((minCompensation instanceof Integer) ? (Integer) minCompensation : (Long) minCompensation)); + Object maxCompensation = list.get(1); + pigeonResult.setMaxCompensation((maxCompensation == null) ? null : ((maxCompensation instanceof Integer) ? (Integer) maxCompensation : (Long) maxCompensation)); return pigeonResult; } } @@ -301,7 +363,7 @@ public interface InstanceManagerHostApi { /** * Clear the native `InstanceManager`. * - *

This is typically only used after a hot restart. + * This is typically only used after a hot restart. */ void clear(); @@ -309,12 +371,8 @@ public interface InstanceManagerHostApi { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /** - * Sets up an instance of `InstanceManagerHostApi` to handle messages through the - * `binaryMessenger`. - */ - static void setup( - @NonNull BinaryMessenger binaryMessenger, @Nullable InstanceManagerHostApi api) { + /**Sets up an instance of `InstanceManagerHostApi` to handle messages through the `binaryMessenger`. */ + static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable InstanceManagerHostApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -326,7 +384,8 @@ static void setup( try { api.clear(); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -347,9 +406,7 @@ public interface JavaObjectHostApi { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /** - * Sets up an instance of `JavaObjectHostApi` to handle messages through the `binaryMessenger`. - */ + /**Sets up an instance of `JavaObjectHostApi` to handle messages through the `binaryMessenger`. */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable JavaObjectHostApi api) { { BasicMessageChannel channel = @@ -364,7 +421,8 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable JavaObject try { api.dispose((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -384,7 +442,7 @@ public JavaObjectFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -393,7 +451,6 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - public void dispose(@NonNull Long identifierArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -406,29 +463,28 @@ public void dispose(@NonNull Long identifierArg, @NonNull Reply callback) /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface CameraInfoHostApi { - @NonNull + @NonNull Long getSensorRotationDegrees(@NonNull Long identifier); - @NonNull + @NonNull + Long getLiveCameraState(@NonNull Long identifier); + + @NonNull Long getExposureState(@NonNull Long identifier); - @NonNull + @NonNull Long getZoomState(@NonNull Long identifier); /** The codec used by CameraInfoHostApi. */ static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /** - * Sets up an instance of `CameraInfoHostApi` to handle messages through the `binaryMessenger`. - */ + /**Sets up an instance of `CameraInfoHostApi` to handle messages through the `binaryMessenger`. */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraInfoHostApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.CameraInfoHostApi.getSensorRotationDegrees", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.CameraInfoHostApi.getSensorRotationDegrees", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -436,11 +492,10 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraInfo ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - Long output = - api.getSensorRotationDegrees( - (identifierArg == null) ? null : identifierArg.longValue()); + Long output = api.getSensorRotationDegrees((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -453,9 +508,7 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraInfo { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.CameraInfoHostApi.getExposureState", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.CameraInfoHostApi.getLiveCameraState", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -463,11 +516,34 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraInfo ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - Long output = - api.getExposureState( - (identifierArg == null) ? null : identifierArg.longValue()); + Long output = api.getLiveCameraState((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { + ArrayList wrappedError = wrapError(exception); + wrapped = wrappedError; + } + reply.reply(wrapped); + }); + } else { + channel.setMessageHandler(null); + } + } + { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.CameraInfoHostApi.getExposureState", getCodec()); + if (api != null) { + channel.setMessageHandler( + (message, reply) -> { + ArrayList wrapped = new ArrayList(); + ArrayList args = (ArrayList) message; + Number identifierArg = (Number) args.get(0); + try { + Long output = api.getExposureState((identifierArg == null) ? null : identifierArg.longValue()); + wrapped.add(0, output); + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -488,10 +564,10 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraInfo ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - Long output = - api.getZoomState((identifierArg == null) ? null : identifierArg.longValue()); + Long output = api.getZoomState((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -511,7 +587,7 @@ public CameraInfoFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -520,7 +596,6 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - public void create(@NonNull Long identifierArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -535,19 +610,15 @@ public interface CameraSelectorHostApi { void create(@NonNull Long identifier, @Nullable Long lensFacing); - @NonNull + @NonNull List filter(@NonNull Long identifier, @NonNull List cameraInfoIds); /** The codec used by CameraSelectorHostApi. */ static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /** - * Sets up an instance of `CameraSelectorHostApi` to handle messages through the - * `binaryMessenger`. - */ - static void setup( - @NonNull BinaryMessenger binaryMessenger, @Nullable CameraSelectorHostApi api) { + /**Sets up an instance of `CameraSelectorHostApi` to handle messages through the `binaryMessenger`. */ + static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraSelectorHostApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -560,11 +631,10 @@ static void setup( Number identifierArg = (Number) args.get(0); Number lensFacingArg = (Number) args.get(1); try { - api.create( - (identifierArg == null) ? null : identifierArg.longValue(), - (lensFacingArg == null) ? null : lensFacingArg.longValue()); + api.create((identifierArg == null) ? null : identifierArg.longValue(), (lensFacingArg == null) ? null : lensFacingArg.longValue()); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -586,12 +656,10 @@ static void setup( Number identifierArg = (Number) args.get(0); List cameraInfoIdsArg = (List) args.get(1); try { - List output = - api.filter( - (identifierArg == null) ? null : identifierArg.longValue(), - cameraInfoIdsArg); + List output = api.filter((identifierArg == null) ? null : identifierArg.longValue(), cameraInfoIdsArg); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -611,7 +679,7 @@ public CameraSelectorFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -620,9 +688,7 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - - public void create( - @NonNull Long identifierArg, @Nullable Long lensFacingArg, @NonNull Reply callback) { + public void create(@NonNull Long identifierArg, @Nullable Long lensFacingArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.CameraSelectorFlutterApi.create", getCodec()); @@ -636,16 +702,13 @@ public interface ProcessCameraProviderHostApi { void getInstance(@NonNull Result result); - @NonNull + @NonNull List getAvailableCameraInfos(@NonNull Long identifier); - @NonNull - Long bindToLifecycle( - @NonNull Long identifier, - @NonNull Long cameraSelectorIdentifier, - @NonNull List useCaseIds); + @NonNull + Long bindToLifecycle(@NonNull Long identifier, @NonNull Long cameraSelectorIdentifier, @NonNull List useCaseIds); - @NonNull + @NonNull Boolean isBound(@NonNull Long identifier, @NonNull Long useCaseIdentifier); void unbind(@NonNull Long identifier, @NonNull List useCaseIds); @@ -656,18 +719,12 @@ Long bindToLifecycle( static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /** - * Sets up an instance of `ProcessCameraProviderHostApi` to handle messages through the - * `binaryMessenger`. - */ - static void setup( - @NonNull BinaryMessenger binaryMessenger, @Nullable ProcessCameraProviderHostApi api) { + /**Sets up an instance of `ProcessCameraProviderHostApi` to handle messages through the `binaryMessenger`. */ + static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ProcessCameraProviderHostApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.ProcessCameraProviderHostApi.getInstance", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderHostApi.getInstance", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -694,9 +751,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -704,11 +759,10 @@ public void error(Throwable error) { ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - List output = - api.getAvailableCameraInfos( - (identifierArg == null) ? null : identifierArg.longValue()); + List output = api.getAvailableCameraInfos((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -721,9 +775,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -733,15 +785,10 @@ public void error(Throwable error) { Number cameraSelectorIdentifierArg = (Number) args.get(1); List useCaseIdsArg = (List) args.get(2); try { - Long output = - api.bindToLifecycle( - (identifierArg == null) ? null : identifierArg.longValue(), - (cameraSelectorIdentifierArg == null) - ? null - : cameraSelectorIdentifierArg.longValue(), - useCaseIdsArg); + Long output = api.bindToLifecycle((identifierArg == null) ? null : identifierArg.longValue(), (cameraSelectorIdentifierArg == null) ? null : cameraSelectorIdentifierArg.longValue(), useCaseIdsArg); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -754,9 +801,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -765,12 +810,10 @@ public void error(Throwable error) { Number identifierArg = (Number) args.get(0); Number useCaseIdentifierArg = (Number) args.get(1); try { - Boolean output = - api.isBound( - (identifierArg == null) ? null : identifierArg.longValue(), - (useCaseIdentifierArg == null) ? null : useCaseIdentifierArg.longValue()); + Boolean output = api.isBound((identifierArg == null) ? null : identifierArg.longValue(), (useCaseIdentifierArg == null) ? null : useCaseIdentifierArg.longValue()); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -783,9 +826,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -794,10 +835,10 @@ public void error(Throwable error) { Number identifierArg = (Number) args.get(0); List useCaseIdsArg = (List) args.get(1); try { - api.unbind( - (identifierArg == null) ? null : identifierArg.longValue(), useCaseIdsArg); + api.unbind((identifierArg == null) ? null : identifierArg.longValue(), useCaseIdsArg); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -810,9 +851,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.ProcessCameraProviderHostApi.unbindAll", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderHostApi.unbindAll", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -822,7 +861,8 @@ public void error(Throwable error) { try { api.unbindAll((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -842,7 +882,7 @@ public ProcessCameraProviderFlutterApi(@NonNull BinaryMessenger argBinaryMesseng this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -851,13 +891,10 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - public void create(@NonNull Long identifierArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.ProcessCameraProviderFlutterApi.create", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderFlutterApi.create", getCodec()); channel.send( new ArrayList(Collections.singletonList(identifierArg)), channelReply -> callback.reply(null)); @@ -866,14 +903,14 @@ public void create(@NonNull Long identifierArg, @NonNull Reply callback) { /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface CameraHostApi { - @NonNull + @NonNull Long getCameraInfo(@NonNull Long identifier); /** The codec used by CameraHostApi. */ static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /** Sets up an instance of `CameraHostApi` to handle messages through the `binaryMessenger`. */ + /**Sets up an instance of `CameraHostApi` to handle messages through the `binaryMessenger`. */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraHostApi api) { { BasicMessageChannel channel = @@ -886,10 +923,10 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraHost ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - Long output = - api.getCameraInfo((identifierArg == null) ? null : identifierArg.longValue()); + Long output = api.getCameraInfo((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -909,7 +946,7 @@ public CameraFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -918,7 +955,6 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - public void create(@NonNull Long identifierArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -958,11 +994,9 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface SystemServicesHostApi { - void requestCameraPermissions( - @NonNull Boolean enableAudio, @NonNull Result result); + void requestCameraPermissions(@NonNull Boolean enableAudio, @NonNull Result result); - void startListeningForDeviceOrientationChange( - @NonNull Boolean isFrontFacing, @NonNull Long sensorOrientation); + void startListeningForDeviceOrientationChange(@NonNull Boolean isFrontFacing, @NonNull Long sensorOrientation); void stopListeningForDeviceOrientationChange(); @@ -970,18 +1004,12 @@ void startListeningForDeviceOrientationChange( static @NonNull MessageCodec getCodec() { return SystemServicesHostApiCodec.INSTANCE; } - /** - * Sets up an instance of `SystemServicesHostApi` to handle messages through the - * `binaryMessenger`. - */ - static void setup( - @NonNull BinaryMessenger binaryMessenger, @Nullable SystemServicesHostApi api) { + /**Sets up an instance of `SystemServicesHostApi` to handle messages through the `binaryMessenger`. */ + static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable SystemServicesHostApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -1010,9 +1038,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -1021,11 +1047,10 @@ public void error(Throwable error) { Boolean isFrontFacingArg = (Boolean) args.get(0); Number sensorOrientationArg = (Number) args.get(1); try { - api.startListeningForDeviceOrientationChange( - isFrontFacingArg, - (sensorOrientationArg == null) ? null : sensorOrientationArg.longValue()); + api.startListeningForDeviceOrientationChange(isFrontFacingArg, (sensorOrientationArg == null) ? null : sensorOrientationArg.longValue()); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1038,9 +1063,7 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.SystemServicesHostApi.stopListeningForDeviceOrientationChange", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.SystemServicesHostApi.stopListeningForDeviceOrientationChange", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -1048,7 +1071,8 @@ public void error(Throwable error) { try { api.stopListeningForDeviceOrientationChange(); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1068,7 +1092,7 @@ public SystemServicesFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -1077,25 +1101,18 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - - public void onDeviceOrientationChanged( - @NonNull String orientationArg, @NonNull Reply callback) { + public void onDeviceOrientationChanged(@NonNull String orientationArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.SystemServicesFlutterApi.onDeviceOrientationChanged", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.SystemServicesFlutterApi.onDeviceOrientationChanged", getCodec()); channel.send( new ArrayList(Collections.singletonList(orientationArg)), channelReply -> callback.reply(null)); } - public void onCameraError(@NonNull String errorDescriptionArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.SystemServicesFlutterApi.onCameraError", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.SystemServicesFlutterApi.onCameraError", getCodec()); channel.send( new ArrayList(Collections.singletonList(errorDescriptionArg)), channelReply -> callback.reply(null)); @@ -1136,24 +1153,21 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface PreviewHostApi { - void create( - @NonNull Long identifier, - @Nullable Long rotation, - @Nullable ResolutionInfo targetResolution); + void create(@NonNull Long identifier, @Nullable Long rotation, @Nullable ResolutionInfo targetResolution); - @NonNull + @NonNull Long setSurfaceProvider(@NonNull Long identifier); void releaseFlutterSurfaceTexture(); - @NonNull + @NonNull ResolutionInfo getResolutionInfo(@NonNull Long identifier); /** The codec used by PreviewHostApi. */ static @NonNull MessageCodec getCodec() { return PreviewHostApiCodec.INSTANCE; } - /** Sets up an instance of `PreviewHostApi` to handle messages through the `binaryMessenger`. */ + /**Sets up an instance of `PreviewHostApi` to handle messages through the `binaryMessenger`. */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHostApi api) { { BasicMessageChannel channel = @@ -1168,12 +1182,10 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHos Number rotationArg = (Number) args.get(1); ResolutionInfo targetResolutionArg = (ResolutionInfo) args.get(2); try { - api.create( - (identifierArg == null) ? null : identifierArg.longValue(), - (rotationArg == null) ? null : rotationArg.longValue(), - targetResolutionArg); + api.create((identifierArg == null) ? null : identifierArg.longValue(), (rotationArg == null) ? null : rotationArg.longValue(), targetResolutionArg); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1186,9 +1198,7 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHos { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.PreviewHostApi.setSurfaceProvider", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.PreviewHostApi.setSurfaceProvider", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -1196,11 +1206,10 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHos ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - Long output = - api.setSurfaceProvider( - (identifierArg == null) ? null : identifierArg.longValue()); + Long output = api.setSurfaceProvider((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1213,9 +1222,7 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHos { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.PreviewHostApi.releaseFlutterSurfaceTexture", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.PreviewHostApi.releaseFlutterSurfaceTexture", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -1223,7 +1230,8 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHos try { api.releaseFlutterSurfaceTexture(); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1244,11 +1252,10 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHos ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - ResolutionInfo output = - api.getResolutionInfo( - (identifierArg == null) ? null : identifierArg.longValue()); + ResolutionInfo output = api.getResolutionInfo((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1290,10 +1297,7 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface ImageCaptureHostApi { - void create( - @NonNull Long identifier, - @Nullable Long flashMode, - @Nullable ResolutionInfo targetResolution); + void create(@NonNull Long identifier, @Nullable Long flashMode, @Nullable ResolutionInfo targetResolution); void setFlashMode(@NonNull Long identifier, @NonNull Long flashMode); @@ -1303,10 +1307,7 @@ void create( static @NonNull MessageCodec getCodec() { return ImageCaptureHostApiCodec.INSTANCE; } - /** - * Sets up an instance of `ImageCaptureHostApi` to handle messages through the - * `binaryMessenger`. - */ + /**Sets up an instance of `ImageCaptureHostApi` to handle messages through the `binaryMessenger`. */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageCaptureHostApi api) { { BasicMessageChannel channel = @@ -1321,12 +1322,10 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageCaptu Number flashModeArg = (Number) args.get(1); ResolutionInfo targetResolutionArg = (ResolutionInfo) args.get(2); try { - api.create( - (identifierArg == null) ? null : identifierArg.longValue(), - (flashModeArg == null) ? null : flashModeArg.longValue(), - targetResolutionArg); + api.create((identifierArg == null) ? null : identifierArg.longValue(), (flashModeArg == null) ? null : flashModeArg.longValue(), targetResolutionArg); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1348,11 +1347,10 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageCaptu Number identifierArg = (Number) args.get(0); Number flashModeArg = (Number) args.get(1); try { - api.setFlashMode( - (identifierArg == null) ? null : identifierArg.longValue(), - (flashModeArg == null) ? null : flashModeArg.longValue()); + api.setFlashMode((identifierArg == null) ? null : identifierArg.longValue(), (flashModeArg == null) ? null : flashModeArg.longValue()); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1385,8 +1383,7 @@ public void error(Throwable error) { } }; - api.takePicture( - (identifierArg == null) ? null : identifierArg.longValue(), resultCallback); + api.takePicture((identifierArg == null) ? null : identifierArg.longValue(), resultCallback); }); } else { channel.setMessageHandler(null); @@ -1429,7 +1426,7 @@ public ExposureStateFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -1438,19 +1435,12 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return ExposureStateFlutterApiCodec.INSTANCE; } - - public void create( - @NonNull Long identifierArg, - @NonNull ExposureCompensationRange exposureCompensationRangeArg, - @NonNull Double exposureCompensationStepArg, - @NonNull Reply callback) { + public void create(@NonNull Long identifierArg, @NonNull ExposureCompensationRange exposureCompensationRangeArg, @NonNull Double exposureCompensationStepArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.ExposureStateFlutterApi.create", getCodec()); channel.send( - new ArrayList( - Arrays.asList( - identifierArg, exposureCompensationRangeArg, exposureCompensationStepArg)), + new ArrayList(Arrays.asList(identifierArg, exposureCompensationRangeArg, exposureCompensationStepArg)), channelReply -> callback.reply(null)); } } @@ -1462,7 +1452,7 @@ public ZoomStateFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -1471,12 +1461,86 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } + public void create(@NonNull Long identifierArg, @NonNull Double minZoomRatioArg, @NonNull Double maxZoomRatioArg, @NonNull Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.ZoomStateFlutterApi.create", getCodec()); + channel.send( + new ArrayList(Arrays.asList(identifierArg, minZoomRatioArg, maxZoomRatioArg)), + channelReply -> callback.reply(null)); + } + } + + private static class ExposureStateFlutterApiCodec extends StandardMessageCodec { + public static final ExposureStateFlutterApiCodec INSTANCE = new ExposureStateFlutterApiCodec(); + + private ExposureStateFlutterApiCodec() {} + + @Override + protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { + switch (type) { + case (byte) 128: + return ExposureCompensationRange.fromList((ArrayList) readValue(buffer)); + default: + return super.readValueOfType(type, buffer); + } + } + + @Override + protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { + if (value instanceof ExposureCompensationRange) { + stream.write(128); + writeValue(stream, ((ExposureCompensationRange) value).toList()); + } else { + super.writeValue(stream, value); + } + } + } + + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class ExposureStateFlutterApi { + private final @NonNull BinaryMessenger binaryMessenger; - public void create( - @NonNull Long identifierArg, - @NonNull Double minZoomRatioArg, - @NonNull Double maxZoomRatioArg, - @NonNull Reply callback) { + public ExposureStateFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + /** Public interface for sending reply. */ + @SuppressWarnings("UnknownNullness") + public interface Reply { + void reply(T reply); + } + /** The codec used by ExposureStateFlutterApi. */ + static @NonNull MessageCodec getCodec() { + return ExposureStateFlutterApiCodec.INSTANCE; + } + public void create(@NonNull Long identifierArg, @NonNull ExposureCompensationRange exposureCompensationRangeArg, @NonNull Double exposureCompensationStepArg, @NonNull Reply callback) { + BasicMessageChannel channel = + new BasicMessageChannel<>( + binaryMessenger, "dev.flutter.pigeon.ExposureStateFlutterApi.create", getCodec()); + channel.send( + new ArrayList(Arrays.asList(identifierArg, exposureCompensationRangeArg, exposureCompensationStepArg)), + channelReply -> callback.reply(null)); + } + } + /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ + public static class ZoomStateFlutterApi { + private final @NonNull BinaryMessenger binaryMessenger; + + public ZoomStateFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { + this.binaryMessenger = argBinaryMessenger; + } + + /** Public interface for sending reply. */ + @SuppressWarnings("UnknownNullness") + public interface Reply { + void reply(T reply); + } + /** The codec used by ZoomStateFlutterApi. */ + static @NonNull MessageCodec getCodec() { + return new StandardMessageCodec(); + } + public void create(@NonNull Long identifierArg, @NonNull Double minZoomRatioArg, @NonNull Double maxZoomRatioArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.ZoomStateFlutterApi.create", getCodec()); @@ -1525,12 +1589,8 @@ public interface ImageAnalysisHostApi { static @NonNull MessageCodec getCodec() { return ImageAnalysisHostApiCodec.INSTANCE; } - /** - * Sets up an instance of `ImageAnalysisHostApi` to handle messages through the - * `binaryMessenger`. - */ - static void setup( - @NonNull BinaryMessenger binaryMessenger, @Nullable ImageAnalysisHostApi api) { + /**Sets up an instance of `ImageAnalysisHostApi` to handle messages through the `binaryMessenger`. */ + static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageAnalysisHostApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -1543,11 +1603,10 @@ static void setup( Number identifierArg = (Number) args.get(0); ResolutionInfo targetResolutionIdentifierArg = (ResolutionInfo) args.get(1); try { - api.create( - (identifierArg == null) ? null : identifierArg.longValue(), - targetResolutionIdentifierArg); + api.create((identifierArg == null) ? null : identifierArg.longValue(), targetResolutionIdentifierArg); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1569,11 +1628,10 @@ static void setup( Number identifierArg = (Number) args.get(0); Number analyzerIdentifierArg = (Number) args.get(1); try { - api.setAnalyzer( - (identifierArg == null) ? null : identifierArg.longValue(), - (analyzerIdentifierArg == null) ? null : analyzerIdentifierArg.longValue()); + api.setAnalyzer((identifierArg == null) ? null : identifierArg.longValue(), (analyzerIdentifierArg == null) ? null : analyzerIdentifierArg.longValue()); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1586,9 +1644,7 @@ static void setup( { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, - "dev.flutter.pigeon.ImageAnalysisHostApi.clearAnalyzer", - getCodec()); + binaryMessenger, "dev.flutter.pigeon.ImageAnalysisHostApi.clearAnalyzer", getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -1598,7 +1654,8 @@ static void setup( try { api.clearAnalyzer((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1619,9 +1676,7 @@ public interface AnalyzerHostApi { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /** - * Sets up an instance of `AnalyzerHostApi` to handle messages through the `binaryMessenger`. - */ + /**Sets up an instance of `AnalyzerHostApi` to handle messages through the `binaryMessenger`. */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable AnalyzerHostApi api) { { BasicMessageChannel channel = @@ -1636,7 +1691,8 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable AnalyzerHo try { api.create((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1656,7 +1712,7 @@ public AnalyzerFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -1665,7 +1721,6 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - public void create(@NonNull Long identifierArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -1674,11 +1729,7 @@ public void create(@NonNull Long identifierArg, @NonNull Reply callback) { new ArrayList(Collections.singletonList(identifierArg)), channelReply -> callback.reply(null)); } - - public void analyze( - @NonNull Long identifierArg, - @NonNull Long imageProxyIdentifierArg, - @NonNull Reply callback) { + public void analyze(@NonNull Long identifierArg, @NonNull Long imageProxyIdentifierArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.AnalyzerFlutterApi.analyze", getCodec()); @@ -1690,7 +1741,7 @@ public void analyze( /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface ImageProxyHostApi { - @NonNull + @NonNull List getPlanes(@NonNull Long identifier); void close(@NonNull Long identifier); @@ -1699,9 +1750,7 @@ public interface ImageProxyHostApi { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /** - * Sets up an instance of `ImageProxyHostApi` to handle messages through the `binaryMessenger`. - */ + /**Sets up an instance of `ImageProxyHostApi` to handle messages through the `binaryMessenger`. */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageProxyHostApi api) { { BasicMessageChannel channel = @@ -1714,10 +1763,10 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageProxy ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - List output = - api.getPlanes((identifierArg == null) ? null : identifierArg.longValue()); + List output = api.getPlanes((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1740,7 +1789,8 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageProxy try { api.close((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, null); - } catch (Throwable exception) { + } + catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1760,7 +1810,7 @@ public ImageProxyFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -1769,13 +1819,7 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - - public void create( - @NonNull Long identifierArg, - @NonNull Long formatArg, - @NonNull Long heightArg, - @NonNull Long widthArg, - @NonNull Reply callback) { + public void create(@NonNull Long identifierArg, @NonNull Long formatArg, @NonNull Long heightArg, @NonNull Long widthArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.ImageProxyFlutterApi.create", getCodec()); @@ -1792,7 +1836,7 @@ public PlaneProxyFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -1801,19 +1845,12 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - - public void create( - @NonNull Long identifierArg, - @NonNull byte[] bufferArg, - @NonNull Long pixelStrideArg, - @NonNull Long rowStrideArg, - @NonNull Reply callback) { + public void create(@NonNull Long identifierArg, @NonNull byte[] bufferArg, @NonNull Long pixelStrideArg, @NonNull Long rowStrideArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.PlaneProxyFlutterApi.create", getCodec()); channel.send( - new ArrayList( - Arrays.asList(identifierArg, bufferArg, pixelStrideArg, rowStrideArg)), + new ArrayList(Arrays.asList(identifierArg, bufferArg, pixelStrideArg, rowStrideArg)), channelReply -> callback.reply(null)); } } diff --git a/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/CameraInfoTest.java b/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/CameraInfoTest.java index 5cfd06935b85..379cf3f3b05c 100644 --- a/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/CameraInfoTest.java +++ b/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/CameraInfoTest.java @@ -13,6 +13,7 @@ import static org.mockito.Mockito.when; import androidx.camera.core.CameraInfo; +import androidx.camera.core.CameraState; import androidx.camera.core.ExposureState; import androidx.camera.core.ZoomState; import androidx.lifecycle.LiveData; diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index 174a373e3b9b..f0eac80d9eed 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -45,6 +45,10 @@ class AndroidCameraCameraX extends CameraPlatform { @visibleForTesting CameraInfo? cameraInfo; + /// The [LiveData] of the [CameraState] that represents the state of the + /// [camera] instance. + LiveData? liveCameraState; + /// The [Preview] instance that can be configured to present a live camera preview. @visibleForTesting Preview? preview; @@ -196,6 +200,7 @@ class AndroidCameraCameraX extends CameraPlatform { // instance as bound but not paused. camera = await processCameraProvider! .bindToLifecycle(cameraSelector!, [preview!, imageCapture!]); + await _updateLiveCameraState(flutterSurfaceTextureId); cameraInfo = await camera!.getCameraInfo(); _previewIsPaused = false; @@ -325,6 +330,55 @@ class AndroidCameraCameraX extends CameraPlatform { return exposureState.minZoomRatio; } + /// Gets the minimum supported exposure offset for the selected camera in EV units. + /// + /// [cameraId] not used. + @override + Future getMinExposureOffset(int cameraId) async { + final ExposureState exposureState = await cameraInfo!.getExposureState(); + return exposureState.exposureCompensationRange.minCompensation * + exposureState.exposureCompensationStep; + } + + /// Gets the maximum supported exposure offset for the selected camera in EV units. + /// + /// [cameraId] not used. + @override + Future getMaxExposureOffset(int cameraId) async { + final ExposureState exposureState = await cameraInfo!.getExposureState(); + return exposureState.exposureCompensationRange.maxCompensation * + exposureState.exposureCompensationStep; + } + + /// Gets the supported step size for exposure offset for the selected camera in EV units. + /// + /// Returns 0 when exposure compensation is not supported. + /// + /// [cameraId] not used. + @override + Future getExposureOffsetStepSize(int cameraId) async { + final ExposureState exposureState = await cameraInfo!.getExposureState(); + return exposureState.exposureCompensationStep; + } + + /// Gets the maximum supported zoom level for the selected camera. + /// + /// [cameraId] not used. + @override + Future getMaxZoomLevel(int cameraId) async { + final ZoomState exposureState = await cameraInfo!.getZoomState(); + return exposureState.maxZoomRatio; + } + + /// Gets the minimum supported zoom level for the selected camera. + /// + /// [cameraId] not used. + @override + Future getMinZoomLevel(int cameraId) async { + final ZoomState exposureState = await cameraInfo!.getZoomState(); + return exposureState.minZoomRatio; + } + /// The ui orientation changed. @override Stream onDeviceOrientationChanged() { @@ -413,6 +467,7 @@ class AndroidCameraCameraX extends CameraPlatform { camera = await processCameraProvider! .bindToLifecycle(cameraSelector!, [preview!]); + await _updateLiveCameraState(cameraId); cameraInfo = await camera!.getCameraInfo(); } diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax_flutter_api_impls.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax_flutter_api_impls.dart index c5692ae105f2..f92ef8349267 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax_flutter_api_impls.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax_flutter_api_impls.dart @@ -19,33 +19,46 @@ import 'zoom_state.dart'; class AndroidCameraXCameraFlutterApis { /// Creates a [AndroidCameraXCameraFlutterApis]. AndroidCameraXCameraFlutterApis({ - JavaObjectFlutterApiImpl? javaObjectFlutterApi, - CameraFlutterApiImpl? cameraFlutterApi, - CameraInfoFlutterApiImpl? cameraInfoFlutterApi, - CameraSelectorFlutterApiImpl? cameraSelectorFlutterApi, - ProcessCameraProviderFlutterApiImpl? processCameraProviderFlutterApi, - SystemServicesFlutterApiImpl? systemServicesFlutterApi, + JavaObjectFlutterApiImpl? javaObjectFlutterApiImpl, + CameraFlutterApiImpl? cameraFlutterApiImpl, + CameraInfoFlutterApiImpl? cameraInfoFlutterApiImpl, + CameraSelectorFlutterApiImpl? cameraSelectorFlutterApiImpl, + ProcessCameraProviderFlutterApiImpl? processCameraProviderFlutterApiImpl, + SystemServicesFlutterApiImpl? systemServicesFlutterApiImpl, + CameraStateErrorFlutterApiImpl? cameraStateErrorFlutterApiImpl, + CameraStateFlutterApiImpl? cameraStateFlutterApiImpl, ExposureStateFlutterApiImpl? exposureStateFlutterApiImpl, ZoomStateFlutterApiImpl? zoomStateFlutterApiImpl, - AnalyzerFlutterApiImpl? analyzerFlutterApiImpl, + LiveDataFlutterApiImpl? liveDataFlutterApiImpl, + ObserverFlutterApiImpl? observerFlutterApiImpl, ImageProxyFlutterApiImpl? imageProxyFlutterApiImpl, PlaneProxyFlutterApiImpl? planeProxyFlutterApiImpl, + AnalyzerFlutterApiImpl? analyzerFlutterApiImpl, }) { - this.javaObjectFlutterApi = - javaObjectFlutterApi ?? JavaObjectFlutterApiImpl(); - this.cameraInfoFlutterApi = - cameraInfoFlutterApi ?? CameraInfoFlutterApiImpl(); - this.cameraSelectorFlutterApi = - cameraSelectorFlutterApi ?? CameraSelectorFlutterApiImpl(); - this.processCameraProviderFlutterApi = processCameraProviderFlutterApi ?? - ProcessCameraProviderFlutterApiImpl(); - this.cameraFlutterApi = cameraFlutterApi ?? CameraFlutterApiImpl(); - this.systemServicesFlutterApi = - systemServicesFlutterApi ?? SystemServicesFlutterApiImpl(); + this.javaObjectFlutterApiImpl = + javaObjectFlutterApiImpl ?? JavaObjectFlutterApiImpl(); + this.cameraInfoFlutterApiImpl = + cameraInfoFlutterApiImpl ?? CameraInfoFlutterApiImpl(); + this.cameraSelectorFlutterApiImpl = + cameraSelectorFlutterApiImpl ?? CameraSelectorFlutterApiImpl(); + this.processCameraProviderFlutterApiImpl = + processCameraProviderFlutterApiImpl ?? + ProcessCameraProviderFlutterApiImpl(); + this.cameraFlutterApiImpl = cameraFlutterApiImpl ?? CameraFlutterApiImpl(); + this.systemServicesFlutterApiImpl = + systemServicesFlutterApiImpl ?? SystemServicesFlutterApiImpl(); + this.cameraStateErrorFlutterApiImpl = + cameraStateErrorFlutterApiImpl ?? CameraStateErrorFlutterApiImpl(); + this.cameraStateFlutterApiImpl = + cameraStateFlutterApiImpl ?? CameraStateFlutterApiImpl(); this.exposureStateFlutterApiImpl = exposureStateFlutterApiImpl ?? ExposureStateFlutterApiImpl(); this.zoomStateFlutterApiImpl = zoomStateFlutterApiImpl ?? ZoomStateFlutterApiImpl(); + this.liveDataFlutterApiImpl = + liveDataFlutterApiImpl ?? LiveDataFlutterApiImpl(); + this.observerFlutterApiImpl = + observerFlutterApiImpl ?? ObserverFlutterApiImpl(); this.analyzerFlutterApiImpl = analyzerFlutterApiImpl ?? AnalyzerFlutterApiImpl(); this.imageProxyFlutterApiImpl = @@ -87,6 +100,12 @@ class AndroidCameraXCameraFlutterApis { /// Flutter Api for [ZoomState]. late final ZoomStateFlutterApiImpl zoomStateFlutterApiImpl; + /// Flutter Api for [ExposureState]. + late final ExposureStateFlutterApiImpl exposureStateFlutterApiImpl; + + /// Flutter Api for [ZoomState]. + late final ZoomStateFlutterApiImpl zoomStateFlutterApiImpl; + /// Flutter Api implementation for [Analyzer]. late final AnalyzerFlutterApiImpl analyzerFlutterApiImpl; @@ -99,12 +118,15 @@ class AndroidCameraXCameraFlutterApis { /// Ensures all the Flutter APIs have been setup to receive calls from native code. void ensureSetUp() { if (!_haveBeenSetUp) { - JavaObjectFlutterApi.setup(javaObjectFlutterApi); - CameraInfoFlutterApi.setup(cameraInfoFlutterApi); - CameraSelectorFlutterApi.setup(cameraSelectorFlutterApi); - ProcessCameraProviderFlutterApi.setup(processCameraProviderFlutterApi); - CameraFlutterApi.setup(cameraFlutterApi); - SystemServicesFlutterApi.setup(systemServicesFlutterApi); + JavaObjectFlutterApi.setup(javaObjectFlutterApiImpl); + CameraInfoFlutterApi.setup(cameraInfoFlutterApiImpl); + CameraSelectorFlutterApi.setup(cameraSelectorFlutterApiImpl); + ProcessCameraProviderFlutterApi.setup( + processCameraProviderFlutterApiImpl); + CameraFlutterApi.setup(cameraFlutterApiImpl); + SystemServicesFlutterApi.setup(systemServicesFlutterApiImpl); + CameraStateErrorFlutterApi.setup(cameraStateErrorFlutterApiImpl); + CameraStateFlutterApi.setup(cameraStateFlutterApiImpl); ExposureStateFlutterApi.setup(exposureStateFlutterApiImpl); ZoomStateFlutterApi.setup(zoomStateFlutterApiImpl); AnalyzerFlutterApi.setup(analyzerFlutterApiImpl); diff --git a/packages/camera/camera_android_camerax/lib/src/camera_info.dart b/packages/camera/camera_android_camerax/lib/src/camera_info.dart index f2fdc1fdc879..07e6816fc70a 100644 --- a/packages/camera/camera_android_camerax/lib/src/camera_info.dart +++ b/packages/camera/camera_android_camerax/lib/src/camera_info.dart @@ -9,6 +9,7 @@ import 'camerax_library.g.dart'; import 'exposure_state.dart'; import 'instance_manager.dart'; import 'java_object.dart'; +import 'live_data.dart'; import 'zoom_state.dart'; /// Represents the metadata of a camera. @@ -32,6 +33,10 @@ class CameraInfo extends JavaObject { Future getSensorRotationDegrees() => _api.getSensorRotationDegreesFromInstance(this); + /// Starts listening for the camera closing. + Future> getLiveCameraState() => + _api.getLiveCameraStateFromInstance(this); + /// Gets the exposure state of the camera. Future getExposureState() => _api.getExposureStateFromInstance(this); @@ -76,6 +81,23 @@ class _CameraInfoHostApiImpl extends CameraInfoHostApi { return instanceManager .getInstanceWithWeakReference(zoomStateIdentifier)!; } + + /// Gets the [ExposureState] of the specified [CameraInfo] instance. + Future getExposureStateFromInstance( + CameraInfo instance) async { + final int? identifier = instanceManager.getIdentifier(instance); + final int exposureStateIdentifier = await getExposureState(identifier!); + return instanceManager + .getInstanceWithWeakReference(exposureStateIdentifier)!; + } + + /// Gets the [ZoomState] of the specified [CameraInfo] instance. + Future getZoomStateFromInstance(CameraInfo instance) async { + final int? identifier = instanceManager.getIdentifier(instance); + final int zoomStateIdentifier = await getZoomState(identifier!); + return instanceManager + .getInstanceWithWeakReference(zoomStateIdentifier)!; + } } /// Flutter API implementation of [CameraInfo]. diff --git a/packages/camera/camera_android_camerax/lib/src/camerax_library.g.dart b/packages/camera/camera_android_camerax/lib/src/camerax_library.g.dart index f2d2e17152fb..b5afcaa735a9 100644 --- a/packages/camera/camera_android_camerax/lib/src/camerax_library.g.dart +++ b/packages/camera/camera_android_camerax/lib/src/camerax_library.g.dart @@ -89,6 +89,32 @@ class ExposureCompensationRange { } } +class ExposureCompensationRange { + ExposureCompensationRange({ + required this.minCompensation, + required this.maxCompensation, + }); + + int minCompensation; + + int maxCompensation; + + Object encode() { + return [ + minCompensation, + maxCompensation, + ]; + } + + static ExposureCompensationRange decode(Object result) { + result as List; + return ExposureCompensationRange( + minCompensation: result[0]! as int, + maxCompensation: result[1]! as int, + ); + } +} + class InstanceManagerHostApi { /// Constructor for [InstanceManagerHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default @@ -106,7 +132,8 @@ class InstanceManagerHostApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.InstanceManagerHostApi.clear', codec, binaryMessenger: _binaryMessenger); - final List? replyList = await channel.send(null) as List?; + final List? replyList = + await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -162,8 +189,7 @@ abstract class JavaObjectFlutterApi { void dispose(int identifier); - static void setup(JavaObjectFlutterApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(JavaObjectFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.JavaObjectFlutterApi.dispose', codec, @@ -173,7 +199,7 @@ abstract class JavaObjectFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.JavaObjectFlutterApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.JavaObjectFlutterApi.dispose was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -223,6 +249,33 @@ class CameraInfoHostApi { } } + Future getLiveCameraState(int arg_identifier) async { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.CameraInfoHostApi.getLiveCameraState', codec, + binaryMessenger: _binaryMessenger); + final List? replyList = + await channel.send([arg_identifier]) as List?; + if (replyList == null) { + throw PlatformException( + code: 'channel-error', + message: 'Unable to establish connection on channel.', + ); + } else if (replyList.length > 1) { + throw PlatformException( + code: replyList[0]! as String, + message: replyList[1] as String?, + details: replyList[2], + ); + } else if (replyList[0] == null) { + throw PlatformException( + code: 'null-error', + message: 'Host platform returned null value for non-null return value.', + ); + } else { + return (replyList[0] as int?)!; + } + } + Future getExposureState(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraInfoHostApi.getExposureState', codec, @@ -283,8 +336,7 @@ abstract class CameraInfoFlutterApi { void create(int identifier); - static void setup(CameraInfoFlutterApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(CameraInfoFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraInfoFlutterApi.create', codec, @@ -294,7 +346,7 @@ abstract class CameraInfoFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraInfoFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.CameraInfoFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -321,8 +373,8 @@ class CameraSelectorHostApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraSelectorHostApi.create', codec, binaryMessenger: _binaryMessenger); - final List? replyList = await channel - .send([arg_identifier, arg_lensFacing]) as List?; + final List? replyList = + await channel.send([arg_identifier, arg_lensFacing]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -339,13 +391,12 @@ class CameraSelectorHostApi { } } - Future> filter( - int arg_identifier, List arg_cameraInfoIds) async { + Future> filter(int arg_identifier, List arg_cameraInfoIds) async { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraSelectorHostApi.filter', codec, binaryMessenger: _binaryMessenger); - final List? replyList = await channel - .send([arg_identifier, arg_cameraInfoIds]) as List?; + final List? replyList = + await channel.send([arg_identifier, arg_cameraInfoIds]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -373,8 +424,7 @@ abstract class CameraSelectorFlutterApi { void create(int identifier, int? lensFacing); - static void setup(CameraSelectorFlutterApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(CameraSelectorFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraSelectorFlutterApi.create', codec, @@ -384,7 +434,7 @@ abstract class CameraSelectorFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraSelectorFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.CameraSelectorFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -412,7 +462,8 @@ class ProcessCameraProviderHostApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ProcessCameraProviderHostApi.getInstance', codec, binaryMessenger: _binaryMessenger); - final List? replyList = await channel.send(null) as List?; + final List? replyList = + await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -436,8 +487,7 @@ class ProcessCameraProviderHostApi { Future> getAvailableCameraInfos(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos', - codec, + 'dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; @@ -462,17 +512,12 @@ class ProcessCameraProviderHostApi { } } - Future bindToLifecycle(int arg_identifier, - int arg_cameraSelectorIdentifier, List arg_useCaseIds) async { + Future bindToLifecycle(int arg_identifier, int arg_cameraSelectorIdentifier, List arg_useCaseIds) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle', - codec, + 'dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle', codec, binaryMessenger: _binaryMessenger); - final List? replyList = await channel.send([ - arg_identifier, - arg_cameraSelectorIdentifier, - arg_useCaseIds - ]) as List?; + final List? replyList = + await channel.send([arg_identifier, arg_cameraSelectorIdentifier, arg_useCaseIds]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -499,8 +544,7 @@ class ProcessCameraProviderHostApi { 'dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound', codec, binaryMessenger: _binaryMessenger); final List? replyList = - await channel.send([arg_identifier, arg_useCaseIdentifier]) - as List?; + await channel.send([arg_identifier, arg_useCaseIdentifier]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -526,8 +570,8 @@ class ProcessCameraProviderHostApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind', codec, binaryMessenger: _binaryMessenger); - final List? replyList = await channel - .send([arg_identifier, arg_useCaseIds]) as List?; + final List? replyList = + await channel.send([arg_identifier, arg_useCaseIds]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -572,8 +616,7 @@ abstract class ProcessCameraProviderFlutterApi { void create(int identifier); - static void setup(ProcessCameraProviderFlutterApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(ProcessCameraProviderFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ProcessCameraProviderFlutterApi.create', codec, @@ -583,7 +626,7 @@ abstract class ProcessCameraProviderFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ProcessCameraProviderFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.ProcessCameraProviderFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -649,7 +692,7 @@ abstract class CameraFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.CameraFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -677,7 +720,7 @@ class _SystemServicesHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return CameraPermissionsErrorData.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -695,11 +738,9 @@ class SystemServicesHostApi { static const MessageCodec codec = _SystemServicesHostApiCodec(); - Future requestCameraPermissions( - bool arg_enableAudio) async { + Future requestCameraPermissions(bool arg_enableAudio) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions', - codec, + 'dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions', codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_enableAudio]) as List?; @@ -719,15 +760,12 @@ class SystemServicesHostApi { } } - Future startListeningForDeviceOrientationChange( - bool arg_isFrontFacing, int arg_sensorOrientation) async { + Future startListeningForDeviceOrientationChange(bool arg_isFrontFacing, int arg_sensorOrientation) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange', - codec, + 'dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange', codec, binaryMessenger: _binaryMessenger); final List? replyList = - await channel.send([arg_isFrontFacing, arg_sensorOrientation]) - as List?; + await channel.send([arg_isFrontFacing, arg_sensorOrientation]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -746,10 +784,10 @@ class SystemServicesHostApi { Future stopListeningForDeviceOrientationChange() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesHostApi.stopListeningForDeviceOrientationChange', - codec, + 'dev.flutter.pigeon.SystemServicesHostApi.stopListeningForDeviceOrientationChange', codec, binaryMessenger: _binaryMessenger); - final List? replyList = await channel.send(null) as List?; + final List? replyList = + await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -774,19 +812,17 @@ abstract class SystemServicesFlutterApi { void onCameraError(String errorDescription); - static void setup(SystemServicesFlutterApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(SystemServicesFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesFlutterApi.onDeviceOrientationChanged', - codec, + 'dev.flutter.pigeon.SystemServicesFlutterApi.onDeviceOrientationChanged', codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMessageHandler(null); } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.SystemServicesFlutterApi.onDeviceOrientationChanged was null.'); + 'Argument for dev.flutter.pigeon.SystemServicesFlutterApi.onDeviceOrientationChanged was null.'); final List args = (message as List?)!; final String? arg_orientation = (args[0] as String?); assert(arg_orientation != null, @@ -805,7 +841,7 @@ abstract class SystemServicesFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.SystemServicesFlutterApi.onCameraError was null.'); + 'Argument for dev.flutter.pigeon.SystemServicesFlutterApi.onCameraError was null.'); final List args = (message as List?)!; final String? arg_errorDescription = (args[0] as String?); assert(arg_errorDescription != null, @@ -836,9 +872,9 @@ class _PreviewHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ResolutionInfo.decode(readValue(buffer)!); - case 129: + case 129: return ResolutionInfo.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -856,14 +892,12 @@ class PreviewHostApi { static const MessageCodec codec = _PreviewHostApiCodec(); - Future create(int arg_identifier, int? arg_rotation, - ResolutionInfo? arg_targetResolution) async { + Future create(int arg_identifier, int? arg_rotation, ResolutionInfo? arg_targetResolution) async { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.PreviewHostApi.create', codec, binaryMessenger: _binaryMessenger); - final List? replyList = await channel - .send([arg_identifier, arg_rotation, arg_targetResolution]) - as List?; + final List? replyList = + await channel.send([arg_identifier, arg_rotation, arg_targetResolution]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -911,7 +945,8 @@ class PreviewHostApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.PreviewHostApi.releaseFlutterSurfaceTexture', codec, binaryMessenger: _binaryMessenger); - final List? replyList = await channel.send(null) as List?; + final List? replyList = + await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -971,7 +1006,7 @@ class _ImageCaptureHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ResolutionInfo.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -989,14 +1024,12 @@ class ImageCaptureHostApi { static const MessageCodec codec = _ImageCaptureHostApiCodec(); - Future create(int arg_identifier, int? arg_flashMode, - ResolutionInfo? arg_targetResolution) async { + Future create(int arg_identifier, int? arg_flashMode, ResolutionInfo? arg_targetResolution) async { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageCaptureHostApi.create', codec, binaryMessenger: _binaryMessenger); - final List? replyList = await channel.send( - [arg_identifier, arg_flashMode, arg_targetResolution]) - as List?; + final List? replyList = + await channel.send([arg_identifier, arg_flashMode, arg_targetResolution]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1017,8 +1050,8 @@ class ImageCaptureHostApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageCaptureHostApi.setFlashMode', codec, binaryMessenger: _binaryMessenger); - final List? replyList = await channel - .send([arg_identifier, arg_flashMode]) as List?; + final List? replyList = + await channel.send([arg_identifier, arg_flashMode]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1078,7 +1111,98 @@ class _ExposureStateFlutterApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: + return ExposureCompensationRange.decode(readValue(buffer)!); + default: + return super.readValueOfType(type, buffer); + } + } +} + +abstract class ExposureStateFlutterApi { + static const MessageCodec codec = _ExposureStateFlutterApiCodec(); + + void create(int identifier, ExposureCompensationRange exposureCompensationRange, double exposureCompensationStep); + + static void setup(ExposureStateFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.ExposureStateFlutterApi.create', codec, + binaryMessenger: binaryMessenger); + if (api == null) { + channel.setMessageHandler(null); + } else { + channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null.'); + final List args = (message as List?)!; + final int? arg_identifier = (args[0] as int?); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null, expected non-null int.'); + final ExposureCompensationRange? arg_exposureCompensationRange = (args[1] as ExposureCompensationRange?); + assert(arg_exposureCompensationRange != null, + 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null, expected non-null ExposureCompensationRange.'); + final double? arg_exposureCompensationStep = (args[2] as double?); + assert(arg_exposureCompensationStep != null, + 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null, expected non-null double.'); + api.create(arg_identifier!, arg_exposureCompensationRange!, arg_exposureCompensationStep!); + return; + }); + } + } + } +} + +abstract class ZoomStateFlutterApi { + static const MessageCodec codec = StandardMessageCodec(); + + void create(int identifier, double minZoomRatio, double maxZoomRatio); + + static void setup(ZoomStateFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.ZoomStateFlutterApi.create', codec, + binaryMessenger: binaryMessenger); + if (api == null) { + channel.setMessageHandler(null); + } else { + channel.setMessageHandler((Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.ZoomStateFlutterApi.create was null.'); + final List args = (message as List?)!; + final int? arg_identifier = (args[0] as int?); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.ZoomStateFlutterApi.create was null, expected non-null int.'); + final double? arg_minZoomRatio = (args[1] as double?); + assert(arg_minZoomRatio != null, + 'Argument for dev.flutter.pigeon.ZoomStateFlutterApi.create was null, expected non-null double.'); + final double? arg_maxZoomRatio = (args[2] as double?); + assert(arg_maxZoomRatio != null, + 'Argument for dev.flutter.pigeon.ZoomStateFlutterApi.create was null, expected non-null double.'); + api.create(arg_identifier!, arg_minZoomRatio!, arg_maxZoomRatio!); + return; + }); + } + } + } +} + +class _ExposureStateFlutterApiCodec extends StandardMessageCodec { + const _ExposureStateFlutterApiCodec(); + @override + void writeValue(WriteBuffer buffer, Object? value) { + if (value is ExposureCompensationRange) { + buffer.putUint8(128); + writeValue(buffer, value.encode()); + } else { + super.writeValue(buffer, value); + } + } + + @override + Object? readValueOfType(int type, ReadBuffer buffer) { + switch (type) { + case 128: return ExposureCompensationRange.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -1089,13 +1213,9 @@ class _ExposureStateFlutterApiCodec extends StandardMessageCodec { abstract class ExposureStateFlutterApi { static const MessageCodec codec = _ExposureStateFlutterApiCodec(); - void create( - int identifier, - ExposureCompensationRange exposureCompensationRange, - double exposureCompensationStep); + void create(int identifier, ExposureCompensationRange exposureCompensationRange, double exposureCompensationStep); - static void setup(ExposureStateFlutterApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(ExposureStateFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ExposureStateFlutterApi.create', codec, @@ -1105,20 +1225,18 @@ abstract class ExposureStateFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null, expected non-null int.'); - final ExposureCompensationRange? arg_exposureCompensationRange = - (args[1] as ExposureCompensationRange?); + final ExposureCompensationRange? arg_exposureCompensationRange = (args[1] as ExposureCompensationRange?); assert(arg_exposureCompensationRange != null, 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null, expected non-null ExposureCompensationRange.'); final double? arg_exposureCompensationStep = (args[2] as double?); assert(arg_exposureCompensationStep != null, 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null, expected non-null double.'); - api.create(arg_identifier!, arg_exposureCompensationRange!, - arg_exposureCompensationStep!); + api.create(arg_identifier!, arg_exposureCompensationRange!, arg_exposureCompensationStep!); return; }); } @@ -1131,8 +1249,7 @@ abstract class ZoomStateFlutterApi { void create(int identifier, double minZoomRatio, double maxZoomRatio); - static void setup(ZoomStateFlutterApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(ZoomStateFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ZoomStateFlutterApi.create', codec, @@ -1142,7 +1259,7 @@ abstract class ZoomStateFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ZoomStateFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.ZoomStateFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -1176,7 +1293,7 @@ class _ImageAnalysisHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ResolutionInfo.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -1194,14 +1311,12 @@ class ImageAnalysisHostApi { static const MessageCodec codec = _ImageAnalysisHostApiCodec(); - Future create(int arg_identifier, - ResolutionInfo? arg_targetResolutionIdentifier) async { + Future create(int arg_identifier, ResolutionInfo? arg_targetResolutionIdentifier) async { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageAnalysisHostApi.create', codec, binaryMessenger: _binaryMessenger); - final List? replyList = await channel - .send([arg_identifier, arg_targetResolutionIdentifier]) - as List?; + final List? replyList = + await channel.send([arg_identifier, arg_targetResolutionIdentifier]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1218,14 +1333,12 @@ class ImageAnalysisHostApi { } } - Future setAnalyzer( - int arg_identifier, int arg_analyzerIdentifier) async { + Future setAnalyzer(int arg_identifier, int arg_analyzerIdentifier) async { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageAnalysisHostApi.setAnalyzer', codec, binaryMessenger: _binaryMessenger); final List? replyList = - await channel.send([arg_identifier, arg_analyzerIdentifier]) - as List?; + await channel.send([arg_identifier, arg_analyzerIdentifier]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1305,8 +1418,7 @@ abstract class AnalyzerFlutterApi { void analyze(int identifier, int imageProxyIdentifier); - static void setup(AnalyzerFlutterApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(AnalyzerFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AnalyzerFlutterApi.create', codec, @@ -1316,7 +1428,7 @@ abstract class AnalyzerFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.AnalyzerFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.AnalyzerFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -1335,7 +1447,7 @@ abstract class AnalyzerFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.AnalyzerFlutterApi.analyze was null.'); + 'Argument for dev.flutter.pigeon.AnalyzerFlutterApi.analyze was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -1416,8 +1528,7 @@ abstract class ImageProxyFlutterApi { void create(int identifier, int format, int height, int width); - static void setup(ImageProxyFlutterApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(ImageProxyFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageProxyFlutterApi.create', codec, @@ -1427,7 +1538,7 @@ abstract class ImageProxyFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageProxyFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.ImageProxyFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -1454,8 +1565,7 @@ abstract class PlaneProxyFlutterApi { void create(int identifier, Uint8List buffer, int pixelStride, int rowStride); - static void setup(PlaneProxyFlutterApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(PlaneProxyFlutterApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.PlaneProxyFlutterApi.create', codec, @@ -1465,7 +1575,7 @@ abstract class PlaneProxyFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.PlaneProxyFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.PlaneProxyFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -1479,8 +1589,7 @@ abstract class PlaneProxyFlutterApi { final int? arg_rowStride = (args[3] as int?); assert(arg_rowStride != null, 'Argument for dev.flutter.pigeon.PlaneProxyFlutterApi.create was null, expected non-null int.'); - api.create( - arg_identifier!, arg_buffer!, arg_pixelStride!, arg_rowStride!); + api.create(arg_identifier!, arg_buffer!, arg_pixelStride!, arg_rowStride!); return; }); } diff --git a/packages/camera/camera_android_camerax/pigeons/camerax_library.dart b/packages/camera/camera_android_camerax/pigeons/camerax_library.dart index c8b3885d064b..8e4b0ca7431f 100644 --- a/packages/camera/camera_android_camerax/pigeons/camerax_library.dart +++ b/packages/camera/camera_android_camerax/pigeons/camerax_library.dart @@ -56,6 +56,16 @@ class ExposureCompensationRange { int maxCompensation; } +class ExposureCompensationRange { + ExposureCompensationRange({ + required this.minCompensation, + required this.maxCompensation, + }); + + int minCompensation; + int maxCompensation; +} + @HostApi(dartHostTestHandler: 'TestInstanceManagerHostApi') abstract class InstanceManagerHostApi { /// Clear the native `InstanceManager`. @@ -78,6 +88,8 @@ abstract class JavaObjectFlutterApi { abstract class CameraInfoHostApi { int getSensorRotationDegrees(int identifier); + int getLiveCameraState(int identifier); + int getExposureState(int identifier); int getZoomState(int identifier); @@ -184,6 +196,19 @@ abstract class ZoomStateFlutterApi { void create(int identifier, double minZoomRatio, double maxZoomRatio); } +@FlutterApi() +abstract class ExposureStateFlutterApi { + void create( + int identifier, + ExposureCompensationRange exposureCompensationRange, + double exposureCompensationStep); +} + +@FlutterApi() +abstract class ZoomStateFlutterApi { + void create(int identifier, double minZoomRatio, double maxZoomRatio); +} + @HostApi(dartHostTestHandler: 'TestImageAnalysisHostApi') abstract class ImageAnalysisHostApi { void create(int identifier, ResolutionInfo? targetResolutionIdentifier); diff --git a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart index e7a6707d6e3f..079abe0f2fd4 100644 --- a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart +++ b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart @@ -132,12 +132,19 @@ void main() { camera.processCameraProvider = mockProcessCameraProvider; + camera.processCameraProvider = mockProcessCameraProvider; + when(camera.testPreview.setSurfaceProvider()) .thenAnswer((_) async => testSurfaceTextureId); - when(mockProcessCameraProvider.bindToLifecycle(any, any)) - .thenAnswer((_) => Future.value(mockCamera)); - when(mockCamera.getCameraInfo()) - .thenAnswer((_) => Future.value(MockCameraInfo())); + when(mockProcessCameraProvider.bindToLifecycle( + camera.mockBackCameraSelector, + [camera.testPreview, camera.testImageCapture])) + .thenAnswer((_) async => mockCamera); + when(mockCamera.getCameraInfo()).thenAnswer((_) async => mockCameraInfo); + when(mockCameraInfo.getLiveCameraState()) + .thenAnswer((_) async => mockLiveCameraState); + camera.processCameraProvider = mockProcessCameraProvider; + camera.createDetachedObjectForTesting = true; expect( await camera.createCamera(testCameraDescription, testResolutionPreset, @@ -165,7 +172,7 @@ void main() { 'createCamera binds Preview and ImageCapture use cases to ProcessCameraProvider instance', () async { final MockAndroidCameraCameraX camera = MockAndroidCameraCameraX(); - final MockProcessCameraProvider mockProcessCameraProvider = + final ProcessCameraProvider mockProcessCameraProvider = MockProcessCameraProvider(); final MockCamera mockCamera = MockCamera(); final MockCameraInfo mockCameraInfo = MockCameraInfo(); @@ -178,6 +185,16 @@ void main() { const ResolutionPreset testResolutionPreset = ResolutionPreset.veryHigh; const bool enableAudio = true; + when(mockProcessCameraProvider.bindToLifecycle( + camera.mockBackCameraSelector, + [camera.testPreview, camera.testImageCapture])) + .thenAnswer((_) async => mockCamera); + when(mockCamera.getCameraInfo()).thenAnswer((_) async => mockCameraInfo); + when(mockCameraInfo.getLiveCameraState()) + .thenAnswer((_) async => MockLiveData()); + camera.processCameraProvider = mockProcessCameraProvider; + camera.createDetachedObjectForTesting = true; + camera.processCameraProvider = mockProcessCameraProvider; when(mockProcessCameraProvider.bindToLifecycle( @@ -254,6 +271,16 @@ void main() { await camera.createCamera(testCameraDescription, testResolutionPreset, enableAudio: enableAudio); + when(mockProcessCameraProvider.bindToLifecycle(any, any)) + .thenAnswer((_) async => mockCamera); + when(mockCamera.getCameraInfo()) + .thenAnswer((_) => Future.value(MockCameraInfo())); + when(camera.testPreview.getResolutionInfo()) + .thenAnswer((_) async => testResolutionInfo); + + await camera.createCamera(testCameraDescription, testResolutionPreset, + enableAudio: enableAudio); + // Start listening to camera events stream to verify the proper CameraInitializedEvent is sent. camera.cameraEventStreamController.stream.listen((CameraEvent event) { expect(event, const TypeMatcher()); @@ -381,6 +408,7 @@ void main() { verifyNever(camera.processCameraProvider! .bindToLifecycle(camera.cameraSelector!, [camera.preview!])); + verifyNever(mockLiveCameraState.observe(any)); expect(camera.cameraInfo, isNot(mockCameraInfo)); }); @@ -396,6 +424,11 @@ void main() { camera.cameraSelector = MockCameraSelector(); camera.preview = MockPreview(); + when(mockProcessCameraProvider.bindToLifecycle(any, any)) + .thenAnswer((_) => Future.value(mockCamera)); + when(mockCamera.getCameraInfo()) + .thenAnswer((_) => Future.value(mockCameraInfo)); + when(mockProcessCameraProvider.bindToLifecycle(any, any)) .thenAnswer((_) => Future.value(mockCamera)); when(mockCamera.getCameraInfo()) @@ -405,6 +438,13 @@ void main() { verify(camera.processCameraProvider! .bindToLifecycle(camera.cameraSelector!, [camera.preview!])); + expect( + await testCameraClosingObserver( + camera, + 78, + verify(mockLiveCameraState.observe(captureAny)).captured.single + as Observer), + isTrue); expect(camera.cameraInfo, equals(mockCameraInfo)); }); @@ -421,6 +461,11 @@ void main() { camera.cameraSelector = MockCameraSelector(); camera.preview = MockPreview(); + when(mockProcessCameraProvider.bindToLifecycle(any, any)) + .thenAnswer((_) => Future.value(mockCamera)); + when(mockCamera.getCameraInfo()) + .thenAnswer((_) => Future.value(MockCameraInfo())); + when(mockProcessCameraProvider.bindToLifecycle(any, any)) .thenAnswer((_) => Future.value(mockCamera)); when(mockCamera.getCameraInfo()) @@ -457,6 +502,11 @@ void main() { camera.cameraSelector = MockCameraSelector(); camera.preview = MockPreview(); + when(mockProcessCameraProvider.bindToLifecycle(any, any)) + .thenAnswer((_) => Future.value(mockCamera)); + when(mockCamera.getCameraInfo()) + .thenAnswer((_) => Future.value(mockCameraInfo)); + when(mockProcessCameraProvider.bindToLifecycle(any, any)) .thenAnswer((_) => Future.value(mockCamera)); when(mockCamera.getCameraInfo()) @@ -581,6 +631,11 @@ void main() { camera.cameraSelector = MockCameraSelector(); camera.createDetachedCallbacks = true; + when(mockProcessCameraProvider.bindToLifecycle(any, any)) + .thenAnswer((_) => Future.value(mockCamera)); + when(mockCamera.getCameraInfo()) + .thenAnswer((_) => Future.value(MockCameraInfo())); + when(mockProcessCameraProvider.bindToLifecycle(any, any)) .thenAnswer((_) => Future.value(mockCamera)); when(mockCamera.getCameraInfo()) diff --git a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.mocks.dart b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.mocks.dart index b7365a2e90d4..0c88413c1ad6 100644 --- a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.mocks.dart +++ b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.mocks.dart @@ -203,6 +203,15 @@ class MockCameraInfo extends _i1.Mock implements _i2.CameraInfo { returnValueForMissingStub: _i11.Future.value(0), ) as _i11.Future); @override + _i11.Future getLiveCameraState() => (super.noSuchMethod( + Invocation.method( + #getLiveCameraState, + [], + ), + returnValue: _i11.Future.value(), + returnValueForMissingStub: _i11.Future.value(), + ) as _i11.Future); + @override _i11.Future<_i3.ExposureState> getExposureState() => (super.noSuchMethod( Invocation.method( #getExposureState, diff --git a/packages/camera/camera_android_camerax/test/camera_info_test.dart b/packages/camera/camera_android_camerax/test/camera_info_test.dart index 9826b88e367e..7edf6c409fe0 100644 --- a/packages/camera/camera_android_camerax/test/camera_info_test.dart +++ b/packages/camera/camera_android_camerax/test/camera_info_test.dart @@ -6,6 +6,7 @@ import 'package:camera_android_camerax/src/camera_info.dart'; import 'package:camera_android_camerax/src/camerax_library.g.dart'; import 'package:camera_android_camerax/src/exposure_state.dart'; import 'package:camera_android_camerax/src/instance_manager.dart'; +import 'package:camera_android_camerax/src/live_data.dart'; import 'package:camera_android_camerax/src/zoom_state.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; diff --git a/packages/camera/camera_android_camerax/test/camera_info_test.mocks.dart b/packages/camera/camera_android_camerax/test/camera_info_test.mocks.dart index 968dc6e8b621..4c1bdf696938 100644 --- a/packages/camera/camera_android_camerax/test/camera_info_test.mocks.dart +++ b/packages/camera/camera_android_camerax/test/camera_info_test.mocks.dart @@ -36,6 +36,14 @@ class MockTestCameraInfoHostApi extends _i1.Mock returnValue: 0, ) as int); @override + int getLiveCameraState(int? identifier) => (super.noSuchMethod( + Invocation.method( + #getLiveCameraState, + [identifier], + ), + returnValue: 0, + ) as int); + @override int getExposureState(int? identifier) => (super.noSuchMethod( Invocation.method( #getExposureState, diff --git a/packages/camera/camera_android_camerax/test/camera_test.dart b/packages/camera/camera_android_camerax/test/camera_test.dart index 742a60799e6f..05f5fe7dd029 100644 --- a/packages/camera/camera_android_camerax/test/camera_test.dart +++ b/packages/camera/camera_android_camerax/test/camera_test.dart @@ -20,6 +20,8 @@ void main() { TestInstanceManagerHostApi.setup(MockTestInstanceManagerHostApi()); group('Camera', () { + tearDown(() => TestCameraHostApi.setup(null)); + test('getCameraInfo makes call to retrieve expected CameraInfo', () async { final MockTestCameraHostApi mockApi = MockTestCameraHostApi(); TestCameraHostApi.setup(mockApi); @@ -52,7 +54,7 @@ void main() { verify(mockApi.getCameraInfo(cameraIdentifier)); }); - test('flutterApiCreateTest', () { + test('flutterApiCreate makes call to add instance to instance manager', () { final InstanceManager instanceManager = InstanceManager( onWeakReferenceRemoved: (_) {}, ); diff --git a/packages/camera/camera_android_camerax/test/test_camerax_library.g.dart b/packages/camera/camera_android_camerax/test/test_camerax_library.g.dart index 40bd8f2e4335..098b297bcf0a 100644 --- a/packages/camera/camera_android_camerax/test/test_camerax_library.g.dart +++ b/packages/camera/camera_android_camerax/test/test_camerax_library.g.dart @@ -14,8 +14,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:camera_android_camerax/src/camerax_library.g.dart'; abstract class TestInstanceManagerHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => - TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// Clear the native `InstanceManager`. @@ -23,19 +22,15 @@ abstract class TestInstanceManagerHostApi { /// This is typically only used after a hot restart. void clear(); - static void setup(TestInstanceManagerHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestInstanceManagerHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.InstanceManagerHostApi.clear', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { // ignore message api.clear(); return []; @@ -46,27 +41,22 @@ abstract class TestInstanceManagerHostApi { } abstract class TestJavaObjectHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => - TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); void dispose(int identifier); - static void setup(TestJavaObjectHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestJavaObjectHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.JavaObjectHostApi.dispose', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.JavaObjectHostApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.JavaObjectHostApi.dispose was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -80,32 +70,28 @@ abstract class TestJavaObjectHostApi { } abstract class TestCameraInfoHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => - TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); int getSensorRotationDegrees(int identifier); + int getLiveCameraState(int identifier); + int getExposureState(int identifier); int getZoomState(int identifier); - static void setup(TestCameraInfoHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestCameraInfoHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.CameraInfoHostApi.getSensorRotationDegrees', - codec, + 'dev.flutter.pigeon.CameraInfoHostApi.getSensorRotationDegrees', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getSensorRotationDegrees was null.'); + 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getSensorRotationDegrees was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -115,19 +101,35 @@ abstract class TestCameraInfoHostApi { }); } } + { + final BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.CameraInfoHostApi.getLiveCameraState', codec, + binaryMessenger: binaryMessenger); + if (api == null) { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + } else { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + assert(message != null, + 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getLiveCameraState was null.'); + final List args = (message as List?)!; + final int? arg_identifier = (args[0] as int?); + assert(arg_identifier != null, + 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getLiveCameraState was null, expected non-null int.'); + final int output = api.getLiveCameraState(arg_identifier!); + return [output]; + }); + } + } { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraInfoHostApi.getExposureState', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getExposureState was null.'); + 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getExposureState was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -142,14 +144,11 @@ abstract class TestCameraInfoHostApi { 'dev.flutter.pigeon.CameraInfoHostApi.getZoomState', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getZoomState was null.'); + 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getZoomState was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -163,29 +162,24 @@ abstract class TestCameraInfoHostApi { } abstract class TestCameraSelectorHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => - TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); void create(int identifier, int? lensFacing); List filter(int identifier, List cameraInfoIds); - static void setup(TestCameraSelectorHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestCameraSelectorHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraSelectorHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraSelectorHostApi.create was null.'); + 'Argument for dev.flutter.pigeon.CameraSelectorHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -201,24 +195,19 @@ abstract class TestCameraSelectorHostApi { 'dev.flutter.pigeon.CameraSelectorHostApi.filter', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraSelectorHostApi.filter was null.'); + 'Argument for dev.flutter.pigeon.CameraSelectorHostApi.filter was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.CameraSelectorHostApi.filter was null, expected non-null int.'); - final List? arg_cameraInfoIds = - (args[1] as List?)?.cast(); + final List? arg_cameraInfoIds = (args[1] as List?)?.cast(); assert(arg_cameraInfoIds != null, 'Argument for dev.flutter.pigeon.CameraSelectorHostApi.filter was null, expected non-null List.'); - final List output = - api.filter(arg_identifier!, arg_cameraInfoIds!); + final List output = api.filter(arg_identifier!, arg_cameraInfoIds!); return [output]; }); } @@ -227,16 +216,14 @@ abstract class TestCameraSelectorHostApi { } abstract class TestProcessCameraProviderHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => - TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); Future getInstance(); List getAvailableCameraInfos(int identifier); - int bindToLifecycle( - int identifier, int cameraSelectorIdentifier, List useCaseIds); + int bindToLifecycle(int identifier, int cameraSelectorIdentifier, List useCaseIds); bool isBound(int identifier, int useCaseIdentifier); @@ -244,19 +231,15 @@ abstract class TestProcessCameraProviderHostApi { void unbindAll(int identifier); - static void setup(TestProcessCameraProviderHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestProcessCameraProviderHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ProcessCameraProviderHostApi.getInstance', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { // ignore message final int output = await api.getInstance(); return [output]; @@ -265,42 +248,33 @@ abstract class TestProcessCameraProviderHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos', - codec, + 'dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos was null.'); + 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos was null, expected non-null int.'); - final List output = - api.getAvailableCameraInfos(arg_identifier!); + final List output = api.getAvailableCameraInfos(arg_identifier!); return [output]; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle', - codec, + 'dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle was null.'); + 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -308,12 +282,10 @@ abstract class TestProcessCameraProviderHostApi { final int? arg_cameraSelectorIdentifier = (args[1] as int?); assert(arg_cameraSelectorIdentifier != null, 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle was null, expected non-null int.'); - final List? arg_useCaseIds = - (args[2] as List?)?.cast(); + final List? arg_useCaseIds = (args[2] as List?)?.cast(); assert(arg_useCaseIds != null, 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle was null, expected non-null List.'); - final int output = api.bindToLifecycle( - arg_identifier!, arg_cameraSelectorIdentifier!, arg_useCaseIds!); + final int output = api.bindToLifecycle(arg_identifier!, arg_cameraSelectorIdentifier!, arg_useCaseIds!); return [output]; }); } @@ -323,14 +295,11 @@ abstract class TestProcessCameraProviderHostApi { 'dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound was null.'); + 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -338,8 +307,7 @@ abstract class TestProcessCameraProviderHostApi { final int? arg_useCaseIdentifier = (args[1] as int?); assert(arg_useCaseIdentifier != null, 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound was null, expected non-null int.'); - final bool output = - api.isBound(arg_identifier!, arg_useCaseIdentifier!); + final bool output = api.isBound(arg_identifier!, arg_useCaseIdentifier!); return [output]; }); } @@ -349,20 +317,16 @@ abstract class TestProcessCameraProviderHostApi { 'dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind was null.'); + 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind was null, expected non-null int.'); - final List? arg_useCaseIds = - (args[1] as List?)?.cast(); + final List? arg_useCaseIds = (args[1] as List?)?.cast(); assert(arg_useCaseIds != null, 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind was null, expected non-null List.'); api.unbind(arg_identifier!, arg_useCaseIds!); @@ -375,14 +339,11 @@ abstract class TestProcessCameraProviderHostApi { 'dev.flutter.pigeon.ProcessCameraProviderHostApi.unbindAll', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.unbindAll was null.'); + 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.unbindAll was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -396,27 +357,22 @@ abstract class TestProcessCameraProviderHostApi { } abstract class TestCameraHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => - TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); int getCameraInfo(int identifier); - static void setup(TestCameraHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestCameraHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraHostApi.getCameraInfo', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraHostApi.getCameraInfo was null.'); + 'Argument for dev.flutter.pigeon.CameraHostApi.getCameraInfo was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -444,7 +400,7 @@ class _TestSystemServicesHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return CameraPermissionsErrorData.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -453,58 +409,45 @@ class _TestSystemServicesHostApiCodec extends StandardMessageCodec { } abstract class TestSystemServicesHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => - TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = _TestSystemServicesHostApiCodec(); - Future requestCameraPermissions( - bool enableAudio); + Future requestCameraPermissions(bool enableAudio); - void startListeningForDeviceOrientationChange( - bool isFrontFacing, int sensorOrientation); + void startListeningForDeviceOrientationChange(bool isFrontFacing, int sensorOrientation); void stopListeningForDeviceOrientationChange(); - static void setup(TestSystemServicesHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestSystemServicesHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions', - codec, + 'dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions was null.'); + 'Argument for dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions was null.'); final List args = (message as List?)!; final bool? arg_enableAudio = (args[0] as bool?); assert(arg_enableAudio != null, 'Argument for dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions was null, expected non-null bool.'); - final CameraPermissionsErrorData? output = - await api.requestCameraPermissions(arg_enableAudio!); + final CameraPermissionsErrorData? output = await api.requestCameraPermissions(arg_enableAudio!); return [output]; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange', - codec, + 'dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange was null.'); + 'Argument for dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange was null.'); final List args = (message as List?)!; final bool? arg_isFrontFacing = (args[0] as bool?); assert(arg_isFrontFacing != null, @@ -512,24 +455,19 @@ abstract class TestSystemServicesHostApi { final int? arg_sensorOrientation = (args[1] as int?); assert(arg_sensorOrientation != null, 'Argument for dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange was null, expected non-null int.'); - api.startListeningForDeviceOrientationChange( - arg_isFrontFacing!, arg_sensorOrientation!); + api.startListeningForDeviceOrientationChange(arg_isFrontFacing!, arg_sensorOrientation!); return []; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesHostApi.stopListeningForDeviceOrientationChange', - codec, + 'dev.flutter.pigeon.SystemServicesHostApi.stopListeningForDeviceOrientationChange', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { // ignore message api.stopListeningForDeviceOrientationChange(); return []; @@ -557,9 +495,9 @@ class _TestPreviewHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ResolutionInfo.decode(readValue(buffer)!); - case 129: + case 129: return ResolutionInfo.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -568,8 +506,7 @@ class _TestPreviewHostApiCodec extends StandardMessageCodec { } abstract class TestPreviewHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => - TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = _TestPreviewHostApiCodec(); void create(int identifier, int? rotation, ResolutionInfo? targetResolution); @@ -580,28 +517,23 @@ abstract class TestPreviewHostApi { ResolutionInfo getResolutionInfo(int identifier); - static void setup(TestPreviewHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestPreviewHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.PreviewHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.PreviewHostApi.create was null.'); + 'Argument for dev.flutter.pigeon.PreviewHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.PreviewHostApi.create was null, expected non-null int.'); final int? arg_rotation = (args[1] as int?); - final ResolutionInfo? arg_targetResolution = - (args[2] as ResolutionInfo?); + final ResolutionInfo? arg_targetResolution = (args[2] as ResolutionInfo?); api.create(arg_identifier!, arg_rotation, arg_targetResolution); return []; }); @@ -612,14 +544,11 @@ abstract class TestPreviewHostApi { 'dev.flutter.pigeon.PreviewHostApi.setSurfaceProvider', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.PreviewHostApi.setSurfaceProvider was null.'); + 'Argument for dev.flutter.pigeon.PreviewHostApi.setSurfaceProvider was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -631,16 +560,12 @@ abstract class TestPreviewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PreviewHostApi.releaseFlutterSurfaceTexture', - codec, + 'dev.flutter.pigeon.PreviewHostApi.releaseFlutterSurfaceTexture', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { // ignore message api.releaseFlutterSurfaceTexture(); return []; @@ -652,14 +577,11 @@ abstract class TestPreviewHostApi { 'dev.flutter.pigeon.PreviewHostApi.getResolutionInfo', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.PreviewHostApi.getResolutionInfo was null.'); + 'Argument for dev.flutter.pigeon.PreviewHostApi.getResolutionInfo was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -687,7 +609,7 @@ class _TestImageCaptureHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ResolutionInfo.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -696,8 +618,7 @@ class _TestImageCaptureHostApiCodec extends StandardMessageCodec { } abstract class TestImageCaptureHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => - TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = _TestImageCaptureHostApiCodec(); void create(int identifier, int? flashMode, ResolutionInfo? targetResolution); @@ -706,28 +627,23 @@ abstract class TestImageCaptureHostApi { Future takePicture(int identifier); - static void setup(TestImageCaptureHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestImageCaptureHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageCaptureHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.create was null.'); + 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.create was null, expected non-null int.'); final int? arg_flashMode = (args[1] as int?); - final ResolutionInfo? arg_targetResolution = - (args[2] as ResolutionInfo?); + final ResolutionInfo? arg_targetResolution = (args[2] as ResolutionInfo?); api.create(arg_identifier!, arg_flashMode, arg_targetResolution); return []; }); @@ -738,14 +654,11 @@ abstract class TestImageCaptureHostApi { 'dev.flutter.pigeon.ImageCaptureHostApi.setFlashMode', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.setFlashMode was null.'); + 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.setFlashMode was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -763,14 +676,11 @@ abstract class TestImageCaptureHostApi { 'dev.flutter.pigeon.ImageCaptureHostApi.takePicture', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.takePicture was null.'); + 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.takePicture was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -798,7 +708,7 @@ class _TestImageAnalysisHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ResolutionInfo.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -807,8 +717,7 @@ class _TestImageAnalysisHostApiCodec extends StandardMessageCodec { } abstract class TestImageAnalysisHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => - TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = _TestImageAnalysisHostApiCodec(); void create(int identifier, ResolutionInfo? targetResolutionIdentifier); @@ -817,27 +726,22 @@ abstract class TestImageAnalysisHostApi { void clearAnalyzer(int identifier); - static void setup(TestImageAnalysisHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestImageAnalysisHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageAnalysisHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.create was null.'); + 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.create was null, expected non-null int.'); - final ResolutionInfo? arg_targetResolutionIdentifier = - (args[1] as ResolutionInfo?); + final ResolutionInfo? arg_targetResolutionIdentifier = (args[1] as ResolutionInfo?); api.create(arg_identifier!, arg_targetResolutionIdentifier); return []; }); @@ -848,14 +752,11 @@ abstract class TestImageAnalysisHostApi { 'dev.flutter.pigeon.ImageAnalysisHostApi.setAnalyzer', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.setAnalyzer was null.'); + 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.setAnalyzer was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -873,14 +774,11 @@ abstract class TestImageAnalysisHostApi { 'dev.flutter.pigeon.ImageAnalysisHostApi.clearAnalyzer', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.clearAnalyzer was null.'); + 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.clearAnalyzer was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -894,27 +792,22 @@ abstract class TestImageAnalysisHostApi { } abstract class TestAnalyzerHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => - TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); void create(int identifier); - static void setup(TestAnalyzerHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestAnalyzerHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AnalyzerHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.AnalyzerHostApi.create was null.'); + 'Argument for dev.flutter.pigeon.AnalyzerHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -928,29 +821,24 @@ abstract class TestAnalyzerHostApi { } abstract class TestImageProxyHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => - TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); List getPlanes(int identifier); void close(int identifier); - static void setup(TestImageProxyHostApi? api, - {BinaryMessenger? binaryMessenger}) { + static void setup(TestImageProxyHostApi? api, {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageProxyHostApi.getPlanes', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageProxyHostApi.getPlanes was null.'); + 'Argument for dev.flutter.pigeon.ImageProxyHostApi.getPlanes was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -965,14 +853,11 @@ abstract class TestImageProxyHostApi { 'dev.flutter.pigeon.ImageProxyHostApi.close', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger - .setMockDecodedMessageHandler(channel, - (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageProxyHostApi.close was null.'); + 'Argument for dev.flutter.pigeon.ImageProxyHostApi.close was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, From 886e0495a79779c1b8593cb44b54f58bbf06e48d Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 2 May 2023 14:55:25 -0700 Subject: [PATCH 02/15] Start writing readme --- .../camera/camera_android_camerax/README.md | 63 ++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/packages/camera/camera_android_camerax/README.md b/packages/camera/camera_android_camerax/README.md index 06d837ac7214..34376d32dc9c 100644 --- a/packages/camera/camera_android_camerax/README.md +++ b/packages/camera/camera_android_camerax/README.md @@ -1,3 +1,62 @@ -# camera_android_camerax +# camera\_android\_camerax -An implementation of the camera plugin on Android using CameraX. +An Android implementation of [`camera`][1] that uses the [CameraX library][2]. + +*Note*: This package is under development. +See [missing implementations and limitations](#missing-features-and-limitations). + +## Usage + +This package is [unendorsed][3]; the endorsed Android implementation of `camera` +is [`camera_android`][4]. To use this implementation of the plugin, you will need +to specify it in your `pubsepc.yaml` file as a dependency in addition to `camera`: + +```yaml +dependencies: + # ...along with your other dependencies + camera: ^0.10.4 + camera_android_camerax: ^0.5.0 +``` + +## Contributing + + +## Missing features and limitations + +### Resolution configuration \[[Issue #120462][5]\] + +Any specified `ResolutionPreset` is unused in favor of CameraX defaults and +`onCameraResolutionChanged` is unimplemented. + +### Locking/Unlocking capture orientation \[[Issue #125915][6]\] + +`lockCaptureOrientation` & `unLockCaptureOrientation` are unimplemented. + +### Flash mode configuration \[[Issue #120715][7]\] + +`setFlashMode` is unimplemented. + +### Exposure mode, point, & offset configuration \[[Issue #120468][8]\] + +`setExposureMode`, `setExposurePoint`, & `setExposureOffset` are unimplemented. + +### Focus mode & point configuration \[[Issue #120467][9]\] + +`setFocusMode` & `setFocusPoint` are unimplemented. + +### Zoom configuration \[[Issue #125371][9]\] + +`setZoomLevel` is unimplemented. + + + +[1]: https://pub.dev/packages/camera +[2]: https://developer.android.com/training/camerax +[3]: https://docs.flutter.dev/packages-and-plugins/developing-packages#non-endorsed-federated-plugin +[4]: https://pub.dev/packages/camera_android +[5]: https://github.com/flutter/flutter/issues/120462 +[6]: https://github.com/flutter/flutter/issues/125915 +[7]: https://github.com/flutter/flutter/issues/120715 +[8]: https://github.com/flutter/flutter/issues/120468 +[9]: https://github.com/flutter/flutter/issues/120467 +[10]: https://github.com/flutter/flutter/issues/125371 From cd1f2a72d54137f399799347de14db2eecc73156 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 2 May 2023 17:59:58 -0700 Subject: [PATCH 03/15] Finish draft --- .../camera/camera_android_camerax/README.md | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/packages/camera/camera_android_camerax/README.md b/packages/camera/camera_android_camerax/README.md index 34376d32dc9c..dda30612cabd 100644 --- a/packages/camera/camera_android_camerax/README.md +++ b/packages/camera/camera_android_camerax/README.md @@ -20,6 +20,40 @@ dependencies: ## Contributing +The `camera` implementation is located at `./lib/src/android_camera_camerax.dart`, and +it is implemented using Dart classes that act as wrapped versions of the Android +classes that the implementation needs access to. + +To understand how this works, consider the example of [`Camera`][11], the interface +provided by CameraX used to control the flow of data to use cases, control the camera, +and publish the state of the camera via CameraInfo. The Dart-wrapped version of this +class is located at `./lib/src/camera.dart`. You'll notice its implementation as +`Camera`, but also two additional classes: `CameraHostApiImpl`, an extension +of the Host API used by [`pigeon`][12] to communicate with native code, and +`CameraFlutterApiImpl`, the implementation of the Flutter API used by `pigeon` to +communicate with native code. The file that `pigeon` uses to generate the Host +and Flutter APIs used by these classes is located at `pigeons/camerax_library.dart`. + +Both `CameraHostApiImpl` and `CameraFlutterApiImpl` utilize `BinaryMessenger` +instances to communicate with native code using `pigeon`; for more information on +`pigeon`, see its [documentation][12]. Both of these classes additionally utilize +an `InstanceManager` instance that is used to manage Dart objects that represent +their Android counterparts. For example, the `InstanceManager` instance is used +to manage any instances of `Camera` we create in Dart and in native, and any other +instances that `Camera` methods may create. + +On the native side, you'll find two Java classes that mirror these two Dart classes +discussed: in `./android/src/main/java/io/flutter/plugins/camerax/`. you will find +`CameraHostApiImpl.java` and `CameraFlutterApiImpl.java`, which implement the Host +API and extend the Flutter API used by `pigeon`, respectfully. + +WHAT IF INSTEAD I JUST DID A MAP OF THE STRUCTURE VERSUS A LENGTHY EXAMPLE. + + +Thus, if you want to implement any new functionality in the implementation or fix any +bugs, you will want to search in `./lib/src/` for any wrapped classes you may need. If +any classes you need are not wrapped or you need to implement any additional methods, +you will need to take additional steps to wrap them. ## Missing features and limitations @@ -60,3 +94,5 @@ Any specified `ResolutionPreset` is unused in favor of CameraX defaults and [8]: https://github.com/flutter/flutter/issues/120468 [9]: https://github.com/flutter/flutter/issues/120467 [10]: https://github.com/flutter/flutter/issues/125371 +[11]: https://developer.android.com/reference/androidx/camera/core/Camera +[12]: \ No newline at end of file From b7e3cf6d3b14cc9d4fde4840fe3d48069432bef8 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 2 May 2023 18:05:18 -0700 Subject: [PATCH 04/15] Undo unecessary changes --- .../camerax/CameraInfoHostApiImpl.java | 38 -- .../camerax/GeneratedCameraXLibrary.java | 627 ++++++++---------- .../plugins/camerax/CameraInfoTest.java | 1 - .../lib/src/android_camera_camerax.dart | 55 -- ...roid_camera_camerax_flutter_api_impls.dart | 70 +- .../lib/src/camera_info.dart | 22 - .../lib/src/camerax_library.g.dart | 327 +++------ .../pigeons/camerax_library.dart | 25 - .../test/android_camera_camerax_test.dart | 65 +- .../android_camera_camerax_test.mocks.dart | 9 - .../test/camera_info_test.dart | 1 - .../test/camera_info_test.mocks.dart | 8 - .../test/camera_test.dart | 4 +- .../test/test_camerax_library.g.dart | 431 +++++++----- 14 files changed, 707 insertions(+), 976 deletions(-) diff --git a/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/CameraInfoHostApiImpl.java b/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/CameraInfoHostApiImpl.java index 973e2928d789..f9fd7722fc87 100644 --- a/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/CameraInfoHostApiImpl.java +++ b/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/CameraInfoHostApiImpl.java @@ -6,10 +6,8 @@ import androidx.annotation.NonNull; import androidx.camera.core.CameraInfo; -import androidx.camera.core.CameraState; import androidx.camera.core.ExposureState; import androidx.camera.core.ZoomState; -import androidx.lifecycle.LiveData; import io.flutter.plugin.common.BinaryMessenger; import io.flutter.plugins.camerax.GeneratedCameraXLibrary.CameraInfoHostApi; import java.util.Objects; @@ -68,40 +66,4 @@ public Long getZoomState(@NonNull Long identifier) { return instanceManager.getIdentifierForStrongReference(zoomState); } - - /** - * Retrieves the {@link ExposureState} of the {@link CameraInfo} with the specified identifier. - */ - @Override - @NonNull - public Long getExposureState(@NonNull Long identifier) { - CameraInfo cameraInfo = - (CameraInfo) Objects.requireNonNull(instanceManager.getInstance(identifier)); - ExposureState exposureState = cameraInfo.getExposureState(); - - ExposureStateFlutterApiImpl exposureStateFlutterApiImpl = - new ExposureStateFlutterApiImpl(binaryMessenger, instanceManager); - exposureStateFlutterApiImpl.create(exposureState, result -> {}); - - return instanceManager.getIdentifierForStrongReference(exposureState); - } - - /** - * Retrieves the current {@link ZoomState} value of the {@link CameraInfo} with the specified - * identifier. - */ - @NonNull - @Override - public Long getZoomState(@NonNull Long identifier) { - CameraInfo cameraInfo = - (CameraInfo) Objects.requireNonNull(instanceManager.getInstance(identifier)); - // TODO(camsim99): Create/return LiveData once https://github.com/flutter/packages/pull/3419 lands. - ZoomState zoomState = cameraInfo.getZoomState().getValue(); - - ZoomStateFlutterApiImpl zoomStateFlutterApiImpl = - new ZoomStateFlutterApiImpl(binaryMessenger, instanceManager); - zoomStateFlutterApiImpl.create(zoomState, result -> {}); - - return instanceManager.getIdentifierForStrongReference(zoomState); - } } diff --git a/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/GeneratedCameraXLibrary.java b/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/GeneratedCameraXLibrary.java index d48feb044a36..882c1d146323 100644 --- a/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/GeneratedCameraXLibrary.java +++ b/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/GeneratedCameraXLibrary.java @@ -18,9 +18,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** Generated class from Pigeon. */ @SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression", "serial"}) @@ -35,8 +33,7 @@ public static class FlutterError extends RuntimeException { /** The error details. Must be a datatype supported by the api codec. */ public final Object details; - public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) - { + public FlutterError(@NonNull String code, @Nullable String message, @Nullable Object details) { super(message); this.code = code; this.details = details; @@ -55,7 +52,7 @@ protected static ArrayList wrapError(@NonNull Throwable exception) { errorList.add(exception.toString()); errorList.add(exception.getClass().getSimpleName()); errorList.add( - "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); + "Cause: " + exception.getCause() + ", Stacktrace: " + Log.getStackTraceString(exception)); } return errorList; } @@ -126,9 +123,13 @@ ArrayList toList() { static @NonNull ResolutionInfo fromList(@NonNull ArrayList list) { ResolutionInfo pigeonResult = new ResolutionInfo(); Object width = list.get(0); - pigeonResult.setWidth((width == null) ? null : ((width instanceof Integer) ? (Integer) width : (Long) width)); + pigeonResult.setWidth( + (width == null) ? null : ((width instanceof Integer) ? (Integer) width : (Long) width)); Object height = list.get(1); - pigeonResult.setHeight((height == null) ? null : ((height instanceof Integer) ? (Integer) height : (Long) height)); + pigeonResult.setHeight( + (height == null) + ? null + : ((height instanceof Integer) ? (Integer) height : (Long) height)); return pigeonResult; } } @@ -272,82 +273,19 @@ ArrayList toList() { static @NonNull ExposureCompensationRange fromList(@NonNull ArrayList list) { ExposureCompensationRange pigeonResult = new ExposureCompensationRange(); Object minCompensation = list.get(0); - pigeonResult.setMinCompensation((minCompensation == null) ? null : ((minCompensation instanceof Integer) ? (Integer) minCompensation : (Long) minCompensation)); + pigeonResult.setMinCompensation( + (minCompensation == null) + ? null + : ((minCompensation instanceof Integer) + ? (Integer) minCompensation + : (Long) minCompensation)); Object maxCompensation = list.get(1); - pigeonResult.setMaxCompensation((maxCompensation == null) ? null : ((maxCompensation instanceof Integer) ? (Integer) maxCompensation : (Long) maxCompensation)); - return pigeonResult; - } - } - - /** Generated class from Pigeon that represents data sent in messages. */ - public static final class ExposureCompensationRange { - private @NonNull Long minCompensation; - - public @NonNull Long getMinCompensation() { - return minCompensation; - } - - public void setMinCompensation(@NonNull Long setterArg) { - if (setterArg == null) { - throw new IllegalStateException("Nonnull field \"minCompensation\" is null."); - } - this.minCompensation = setterArg; - } - - private @NonNull Long maxCompensation; - - public @NonNull Long getMaxCompensation() { - return maxCompensation; - } - - public void setMaxCompensation(@NonNull Long setterArg) { - if (setterArg == null) { - throw new IllegalStateException("Nonnull field \"maxCompensation\" is null."); - } - this.maxCompensation = setterArg; - } - - /** Constructor is non-public to enforce null safety; use Builder. */ - ExposureCompensationRange() {} - - public static final class Builder { - - private @Nullable Long minCompensation; - - public @NonNull Builder setMinCompensation(@NonNull Long setterArg) { - this.minCompensation = setterArg; - return this; - } - - private @Nullable Long maxCompensation; - - public @NonNull Builder setMaxCompensation(@NonNull Long setterArg) { - this.maxCompensation = setterArg; - return this; - } - - public @NonNull ExposureCompensationRange build() { - ExposureCompensationRange pigeonReturn = new ExposureCompensationRange(); - pigeonReturn.setMinCompensation(minCompensation); - pigeonReturn.setMaxCompensation(maxCompensation); - return pigeonReturn; - } - } - - @NonNull - ArrayList toList() { - ArrayList toListResult = new ArrayList(2); - toListResult.add(minCompensation); - toListResult.add(maxCompensation); - return toListResult; - } - - static @NonNull ExposureCompensationRange fromList(@NonNull ArrayList list) { - ExposureCompensationRange pigeonResult = new ExposureCompensationRange(); - Object minCompensation = list.get(0); - pigeonResult.setMinCompensation((minCompensation == null) ? null : ((minCompensation instanceof Integer) ? (Integer) minCompensation : (Long) minCompensation)); - Object maxCompensation = list.get(1); - pigeonResult.setMaxCompensation((maxCompensation == null) ? null : ((maxCompensation instanceof Integer) ? (Integer) maxCompensation : (Long) maxCompensation)); + pigeonResult.setMaxCompensation( + (maxCompensation == null) + ? null + : ((maxCompensation instanceof Integer) + ? (Integer) maxCompensation + : (Long) maxCompensation)); return pigeonResult; } } @@ -363,7 +301,7 @@ public interface InstanceManagerHostApi { /** * Clear the native `InstanceManager`. * - * This is typically only used after a hot restart. + *

This is typically only used after a hot restart. */ void clear(); @@ -371,8 +309,12 @@ public interface InstanceManagerHostApi { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /**Sets up an instance of `InstanceManagerHostApi` to handle messages through the `binaryMessenger`. */ - static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable InstanceManagerHostApi api) { + /** + * Sets up an instance of `InstanceManagerHostApi` to handle messages through the + * `binaryMessenger`. + */ + static void setup( + @NonNull BinaryMessenger binaryMessenger, @Nullable InstanceManagerHostApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -384,8 +326,7 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable InstanceMa try { api.clear(); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -406,7 +347,9 @@ public interface JavaObjectHostApi { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /**Sets up an instance of `JavaObjectHostApi` to handle messages through the `binaryMessenger`. */ + /** + * Sets up an instance of `JavaObjectHostApi` to handle messages through the `binaryMessenger`. + */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable JavaObjectHostApi api) { { BasicMessageChannel channel = @@ -421,8 +364,7 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable JavaObject try { api.dispose((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -442,7 +384,7 @@ public JavaObjectFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -451,6 +393,7 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } + public void dispose(@NonNull Long identifierArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -463,28 +406,29 @@ public void dispose(@NonNull Long identifierArg, @NonNull Reply callback) /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface CameraInfoHostApi { - @NonNull + @NonNull Long getSensorRotationDegrees(@NonNull Long identifier); - @NonNull - Long getLiveCameraState(@NonNull Long identifier); - - @NonNull + @NonNull Long getExposureState(@NonNull Long identifier); - @NonNull + @NonNull Long getZoomState(@NonNull Long identifier); /** The codec used by CameraInfoHostApi. */ static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /**Sets up an instance of `CameraInfoHostApi` to handle messages through the `binaryMessenger`. */ + /** + * Sets up an instance of `CameraInfoHostApi` to handle messages through the `binaryMessenger`. + */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraInfoHostApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.CameraInfoHostApi.getSensorRotationDegrees", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.CameraInfoHostApi.getSensorRotationDegrees", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -492,10 +436,11 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraInfo ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - Long output = api.getSensorRotationDegrees((identifierArg == null) ? null : identifierArg.longValue()); + Long output = + api.getSensorRotationDegrees( + (identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -508,7 +453,9 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraInfo { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.CameraInfoHostApi.getLiveCameraState", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.CameraInfoHostApi.getExposureState", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -516,34 +463,11 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraInfo ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - Long output = api.getLiveCameraState((identifierArg == null) ? null : identifierArg.longValue()); + Long output = + api.getExposureState( + (identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } - catch (Throwable exception) { - ArrayList wrappedError = wrapError(exception); - wrapped = wrappedError; - } - reply.reply(wrapped); - }); - } else { - channel.setMessageHandler(null); - } - } - { - BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.CameraInfoHostApi.getExposureState", getCodec()); - if (api != null) { - channel.setMessageHandler( - (message, reply) -> { - ArrayList wrapped = new ArrayList(); - ArrayList args = (ArrayList) message; - Number identifierArg = (Number) args.get(0); - try { - Long output = api.getExposureState((identifierArg == null) ? null : identifierArg.longValue()); - wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -564,10 +488,10 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraInfo ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - Long output = api.getZoomState((identifierArg == null) ? null : identifierArg.longValue()); + Long output = + api.getZoomState((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -587,7 +511,7 @@ public CameraInfoFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -596,6 +520,7 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } + public void create(@NonNull Long identifierArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -610,15 +535,19 @@ public interface CameraSelectorHostApi { void create(@NonNull Long identifier, @Nullable Long lensFacing); - @NonNull + @NonNull List filter(@NonNull Long identifier, @NonNull List cameraInfoIds); /** The codec used by CameraSelectorHostApi. */ static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /**Sets up an instance of `CameraSelectorHostApi` to handle messages through the `binaryMessenger`. */ - static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraSelectorHostApi api) { + /** + * Sets up an instance of `CameraSelectorHostApi` to handle messages through the + * `binaryMessenger`. + */ + static void setup( + @NonNull BinaryMessenger binaryMessenger, @Nullable CameraSelectorHostApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -631,10 +560,11 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraSele Number identifierArg = (Number) args.get(0); Number lensFacingArg = (Number) args.get(1); try { - api.create((identifierArg == null) ? null : identifierArg.longValue(), (lensFacingArg == null) ? null : lensFacingArg.longValue()); + api.create( + (identifierArg == null) ? null : identifierArg.longValue(), + (lensFacingArg == null) ? null : lensFacingArg.longValue()); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -656,10 +586,12 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraSele Number identifierArg = (Number) args.get(0); List cameraInfoIdsArg = (List) args.get(1); try { - List output = api.filter((identifierArg == null) ? null : identifierArg.longValue(), cameraInfoIdsArg); + List output = + api.filter( + (identifierArg == null) ? null : identifierArg.longValue(), + cameraInfoIdsArg); wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -679,7 +611,7 @@ public CameraSelectorFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -688,7 +620,9 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - public void create(@NonNull Long identifierArg, @Nullable Long lensFacingArg, @NonNull Reply callback) { + + public void create( + @NonNull Long identifierArg, @Nullable Long lensFacingArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.CameraSelectorFlutterApi.create", getCodec()); @@ -702,13 +636,16 @@ public interface ProcessCameraProviderHostApi { void getInstance(@NonNull Result result); - @NonNull + @NonNull List getAvailableCameraInfos(@NonNull Long identifier); - @NonNull - Long bindToLifecycle(@NonNull Long identifier, @NonNull Long cameraSelectorIdentifier, @NonNull List useCaseIds); + @NonNull + Long bindToLifecycle( + @NonNull Long identifier, + @NonNull Long cameraSelectorIdentifier, + @NonNull List useCaseIds); - @NonNull + @NonNull Boolean isBound(@NonNull Long identifier, @NonNull Long useCaseIdentifier); void unbind(@NonNull Long identifier, @NonNull List useCaseIds); @@ -719,12 +656,18 @@ public interface ProcessCameraProviderHostApi { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /**Sets up an instance of `ProcessCameraProviderHostApi` to handle messages through the `binaryMessenger`. */ - static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ProcessCameraProviderHostApi api) { + /** + * Sets up an instance of `ProcessCameraProviderHostApi` to handle messages through the + * `binaryMessenger`. + */ + static void setup( + @NonNull BinaryMessenger binaryMessenger, @Nullable ProcessCameraProviderHostApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderHostApi.getInstance", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.ProcessCameraProviderHostApi.getInstance", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -751,7 +694,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -759,10 +704,11 @@ public void error(Throwable error) { ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - List output = api.getAvailableCameraInfos((identifierArg == null) ? null : identifierArg.longValue()); + List output = + api.getAvailableCameraInfos( + (identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -775,7 +721,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -785,10 +733,15 @@ public void error(Throwable error) { Number cameraSelectorIdentifierArg = (Number) args.get(1); List useCaseIdsArg = (List) args.get(2); try { - Long output = api.bindToLifecycle((identifierArg == null) ? null : identifierArg.longValue(), (cameraSelectorIdentifierArg == null) ? null : cameraSelectorIdentifierArg.longValue(), useCaseIdsArg); + Long output = + api.bindToLifecycle( + (identifierArg == null) ? null : identifierArg.longValue(), + (cameraSelectorIdentifierArg == null) + ? null + : cameraSelectorIdentifierArg.longValue(), + useCaseIdsArg); wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -801,7 +754,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -810,10 +765,12 @@ public void error(Throwable error) { Number identifierArg = (Number) args.get(0); Number useCaseIdentifierArg = (Number) args.get(1); try { - Boolean output = api.isBound((identifierArg == null) ? null : identifierArg.longValue(), (useCaseIdentifierArg == null) ? null : useCaseIdentifierArg.longValue()); + Boolean output = + api.isBound( + (identifierArg == null) ? null : identifierArg.longValue(), + (useCaseIdentifierArg == null) ? null : useCaseIdentifierArg.longValue()); wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -826,7 +783,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -835,10 +794,10 @@ public void error(Throwable error) { Number identifierArg = (Number) args.get(0); List useCaseIdsArg = (List) args.get(1); try { - api.unbind((identifierArg == null) ? null : identifierArg.longValue(), useCaseIdsArg); + api.unbind( + (identifierArg == null) ? null : identifierArg.longValue(), useCaseIdsArg); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -851,7 +810,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderHostApi.unbindAll", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.ProcessCameraProviderHostApi.unbindAll", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -861,8 +822,7 @@ public void error(Throwable error) { try { api.unbindAll((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -882,7 +842,7 @@ public ProcessCameraProviderFlutterApi(@NonNull BinaryMessenger argBinaryMesseng this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -891,10 +851,13 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } + public void create(@NonNull Long identifierArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.ProcessCameraProviderFlutterApi.create", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.ProcessCameraProviderFlutterApi.create", + getCodec()); channel.send( new ArrayList(Collections.singletonList(identifierArg)), channelReply -> callback.reply(null)); @@ -903,14 +866,14 @@ public void create(@NonNull Long identifierArg, @NonNull Reply callback) { /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface CameraHostApi { - @NonNull + @NonNull Long getCameraInfo(@NonNull Long identifier); /** The codec used by CameraHostApi. */ static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /**Sets up an instance of `CameraHostApi` to handle messages through the `binaryMessenger`. */ + /** Sets up an instance of `CameraHostApi` to handle messages through the `binaryMessenger`. */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraHostApi api) { { BasicMessageChannel channel = @@ -923,10 +886,10 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable CameraHost ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - Long output = api.getCameraInfo((identifierArg == null) ? null : identifierArg.longValue()); + Long output = + api.getCameraInfo((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -946,7 +909,7 @@ public CameraFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -955,6 +918,7 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } + public void create(@NonNull Long identifierArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -994,9 +958,11 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface SystemServicesHostApi { - void requestCameraPermissions(@NonNull Boolean enableAudio, @NonNull Result result); + void requestCameraPermissions( + @NonNull Boolean enableAudio, @NonNull Result result); - void startListeningForDeviceOrientationChange(@NonNull Boolean isFrontFacing, @NonNull Long sensorOrientation); + void startListeningForDeviceOrientationChange( + @NonNull Boolean isFrontFacing, @NonNull Long sensorOrientation); void stopListeningForDeviceOrientationChange(); @@ -1004,12 +970,18 @@ public interface SystemServicesHostApi { static @NonNull MessageCodec getCodec() { return SystemServicesHostApiCodec.INSTANCE; } - /**Sets up an instance of `SystemServicesHostApi` to handle messages through the `binaryMessenger`. */ - static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable SystemServicesHostApi api) { + /** + * Sets up an instance of `SystemServicesHostApi` to handle messages through the + * `binaryMessenger`. + */ + static void setup( + @NonNull BinaryMessenger binaryMessenger, @Nullable SystemServicesHostApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -1038,7 +1010,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -1047,10 +1021,11 @@ public void error(Throwable error) { Boolean isFrontFacingArg = (Boolean) args.get(0); Number sensorOrientationArg = (Number) args.get(1); try { - api.startListeningForDeviceOrientationChange(isFrontFacingArg, (sensorOrientationArg == null) ? null : sensorOrientationArg.longValue()); + api.startListeningForDeviceOrientationChange( + isFrontFacingArg, + (sensorOrientationArg == null) ? null : sensorOrientationArg.longValue()); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1063,7 +1038,9 @@ public void error(Throwable error) { { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.SystemServicesHostApi.stopListeningForDeviceOrientationChange", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.SystemServicesHostApi.stopListeningForDeviceOrientationChange", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -1071,8 +1048,7 @@ public void error(Throwable error) { try { api.stopListeningForDeviceOrientationChange(); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1092,7 +1068,7 @@ public SystemServicesFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -1101,18 +1077,25 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - public void onDeviceOrientationChanged(@NonNull String orientationArg, @NonNull Reply callback) { + + public void onDeviceOrientationChanged( + @NonNull String orientationArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.SystemServicesFlutterApi.onDeviceOrientationChanged", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.SystemServicesFlutterApi.onDeviceOrientationChanged", + getCodec()); channel.send( new ArrayList(Collections.singletonList(orientationArg)), channelReply -> callback.reply(null)); } + public void onCameraError(@NonNull String errorDescriptionArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.SystemServicesFlutterApi.onCameraError", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.SystemServicesFlutterApi.onCameraError", + getCodec()); channel.send( new ArrayList(Collections.singletonList(errorDescriptionArg)), channelReply -> callback.reply(null)); @@ -1153,21 +1136,24 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface PreviewHostApi { - void create(@NonNull Long identifier, @Nullable Long rotation, @Nullable ResolutionInfo targetResolution); + void create( + @NonNull Long identifier, + @Nullable Long rotation, + @Nullable ResolutionInfo targetResolution); - @NonNull + @NonNull Long setSurfaceProvider(@NonNull Long identifier); void releaseFlutterSurfaceTexture(); - @NonNull + @NonNull ResolutionInfo getResolutionInfo(@NonNull Long identifier); /** The codec used by PreviewHostApi. */ static @NonNull MessageCodec getCodec() { return PreviewHostApiCodec.INSTANCE; } - /**Sets up an instance of `PreviewHostApi` to handle messages through the `binaryMessenger`. */ + /** Sets up an instance of `PreviewHostApi` to handle messages through the `binaryMessenger`. */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHostApi api) { { BasicMessageChannel channel = @@ -1182,10 +1168,12 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHos Number rotationArg = (Number) args.get(1); ResolutionInfo targetResolutionArg = (ResolutionInfo) args.get(2); try { - api.create((identifierArg == null) ? null : identifierArg.longValue(), (rotationArg == null) ? null : rotationArg.longValue(), targetResolutionArg); + api.create( + (identifierArg == null) ? null : identifierArg.longValue(), + (rotationArg == null) ? null : rotationArg.longValue(), + targetResolutionArg); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1198,7 +1186,9 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHos { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.PreviewHostApi.setSurfaceProvider", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.PreviewHostApi.setSurfaceProvider", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -1206,10 +1196,11 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHos ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - Long output = api.setSurfaceProvider((identifierArg == null) ? null : identifierArg.longValue()); + Long output = + api.setSurfaceProvider( + (identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1222,7 +1213,9 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHos { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.PreviewHostApi.releaseFlutterSurfaceTexture", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.PreviewHostApi.releaseFlutterSurfaceTexture", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -1230,8 +1223,7 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHos try { api.releaseFlutterSurfaceTexture(); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1252,10 +1244,11 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable PreviewHos ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - ResolutionInfo output = api.getResolutionInfo((identifierArg == null) ? null : identifierArg.longValue()); + ResolutionInfo output = + api.getResolutionInfo( + (identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1297,7 +1290,10 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface ImageCaptureHostApi { - void create(@NonNull Long identifier, @Nullable Long flashMode, @Nullable ResolutionInfo targetResolution); + void create( + @NonNull Long identifier, + @Nullable Long flashMode, + @Nullable ResolutionInfo targetResolution); void setFlashMode(@NonNull Long identifier, @NonNull Long flashMode); @@ -1307,7 +1303,10 @@ public interface ImageCaptureHostApi { static @NonNull MessageCodec getCodec() { return ImageCaptureHostApiCodec.INSTANCE; } - /**Sets up an instance of `ImageCaptureHostApi` to handle messages through the `binaryMessenger`. */ + /** + * Sets up an instance of `ImageCaptureHostApi` to handle messages through the + * `binaryMessenger`. + */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageCaptureHostApi api) { { BasicMessageChannel channel = @@ -1322,10 +1321,12 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageCaptu Number flashModeArg = (Number) args.get(1); ResolutionInfo targetResolutionArg = (ResolutionInfo) args.get(2); try { - api.create((identifierArg == null) ? null : identifierArg.longValue(), (flashModeArg == null) ? null : flashModeArg.longValue(), targetResolutionArg); + api.create( + (identifierArg == null) ? null : identifierArg.longValue(), + (flashModeArg == null) ? null : flashModeArg.longValue(), + targetResolutionArg); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1347,10 +1348,11 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageCaptu Number identifierArg = (Number) args.get(0); Number flashModeArg = (Number) args.get(1); try { - api.setFlashMode((identifierArg == null) ? null : identifierArg.longValue(), (flashModeArg == null) ? null : flashModeArg.longValue()); + api.setFlashMode( + (identifierArg == null) ? null : identifierArg.longValue(), + (flashModeArg == null) ? null : flashModeArg.longValue()); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1383,7 +1385,8 @@ public void error(Throwable error) { } }; - api.takePicture((identifierArg == null) ? null : identifierArg.longValue(), resultCallback); + api.takePicture( + (identifierArg == null) ? null : identifierArg.longValue(), resultCallback); }); } else { channel.setMessageHandler(null); @@ -1426,7 +1429,7 @@ public ExposureStateFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -1435,91 +1438,19 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return ExposureStateFlutterApiCodec.INSTANCE; } - public void create(@NonNull Long identifierArg, @NonNull ExposureCompensationRange exposureCompensationRangeArg, @NonNull Double exposureCompensationStepArg, @NonNull Reply callback) { - BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.ExposureStateFlutterApi.create", getCodec()); - channel.send( - new ArrayList(Arrays.asList(identifierArg, exposureCompensationRangeArg, exposureCompensationStepArg)), - channelReply -> callback.reply(null)); - } - } - /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ - public static class ZoomStateFlutterApi { - private final @NonNull BinaryMessenger binaryMessenger; - - public ZoomStateFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { - this.binaryMessenger = argBinaryMessenger; - } - - /** Public interface for sending reply. */ - @SuppressWarnings("UnknownNullness") - public interface Reply { - void reply(T reply); - } - /** The codec used by ZoomStateFlutterApi. */ - static @NonNull MessageCodec getCodec() { - return new StandardMessageCodec(); - } - public void create(@NonNull Long identifierArg, @NonNull Double minZoomRatioArg, @NonNull Double maxZoomRatioArg, @NonNull Reply callback) { - BasicMessageChannel channel = - new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.ZoomStateFlutterApi.create", getCodec()); - channel.send( - new ArrayList(Arrays.asList(identifierArg, minZoomRatioArg, maxZoomRatioArg)), - channelReply -> callback.reply(null)); - } - } - - private static class ExposureStateFlutterApiCodec extends StandardMessageCodec { - public static final ExposureStateFlutterApiCodec INSTANCE = new ExposureStateFlutterApiCodec(); - - private ExposureStateFlutterApiCodec() {} - - @Override - protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { - switch (type) { - case (byte) 128: - return ExposureCompensationRange.fromList((ArrayList) readValue(buffer)); - default: - return super.readValueOfType(type, buffer); - } - } - - @Override - protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { - if (value instanceof ExposureCompensationRange) { - stream.write(128); - writeValue(stream, ((ExposureCompensationRange) value).toList()); - } else { - super.writeValue(stream, value); - } - } - } - /** Generated class from Pigeon that represents Flutter messages that can be called from Java. */ - public static class ExposureStateFlutterApi { - private final @NonNull BinaryMessenger binaryMessenger; - - public ExposureStateFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { - this.binaryMessenger = argBinaryMessenger; - } - - /** Public interface for sending reply. */ - @SuppressWarnings("UnknownNullness") - public interface Reply { - void reply(T reply); - } - /** The codec used by ExposureStateFlutterApi. */ - static @NonNull MessageCodec getCodec() { - return ExposureStateFlutterApiCodec.INSTANCE; - } - public void create(@NonNull Long identifierArg, @NonNull ExposureCompensationRange exposureCompensationRangeArg, @NonNull Double exposureCompensationStepArg, @NonNull Reply callback) { + public void create( + @NonNull Long identifierArg, + @NonNull ExposureCompensationRange exposureCompensationRangeArg, + @NonNull Double exposureCompensationStepArg, + @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.ExposureStateFlutterApi.create", getCodec()); channel.send( - new ArrayList(Arrays.asList(identifierArg, exposureCompensationRangeArg, exposureCompensationStepArg)), + new ArrayList( + Arrays.asList( + identifierArg, exposureCompensationRangeArg, exposureCompensationStepArg)), channelReply -> callback.reply(null)); } } @@ -1531,7 +1462,7 @@ public ZoomStateFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -1540,7 +1471,12 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - public void create(@NonNull Long identifierArg, @NonNull Double minZoomRatioArg, @NonNull Double maxZoomRatioArg, @NonNull Reply callback) { + + public void create( + @NonNull Long identifierArg, + @NonNull Double minZoomRatioArg, + @NonNull Double maxZoomRatioArg, + @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.ZoomStateFlutterApi.create", getCodec()); @@ -1589,8 +1525,12 @@ public interface ImageAnalysisHostApi { static @NonNull MessageCodec getCodec() { return ImageAnalysisHostApiCodec.INSTANCE; } - /**Sets up an instance of `ImageAnalysisHostApi` to handle messages through the `binaryMessenger`. */ - static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageAnalysisHostApi api) { + /** + * Sets up an instance of `ImageAnalysisHostApi` to handle messages through the + * `binaryMessenger`. + */ + static void setup( + @NonNull BinaryMessenger binaryMessenger, @Nullable ImageAnalysisHostApi api) { { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -1603,10 +1543,11 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageAnaly Number identifierArg = (Number) args.get(0); ResolutionInfo targetResolutionIdentifierArg = (ResolutionInfo) args.get(1); try { - api.create((identifierArg == null) ? null : identifierArg.longValue(), targetResolutionIdentifierArg); + api.create( + (identifierArg == null) ? null : identifierArg.longValue(), + targetResolutionIdentifierArg); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1628,10 +1569,11 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageAnaly Number identifierArg = (Number) args.get(0); Number analyzerIdentifierArg = (Number) args.get(1); try { - api.setAnalyzer((identifierArg == null) ? null : identifierArg.longValue(), (analyzerIdentifierArg == null) ? null : analyzerIdentifierArg.longValue()); + api.setAnalyzer( + (identifierArg == null) ? null : identifierArg.longValue(), + (analyzerIdentifierArg == null) ? null : analyzerIdentifierArg.longValue()); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1644,7 +1586,9 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageAnaly { BasicMessageChannel channel = new BasicMessageChannel<>( - binaryMessenger, "dev.flutter.pigeon.ImageAnalysisHostApi.clearAnalyzer", getCodec()); + binaryMessenger, + "dev.flutter.pigeon.ImageAnalysisHostApi.clearAnalyzer", + getCodec()); if (api != null) { channel.setMessageHandler( (message, reply) -> { @@ -1654,8 +1598,7 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageAnaly try { api.clearAnalyzer((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1676,7 +1619,9 @@ public interface AnalyzerHostApi { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /**Sets up an instance of `AnalyzerHostApi` to handle messages through the `binaryMessenger`. */ + /** + * Sets up an instance of `AnalyzerHostApi` to handle messages through the `binaryMessenger`. + */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable AnalyzerHostApi api) { { BasicMessageChannel channel = @@ -1691,8 +1636,7 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable AnalyzerHo try { api.create((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1712,7 +1656,7 @@ public AnalyzerFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -1721,6 +1665,7 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } + public void create(@NonNull Long identifierArg, @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( @@ -1729,7 +1674,11 @@ public void create(@NonNull Long identifierArg, @NonNull Reply callback) { new ArrayList(Collections.singletonList(identifierArg)), channelReply -> callback.reply(null)); } - public void analyze(@NonNull Long identifierArg, @NonNull Long imageProxyIdentifierArg, @NonNull Reply callback) { + + public void analyze( + @NonNull Long identifierArg, + @NonNull Long imageProxyIdentifierArg, + @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.AnalyzerFlutterApi.analyze", getCodec()); @@ -1741,7 +1690,7 @@ public void analyze(@NonNull Long identifierArg, @NonNull Long imageProxyIdentif /** Generated interface from Pigeon that represents a handler of messages from Flutter. */ public interface ImageProxyHostApi { - @NonNull + @NonNull List getPlanes(@NonNull Long identifier); void close(@NonNull Long identifier); @@ -1750,7 +1699,9 @@ public interface ImageProxyHostApi { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - /**Sets up an instance of `ImageProxyHostApi` to handle messages through the `binaryMessenger`. */ + /** + * Sets up an instance of `ImageProxyHostApi` to handle messages through the `binaryMessenger`. + */ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageProxyHostApi api) { { BasicMessageChannel channel = @@ -1763,10 +1714,10 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageProxy ArrayList args = (ArrayList) message; Number identifierArg = (Number) args.get(0); try { - List output = api.getPlanes((identifierArg == null) ? null : identifierArg.longValue()); + List output = + api.getPlanes((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, output); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1789,8 +1740,7 @@ static void setup(@NonNull BinaryMessenger binaryMessenger, @Nullable ImageProxy try { api.close((identifierArg == null) ? null : identifierArg.longValue()); wrapped.add(0, null); - } - catch (Throwable exception) { + } catch (Throwable exception) { ArrayList wrappedError = wrapError(exception); wrapped = wrappedError; } @@ -1810,7 +1760,7 @@ public ImageProxyFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -1819,7 +1769,13 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - public void create(@NonNull Long identifierArg, @NonNull Long formatArg, @NonNull Long heightArg, @NonNull Long widthArg, @NonNull Reply callback) { + + public void create( + @NonNull Long identifierArg, + @NonNull Long formatArg, + @NonNull Long heightArg, + @NonNull Long widthArg, + @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.ImageProxyFlutterApi.create", getCodec()); @@ -1836,7 +1792,7 @@ public PlaneProxyFlutterApi(@NonNull BinaryMessenger argBinaryMessenger) { this.binaryMessenger = argBinaryMessenger; } - /** Public interface for sending reply. */ + /** Public interface for sending reply. */ @SuppressWarnings("UnknownNullness") public interface Reply { void reply(T reply); @@ -1845,12 +1801,19 @@ public interface Reply { static @NonNull MessageCodec getCodec() { return new StandardMessageCodec(); } - public void create(@NonNull Long identifierArg, @NonNull byte[] bufferArg, @NonNull Long pixelStrideArg, @NonNull Long rowStrideArg, @NonNull Reply callback) { + + public void create( + @NonNull Long identifierArg, + @NonNull byte[] bufferArg, + @NonNull Long pixelStrideArg, + @NonNull Long rowStrideArg, + @NonNull Reply callback) { BasicMessageChannel channel = new BasicMessageChannel<>( binaryMessenger, "dev.flutter.pigeon.PlaneProxyFlutterApi.create", getCodec()); channel.send( - new ArrayList(Arrays.asList(identifierArg, bufferArg, pixelStrideArg, rowStrideArg)), + new ArrayList( + Arrays.asList(identifierArg, bufferArg, pixelStrideArg, rowStrideArg)), channelReply -> callback.reply(null)); } } diff --git a/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/CameraInfoTest.java b/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/CameraInfoTest.java index 379cf3f3b05c..5cfd06935b85 100644 --- a/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/CameraInfoTest.java +++ b/packages/camera/camera_android_camerax/android/src/test/java/io/flutter/plugins/camerax/CameraInfoTest.java @@ -13,7 +13,6 @@ import static org.mockito.Mockito.when; import androidx.camera.core.CameraInfo; -import androidx.camera.core.CameraState; import androidx.camera.core.ExposureState; import androidx.camera.core.ZoomState; import androidx.lifecycle.LiveData; diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart index f0eac80d9eed..174a373e3b9b 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax.dart @@ -45,10 +45,6 @@ class AndroidCameraCameraX extends CameraPlatform { @visibleForTesting CameraInfo? cameraInfo; - /// The [LiveData] of the [CameraState] that represents the state of the - /// [camera] instance. - LiveData? liveCameraState; - /// The [Preview] instance that can be configured to present a live camera preview. @visibleForTesting Preview? preview; @@ -200,7 +196,6 @@ class AndroidCameraCameraX extends CameraPlatform { // instance as bound but not paused. camera = await processCameraProvider! .bindToLifecycle(cameraSelector!, [preview!, imageCapture!]); - await _updateLiveCameraState(flutterSurfaceTextureId); cameraInfo = await camera!.getCameraInfo(); _previewIsPaused = false; @@ -330,55 +325,6 @@ class AndroidCameraCameraX extends CameraPlatform { return exposureState.minZoomRatio; } - /// Gets the minimum supported exposure offset for the selected camera in EV units. - /// - /// [cameraId] not used. - @override - Future getMinExposureOffset(int cameraId) async { - final ExposureState exposureState = await cameraInfo!.getExposureState(); - return exposureState.exposureCompensationRange.minCompensation * - exposureState.exposureCompensationStep; - } - - /// Gets the maximum supported exposure offset for the selected camera in EV units. - /// - /// [cameraId] not used. - @override - Future getMaxExposureOffset(int cameraId) async { - final ExposureState exposureState = await cameraInfo!.getExposureState(); - return exposureState.exposureCompensationRange.maxCompensation * - exposureState.exposureCompensationStep; - } - - /// Gets the supported step size for exposure offset for the selected camera in EV units. - /// - /// Returns 0 when exposure compensation is not supported. - /// - /// [cameraId] not used. - @override - Future getExposureOffsetStepSize(int cameraId) async { - final ExposureState exposureState = await cameraInfo!.getExposureState(); - return exposureState.exposureCompensationStep; - } - - /// Gets the maximum supported zoom level for the selected camera. - /// - /// [cameraId] not used. - @override - Future getMaxZoomLevel(int cameraId) async { - final ZoomState exposureState = await cameraInfo!.getZoomState(); - return exposureState.maxZoomRatio; - } - - /// Gets the minimum supported zoom level for the selected camera. - /// - /// [cameraId] not used. - @override - Future getMinZoomLevel(int cameraId) async { - final ZoomState exposureState = await cameraInfo!.getZoomState(); - return exposureState.minZoomRatio; - } - /// The ui orientation changed. @override Stream onDeviceOrientationChanged() { @@ -467,7 +413,6 @@ class AndroidCameraCameraX extends CameraPlatform { camera = await processCameraProvider! .bindToLifecycle(cameraSelector!, [preview!]); - await _updateLiveCameraState(cameraId); cameraInfo = await camera!.getCameraInfo(); } diff --git a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax_flutter_api_impls.dart b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax_flutter_api_impls.dart index f92ef8349267..c5692ae105f2 100644 --- a/packages/camera/camera_android_camerax/lib/src/android_camera_camerax_flutter_api_impls.dart +++ b/packages/camera/camera_android_camerax/lib/src/android_camera_camerax_flutter_api_impls.dart @@ -19,46 +19,33 @@ import 'zoom_state.dart'; class AndroidCameraXCameraFlutterApis { /// Creates a [AndroidCameraXCameraFlutterApis]. AndroidCameraXCameraFlutterApis({ - JavaObjectFlutterApiImpl? javaObjectFlutterApiImpl, - CameraFlutterApiImpl? cameraFlutterApiImpl, - CameraInfoFlutterApiImpl? cameraInfoFlutterApiImpl, - CameraSelectorFlutterApiImpl? cameraSelectorFlutterApiImpl, - ProcessCameraProviderFlutterApiImpl? processCameraProviderFlutterApiImpl, - SystemServicesFlutterApiImpl? systemServicesFlutterApiImpl, - CameraStateErrorFlutterApiImpl? cameraStateErrorFlutterApiImpl, - CameraStateFlutterApiImpl? cameraStateFlutterApiImpl, + JavaObjectFlutterApiImpl? javaObjectFlutterApi, + CameraFlutterApiImpl? cameraFlutterApi, + CameraInfoFlutterApiImpl? cameraInfoFlutterApi, + CameraSelectorFlutterApiImpl? cameraSelectorFlutterApi, + ProcessCameraProviderFlutterApiImpl? processCameraProviderFlutterApi, + SystemServicesFlutterApiImpl? systemServicesFlutterApi, ExposureStateFlutterApiImpl? exposureStateFlutterApiImpl, ZoomStateFlutterApiImpl? zoomStateFlutterApiImpl, - LiveDataFlutterApiImpl? liveDataFlutterApiImpl, - ObserverFlutterApiImpl? observerFlutterApiImpl, + AnalyzerFlutterApiImpl? analyzerFlutterApiImpl, ImageProxyFlutterApiImpl? imageProxyFlutterApiImpl, PlaneProxyFlutterApiImpl? planeProxyFlutterApiImpl, - AnalyzerFlutterApiImpl? analyzerFlutterApiImpl, }) { - this.javaObjectFlutterApiImpl = - javaObjectFlutterApiImpl ?? JavaObjectFlutterApiImpl(); - this.cameraInfoFlutterApiImpl = - cameraInfoFlutterApiImpl ?? CameraInfoFlutterApiImpl(); - this.cameraSelectorFlutterApiImpl = - cameraSelectorFlutterApiImpl ?? CameraSelectorFlutterApiImpl(); - this.processCameraProviderFlutterApiImpl = - processCameraProviderFlutterApiImpl ?? - ProcessCameraProviderFlutterApiImpl(); - this.cameraFlutterApiImpl = cameraFlutterApiImpl ?? CameraFlutterApiImpl(); - this.systemServicesFlutterApiImpl = - systemServicesFlutterApiImpl ?? SystemServicesFlutterApiImpl(); - this.cameraStateErrorFlutterApiImpl = - cameraStateErrorFlutterApiImpl ?? CameraStateErrorFlutterApiImpl(); - this.cameraStateFlutterApiImpl = - cameraStateFlutterApiImpl ?? CameraStateFlutterApiImpl(); + this.javaObjectFlutterApi = + javaObjectFlutterApi ?? JavaObjectFlutterApiImpl(); + this.cameraInfoFlutterApi = + cameraInfoFlutterApi ?? CameraInfoFlutterApiImpl(); + this.cameraSelectorFlutterApi = + cameraSelectorFlutterApi ?? CameraSelectorFlutterApiImpl(); + this.processCameraProviderFlutterApi = processCameraProviderFlutterApi ?? + ProcessCameraProviderFlutterApiImpl(); + this.cameraFlutterApi = cameraFlutterApi ?? CameraFlutterApiImpl(); + this.systemServicesFlutterApi = + systemServicesFlutterApi ?? SystemServicesFlutterApiImpl(); this.exposureStateFlutterApiImpl = exposureStateFlutterApiImpl ?? ExposureStateFlutterApiImpl(); this.zoomStateFlutterApiImpl = zoomStateFlutterApiImpl ?? ZoomStateFlutterApiImpl(); - this.liveDataFlutterApiImpl = - liveDataFlutterApiImpl ?? LiveDataFlutterApiImpl(); - this.observerFlutterApiImpl = - observerFlutterApiImpl ?? ObserverFlutterApiImpl(); this.analyzerFlutterApiImpl = analyzerFlutterApiImpl ?? AnalyzerFlutterApiImpl(); this.imageProxyFlutterApiImpl = @@ -100,12 +87,6 @@ class AndroidCameraXCameraFlutterApis { /// Flutter Api for [ZoomState]. late final ZoomStateFlutterApiImpl zoomStateFlutterApiImpl; - /// Flutter Api for [ExposureState]. - late final ExposureStateFlutterApiImpl exposureStateFlutterApiImpl; - - /// Flutter Api for [ZoomState]. - late final ZoomStateFlutterApiImpl zoomStateFlutterApiImpl; - /// Flutter Api implementation for [Analyzer]. late final AnalyzerFlutterApiImpl analyzerFlutterApiImpl; @@ -118,15 +99,12 @@ class AndroidCameraXCameraFlutterApis { /// Ensures all the Flutter APIs have been setup to receive calls from native code. void ensureSetUp() { if (!_haveBeenSetUp) { - JavaObjectFlutterApi.setup(javaObjectFlutterApiImpl); - CameraInfoFlutterApi.setup(cameraInfoFlutterApiImpl); - CameraSelectorFlutterApi.setup(cameraSelectorFlutterApiImpl); - ProcessCameraProviderFlutterApi.setup( - processCameraProviderFlutterApiImpl); - CameraFlutterApi.setup(cameraFlutterApiImpl); - SystemServicesFlutterApi.setup(systemServicesFlutterApiImpl); - CameraStateErrorFlutterApi.setup(cameraStateErrorFlutterApiImpl); - CameraStateFlutterApi.setup(cameraStateFlutterApiImpl); + JavaObjectFlutterApi.setup(javaObjectFlutterApi); + CameraInfoFlutterApi.setup(cameraInfoFlutterApi); + CameraSelectorFlutterApi.setup(cameraSelectorFlutterApi); + ProcessCameraProviderFlutterApi.setup(processCameraProviderFlutterApi); + CameraFlutterApi.setup(cameraFlutterApi); + SystemServicesFlutterApi.setup(systemServicesFlutterApi); ExposureStateFlutterApi.setup(exposureStateFlutterApiImpl); ZoomStateFlutterApi.setup(zoomStateFlutterApiImpl); AnalyzerFlutterApi.setup(analyzerFlutterApiImpl); diff --git a/packages/camera/camera_android_camerax/lib/src/camera_info.dart b/packages/camera/camera_android_camerax/lib/src/camera_info.dart index 07e6816fc70a..f2fdc1fdc879 100644 --- a/packages/camera/camera_android_camerax/lib/src/camera_info.dart +++ b/packages/camera/camera_android_camerax/lib/src/camera_info.dart @@ -9,7 +9,6 @@ import 'camerax_library.g.dart'; import 'exposure_state.dart'; import 'instance_manager.dart'; import 'java_object.dart'; -import 'live_data.dart'; import 'zoom_state.dart'; /// Represents the metadata of a camera. @@ -33,10 +32,6 @@ class CameraInfo extends JavaObject { Future getSensorRotationDegrees() => _api.getSensorRotationDegreesFromInstance(this); - /// Starts listening for the camera closing. - Future> getLiveCameraState() => - _api.getLiveCameraStateFromInstance(this); - /// Gets the exposure state of the camera. Future getExposureState() => _api.getExposureStateFromInstance(this); @@ -81,23 +76,6 @@ class _CameraInfoHostApiImpl extends CameraInfoHostApi { return instanceManager .getInstanceWithWeakReference(zoomStateIdentifier)!; } - - /// Gets the [ExposureState] of the specified [CameraInfo] instance. - Future getExposureStateFromInstance( - CameraInfo instance) async { - final int? identifier = instanceManager.getIdentifier(instance); - final int exposureStateIdentifier = await getExposureState(identifier!); - return instanceManager - .getInstanceWithWeakReference(exposureStateIdentifier)!; - } - - /// Gets the [ZoomState] of the specified [CameraInfo] instance. - Future getZoomStateFromInstance(CameraInfo instance) async { - final int? identifier = instanceManager.getIdentifier(instance); - final int zoomStateIdentifier = await getZoomState(identifier!); - return instanceManager - .getInstanceWithWeakReference(zoomStateIdentifier)!; - } } /// Flutter API implementation of [CameraInfo]. diff --git a/packages/camera/camera_android_camerax/lib/src/camerax_library.g.dart b/packages/camera/camera_android_camerax/lib/src/camerax_library.g.dart index b5afcaa735a9..f2d2e17152fb 100644 --- a/packages/camera/camera_android_camerax/lib/src/camerax_library.g.dart +++ b/packages/camera/camera_android_camerax/lib/src/camerax_library.g.dart @@ -89,32 +89,6 @@ class ExposureCompensationRange { } } -class ExposureCompensationRange { - ExposureCompensationRange({ - required this.minCompensation, - required this.maxCompensation, - }); - - int minCompensation; - - int maxCompensation; - - Object encode() { - return [ - minCompensation, - maxCompensation, - ]; - } - - static ExposureCompensationRange decode(Object result) { - result as List; - return ExposureCompensationRange( - minCompensation: result[0]! as int, - maxCompensation: result[1]! as int, - ); - } -} - class InstanceManagerHostApi { /// Constructor for [InstanceManagerHostApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default @@ -132,8 +106,7 @@ class InstanceManagerHostApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.InstanceManagerHostApi.clear', codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; + final List? replyList = await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -189,7 +162,8 @@ abstract class JavaObjectFlutterApi { void dispose(int identifier); - static void setup(JavaObjectFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(JavaObjectFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.JavaObjectFlutterApi.dispose', codec, @@ -199,7 +173,7 @@ abstract class JavaObjectFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.JavaObjectFlutterApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.JavaObjectFlutterApi.dispose was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -249,33 +223,6 @@ class CameraInfoHostApi { } } - Future getLiveCameraState(int arg_identifier) async { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.CameraInfoHostApi.getLiveCameraState', codec, - binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_identifier]) as List?; - if (replyList == null) { - throw PlatformException( - code: 'channel-error', - message: 'Unable to establish connection on channel.', - ); - } else if (replyList.length > 1) { - throw PlatformException( - code: replyList[0]! as String, - message: replyList[1] as String?, - details: replyList[2], - ); - } else if (replyList[0] == null) { - throw PlatformException( - code: 'null-error', - message: 'Host platform returned null value for non-null return value.', - ); - } else { - return (replyList[0] as int?)!; - } - } - Future getExposureState(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraInfoHostApi.getExposureState', codec, @@ -336,7 +283,8 @@ abstract class CameraInfoFlutterApi { void create(int identifier); - static void setup(CameraInfoFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(CameraInfoFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraInfoFlutterApi.create', codec, @@ -346,7 +294,7 @@ abstract class CameraInfoFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraInfoFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.CameraInfoFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -373,8 +321,8 @@ class CameraSelectorHostApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraSelectorHostApi.create', codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_identifier, arg_lensFacing]) as List?; + final List? replyList = await channel + .send([arg_identifier, arg_lensFacing]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -391,12 +339,13 @@ class CameraSelectorHostApi { } } - Future> filter(int arg_identifier, List arg_cameraInfoIds) async { + Future> filter( + int arg_identifier, List arg_cameraInfoIds) async { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraSelectorHostApi.filter', codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_identifier, arg_cameraInfoIds]) as List?; + final List? replyList = await channel + .send([arg_identifier, arg_cameraInfoIds]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -424,7 +373,8 @@ abstract class CameraSelectorFlutterApi { void create(int identifier, int? lensFacing); - static void setup(CameraSelectorFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(CameraSelectorFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraSelectorFlutterApi.create', codec, @@ -434,7 +384,7 @@ abstract class CameraSelectorFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraSelectorFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.CameraSelectorFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -462,8 +412,7 @@ class ProcessCameraProviderHostApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ProcessCameraProviderHostApi.getInstance', codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; + final List? replyList = await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -487,7 +436,8 @@ class ProcessCameraProviderHostApi { Future> getAvailableCameraInfos(int arg_identifier) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos', codec, + 'dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_identifier]) as List?; @@ -512,12 +462,17 @@ class ProcessCameraProviderHostApi { } } - Future bindToLifecycle(int arg_identifier, int arg_cameraSelectorIdentifier, List arg_useCaseIds) async { + Future bindToLifecycle(int arg_identifier, + int arg_cameraSelectorIdentifier, List arg_useCaseIds) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle', codec, + 'dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_identifier, arg_cameraSelectorIdentifier, arg_useCaseIds]) as List?; + final List? replyList = await channel.send([ + arg_identifier, + arg_cameraSelectorIdentifier, + arg_useCaseIds + ]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -544,7 +499,8 @@ class ProcessCameraProviderHostApi { 'dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound', codec, binaryMessenger: _binaryMessenger); final List? replyList = - await channel.send([arg_identifier, arg_useCaseIdentifier]) as List?; + await channel.send([arg_identifier, arg_useCaseIdentifier]) + as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -570,8 +526,8 @@ class ProcessCameraProviderHostApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind', codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_identifier, arg_useCaseIds]) as List?; + final List? replyList = await channel + .send([arg_identifier, arg_useCaseIds]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -616,7 +572,8 @@ abstract class ProcessCameraProviderFlutterApi { void create(int identifier); - static void setup(ProcessCameraProviderFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(ProcessCameraProviderFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ProcessCameraProviderFlutterApi.create', codec, @@ -626,7 +583,7 @@ abstract class ProcessCameraProviderFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ProcessCameraProviderFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.ProcessCameraProviderFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -692,7 +649,7 @@ abstract class CameraFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.CameraFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -720,7 +677,7 @@ class _SystemServicesHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return CameraPermissionsErrorData.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -738,9 +695,11 @@ class SystemServicesHostApi { static const MessageCodec codec = _SystemServicesHostApiCodec(); - Future requestCameraPermissions(bool arg_enableAudio) async { + Future requestCameraPermissions( + bool arg_enableAudio) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions', codec, + 'dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions', + codec, binaryMessenger: _binaryMessenger); final List? replyList = await channel.send([arg_enableAudio]) as List?; @@ -760,12 +719,15 @@ class SystemServicesHostApi { } } - Future startListeningForDeviceOrientationChange(bool arg_isFrontFacing, int arg_sensorOrientation) async { + Future startListeningForDeviceOrientationChange( + bool arg_isFrontFacing, int arg_sensorOrientation) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange', codec, + 'dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange', + codec, binaryMessenger: _binaryMessenger); final List? replyList = - await channel.send([arg_isFrontFacing, arg_sensorOrientation]) as List?; + await channel.send([arg_isFrontFacing, arg_sensorOrientation]) + as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -784,10 +746,10 @@ class SystemServicesHostApi { Future stopListeningForDeviceOrientationChange() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesHostApi.stopListeningForDeviceOrientationChange', codec, + 'dev.flutter.pigeon.SystemServicesHostApi.stopListeningForDeviceOrientationChange', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; + final List? replyList = await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -812,17 +774,19 @@ abstract class SystemServicesFlutterApi { void onCameraError(String errorDescription); - static void setup(SystemServicesFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(SystemServicesFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesFlutterApi.onDeviceOrientationChanged', codec, + 'dev.flutter.pigeon.SystemServicesFlutterApi.onDeviceOrientationChanged', + codec, binaryMessenger: binaryMessenger); if (api == null) { channel.setMessageHandler(null); } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.SystemServicesFlutterApi.onDeviceOrientationChanged was null.'); + 'Argument for dev.flutter.pigeon.SystemServicesFlutterApi.onDeviceOrientationChanged was null.'); final List args = (message as List?)!; final String? arg_orientation = (args[0] as String?); assert(arg_orientation != null, @@ -841,7 +805,7 @@ abstract class SystemServicesFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.SystemServicesFlutterApi.onCameraError was null.'); + 'Argument for dev.flutter.pigeon.SystemServicesFlutterApi.onCameraError was null.'); final List args = (message as List?)!; final String? arg_errorDescription = (args[0] as String?); assert(arg_errorDescription != null, @@ -872,9 +836,9 @@ class _PreviewHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ResolutionInfo.decode(readValue(buffer)!); - case 129: + case 129: return ResolutionInfo.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -892,12 +856,14 @@ class PreviewHostApi { static const MessageCodec codec = _PreviewHostApiCodec(); - Future create(int arg_identifier, int? arg_rotation, ResolutionInfo? arg_targetResolution) async { + Future create(int arg_identifier, int? arg_rotation, + ResolutionInfo? arg_targetResolution) async { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.PreviewHostApi.create', codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_identifier, arg_rotation, arg_targetResolution]) as List?; + final List? replyList = await channel + .send([arg_identifier, arg_rotation, arg_targetResolution]) + as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -945,8 +911,7 @@ class PreviewHostApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.PreviewHostApi.releaseFlutterSurfaceTexture', codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; + final List? replyList = await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1006,7 +971,7 @@ class _ImageCaptureHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ResolutionInfo.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -1024,12 +989,14 @@ class ImageCaptureHostApi { static const MessageCodec codec = _ImageCaptureHostApiCodec(); - Future create(int arg_identifier, int? arg_flashMode, ResolutionInfo? arg_targetResolution) async { + Future create(int arg_identifier, int? arg_flashMode, + ResolutionInfo? arg_targetResolution) async { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageCaptureHostApi.create', codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_identifier, arg_flashMode, arg_targetResolution]) as List?; + final List? replyList = await channel.send( + [arg_identifier, arg_flashMode, arg_targetResolution]) + as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1050,8 +1017,8 @@ class ImageCaptureHostApi { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageCaptureHostApi.setFlashMode', codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_identifier, arg_flashMode]) as List?; + final List? replyList = await channel + .send([arg_identifier, arg_flashMode]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1111,98 +1078,7 @@ class _ExposureStateFlutterApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: - return ExposureCompensationRange.decode(readValue(buffer)!); - default: - return super.readValueOfType(type, buffer); - } - } -} - -abstract class ExposureStateFlutterApi { - static const MessageCodec codec = _ExposureStateFlutterApiCodec(); - - void create(int identifier, ExposureCompensationRange exposureCompensationRange, double exposureCompensationStep); - - static void setup(ExposureStateFlutterApi? api, {BinaryMessenger? binaryMessenger}) { - { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ExposureStateFlutterApi.create', codec, - binaryMessenger: binaryMessenger); - if (api == null) { - channel.setMessageHandler(null); - } else { - channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null.'); - final List args = (message as List?)!; - final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, - 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null, expected non-null int.'); - final ExposureCompensationRange? arg_exposureCompensationRange = (args[1] as ExposureCompensationRange?); - assert(arg_exposureCompensationRange != null, - 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null, expected non-null ExposureCompensationRange.'); - final double? arg_exposureCompensationStep = (args[2] as double?); - assert(arg_exposureCompensationStep != null, - 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null, expected non-null double.'); - api.create(arg_identifier!, arg_exposureCompensationRange!, arg_exposureCompensationStep!); - return; - }); - } - } - } -} - -abstract class ZoomStateFlutterApi { - static const MessageCodec codec = StandardMessageCodec(); - - void create(int identifier, double minZoomRatio, double maxZoomRatio); - - static void setup(ZoomStateFlutterApi? api, {BinaryMessenger? binaryMessenger}) { - { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ZoomStateFlutterApi.create', codec, - binaryMessenger: binaryMessenger); - if (api == null) { - channel.setMessageHandler(null); - } else { - channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.ZoomStateFlutterApi.create was null.'); - final List args = (message as List?)!; - final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, - 'Argument for dev.flutter.pigeon.ZoomStateFlutterApi.create was null, expected non-null int.'); - final double? arg_minZoomRatio = (args[1] as double?); - assert(arg_minZoomRatio != null, - 'Argument for dev.flutter.pigeon.ZoomStateFlutterApi.create was null, expected non-null double.'); - final double? arg_maxZoomRatio = (args[2] as double?); - assert(arg_maxZoomRatio != null, - 'Argument for dev.flutter.pigeon.ZoomStateFlutterApi.create was null, expected non-null double.'); - api.create(arg_identifier!, arg_minZoomRatio!, arg_maxZoomRatio!); - return; - }); - } - } - } -} - -class _ExposureStateFlutterApiCodec extends StandardMessageCodec { - const _ExposureStateFlutterApiCodec(); - @override - void writeValue(WriteBuffer buffer, Object? value) { - if (value is ExposureCompensationRange) { - buffer.putUint8(128); - writeValue(buffer, value.encode()); - } else { - super.writeValue(buffer, value); - } - } - - @override - Object? readValueOfType(int type, ReadBuffer buffer) { - switch (type) { - case 128: + case 128: return ExposureCompensationRange.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -1213,9 +1089,13 @@ class _ExposureStateFlutterApiCodec extends StandardMessageCodec { abstract class ExposureStateFlutterApi { static const MessageCodec codec = _ExposureStateFlutterApiCodec(); - void create(int identifier, ExposureCompensationRange exposureCompensationRange, double exposureCompensationStep); + void create( + int identifier, + ExposureCompensationRange exposureCompensationRange, + double exposureCompensationStep); - static void setup(ExposureStateFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(ExposureStateFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ExposureStateFlutterApi.create', codec, @@ -1225,18 +1105,20 @@ abstract class ExposureStateFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null, expected non-null int.'); - final ExposureCompensationRange? arg_exposureCompensationRange = (args[1] as ExposureCompensationRange?); + final ExposureCompensationRange? arg_exposureCompensationRange = + (args[1] as ExposureCompensationRange?); assert(arg_exposureCompensationRange != null, 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null, expected non-null ExposureCompensationRange.'); final double? arg_exposureCompensationStep = (args[2] as double?); assert(arg_exposureCompensationStep != null, 'Argument for dev.flutter.pigeon.ExposureStateFlutterApi.create was null, expected non-null double.'); - api.create(arg_identifier!, arg_exposureCompensationRange!, arg_exposureCompensationStep!); + api.create(arg_identifier!, arg_exposureCompensationRange!, + arg_exposureCompensationStep!); return; }); } @@ -1249,7 +1131,8 @@ abstract class ZoomStateFlutterApi { void create(int identifier, double minZoomRatio, double maxZoomRatio); - static void setup(ZoomStateFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(ZoomStateFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ZoomStateFlutterApi.create', codec, @@ -1259,7 +1142,7 @@ abstract class ZoomStateFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ZoomStateFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.ZoomStateFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -1293,7 +1176,7 @@ class _ImageAnalysisHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ResolutionInfo.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -1311,12 +1194,14 @@ class ImageAnalysisHostApi { static const MessageCodec codec = _ImageAnalysisHostApiCodec(); - Future create(int arg_identifier, ResolutionInfo? arg_targetResolutionIdentifier) async { + Future create(int arg_identifier, + ResolutionInfo? arg_targetResolutionIdentifier) async { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageAnalysisHostApi.create', codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_identifier, arg_targetResolutionIdentifier]) as List?; + final List? replyList = await channel + .send([arg_identifier, arg_targetResolutionIdentifier]) + as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1333,12 +1218,14 @@ class ImageAnalysisHostApi { } } - Future setAnalyzer(int arg_identifier, int arg_analyzerIdentifier) async { + Future setAnalyzer( + int arg_identifier, int arg_analyzerIdentifier) async { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageAnalysisHostApi.setAnalyzer', codec, binaryMessenger: _binaryMessenger); final List? replyList = - await channel.send([arg_identifier, arg_analyzerIdentifier]) as List?; + await channel.send([arg_identifier, arg_analyzerIdentifier]) + as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -1418,7 +1305,8 @@ abstract class AnalyzerFlutterApi { void analyze(int identifier, int imageProxyIdentifier); - static void setup(AnalyzerFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(AnalyzerFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AnalyzerFlutterApi.create', codec, @@ -1428,7 +1316,7 @@ abstract class AnalyzerFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.AnalyzerFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.AnalyzerFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -1447,7 +1335,7 @@ abstract class AnalyzerFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.AnalyzerFlutterApi.analyze was null.'); + 'Argument for dev.flutter.pigeon.AnalyzerFlutterApi.analyze was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -1528,7 +1416,8 @@ abstract class ImageProxyFlutterApi { void create(int identifier, int format, int height, int width); - static void setup(ImageProxyFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(ImageProxyFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageProxyFlutterApi.create', codec, @@ -1538,7 +1427,7 @@ abstract class ImageProxyFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageProxyFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.ImageProxyFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -1565,7 +1454,8 @@ abstract class PlaneProxyFlutterApi { void create(int identifier, Uint8List buffer, int pixelStride, int rowStride); - static void setup(PlaneProxyFlutterApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(PlaneProxyFlutterApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.PlaneProxyFlutterApi.create', codec, @@ -1575,7 +1465,7 @@ abstract class PlaneProxyFlutterApi { } else { channel.setMessageHandler((Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.PlaneProxyFlutterApi.create was null.'); + 'Argument for dev.flutter.pigeon.PlaneProxyFlutterApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -1589,7 +1479,8 @@ abstract class PlaneProxyFlutterApi { final int? arg_rowStride = (args[3] as int?); assert(arg_rowStride != null, 'Argument for dev.flutter.pigeon.PlaneProxyFlutterApi.create was null, expected non-null int.'); - api.create(arg_identifier!, arg_buffer!, arg_pixelStride!, arg_rowStride!); + api.create( + arg_identifier!, arg_buffer!, arg_pixelStride!, arg_rowStride!); return; }); } diff --git a/packages/camera/camera_android_camerax/pigeons/camerax_library.dart b/packages/camera/camera_android_camerax/pigeons/camerax_library.dart index 8e4b0ca7431f..c8b3885d064b 100644 --- a/packages/camera/camera_android_camerax/pigeons/camerax_library.dart +++ b/packages/camera/camera_android_camerax/pigeons/camerax_library.dart @@ -56,16 +56,6 @@ class ExposureCompensationRange { int maxCompensation; } -class ExposureCompensationRange { - ExposureCompensationRange({ - required this.minCompensation, - required this.maxCompensation, - }); - - int minCompensation; - int maxCompensation; -} - @HostApi(dartHostTestHandler: 'TestInstanceManagerHostApi') abstract class InstanceManagerHostApi { /// Clear the native `InstanceManager`. @@ -88,8 +78,6 @@ abstract class JavaObjectFlutterApi { abstract class CameraInfoHostApi { int getSensorRotationDegrees(int identifier); - int getLiveCameraState(int identifier); - int getExposureState(int identifier); int getZoomState(int identifier); @@ -196,19 +184,6 @@ abstract class ZoomStateFlutterApi { void create(int identifier, double minZoomRatio, double maxZoomRatio); } -@FlutterApi() -abstract class ExposureStateFlutterApi { - void create( - int identifier, - ExposureCompensationRange exposureCompensationRange, - double exposureCompensationStep); -} - -@FlutterApi() -abstract class ZoomStateFlutterApi { - void create(int identifier, double minZoomRatio, double maxZoomRatio); -} - @HostApi(dartHostTestHandler: 'TestImageAnalysisHostApi') abstract class ImageAnalysisHostApi { void create(int identifier, ResolutionInfo? targetResolutionIdentifier); diff --git a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart index 079abe0f2fd4..e7a6707d6e3f 100644 --- a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart +++ b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.dart @@ -132,19 +132,12 @@ void main() { camera.processCameraProvider = mockProcessCameraProvider; - camera.processCameraProvider = mockProcessCameraProvider; - when(camera.testPreview.setSurfaceProvider()) .thenAnswer((_) async => testSurfaceTextureId); - when(mockProcessCameraProvider.bindToLifecycle( - camera.mockBackCameraSelector, - [camera.testPreview, camera.testImageCapture])) - .thenAnswer((_) async => mockCamera); - when(mockCamera.getCameraInfo()).thenAnswer((_) async => mockCameraInfo); - when(mockCameraInfo.getLiveCameraState()) - .thenAnswer((_) async => mockLiveCameraState); - camera.processCameraProvider = mockProcessCameraProvider; - camera.createDetachedObjectForTesting = true; + when(mockProcessCameraProvider.bindToLifecycle(any, any)) + .thenAnswer((_) => Future.value(mockCamera)); + when(mockCamera.getCameraInfo()) + .thenAnswer((_) => Future.value(MockCameraInfo())); expect( await camera.createCamera(testCameraDescription, testResolutionPreset, @@ -172,7 +165,7 @@ void main() { 'createCamera binds Preview and ImageCapture use cases to ProcessCameraProvider instance', () async { final MockAndroidCameraCameraX camera = MockAndroidCameraCameraX(); - final ProcessCameraProvider mockProcessCameraProvider = + final MockProcessCameraProvider mockProcessCameraProvider = MockProcessCameraProvider(); final MockCamera mockCamera = MockCamera(); final MockCameraInfo mockCameraInfo = MockCameraInfo(); @@ -185,16 +178,6 @@ void main() { const ResolutionPreset testResolutionPreset = ResolutionPreset.veryHigh; const bool enableAudio = true; - when(mockProcessCameraProvider.bindToLifecycle( - camera.mockBackCameraSelector, - [camera.testPreview, camera.testImageCapture])) - .thenAnswer((_) async => mockCamera); - when(mockCamera.getCameraInfo()).thenAnswer((_) async => mockCameraInfo); - when(mockCameraInfo.getLiveCameraState()) - .thenAnswer((_) async => MockLiveData()); - camera.processCameraProvider = mockProcessCameraProvider; - camera.createDetachedObjectForTesting = true; - camera.processCameraProvider = mockProcessCameraProvider; when(mockProcessCameraProvider.bindToLifecycle( @@ -271,16 +254,6 @@ void main() { await camera.createCamera(testCameraDescription, testResolutionPreset, enableAudio: enableAudio); - when(mockProcessCameraProvider.bindToLifecycle(any, any)) - .thenAnswer((_) async => mockCamera); - when(mockCamera.getCameraInfo()) - .thenAnswer((_) => Future.value(MockCameraInfo())); - when(camera.testPreview.getResolutionInfo()) - .thenAnswer((_) async => testResolutionInfo); - - await camera.createCamera(testCameraDescription, testResolutionPreset, - enableAudio: enableAudio); - // Start listening to camera events stream to verify the proper CameraInitializedEvent is sent. camera.cameraEventStreamController.stream.listen((CameraEvent event) { expect(event, const TypeMatcher()); @@ -408,7 +381,6 @@ void main() { verifyNever(camera.processCameraProvider! .bindToLifecycle(camera.cameraSelector!, [camera.preview!])); - verifyNever(mockLiveCameraState.observe(any)); expect(camera.cameraInfo, isNot(mockCameraInfo)); }); @@ -424,11 +396,6 @@ void main() { camera.cameraSelector = MockCameraSelector(); camera.preview = MockPreview(); - when(mockProcessCameraProvider.bindToLifecycle(any, any)) - .thenAnswer((_) => Future.value(mockCamera)); - when(mockCamera.getCameraInfo()) - .thenAnswer((_) => Future.value(mockCameraInfo)); - when(mockProcessCameraProvider.bindToLifecycle(any, any)) .thenAnswer((_) => Future.value(mockCamera)); when(mockCamera.getCameraInfo()) @@ -438,13 +405,6 @@ void main() { verify(camera.processCameraProvider! .bindToLifecycle(camera.cameraSelector!, [camera.preview!])); - expect( - await testCameraClosingObserver( - camera, - 78, - verify(mockLiveCameraState.observe(captureAny)).captured.single - as Observer), - isTrue); expect(camera.cameraInfo, equals(mockCameraInfo)); }); @@ -461,11 +421,6 @@ void main() { camera.cameraSelector = MockCameraSelector(); camera.preview = MockPreview(); - when(mockProcessCameraProvider.bindToLifecycle(any, any)) - .thenAnswer((_) => Future.value(mockCamera)); - when(mockCamera.getCameraInfo()) - .thenAnswer((_) => Future.value(MockCameraInfo())); - when(mockProcessCameraProvider.bindToLifecycle(any, any)) .thenAnswer((_) => Future.value(mockCamera)); when(mockCamera.getCameraInfo()) @@ -502,11 +457,6 @@ void main() { camera.cameraSelector = MockCameraSelector(); camera.preview = MockPreview(); - when(mockProcessCameraProvider.bindToLifecycle(any, any)) - .thenAnswer((_) => Future.value(mockCamera)); - when(mockCamera.getCameraInfo()) - .thenAnswer((_) => Future.value(mockCameraInfo)); - when(mockProcessCameraProvider.bindToLifecycle(any, any)) .thenAnswer((_) => Future.value(mockCamera)); when(mockCamera.getCameraInfo()) @@ -631,11 +581,6 @@ void main() { camera.cameraSelector = MockCameraSelector(); camera.createDetachedCallbacks = true; - when(mockProcessCameraProvider.bindToLifecycle(any, any)) - .thenAnswer((_) => Future.value(mockCamera)); - when(mockCamera.getCameraInfo()) - .thenAnswer((_) => Future.value(MockCameraInfo())); - when(mockProcessCameraProvider.bindToLifecycle(any, any)) .thenAnswer((_) => Future.value(mockCamera)); when(mockCamera.getCameraInfo()) diff --git a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.mocks.dart b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.mocks.dart index 0c88413c1ad6..b7365a2e90d4 100644 --- a/packages/camera/camera_android_camerax/test/android_camera_camerax_test.mocks.dart +++ b/packages/camera/camera_android_camerax/test/android_camera_camerax_test.mocks.dart @@ -203,15 +203,6 @@ class MockCameraInfo extends _i1.Mock implements _i2.CameraInfo { returnValueForMissingStub: _i11.Future.value(0), ) as _i11.Future); @override - _i11.Future getLiveCameraState() => (super.noSuchMethod( - Invocation.method( - #getLiveCameraState, - [], - ), - returnValue: _i11.Future.value(), - returnValueForMissingStub: _i11.Future.value(), - ) as _i11.Future); - @override _i11.Future<_i3.ExposureState> getExposureState() => (super.noSuchMethod( Invocation.method( #getExposureState, diff --git a/packages/camera/camera_android_camerax/test/camera_info_test.dart b/packages/camera/camera_android_camerax/test/camera_info_test.dart index 7edf6c409fe0..9826b88e367e 100644 --- a/packages/camera/camera_android_camerax/test/camera_info_test.dart +++ b/packages/camera/camera_android_camerax/test/camera_info_test.dart @@ -6,7 +6,6 @@ import 'package:camera_android_camerax/src/camera_info.dart'; import 'package:camera_android_camerax/src/camerax_library.g.dart'; import 'package:camera_android_camerax/src/exposure_state.dart'; import 'package:camera_android_camerax/src/instance_manager.dart'; -import 'package:camera_android_camerax/src/live_data.dart'; import 'package:camera_android_camerax/src/zoom_state.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:mockito/annotations.dart'; diff --git a/packages/camera/camera_android_camerax/test/camera_info_test.mocks.dart b/packages/camera/camera_android_camerax/test/camera_info_test.mocks.dart index 4c1bdf696938..968dc6e8b621 100644 --- a/packages/camera/camera_android_camerax/test/camera_info_test.mocks.dart +++ b/packages/camera/camera_android_camerax/test/camera_info_test.mocks.dart @@ -36,14 +36,6 @@ class MockTestCameraInfoHostApi extends _i1.Mock returnValue: 0, ) as int); @override - int getLiveCameraState(int? identifier) => (super.noSuchMethod( - Invocation.method( - #getLiveCameraState, - [identifier], - ), - returnValue: 0, - ) as int); - @override int getExposureState(int? identifier) => (super.noSuchMethod( Invocation.method( #getExposureState, diff --git a/packages/camera/camera_android_camerax/test/camera_test.dart b/packages/camera/camera_android_camerax/test/camera_test.dart index 05f5fe7dd029..742a60799e6f 100644 --- a/packages/camera/camera_android_camerax/test/camera_test.dart +++ b/packages/camera/camera_android_camerax/test/camera_test.dart @@ -20,8 +20,6 @@ void main() { TestInstanceManagerHostApi.setup(MockTestInstanceManagerHostApi()); group('Camera', () { - tearDown(() => TestCameraHostApi.setup(null)); - test('getCameraInfo makes call to retrieve expected CameraInfo', () async { final MockTestCameraHostApi mockApi = MockTestCameraHostApi(); TestCameraHostApi.setup(mockApi); @@ -54,7 +52,7 @@ void main() { verify(mockApi.getCameraInfo(cameraIdentifier)); }); - test('flutterApiCreate makes call to add instance to instance manager', () { + test('flutterApiCreateTest', () { final InstanceManager instanceManager = InstanceManager( onWeakReferenceRemoved: (_) {}, ); diff --git a/packages/camera/camera_android_camerax/test/test_camerax_library.g.dart b/packages/camera/camera_android_camerax/test/test_camerax_library.g.dart index 098b297bcf0a..40bd8f2e4335 100644 --- a/packages/camera/camera_android_camerax/test/test_camerax_library.g.dart +++ b/packages/camera/camera_android_camerax/test/test_camerax_library.g.dart @@ -14,7 +14,8 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:camera_android_camerax/src/camerax_library.g.dart'; abstract class TestInstanceManagerHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); /// Clear the native `InstanceManager`. @@ -22,15 +23,19 @@ abstract class TestInstanceManagerHostApi { /// This is typically only used after a hot restart. void clear(); - static void setup(TestInstanceManagerHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestInstanceManagerHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.InstanceManagerHostApi.clear', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { // ignore message api.clear(); return []; @@ -41,22 +46,27 @@ abstract class TestInstanceManagerHostApi { } abstract class TestJavaObjectHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); void dispose(int identifier); - static void setup(TestJavaObjectHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestJavaObjectHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.JavaObjectHostApi.dispose', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.JavaObjectHostApi.dispose was null.'); + 'Argument for dev.flutter.pigeon.JavaObjectHostApi.dispose was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -70,28 +80,32 @@ abstract class TestJavaObjectHostApi { } abstract class TestCameraInfoHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); int getSensorRotationDegrees(int identifier); - int getLiveCameraState(int identifier); - int getExposureState(int identifier); int getZoomState(int identifier); - static void setup(TestCameraInfoHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestCameraInfoHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.CameraInfoHostApi.getSensorRotationDegrees', codec, + 'dev.flutter.pigeon.CameraInfoHostApi.getSensorRotationDegrees', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getSensorRotationDegrees was null.'); + 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getSensorRotationDegrees was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -101,35 +115,19 @@ abstract class TestCameraInfoHostApi { }); } } - { - final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.CameraInfoHostApi.getLiveCameraState', codec, - binaryMessenger: binaryMessenger); - if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); - } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getLiveCameraState was null.'); - final List args = (message as List?)!; - final int? arg_identifier = (args[0] as int?); - assert(arg_identifier != null, - 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getLiveCameraState was null, expected non-null int.'); - final int output = api.getLiveCameraState(arg_identifier!); - return [output]; - }); - } - } { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraInfoHostApi.getExposureState', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getExposureState was null.'); + 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getExposureState was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -144,11 +142,14 @@ abstract class TestCameraInfoHostApi { 'dev.flutter.pigeon.CameraInfoHostApi.getZoomState', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getZoomState was null.'); + 'Argument for dev.flutter.pigeon.CameraInfoHostApi.getZoomState was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -162,24 +163,29 @@ abstract class TestCameraInfoHostApi { } abstract class TestCameraSelectorHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); void create(int identifier, int? lensFacing); List filter(int identifier, List cameraInfoIds); - static void setup(TestCameraSelectorHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestCameraSelectorHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraSelectorHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraSelectorHostApi.create was null.'); + 'Argument for dev.flutter.pigeon.CameraSelectorHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -195,19 +201,24 @@ abstract class TestCameraSelectorHostApi { 'dev.flutter.pigeon.CameraSelectorHostApi.filter', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraSelectorHostApi.filter was null.'); + 'Argument for dev.flutter.pigeon.CameraSelectorHostApi.filter was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.CameraSelectorHostApi.filter was null, expected non-null int.'); - final List? arg_cameraInfoIds = (args[1] as List?)?.cast(); + final List? arg_cameraInfoIds = + (args[1] as List?)?.cast(); assert(arg_cameraInfoIds != null, 'Argument for dev.flutter.pigeon.CameraSelectorHostApi.filter was null, expected non-null List.'); - final List output = api.filter(arg_identifier!, arg_cameraInfoIds!); + final List output = + api.filter(arg_identifier!, arg_cameraInfoIds!); return [output]; }); } @@ -216,14 +227,16 @@ abstract class TestCameraSelectorHostApi { } abstract class TestProcessCameraProviderHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); Future getInstance(); List getAvailableCameraInfos(int identifier); - int bindToLifecycle(int identifier, int cameraSelectorIdentifier, List useCaseIds); + int bindToLifecycle( + int identifier, int cameraSelectorIdentifier, List useCaseIds); bool isBound(int identifier, int useCaseIdentifier); @@ -231,15 +244,19 @@ abstract class TestProcessCameraProviderHostApi { void unbindAll(int identifier); - static void setup(TestProcessCameraProviderHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestProcessCameraProviderHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ProcessCameraProviderHostApi.getInstance', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { // ignore message final int output = await api.getInstance(); return [output]; @@ -248,33 +265,42 @@ abstract class TestProcessCameraProviderHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos', codec, + 'dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos was null.'); + 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos was null, expected non-null int.'); - final List output = api.getAvailableCameraInfos(arg_identifier!); + final List output = + api.getAvailableCameraInfos(arg_identifier!); return [output]; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle', codec, + 'dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle was null.'); + 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -282,10 +308,12 @@ abstract class TestProcessCameraProviderHostApi { final int? arg_cameraSelectorIdentifier = (args[1] as int?); assert(arg_cameraSelectorIdentifier != null, 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle was null, expected non-null int.'); - final List? arg_useCaseIds = (args[2] as List?)?.cast(); + final List? arg_useCaseIds = + (args[2] as List?)?.cast(); assert(arg_useCaseIds != null, 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.bindToLifecycle was null, expected non-null List.'); - final int output = api.bindToLifecycle(arg_identifier!, arg_cameraSelectorIdentifier!, arg_useCaseIds!); + final int output = api.bindToLifecycle( + arg_identifier!, arg_cameraSelectorIdentifier!, arg_useCaseIds!); return [output]; }); } @@ -295,11 +323,14 @@ abstract class TestProcessCameraProviderHostApi { 'dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound was null.'); + 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -307,7 +338,8 @@ abstract class TestProcessCameraProviderHostApi { final int? arg_useCaseIdentifier = (args[1] as int?); assert(arg_useCaseIdentifier != null, 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.isBound was null, expected non-null int.'); - final bool output = api.isBound(arg_identifier!, arg_useCaseIdentifier!); + final bool output = + api.isBound(arg_identifier!, arg_useCaseIdentifier!); return [output]; }); } @@ -317,16 +349,20 @@ abstract class TestProcessCameraProviderHostApi { 'dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind was null.'); + 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind was null, expected non-null int.'); - final List? arg_useCaseIds = (args[1] as List?)?.cast(); + final List? arg_useCaseIds = + (args[1] as List?)?.cast(); assert(arg_useCaseIds != null, 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.unbind was null, expected non-null List.'); api.unbind(arg_identifier!, arg_useCaseIds!); @@ -339,11 +375,14 @@ abstract class TestProcessCameraProviderHostApi { 'dev.flutter.pigeon.ProcessCameraProviderHostApi.unbindAll', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.unbindAll was null.'); + 'Argument for dev.flutter.pigeon.ProcessCameraProviderHostApi.unbindAll was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -357,22 +396,27 @@ abstract class TestProcessCameraProviderHostApi { } abstract class TestCameraHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); int getCameraInfo(int identifier); - static void setup(TestCameraHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestCameraHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.CameraHostApi.getCameraInfo', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.CameraHostApi.getCameraInfo was null.'); + 'Argument for dev.flutter.pigeon.CameraHostApi.getCameraInfo was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -400,7 +444,7 @@ class _TestSystemServicesHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return CameraPermissionsErrorData.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -409,45 +453,58 @@ class _TestSystemServicesHostApiCodec extends StandardMessageCodec { } abstract class TestSystemServicesHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = _TestSystemServicesHostApiCodec(); - Future requestCameraPermissions(bool enableAudio); + Future requestCameraPermissions( + bool enableAudio); - void startListeningForDeviceOrientationChange(bool isFrontFacing, int sensorOrientation); + void startListeningForDeviceOrientationChange( + bool isFrontFacing, int sensorOrientation); void stopListeningForDeviceOrientationChange(); - static void setup(TestSystemServicesHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestSystemServicesHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions', codec, + 'dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions was null.'); + 'Argument for dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions was null.'); final List args = (message as List?)!; final bool? arg_enableAudio = (args[0] as bool?); assert(arg_enableAudio != null, 'Argument for dev.flutter.pigeon.SystemServicesHostApi.requestCameraPermissions was null, expected non-null bool.'); - final CameraPermissionsErrorData? output = await api.requestCameraPermissions(arg_enableAudio!); + final CameraPermissionsErrorData? output = + await api.requestCameraPermissions(arg_enableAudio!); return [output]; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange', codec, + 'dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange was null.'); + 'Argument for dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange was null.'); final List args = (message as List?)!; final bool? arg_isFrontFacing = (args[0] as bool?); assert(arg_isFrontFacing != null, @@ -455,19 +512,24 @@ abstract class TestSystemServicesHostApi { final int? arg_sensorOrientation = (args[1] as int?); assert(arg_sensorOrientation != null, 'Argument for dev.flutter.pigeon.SystemServicesHostApi.startListeningForDeviceOrientationChange was null, expected non-null int.'); - api.startListeningForDeviceOrientationChange(arg_isFrontFacing!, arg_sensorOrientation!); + api.startListeningForDeviceOrientationChange( + arg_isFrontFacing!, arg_sensorOrientation!); return []; }); } } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.SystemServicesHostApi.stopListeningForDeviceOrientationChange', codec, + 'dev.flutter.pigeon.SystemServicesHostApi.stopListeningForDeviceOrientationChange', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { // ignore message api.stopListeningForDeviceOrientationChange(); return []; @@ -495,9 +557,9 @@ class _TestPreviewHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ResolutionInfo.decode(readValue(buffer)!); - case 129: + case 129: return ResolutionInfo.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -506,7 +568,8 @@ class _TestPreviewHostApiCodec extends StandardMessageCodec { } abstract class TestPreviewHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = _TestPreviewHostApiCodec(); void create(int identifier, int? rotation, ResolutionInfo? targetResolution); @@ -517,23 +580,28 @@ abstract class TestPreviewHostApi { ResolutionInfo getResolutionInfo(int identifier); - static void setup(TestPreviewHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestPreviewHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.PreviewHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.PreviewHostApi.create was null.'); + 'Argument for dev.flutter.pigeon.PreviewHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.PreviewHostApi.create was null, expected non-null int.'); final int? arg_rotation = (args[1] as int?); - final ResolutionInfo? arg_targetResolution = (args[2] as ResolutionInfo?); + final ResolutionInfo? arg_targetResolution = + (args[2] as ResolutionInfo?); api.create(arg_identifier!, arg_rotation, arg_targetResolution); return []; }); @@ -544,11 +612,14 @@ abstract class TestPreviewHostApi { 'dev.flutter.pigeon.PreviewHostApi.setSurfaceProvider', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.PreviewHostApi.setSurfaceProvider was null.'); + 'Argument for dev.flutter.pigeon.PreviewHostApi.setSurfaceProvider was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -560,12 +631,16 @@ abstract class TestPreviewHostApi { } { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.PreviewHostApi.releaseFlutterSurfaceTexture', codec, + 'dev.flutter.pigeon.PreviewHostApi.releaseFlutterSurfaceTexture', + codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { // ignore message api.releaseFlutterSurfaceTexture(); return []; @@ -577,11 +652,14 @@ abstract class TestPreviewHostApi { 'dev.flutter.pigeon.PreviewHostApi.getResolutionInfo', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.PreviewHostApi.getResolutionInfo was null.'); + 'Argument for dev.flutter.pigeon.PreviewHostApi.getResolutionInfo was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -609,7 +687,7 @@ class _TestImageCaptureHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ResolutionInfo.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -618,7 +696,8 @@ class _TestImageCaptureHostApiCodec extends StandardMessageCodec { } abstract class TestImageCaptureHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = _TestImageCaptureHostApiCodec(); void create(int identifier, int? flashMode, ResolutionInfo? targetResolution); @@ -627,23 +706,28 @@ abstract class TestImageCaptureHostApi { Future takePicture(int identifier); - static void setup(TestImageCaptureHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestImageCaptureHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageCaptureHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.create was null.'); + 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.create was null, expected non-null int.'); final int? arg_flashMode = (args[1] as int?); - final ResolutionInfo? arg_targetResolution = (args[2] as ResolutionInfo?); + final ResolutionInfo? arg_targetResolution = + (args[2] as ResolutionInfo?); api.create(arg_identifier!, arg_flashMode, arg_targetResolution); return []; }); @@ -654,11 +738,14 @@ abstract class TestImageCaptureHostApi { 'dev.flutter.pigeon.ImageCaptureHostApi.setFlashMode', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.setFlashMode was null.'); + 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.setFlashMode was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -676,11 +763,14 @@ abstract class TestImageCaptureHostApi { 'dev.flutter.pigeon.ImageCaptureHostApi.takePicture', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.takePicture was null.'); + 'Argument for dev.flutter.pigeon.ImageCaptureHostApi.takePicture was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -708,7 +798,7 @@ class _TestImageAnalysisHostApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return ResolutionInfo.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -717,7 +807,8 @@ class _TestImageAnalysisHostApiCodec extends StandardMessageCodec { } abstract class TestImageAnalysisHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = _TestImageAnalysisHostApiCodec(); void create(int identifier, ResolutionInfo? targetResolutionIdentifier); @@ -726,22 +817,27 @@ abstract class TestImageAnalysisHostApi { void clearAnalyzer(int identifier); - static void setup(TestImageAnalysisHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestImageAnalysisHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageAnalysisHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.create was null.'); + 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.create was null, expected non-null int.'); - final ResolutionInfo? arg_targetResolutionIdentifier = (args[1] as ResolutionInfo?); + final ResolutionInfo? arg_targetResolutionIdentifier = + (args[1] as ResolutionInfo?); api.create(arg_identifier!, arg_targetResolutionIdentifier); return []; }); @@ -752,11 +848,14 @@ abstract class TestImageAnalysisHostApi { 'dev.flutter.pigeon.ImageAnalysisHostApi.setAnalyzer', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.setAnalyzer was null.'); + 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.setAnalyzer was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -774,11 +873,14 @@ abstract class TestImageAnalysisHostApi { 'dev.flutter.pigeon.ImageAnalysisHostApi.clearAnalyzer', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.clearAnalyzer was null.'); + 'Argument for dev.flutter.pigeon.ImageAnalysisHostApi.clearAnalyzer was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -792,22 +894,27 @@ abstract class TestImageAnalysisHostApi { } abstract class TestAnalyzerHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); void create(int identifier); - static void setup(TestAnalyzerHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestAnalyzerHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.AnalyzerHostApi.create', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.AnalyzerHostApi.create was null.'); + 'Argument for dev.flutter.pigeon.AnalyzerHostApi.create was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -821,24 +928,29 @@ abstract class TestAnalyzerHostApi { } abstract class TestImageProxyHostApi { - static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => TestDefaultBinaryMessengerBinding.instance; + static TestDefaultBinaryMessengerBinding? get _testBinaryMessengerBinding => + TestDefaultBinaryMessengerBinding.instance; static const MessageCodec codec = StandardMessageCodec(); List getPlanes(int identifier); void close(int identifier); - static void setup(TestImageProxyHostApi? api, {BinaryMessenger? binaryMessenger}) { + static void setup(TestImageProxyHostApi? api, + {BinaryMessenger? binaryMessenger}) { { final BasicMessageChannel channel = BasicMessageChannel( 'dev.flutter.pigeon.ImageProxyHostApi.getPlanes', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageProxyHostApi.getPlanes was null.'); + 'Argument for dev.flutter.pigeon.ImageProxyHostApi.getPlanes was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, @@ -853,11 +965,14 @@ abstract class TestImageProxyHostApi { 'dev.flutter.pigeon.ImageProxyHostApi.close', codec, binaryMessenger: binaryMessenger); if (api == null) { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, null); + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, null); } else { - _testBinaryMessengerBinding!.defaultBinaryMessenger.setMockDecodedMessageHandler(channel, (Object? message) async { + _testBinaryMessengerBinding!.defaultBinaryMessenger + .setMockDecodedMessageHandler(channel, + (Object? message) async { assert(message != null, - 'Argument for dev.flutter.pigeon.ImageProxyHostApi.close was null.'); + 'Argument for dev.flutter.pigeon.ImageProxyHostApi.close was null.'); final List args = (message as List?)!; final int? arg_identifier = (args[0] as int?); assert(arg_identifier != null, From cdf2e67c3525075998375615b544a767601c34a0 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Tue, 2 May 2023 18:05:42 -0700 Subject: [PATCH 05/15] Undo changelog change --- packages/camera/camera_android_camerax/CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/camera/camera_android_camerax/CHANGELOG.md b/packages/camera/camera_android_camerax/CHANGELOG.md index 24fbec47e8b7..1c901a82bfac 100644 --- a/packages/camera/camera_android_camerax/CHANGELOG.md +++ b/packages/camera/camera_android_camerax/CHANGELOG.md @@ -21,4 +21,3 @@ * Implements image streaming. * Provides LifecycleOwner implementation for Activities that use the plugin that do not implement it themselves. * Implements retrieval of camera information. -* Implements onCameraClosing callback method for indicating the camera is closing and bumps CameraX version to 1.3.0-alpha05. From 597f9d76be233360f07b6ec16aca142d39596d1a Mon Sep 17 00:00:00 2001 From: camsim99 Date: Wed, 3 May 2023 09:17:12 -0700 Subject: [PATCH 06/15] Second draft --- .../camera_android_camerax/CHANGELOG.md | 1 + .../camera/camera_android_camerax/README.md | 46 ++++++++----------- 2 files changed, 20 insertions(+), 27 deletions(-) diff --git a/packages/camera/camera_android_camerax/CHANGELOG.md b/packages/camera/camera_android_camerax/CHANGELOG.md index 1c901a82bfac..e10539e43fc5 100644 --- a/packages/camera/camera_android_camerax/CHANGELOG.md +++ b/packages/camera/camera_android_camerax/CHANGELOG.md @@ -21,3 +21,4 @@ * Implements image streaming. * Provides LifecycleOwner implementation for Activities that use the plugin that do not implement it themselves. * Implements retrieval of camera information. +* Updates README with plugin overview. diff --git a/packages/camera/camera_android_camerax/README.md b/packages/camera/camera_android_camerax/README.md index dda30612cabd..2ff3ae067ad2 100644 --- a/packages/camera/camera_android_camerax/README.md +++ b/packages/camera/camera_android_camerax/README.md @@ -3,7 +3,7 @@ An Android implementation of [`camera`][1] that uses the [CameraX library][2]. *Note*: This package is under development. -See [missing implementations and limitations](#missing-features-and-limitations). +See [missing features and limitations](#missing-features-and-limitations). ## Usage @@ -24,42 +24,33 @@ The `camera` implementation is located at `./lib/src/android_camera_camerax.dart it is implemented using Dart classes that act as wrapped versions of the Android classes that the implementation needs access to. -To understand how this works, consider the example of [`Camera`][11], the interface -provided by CameraX used to control the flow of data to use cases, control the camera, -and publish the state of the camera via CameraInfo. The Dart-wrapped version of this -class is located at `./lib/src/camera.dart`. You'll notice its implementation as -`Camera`, but also two additional classes: `CameraHostApiImpl`, an extension -of the Host API used by [`pigeon`][12] to communicate with native code, and -`CameraFlutterApiImpl`, the implementation of the Flutter API used by `pigeon` to -communicate with native code. The file that `pigeon` uses to generate the Host -and Flutter APIs used by these classes is located at `pigeons/camerax_library.dart`. - -Both `CameraHostApiImpl` and `CameraFlutterApiImpl` utilize `BinaryMessenger` -instances to communicate with native code using `pigeon`; for more information on -`pigeon`, see its [documentation][12]. Both of these classes additionally utilize -an `InstanceManager` instance that is used to manage Dart objects that represent -their Android counterparts. For example, the `InstanceManager` instance is used -to manage any instances of `Camera` we create in Dart and in native, and any other -instances that `Camera` methods may create. - -On the native side, you'll find two Java classes that mirror these two Dart classes -discussed: in `./android/src/main/java/io/flutter/plugins/camerax/`. you will find -`CameraHostApiImpl.java` and `CameraFlutterApiImpl.java`, which implement the Host -API and extend the Flutter API used by `pigeon`, respectfully. - -WHAT IF INSTEAD I JUST DID A MAP OF THE STRUCTURE VERSUS A LENGTHY EXAMPLE. +In `lib/src/` you will find all of the Dart-wrapped native classes that the plugin +currently uses to implement `camera`. Each of these classes uses an `InstanceManager` +(implementation in `instance_manager.dart`) to manage the creation/garbage collection +of objects created by the plugin on the Dart side and their corresponding Java object +on the native side. This plugin uses [`pigeon`][12] to communicate with native code, +so each of these Dart-wrapped classes have Host API and Flutter API implementations, +as needed. +Similarly, on the native side in `android/src/main/java/io/flutter/plugins/camerax/`, +you'll find the Host API and Flutter API implementations of the same classes wrapped +with Dart in `lib/src/`. These implementations call directly to the classes that are +wrapped in the CameraX library or otherwise. The objects created in this native code +are also managed by an `InstanceManager` (implementation in `InstanceManager.java`). Thus, if you want to implement any new functionality in the implementation or fix any bugs, you will want to search in `./lib/src/` for any wrapped classes you may need. If any classes you need are not wrapped or you need to implement any additional methods, you will need to take additional steps to wrap them. +For more information on the approach of wrapping native libraries For plugins, please +see the [design document][13]. + ## Missing features and limitations ### Resolution configuration \[[Issue #120462][5]\] -Any specified `ResolutionPreset` is unused in favor of CameraX defaults and +Any specified `ResolutionPreset` wll go unused in favor of CameraX defaults and `onCameraResolutionChanged` is unimplemented. ### Locking/Unlocking capture orientation \[[Issue #125915][6]\] @@ -95,4 +86,5 @@ Any specified `ResolutionPreset` is unused in favor of CameraX defaults and [9]: https://github.com/flutter/flutter/issues/120467 [10]: https://github.com/flutter/flutter/issues/125371 [11]: https://developer.android.com/reference/androidx/camera/core/Camera -[12]: \ No newline at end of file +[12]: https://pub.dev/packages/pigeon +[13]: https://docs.google.com/document/d/1wXB1zNzYhd2SxCu1_BK3qmNWRhonTB6qdv4erdtBQqo/edit?usp=sharing&resourcekey=0-WOBqqOKiO9SARnziBg28pg \ No newline at end of file From f862d813ac3d19c646cdfa145dba7f3c1e9401e5 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Wed, 3 May 2023 09:34:51 -0700 Subject: [PATCH 07/15] Draft 3 --- .../camera/camera_android_camerax/README.md | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/packages/camera/camera_android_camerax/README.md b/packages/camera/camera_android_camerax/README.md index 2ff3ae067ad2..daa53a5df9e3 100644 --- a/packages/camera/camera_android_camerax/README.md +++ b/packages/camera/camera_android_camerax/README.md @@ -7,9 +7,10 @@ See [missing features and limitations](#missing-features-and-limitations). ## Usage -This package is [unendorsed][3]; the endorsed Android implementation of `camera` -is [`camera_android`][4]. To use this implementation of the plugin, you will need -to specify it in your `pubsepc.yaml` file as a dependency in addition to `camera`: +This package is [non-endorsed][3]; the endorsed Android implementation of `camera` +is [`camera_android`][4]. To use this implementation of the plugin instead of +`camera_android`, you will need to specify it in your `pubsepc.yaml` file as a +dependency in addition to `camera`: ```yaml dependencies: @@ -18,30 +19,32 @@ dependencies: camera_android_camerax: ^0.5.0 ``` -## Contributing +## How this plugin accesses Android libraries The `camera` implementation is located at `./lib/src/android_camera_camerax.dart`, and -it is implemented using Dart classes that act as wrapped versions of the Android +it is implemented using Dart classes that are wrapped versions of the Android classes that the implementation needs access to. In `lib/src/` you will find all of the Dart-wrapped native classes that the plugin currently uses to implement `camera`. Each of these classes uses an `InstanceManager` -(implementation in `instance_manager.dart`) to manage the creation/garbage collection -of objects created by the plugin on the Dart side and their corresponding Java object -on the native side. This plugin uses [`pigeon`][12] to communicate with native code, -so each of these Dart-wrapped classes have Host API and Flutter API implementations, -as needed. +(implementation in `instance_manager.dart`) to manage objects of these Dart-wrapped +classes that are created by the plugin implementation on the Dart side that map +to objects of the same type created on the native side. This plugin uses [`pigeon`][12] +to communicate with native code, so each of these Dart-wrapped classes have Host API +and Flutter API implementations, as needed. For more information on how these APIs are +used by `pigeon`, please see its [documentation][14]. Similarly, on the native side in `android/src/main/java/io/flutter/plugins/camerax/`, you'll find the Host API and Flutter API implementations of the same classes wrapped with Dart in `lib/src/`. These implementations call directly to the classes that are -wrapped in the CameraX library or otherwise. The objects created in this native code -are also managed by an `InstanceManager` (implementation in `InstanceManager.java`). +wrapped in the CameraX library or other Android libraries. The objects created in the +native code map to objects created on the Dart side, and thus, are also managed by an +`InstanceManager` (implementation in `InstanceManager.java`). -Thus, if you want to implement any new functionality in the implementation or fix any -bugs, you will want to search in `./lib/src/` for any wrapped classes you may need. If -any classes you need are not wrapped or you need to implement any additional methods, -you will need to take additional steps to wrap them. +Therefore, if you need to access any Android classes, you should search in `lib/src/` +for any Dart-wrapped classes you may need. If any classes that you need are not wrapped +or you need to access any methods not wrapped in a class, you will need to take the +additional steps to wrap them to maintain the structure of this plugin. For more information on the approach of wrapping native libraries For plugins, please see the [design document][13]. @@ -87,4 +90,5 @@ Any specified `ResolutionPreset` wll go unused in favor of CameraX defaults and [10]: https://github.com/flutter/flutter/issues/125371 [11]: https://developer.android.com/reference/androidx/camera/core/Camera [12]: https://pub.dev/packages/pigeon -[13]: https://docs.google.com/document/d/1wXB1zNzYhd2SxCu1_BK3qmNWRhonTB6qdv4erdtBQqo/edit?usp=sharing&resourcekey=0-WOBqqOKiO9SARnziBg28pg \ No newline at end of file +[13]: https://docs.google.com/document/d/1wXB1zNzYhd2SxCu1_BK3qmNWRhonTB6qdv4erdtBQqo/edit?usp=sharing&resourcekey=0-WOBqqOKiO9SARnziBg28pg +[14]: https://pub.dev/documentation/pigeon/latest/ \ No newline at end of file From 0585bfac166f392f81053ff364022967b90908ef Mon Sep 17 00:00:00 2001 From: camsim99 Date: Wed, 3 May 2023 09:44:56 -0700 Subject: [PATCH 08/15] Draft 4 --- .../camera/camera_android_camerax/README.md | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/camera/camera_android_camerax/README.md b/packages/camera/camera_android_camerax/README.md index daa53a5df9e3..9e784654c737 100644 --- a/packages/camera/camera_android_camerax/README.md +++ b/packages/camera/camera_android_camerax/README.md @@ -22,17 +22,16 @@ dependencies: ## How this plugin accesses Android libraries The `camera` implementation is located at `./lib/src/android_camera_camerax.dart`, and -it is implemented using Dart classes that are wrapped versions of the Android -classes that the implementation needs access to. +it is implemented using Dart classes that are wrapped versions of Android classes. -In `lib/src/` you will find all of the Dart-wrapped native classes that the plugin +In `lib/src/`, you will find all of the Dart-wrapped native classes that the plugin currently uses to implement `camera`. Each of these classes uses an `InstanceManager` -(implementation in `instance_manager.dart`) to manage objects of these Dart-wrapped -classes that are created by the plugin implementation on the Dart side that map -to objects of the same type created on the native side. This plugin uses [`pigeon`][12] -to communicate with native code, so each of these Dart-wrapped classes have Host API -and Flutter API implementations, as needed. For more information on how these APIs are -used by `pigeon`, please see its [documentation][14]. +(implementation in `instance_manager.dart`) to manage objects that are created by +the plugin implementation that map to objects of the same type created on the native +side. This plugin uses [`pigeon`][12] to communicate with native code, so each of +these Dart-wrapped classes also have Host API and Flutter API implementations, as needed. +For more information on how these APIs are used by `pigeon`, please see its +[documentation][14]. Similarly, on the native side in `android/src/main/java/io/flutter/plugins/camerax/`, you'll find the Host API and Flutter API implementations of the same classes wrapped @@ -41,10 +40,10 @@ wrapped in the CameraX library or other Android libraries. The objects created i native code map to objects created on the Dart side, and thus, are also managed by an `InstanceManager` (implementation in `InstanceManager.java`). -Therefore, if you need to access any Android classes, you should search in `lib/src/` -for any Dart-wrapped classes you may need. If any classes that you need are not wrapped -or you need to access any methods not wrapped in a class, you will need to take the -additional steps to wrap them to maintain the structure of this plugin. +If you need to access any Android classes to contribute to this plugin, you should +search in `lib/src/` for any Dart-wrapped classes you may need. If any classes that +you need are not wrapped or you need to access any methods not wrapped in a class, +you must take the additional steps to wrap them to maintain the structure of this plugin. For more information on the approach of wrapping native libraries For plugins, please see the [design document][13]. From e36d36310c4c79fdf75b907d7eb6c7f2c8393417 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Wed, 3 May 2023 13:58:58 -0700 Subject: [PATCH 09/15] Address first reviews --- .../camera_android_camerax/CONTRIBUTING.md | 46 +++++++++++++++ .../camera/camera_android_camerax/README.md | 57 ++++--------------- 2 files changed, 58 insertions(+), 45 deletions(-) create mode 100644 packages/camera/camera_android_camerax/CONTRIBUTING.md diff --git a/packages/camera/camera_android_camerax/CONTRIBUTING.md b/packages/camera/camera_android_camerax/CONTRIBUTING.md new file mode 100644 index 000000000000..311665c1392f --- /dev/null +++ b/packages/camera/camera_android_camerax/CONTRIBUTING.md @@ -0,0 +1,46 @@ +# Contributing to camera\_android\_camerax + +## Note on the plugin structure + +The `camera_platform_interface` implementation is located at +`lib/src/android_camera_camerax.dart`, and it is implemented using Dart classes that +are wrapped versions of native Android Java classes. + +In `lib/src/`, you will find all of the Dart-wrapped native classes that the plugin +currently uses in its implementation. Each of these classes uses an `InstanceManager` +(implementation in `instance_manager.dart`) to manage objects that are created by +the plugin implementation that map to objects of the same type created on the native +side. This plugin uses [`pigeon`][1] to generate the communication layer between Flutter +and native Android code, so each of these Dart-wrapped classes also have Host API and +Flutter API implementations, as needed. The communication interface is defined in +the `pigeons/camerax_library.dart` file. After editing the communication interface, +regenerate the communication layer by running +`dart run pigeon --input pigeons/camerax_library.dart` from the plugin root. + +On the native side in `android/src/main/java/io/flutter/plugins/camerax/`, you'll +find the Host API and Flutter API implementations of the same classes wrapped with +Dart in `lib/src/`. These implementations call directly to the classes that they +are wrapping in the CameraX library or other Android libraries. The objects created +in the native code map to objects created on the Dart side, and thus, are also +managed by an `InstanceManager` (implementation in `InstanceManager.java`). + +If you need to access any Android classes to contribute to this plugin, you should +search in `lib/src/` for any Dart-wrapped classes you may need. If any classes that +you need are not wrapped or you need to access any methods not wrapped in a class, +you must take the additional steps to wrap them to maintain the structure of this plugin. + +For more information on the approach of wrapping native libraries For plugins, please +see the [design document][2]. For more information on contributing packages in general, +check out our [contribution guide][3]. + +## Note on testing + +Besides [`pigeon`][1], this plugin also uses [`mockito`][4] to generate mock objects for +testing purposes. To generate the mock objects, run +`dart run build_runner build --delete-conflicting-outputs`. + + +[1]: https://pub.dev/packages/pigeon +[2]: https://docs.google.com/document/d/1wXB1zNzYhd2SxCu1_BK3qmNWRhonTB6qdv4erdtBQqo/edit?usp=sharing&resourcekey=0-WOBqqOKiO9SARnziBg28pg +[3]: https://github.com/flutter/packages/blob/main/CONTRIBUTING.md +[4]: https://pub.dev/packages/mockito diff --git a/packages/camera/camera_android_camerax/README.md b/packages/camera/camera_android_camerax/README.md index 9e784654c737..b91c7a3cdda7 100644 --- a/packages/camera/camera_android_camerax/README.md +++ b/packages/camera/camera_android_camerax/README.md @@ -19,59 +19,30 @@ dependencies: camera_android_camerax: ^0.5.0 ``` -## How this plugin accesses Android libraries - -The `camera` implementation is located at `./lib/src/android_camera_camerax.dart`, and -it is implemented using Dart classes that are wrapped versions of Android classes. - -In `lib/src/`, you will find all of the Dart-wrapped native classes that the plugin -currently uses to implement `camera`. Each of these classes uses an `InstanceManager` -(implementation in `instance_manager.dart`) to manage objects that are created by -the plugin implementation that map to objects of the same type created on the native -side. This plugin uses [`pigeon`][12] to communicate with native code, so each of -these Dart-wrapped classes also have Host API and Flutter API implementations, as needed. -For more information on how these APIs are used by `pigeon`, please see its -[documentation][14]. - -Similarly, on the native side in `android/src/main/java/io/flutter/plugins/camerax/`, -you'll find the Host API and Flutter API implementations of the same classes wrapped -with Dart in `lib/src/`. These implementations call directly to the classes that are -wrapped in the CameraX library or other Android libraries. The objects created in the -native code map to objects created on the Dart side, and thus, are also managed by an -`InstanceManager` (implementation in `InstanceManager.java`). - -If you need to access any Android classes to contribute to this plugin, you should -search in `lib/src/` for any Dart-wrapped classes you may need. If any classes that -you need are not wrapped or you need to access any methods not wrapped in a class, -you must take the additional steps to wrap them to maintain the structure of this plugin. - -For more information on the approach of wrapping native libraries For plugins, please -see the [design document][13]. - ## Missing features and limitations -### Resolution configuration \[[Issue #120462][5]\] +### Resolution configuration \[[Issue #120462][120462]\] Any specified `ResolutionPreset` wll go unused in favor of CameraX defaults and `onCameraResolutionChanged` is unimplemented. -### Locking/Unlocking capture orientation \[[Issue #125915][6]\] +### Locking/Unlocking capture orientation \[[Issue #125915][125915]\] `lockCaptureOrientation` & `unLockCaptureOrientation` are unimplemented. -### Flash mode configuration \[[Issue #120715][7]\] +### Flash mode configuration \[[Issue #120715][120715]\] `setFlashMode` is unimplemented. -### Exposure mode, point, & offset configuration \[[Issue #120468][8]\] +### Exposure mode, point, & offset configuration \[[Issue #120468][120468]\] `setExposureMode`, `setExposurePoint`, & `setExposureOffset` are unimplemented. -### Focus mode & point configuration \[[Issue #120467][9]\] +### Focus mode & point configuration \[[Issue #120467][120467]\] `setFocusMode` & `setFocusPoint` are unimplemented. -### Zoom configuration \[[Issue #125371][9]\] +### Zoom configuration \[[Issue #125371][125371]\] `setZoomLevel` is unimplemented. @@ -81,13 +52,9 @@ Any specified `ResolutionPreset` wll go unused in favor of CameraX defaults and [2]: https://developer.android.com/training/camerax [3]: https://docs.flutter.dev/packages-and-plugins/developing-packages#non-endorsed-federated-plugin [4]: https://pub.dev/packages/camera_android -[5]: https://github.com/flutter/flutter/issues/120462 -[6]: https://github.com/flutter/flutter/issues/125915 -[7]: https://github.com/flutter/flutter/issues/120715 -[8]: https://github.com/flutter/flutter/issues/120468 -[9]: https://github.com/flutter/flutter/issues/120467 -[10]: https://github.com/flutter/flutter/issues/125371 -[11]: https://developer.android.com/reference/androidx/camera/core/Camera -[12]: https://pub.dev/packages/pigeon -[13]: https://docs.google.com/document/d/1wXB1zNzYhd2SxCu1_BK3qmNWRhonTB6qdv4erdtBQqo/edit?usp=sharing&resourcekey=0-WOBqqOKiO9SARnziBg28pg -[14]: https://pub.dev/documentation/pigeon/latest/ \ No newline at end of file +[120462]: https://github.com/flutter/flutter/issues/120462 +[125915]: https://github.com/flutter/flutter/issues/125915 +[120715]: https://github.com/flutter/flutter/issues/120715 +[120468]: https://github.com/flutter/flutter/issues/120468 +[120467]: https://github.com/flutter/flutter/issues/120467 +[125371]: https://github.com/flutter/flutter/issues/125371 \ No newline at end of file From dfa4173f9644e0f41f9ae8d46144b223d49bab30 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Wed, 3 May 2023 14:01:19 -0700 Subject: [PATCH 10/15] Nits --- packages/camera/camera_android_camerax/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/camera/camera_android_camerax/CONTRIBUTING.md b/packages/camera/camera_android_camerax/CONTRIBUTING.md index 311665c1392f..e5ddbcfbe126 100644 --- a/packages/camera/camera_android_camerax/CONTRIBUTING.md +++ b/packages/camera/camera_android_camerax/CONTRIBUTING.md @@ -29,7 +29,7 @@ search in `lib/src/` for any Dart-wrapped classes you may need. If any classes t you need are not wrapped or you need to access any methods not wrapped in a class, you must take the additional steps to wrap them to maintain the structure of this plugin. -For more information on the approach of wrapping native libraries For plugins, please +For more information on the approach of wrapping native libraries for plugins, please see the [design document][2]. For more information on contributing packages in general, check out our [contribution guide][3]. From 7370a5e6367b34dd6ee49ac1c1813af92e6a9cb7 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Thu, 4 May 2023 10:56:57 -0700 Subject: [PATCH 11/15] address review --- packages/camera/camera_android_camerax/CONTRIBUTING.md | 4 ++-- packages/camera/camera_android_camerax/README.md | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/camera/camera_android_camerax/CONTRIBUTING.md b/packages/camera/camera_android_camerax/CONTRIBUTING.md index e5ddbcfbe126..5050d5904be0 100644 --- a/packages/camera/camera_android_camerax/CONTRIBUTING.md +++ b/packages/camera/camera_android_camerax/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing to camera\_android\_camerax -## Note on the plugin structure +## Plugin structure The `camera_platform_interface` implementation is located at `lib/src/android_camera_camerax.dart`, and it is implemented using Dart classes that @@ -33,7 +33,7 @@ For more information on the approach of wrapping native libraries for plugins, p see the [design document][2]. For more information on contributing packages in general, check out our [contribution guide][3]. -## Note on testing +## Testing Besides [`pigeon`][1], this plugin also uses [`mockito`][4] to generate mock objects for testing purposes. To generate the mock objects, run diff --git a/packages/camera/camera_android_camerax/README.md b/packages/camera/camera_android_camerax/README.md index b91c7a3cdda7..8b78af76328e 100644 --- a/packages/camera/camera_android_camerax/README.md +++ b/packages/camera/camera_android_camerax/README.md @@ -46,6 +46,10 @@ Any specified `ResolutionPreset` wll go unused in favor of CameraX defaults and `setZoomLevel` is unimplemented. +## Contributing + +For more information on contributing to this plugin, see [`CONTRIBUTING.md`](CONTRIBUTING.md). + [1]: https://pub.dev/packages/camera From 83438290c93251af11e59c47b98813ab4a3786a6 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Mon, 8 May 2023 10:09:55 -0700 Subject: [PATCH 12/15] Address review --- .../camera_android_camerax/CONTRIBUTING.md | 74 +++++++++++++------ .../camera/camera_android_camerax/README.md | 7 +- 2 files changed, 56 insertions(+), 25 deletions(-) diff --git a/packages/camera/camera_android_camerax/CONTRIBUTING.md b/packages/camera/camera_android_camerax/CONTRIBUTING.md index 5050d5904be0..48d712d87ff7 100644 --- a/packages/camera/camera_android_camerax/CONTRIBUTING.md +++ b/packages/camera/camera_android_camerax/CONTRIBUTING.md @@ -3,38 +3,64 @@ ## Plugin structure The `camera_platform_interface` implementation is located at -`lib/src/android_camera_camerax.dart`, and it is implemented using Dart classes that -are wrapped versions of native Android Java classes. - -In `lib/src/`, you will find all of the Dart-wrapped native classes that the plugin -currently uses in its implementation. Each of these classes uses an `InstanceManager` -(implementation in `instance_manager.dart`) to manage objects that are created by -the plugin implementation that map to objects of the same type created on the native -side. This plugin uses [`pigeon`][1] to generate the communication layer between Flutter -and native Android code, so each of these Dart-wrapped classes also have Host API and -Flutter API implementations, as needed. The communication interface is defined in +`lib/src/android_camera_camerax.dart`, and it is implemented using Dart classes +that are wrapped versions of native Android Java classes. + +In this approach, each native Android library used in the plugin implementation +is represented by an equivalent Dart class. Instances of these classes are +considered paired and represent each other in Java and Dart, respectively. An +`InstanceManager`, which is essentially map between `long` identifiers and +objects, provides notifications when an object has become unreachable my memory. +There is both a Dart and Java `InstanceManager` implementation, so when a Dart +instance is created that represens an Android native instance, both are stored +in the `InstanceManager` of their respective language with a shared `long` +identifier. These `InstanceManager`s take callbacks that run when objects become +unrechable or removed, allowing the Dart library to easily handle removing +references to native resources automatically. To ensure all created instances +are properly managed and to more easily allow for testing, each wrapped Android +native class in Dart takes an `InstanceManager` and has a detached constructor, +one that allows for the creation of instances not attached to the `InstanceManager` +and unlinked to a paired Android native instance. + +In `lib/src/`, you will find all of the Dart-wrapped native Android classes that +the plugin currently uses in its implementation. As aforementioned, each of +these classes uses an `InstanceManager` (implementation in `instance_manager.dart`) +to manage objects that are created by the plugin implementation that map to objects +of the same type created in the native Android code. This plugin uses [`pigeon`][1] +to generate the communication layer between Flutter and native Android code, so each +of these Dart-wrapped classes may also have Host API and Flutter API implementations +that handle communication to the host native Android platform and from the host +native Android platform, respectively. The communication interface is defined in the `pigeons/camerax_library.dart` file. After editing the communication interface, regenerate the communication layer by running `dart run pigeon --input pigeons/camerax_library.dart` from the plugin root. -On the native side in `android/src/main/java/io/flutter/plugins/camerax/`, you'll -find the Host API and Flutter API implementations of the same classes wrapped with -Dart in `lib/src/`. These implementations call directly to the classes that they -are wrapping in the CameraX library or other Android libraries. The objects created -in the native code map to objects created on the Dart side, and thus, are also -managed by an `InstanceManager` (implementation in `InstanceManager.java`). +In the native Java Android code in `android/src/main/java/io/flutter/plugins/camerax/`, +you'll find the Host API and Flutter API implementations of the same classes +wrapped with Dart in `lib/src/` that handle communication from that Dart code +and to that Dart code, respectively. The Host API implementations should directly +delegate calls to the CameraX or other wrapped Android libraries and should not +have any additional logic or abstraction; any exceptions should be thoroughly +documented in the code. As aforementioned, the objects created in the native +Android code map to objects created on the Dart side and are also managed by +an `InstanceManager` (implementation in `InstanceManager.java`). -If you need to access any Android classes to contribute to this plugin, you should -search in `lib/src/` for any Dart-wrapped classes you may need. If any classes that -you need are not wrapped or you need to access any methods not wrapped in a class, -you must take the additional steps to wrap them to maintain the structure of this plugin. +If CameraX or other Android classes that you need to access do not have a +duplicately named implementation in `lib/src/`, then follow the same structure +described above to add them. -For more information on the approach of wrapping native libraries for plugins, please -see the [design document][2]. For more information on contributing packages in general, -check out our [contribution guide][3]. +For more information on the approach of wrapping native libraries for plugins, +please see the [design document][2] or contact [@bparrishmines][6] on any +questions you may have. For more information on contributing packages in +general, check out our [contribution guide][3]. ## Testing +While none of the generated `pigeon` files are tested, all plugin impelementation and +wrapped native Android classes (Java & Dart) are tested. You can find the Java tests under +`android/src/test/java/io/flutter/plugins/camerax/` and the Dart tests under `test/`. To +run these tests, please see the instructions on [running plugin tests][5]. + Besides [`pigeon`][1], this plugin also uses [`mockito`][4] to generate mock objects for testing purposes. To generate the mock objects, run `dart run build_runner build --delete-conflicting-outputs`. @@ -44,3 +70,5 @@ testing purposes. To generate the mock objects, run [2]: https://docs.google.com/document/d/1wXB1zNzYhd2SxCu1_BK3qmNWRhonTB6qdv4erdtBQqo/edit?usp=sharing&resourcekey=0-WOBqqOKiO9SARnziBg28pg [3]: https://github.com/flutter/packages/blob/main/CONTRIBUTING.md [4]: https://pub.dev/packages/mockito +[5]: https://github.com/flutter/flutter/wiki/Plugin-Tests#running-tests +[6]: https://github.com/bparrishMines \ No newline at end of file diff --git a/packages/camera/camera_android_camerax/README.md b/packages/camera/camera_android_camerax/README.md index 8b78af76328e..e5bbb40534e4 100644 --- a/packages/camera/camera_android_camerax/README.md +++ b/packages/camera/camera_android_camerax/README.md @@ -2,8 +2,10 @@ An Android implementation of [`camera`][1] that uses the [CameraX library][2]. -*Note*: This package is under development. -See [missing features and limitations](#missing-features-and-limitations). +*Note*: This package is under development, so please note the +[missing features and limitations](#missing-features-and-limitations) and +feel free to try out and provide feedback on the current implementation by +filing issues under [`flutter/flutter`][5], which will be actively triaged. ## Usage @@ -56,6 +58,7 @@ For more information on contributing to this plugin, see [`CONTRIBUTING.md`](CON [2]: https://developer.android.com/training/camerax [3]: https://docs.flutter.dev/packages-and-plugins/developing-packages#non-endorsed-federated-plugin [4]: https://pub.dev/packages/camera_android +[5]: https://github.com/flutter/flutter/issues/new/choose [120462]: https://github.com/flutter/flutter/issues/120462 [125915]: https://github.com/flutter/flutter/issues/125915 [120715]: https://github.com/flutter/flutter/issues/120715 From 426f33b85843f7c795dc046fcb403a8529a564aa Mon Sep 17 00:00:00 2001 From: camsim99 Date: Mon, 8 May 2023 10:11:06 -0700 Subject: [PATCH 13/15] Update changelog --- packages/camera/camera_android_camerax/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/camera/camera_android_camerax/CHANGELOG.md b/packages/camera/camera_android_camerax/CHANGELOG.md index e10539e43fc5..65f3f2714588 100644 --- a/packages/camera/camera_android_camerax/CHANGELOG.md +++ b/packages/camera/camera_android_camerax/CHANGELOG.md @@ -21,4 +21,4 @@ * Implements image streaming. * Provides LifecycleOwner implementation for Activities that use the plugin that do not implement it themselves. * Implements retrieval of camera information. -* Updates README with plugin overview. +* Updates README with plugin overview and adds contribution guide to CONTRIBUTING.md. From 93afe6af244777b2a4b811b4fab41b51ba5d83e7 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Mon, 8 May 2023 10:17:44 -0700 Subject: [PATCH 14/15] self review --- .../camera_android_camerax/CHANGELOG.md | 2 +- .../camera_android_camerax/CONTRIBUTING.md | 27 ++++++++++--------- .../camera/camera_android_camerax/README.md | 7 ++--- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/packages/camera/camera_android_camerax/CHANGELOG.md b/packages/camera/camera_android_camerax/CHANGELOG.md index 65f3f2714588..c80f0884f556 100644 --- a/packages/camera/camera_android_camerax/CHANGELOG.md +++ b/packages/camera/camera_android_camerax/CHANGELOG.md @@ -21,4 +21,4 @@ * Implements image streaming. * Provides LifecycleOwner implementation for Activities that use the plugin that do not implement it themselves. * Implements retrieval of camera information. -* Updates README with plugin overview and adds contribution guide to CONTRIBUTING.md. +* Updates README.md with plugin overview and adds contribution guide to CONTRIBUTING.md. diff --git a/packages/camera/camera_android_camerax/CONTRIBUTING.md b/packages/camera/camera_android_camerax/CONTRIBUTING.md index 48d712d87ff7..22a0cbaa77c8 100644 --- a/packages/camera/camera_android_camerax/CONTRIBUTING.md +++ b/packages/camera/camera_android_camerax/CONTRIBUTING.md @@ -9,18 +9,19 @@ that are wrapped versions of native Android Java classes. In this approach, each native Android library used in the plugin implementation is represented by an equivalent Dart class. Instances of these classes are considered paired and represent each other in Java and Dart, respectively. An -`InstanceManager`, which is essentially map between `long` identifiers and -objects, provides notifications when an object has become unreachable my memory. -There is both a Dart and Java `InstanceManager` implementation, so when a Dart -instance is created that represens an Android native instance, both are stored -in the `InstanceManager` of their respective language with a shared `long` -identifier. These `InstanceManager`s take callbacks that run when objects become -unrechable or removed, allowing the Dart library to easily handle removing -references to native resources automatically. To ensure all created instances -are properly managed and to more easily allow for testing, each wrapped Android -native class in Dart takes an `InstanceManager` and has a detached constructor, -one that allows for the creation of instances not attached to the `InstanceManager` -and unlinked to a paired Android native instance. +`InstanceManager`, which is essentially a map between `long` identifiers and +objects that also provides notifications when an object has become unreachable +by memory. There is both a Dart and Java `InstanceManager` implementation, so +when a Dart instance is created that represens an Android native instance, +both are stored in the `InstanceManager` of their respective language with a +shared `long` identifier. These `InstanceManager`s take callbacks that run +when objects become unrechable or removed, allowing the Dart library to easily +handle removing references to native resources automatically. To ensure all +created instances are properly managed and to more easily allow for testing, +each wrapped Android native class in Dart takes an `InstanceManager` and has +a detached constructor, a constructor that allows for the creation of instances +not attached to the `InstanceManager` and unlinked to a paired Android native +instance. In `lib/src/`, you will find all of the Dart-wrapped native Android classes that the plugin currently uses in its implementation. As aforementioned, each of @@ -59,7 +60,7 @@ general, check out our [contribution guide][3]. While none of the generated `pigeon` files are tested, all plugin impelementation and wrapped native Android classes (Java & Dart) are tested. You can find the Java tests under `android/src/test/java/io/flutter/plugins/camerax/` and the Dart tests under `test/`. To -run these tests, please see the instructions on [running plugin tests][5]. +run these tests, please see the instructions in the [running plugin tests guide][5]. Besides [`pigeon`][1], this plugin also uses [`mockito`][4] to generate mock objects for testing purposes. To generate the mock objects, run diff --git a/packages/camera/camera_android_camerax/README.md b/packages/camera/camera_android_camerax/README.md index e5bbb40534e4..a357008b8ba4 100644 --- a/packages/camera/camera_android_camerax/README.md +++ b/packages/camera/camera_android_camerax/README.md @@ -3,9 +3,10 @@ An Android implementation of [`camera`][1] that uses the [CameraX library][2]. *Note*: This package is under development, so please note the -[missing features and limitations](#missing-features-and-limitations) and -feel free to try out and provide feedback on the current implementation by -filing issues under [`flutter/flutter`][5], which will be actively triaged. +[missing features and limitations](#missing-features-and-limitations), but +otherwise feel free to try out the current implementation and provide any +feedback by filing issues under [`flutter/flutter`][5] with `[camerax]` in +the title, which will be actively triaged. ## Usage From d0278e980dcc70ce1a927aee613289b178595289 Mon Sep 17 00:00:00 2001 From: camsim99 Date: Mon, 8 May 2023 14:49:26 -0700 Subject: [PATCH 15/15] Add discord link --- packages/camera/camera_android_camerax/CONTRIBUTING.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/camera/camera_android_camerax/CONTRIBUTING.md b/packages/camera/camera_android_camerax/CONTRIBUTING.md index 22a0cbaa77c8..3d365d791e57 100644 --- a/packages/camera/camera_android_camerax/CONTRIBUTING.md +++ b/packages/camera/camera_android_camerax/CONTRIBUTING.md @@ -50,10 +50,10 @@ If CameraX or other Android classes that you need to access do not have a duplicately named implementation in `lib/src/`, then follow the same structure described above to add them. -For more information on the approach of wrapping native libraries for plugins, -please see the [design document][2] or contact [@bparrishmines][6] on any -questions you may have. For more information on contributing packages in -general, check out our [contribution guide][3]. +For more information, please see the [design document][2] or feel free +to ask any questions on the #hackers-ecosystem channel on [Discord][6]. For +more information on contributing packages in general, check out our +[contribution guide][3]. ## Testing @@ -72,4 +72,4 @@ testing purposes. To generate the mock objects, run [3]: https://github.com/flutter/packages/blob/main/CONTRIBUTING.md [4]: https://pub.dev/packages/mockito [5]: https://github.com/flutter/flutter/wiki/Plugin-Tests#running-tests -[6]: https://github.com/bparrishMines \ No newline at end of file +[6]: https://github.com/flutter/flutter/wiki/Chat \ No newline at end of file