Skip to content
Closed
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
6125eca
Recreating image capture impl from flutter/plugins
camsim99 Feb 23, 2023
5be1371
Merge remote-tracking branch 'upstream/main' into camx_imgcap
camsim99 Feb 23, 2023
b2fce3d
Fix integration tesT
camsim99 Feb 23, 2023
ed62a9a
Merge branch 'main' into camx_imgcap
camsim99 Feb 23, 2023
2e3027b
Analyzer pt 2
camsim99 Feb 23, 2023
fbd3fe5
Merge branch 'camx_imgcap' of github.com:camsim99/packages into camx_…
camsim99 Feb 23, 2023
dfa477e
Personal cleanup
camsim99 Feb 23, 2023
a651b92
Add initialization of controller
camsim99 Feb 24, 2023
884fd6c
Merge remote-tracking branch 'upstream/main' into camx_imgcap
camsim99 Feb 24, 2023
d5f8b91
Modify some docs
camsim99 Feb 24, 2023
060b7e5
Address review
camsim99 Mar 2, 2023
ff50c70
Merge remote-tracking branch 'upstream/main' into camx_imgcap
camsim99 Mar 2, 2023
fe6f1fc
Fix analyze
camsim99 Mar 2, 2023
e2643ae
Update packages/camera/camera_android_camerax/android/src/main/java/i…
camsim99 Mar 3, 2023
b7194f7
Update packages/camera/camera_android_camerax/lib/src/image_capture.dart
camsim99 Mar 3, 2023
dadc230
Start addressing review
camsim99 Mar 6, 2023
d15e1d4
Finish addressing review
camsim99 Mar 7, 2023
6dc2b77
Fix analyze
camsim99 Mar 7, 2023
f826b62
Generate mocks on stable
camsim99 Mar 7, 2023
0f7f29a
Fix/add tests
camsim99 Mar 7, 2023
1e9739b
Add isBound dart test
camsim99 Mar 7, 2023
9ba20d0
Merge remote-tracking branch 'upstream/main' into camx_imgcap
camsim99 Mar 13, 2023
5bf6b17
Start dev
camsim99 Mar 8, 2023
5e58b2c
Add cameraClosing impl
camsim99 Mar 8, 2023
4c8c94d
Add tests
camsim99 Mar 13, 2023
6a0de08
Implement occ with camera state
camsim99 Mar 14, 2023
d3ed3e7
Reimplement with live camera state
camsim99 Mar 15, 2023
d1c684f
Start adding tests
camsim99 Mar 22, 2023
c04d8c1
Add java tests
camsim99 Mar 22, 2023
b2322d2
Formatting
camsim99 Mar 22, 2023
3545aec
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 Mar 22, 2023
e1f5bdb
Fix flutter analyze
camsim99 Mar 22, 2023
2d3409b
Fix analyze
camsim99 Mar 22, 2023
1f40f47
Review
camsim99 Mar 22, 2023
6c9b04e
Fix tests, review 2
camsim99 Mar 23, 2023
6c6cbb4
review 3
camsim99 Mar 23, 2023
a0ea3c5
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 Mar 23, 2023
06c1545
fix analyze
camsim99 Mar 23, 2023
681a117
Fix cast
camsim99 Mar 23, 2023
1143a03
generate mocks on stable
camsim99 Mar 23, 2023
d431511
Formatting
camsim99 Mar 24, 2023
ab3c085
Add missing tests
camsim99 Mar 24, 2023
631f972
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 Mar 24, 2023
70c817a
Fix analyze
camsim99 Mar 24, 2023
426b438
Bump camerax version
camsim99 Mar 27, 2023
2bc4877
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 Mar 28, 2023
0fcf7c6
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 Mar 29, 2023
6c49bd9
Formatting
camsim99 Mar 29, 2023
b9daeb1
pair programming w/maurice
camsim99 Apr 11, 2023
3345878
Fixing plugin
camsim99 Apr 12, 2023
9f6646f
Current status
camsim99 Apr 13, 2023
265eb1e
Remove print statements
camsim99 Apr 14, 2023
bfc4b5e
Add print
camsim99 Apr 14, 2023
4f3c342
remove comments
camsim99 Apr 14, 2023
e3c7a5b
Review 2
camsim99 Apr 17, 2023
f341f7f
Fixing tests
camsim99 Apr 18, 2023
0d4b021
Fix tests, format
camsim99 Apr 18, 2023
ca3bd9e
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 Apr 18, 2023
540ee98
Fix test
camsim99 Apr 18, 2023
debcd3a
Fix camera test
camsim99 Apr 18, 2023
a79ee62
Start addressing review
camsim99 Apr 25, 2023
438f592
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 May 1, 2023
c44fc06
Address review, remove cast
camsim99 May 1, 2023
83aea10
Fix java tests
camsim99 May 1, 2023
5f435e8
Fix dart tests
camsim99 May 1, 2023
581af94
Merge remote-tracking branch 'upstream/main' into camx_occ
camsim99 May 1, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/camera/camera_android_camerax/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
* Implements image capture.
* Fixes cast of CameraInfo to fix integration test failure.
* Updates internal Java InstanceManager to only stop finalization callbacks when stopped.
* Implements onCameraClosing callback method for indicating the camera is closing and bumps CameraX version to 1.3.0-alpha05.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ android {

dependencies {
// CameraX core library using the camera2 implementation must use same version number.
def camerax_version = "1.3.0-alpha04"
def camerax_version = "1.3.0-alpha05"
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package io.flutter.plugins.camerax;

import android.app.Activity;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.lifecycle.LifecycleOwner;
Expand All @@ -17,8 +18,10 @@
public final class CameraAndroidCameraxPlugin implements FlutterPlugin, ActivityAware {
private InstanceManager instanceManager;
private FlutterPluginBinding pluginBinding;
private ProcessCameraProviderHostApiImpl processCameraProviderHostApi;
private ImageCaptureHostApiImpl imageCaptureHostApi;
private ProcessCameraProviderHostApiImpl processCameraProviderHostApiImpl;
private ImageCaptureHostApiImpl imageCaptureHostApiImpl;
private LiveDataHostApiImpl liveDataHostApiImpl;

public SystemServicesHostApiImpl systemServicesHostApi;

/**
Expand All @@ -41,21 +44,28 @@ void setUp(BinaryMessenger binaryMessenger, Context context, TextureRegistry tex
GeneratedCameraXLibrary.InstanceManagerHostApi.setup(
binaryMessenger, () -> instanceManager.clear());
GeneratedCameraXLibrary.CameraInfoHostApi.setup(
binaryMessenger, new CameraInfoHostApiImpl(instanceManager));
binaryMessenger, new CameraInfoHostApiImpl(binaryMessenger, instanceManager));
GeneratedCameraXLibrary.CameraSelectorHostApi.setup(
binaryMessenger, new CameraSelectorHostApiImpl(binaryMessenger, instanceManager));
GeneratedCameraXLibrary.JavaObjectHostApi.setup(
binaryMessenger, new JavaObjectHostApiImpl(instanceManager));
processCameraProviderHostApi =
processCameraProviderHostApiImpl =
new ProcessCameraProviderHostApiImpl(binaryMessenger, instanceManager, context);
GeneratedCameraXLibrary.ProcessCameraProviderHostApi.setup(
binaryMessenger, processCameraProviderHostApi);
binaryMessenger, processCameraProviderHostApiImpl);
systemServicesHostApi = new SystemServicesHostApiImpl(binaryMessenger, instanceManager);
GeneratedCameraXLibrary.SystemServicesHostApi.setup(binaryMessenger, systemServicesHostApi);
GeneratedCameraXLibrary.PreviewHostApi.setup(
binaryMessenger, new PreviewHostApiImpl(binaryMessenger, instanceManager, textureRegistry));
imageCaptureHostApi = new ImageCaptureHostApiImpl(binaryMessenger, instanceManager, context);
GeneratedCameraXLibrary.ImageCaptureHostApi.setup(binaryMessenger, imageCaptureHostApi);
imageCaptureHostApiImpl =
new ImageCaptureHostApiImpl(binaryMessenger, instanceManager, context);
GeneratedCameraXLibrary.ImageCaptureHostApi.setup(binaryMessenger, imageCaptureHostApiImpl);
GeneratedCameraXLibrary.CameraHostApi.setup(
binaryMessenger, new CameraHostApiImpl(binaryMessenger, instanceManager));
liveDataHostApiImpl = new LiveDataHostApiImpl(binaryMessenger, instanceManager);
GeneratedCameraXLibrary.LiveDataHostApi.setup(binaryMessenger, liveDataHostApiImpl);
GeneratedCameraXLibrary.ObserverHostApi.setup(
binaryMessenger, new ObserverHostApiImpl(binaryMessenger, instanceManager));
}

@Override
Expand All @@ -79,9 +89,12 @@ public void onAttachedToActivity(@NonNull ActivityPluginBinding activityPluginBi
pluginBinding.getApplicationContext(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems weird to me that this method takes in an ActivityPluginBinding but all the values that are updated reference pluginBinding and applicationContext is used from pluginBinding instead of the activity context that is available on activityPluginBinding

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems weird to me too. Definitely mistake on my end; fixing.

pluginBinding.getTextureRegistry());
updateContext(pluginBinding.getApplicationContext());
processCameraProviderHostApi.setLifecycleOwner(
(LifecycleOwner) activityPluginBinding.getActivity());
systemServicesHostApi.setActivity(activityPluginBinding.getActivity());

Activity activity = activityPluginBinding.getActivity();
// TODO(camsim99): Handle case where activity is not a LifecycleOwner.
processCameraProviderHostApiImpl.setLifecycleOwner((LifecycleOwner) activity);
Comment thread
camsim99 marked this conversation as resolved.
Outdated
liveDataHostApiImpl.setLifecycleOwner((LifecycleOwner) activity);
systemServicesHostApi.setActivity(activity);
systemServicesHostApi.setPermissionsRegistry(
activityPluginBinding::addRequestPermissionsResultListener);
}
Expand All @@ -107,11 +120,11 @@ public void onDetachedFromActivity() {
* ProcessCameraProvider}.
*/
public void updateContext(Context context) {
if (processCameraProviderHostApi != null) {
processCameraProviderHostApi.setContext(context);
if (processCameraProviderHostApiImpl != null) {
processCameraProviderHostApiImpl.setContext(context);
}
if (imageCaptureHostApi != null) {
processCameraProviderHostApi.setContext(context);
if (imageCaptureHostApiImpl != null) {
imageCaptureHostApiImpl.setContext(context);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.camerax;

import androidx.annotation.NonNull;
import androidx.camera.core.Camera;
import androidx.camera.core.CameraInfo;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugins.camerax.GeneratedCameraXLibrary.CameraHostApi;
import java.util.Objects;

public class CameraHostApiImpl implements CameraHostApi {
private final BinaryMessenger binaryMessenger;
private final InstanceManager instanceManager;

public CameraHostApiImpl(BinaryMessenger binaryMessenger, InstanceManager instanceManager) {
Comment thread
camsim99 marked this conversation as resolved.
Outdated
this.binaryMessenger = binaryMessenger;
this.instanceManager = instanceManager;
}

/**
* Retrieves the {@link CameraInfo} instance that contains information about the {@link Camera}
* instance with the specified identifier.
*/
@Override
public Long getCameraInfo(@NonNull Long identifier) {
Camera camera = (Camera) Objects.requireNonNull(instanceManager.getInstance(identifier));
CameraInfo cameraInfo = camera.getCameraInfo();

if (!instanceManager.containsInstance(cameraInfo)) {
CameraInfoFlutterApiImpl cameraInfoFlutterApiImpl =
new CameraInfoFlutterApiImpl(binaryMessenger, instanceManager);
cameraInfoFlutterApiImpl.create(cameraInfo, reply -> {});
Comment thread
camsim99 marked this conversation as resolved.
}
return instanceManager.getIdentifierForStrongReference(cameraInfo);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,49 @@
package io.flutter.plugins.camerax;

import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.camera.core.CameraInfo;
import androidx.camera.core.CameraState;
import androidx.lifecycle.LiveData;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugins.camerax.GeneratedCameraXLibrary.CameraInfoHostApi;
import java.util.Objects;

public class CameraInfoHostApiImpl implements CameraInfoHostApi {
private final BinaryMessenger binaryMessenger;
private final InstanceManager instanceManager;

public CameraInfoHostApiImpl(InstanceManager instanceManager) {
@VisibleForTesting public CameraXProxy cameraXProxy = new CameraXProxy();

public CameraInfoHostApiImpl(BinaryMessenger binaryMessenger, InstanceManager instanceManager) {
Comment thread
camsim99 marked this conversation as resolved.
Outdated
this.binaryMessenger = binaryMessenger;
this.instanceManager = instanceManager;
}

/**
* Retrieves the sensor rotation degrees of the {@link androidx.camera.core.Camera} that is
* represented by the {@link CameraInfo} with the specified identifier.
*/
@Override
public Long getSensorRotationDegrees(@NonNull Long identifier) {
CameraInfo cameraInfo =
(CameraInfo) Objects.requireNonNull(instanceManager.getInstance(identifier));
return Long.valueOf(cameraInfo.getSensorRotationDegrees());
}

/**
* Retrieves the {@link LiveData} of the {@link CameraState} that is tied to the {@link
* androidx.camera.core.Camera} that is represented by the {@link CameraInfo} with the specified
* identifier.
*/
@Override
public Long getLiveCameraState(@NonNull Long identifier) {
Comment thread
camsim99 marked this conversation as resolved.
CameraInfo cameraInfo =
(CameraInfo) Objects.requireNonNull(instanceManager.getInstance(identifier));
LiveData<CameraState> liveCameraState = cameraInfo.getCameraState();
LiveDataFlutterApiWrapper liveDataFlutterApiWrapper =
new LiveDataFlutterApiWrapper(binaryMessenger, instanceManager);
liveDataFlutterApiWrapper.create(liveCameraState, reply -> {});
Comment thread
reidbaker marked this conversation as resolved.
Outdated
return instanceManager.getIdentifierForStrongReference(liveCameraState);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.camerax;

import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.camera.core.CameraState;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugins.camerax.GeneratedCameraXLibrary.CameraStateErrorFlutterApi;

/**
* Flutter API implementation for {@link CameraStateError}.
*
* <p>This class may handle adding native instances that are attached to a Dart instance or passing
* arguments of callbacks methods to a Dart instance.
*/
public class CameraStateErrorFlutterApiWrapper {
private final BinaryMessenger binaryMessenger;
private final InstanceManager instanceManager;
private CameraStateErrorFlutterApi cameraStateErrorFlutterApi;

/**
* Constructs a {@link CameraStateErrorFlutterApiWrapper}.
*
* @param binaryMessenger used to communicate with Dart over asynchronous messages
* @param instanceManager maintains instances stored to communicate with attached Dart objects
*/
public CameraStateErrorFlutterApiWrapper(
@NonNull BinaryMessenger binaryMessenger, @NonNull InstanceManager instanceManager) {
this.binaryMessenger = binaryMessenger;
this.instanceManager = instanceManager;
cameraStateErrorFlutterApi = new CameraStateErrorFlutterApi(binaryMessenger);
}

/**
* Stores the {@link CameraStateError} instance and notifies Dart to create and store a new {@link
* CameraStateError} instance that is attached to this one. If {@code instance} has already been
* added, this method does nothing.
*/
Comment thread
camsim99 marked this conversation as resolved.
public void create(
@NonNull CameraState.StateError instance,
@NonNull Long code,
@NonNull String description,
@NonNull CameraStateErrorFlutterApi.Reply<Void> callback) {
Comment thread
reidbaker marked this conversation as resolved.
if (!instanceManager.containsInstance(instance)) {
cameraStateErrorFlutterApi.create(
instanceManager.addHostCreatedInstance(instance), code, description, callback);
}
}

/**
* Sets the Flutter API used to send messages to Dart.
*
* <p>This is only visible for testing.
*/
@VisibleForTesting
void setApi(@NonNull CameraStateErrorFlutterApi api) {
this.cameraStateErrorFlutterApi = api;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package io.flutter.plugins.camerax;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.camera.core.CameraState;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.plugins.camerax.GeneratedCameraXLibrary.CameraStateFlutterApi;
import io.flutter.plugins.camerax.GeneratedCameraXLibrary.CameraStateType;
import io.flutter.plugins.camerax.GeneratedCameraXLibrary.CameraStateTypeData;

/**
* Flutter API implementation for {@link CameraState}.
*
* <p>This class may handle adding native instances that are attached to a Dart instance or passing
* arguments of callbacks methods to a Dart instance.
*/
public class CameraStateFlutterApiWrapper {
private final BinaryMessenger binaryMessenger;
private final InstanceManager instanceManager;
private CameraStateFlutterApi cameraStateFlutterApi;

/**
* Constructs a {@link CameraStateFlutterApiWrapper}.
*
* @param binaryMessenger used to communicate with Dart over asynchronous messages
* @param instanceManager maintains instances stored to communicate with attached Dart objects
*/
public CameraStateFlutterApiWrapper(
@NonNull BinaryMessenger binaryMessenger, @NonNull InstanceManager instanceManager) {
this.binaryMessenger = binaryMessenger;
this.instanceManager = instanceManager;
cameraStateFlutterApi = new CameraStateFlutterApi(binaryMessenger);
}

/**
* Stores the {@link CameraState} instance and notifies Dart to create and store a new {@link
* CameraState} instance that is attached to this one. If {@code instance} has already been added,
* this method does nothing.
*/
public void create(
Comment thread
camsim99 marked this conversation as resolved.
@NonNull CameraState instance,
@NonNull CameraState.Type type,
@Nullable CameraState.StateError error,
@NonNull CameraStateFlutterApi.Reply<Void> callback) {

// Convert CameraX CameraState.Type to CameraStateType that the Dart side understands.
CameraStateType cameraStateType = CameraStateType.CLOSED;
Comment thread
camsim99 marked this conversation as resolved.
Outdated
Comment thread
camsim99 marked this conversation as resolved.
Outdated
switch (type) {
case CLOSED:
cameraStateType = CameraStateType.CLOSED;
break;
case CLOSING:
cameraStateType = CameraStateType.CLOSING;
break;
case OPEN:
cameraStateType = CameraStateType.OPEN;
break;
case OPENING:
cameraStateType = CameraStateType.OPENING;
break;
case PENDING_OPEN:
cameraStateType = CameraStateType.PENDING_OPEN;
break;
}

if (error != null) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider moving the error checking higher in the function since we don't need the conversion code to run if there is an error.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error is separate from the type, so we'll still need it. I did, however, move the instance manager check higher.

// We need to create a CameraStateError if there is a problem with the current camera
// state to send to the Dart side.
new CameraStateErrorFlutterApiWrapper(binaryMessenger, instanceManager)
.create(
error,
Long.valueOf(error.getCode()),
getCameraStateErrorDescription(error),
reply -> {});
}

if (!instanceManager.containsInstance(instance)) {
cameraStateFlutterApi.create(
instanceManager.addHostCreatedInstance(instance),
new CameraStateTypeData.Builder().setValue(cameraStateType).build(),
instanceManager.getIdentifierForStrongReference(error),
callback);
}
}

/**
* Returns an error message corresponding to the specified {@link CameraState.StateError}.
*
* <p>See https://developer.android.com/reference/androidx/camera/core/CameraState#constants_1 for
* more information on the different {@link CameraState.StateError} types.
*/
private String getCameraStateErrorDescription(@NonNull CameraState.StateError cameraStateError) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you include who this error string is for? Ex for developers, can it be shown to users, can it be used for error handling etc?

My guess is it is a Developer visible string and should not be used in error handling.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this to Dart and specified this in the documentation.

final int cameraStateErrorCode = cameraStateError.getCode();
final String cameraStateErrorDescription = cameraStateErrorCode + ": ";
switch (cameraStateErrorCode) {
case CameraState.ERROR_CAMERA_IN_USE:
return cameraStateErrorDescription

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that all these values are cameraStateErrorCode + SOME_STRING, I suggest making this easier to read by setting a temporary string (descriptionForCode) for each of these states then after that return cameraStateErrorCode + ": " + descriptionForCode;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Changed this on the Dart side, where I moved it.

I decided to move it because this is not directly provided by CameraX and so I don't think we should be wrapping it like it is.

+ "The camera was already in use, possibly by a higher-priority camera client.";
case CameraState.ERROR_MAX_CAMERAS_IN_USE:
return cameraStateErrorDescription
+ "The limit number of open cameras has been reached, and more cameras cannot be opened until other instances are closed.";
case CameraState.ERROR_OTHER_RECOVERABLE_ERROR:
return cameraStateErrorDescription
+ "The camera device has encountered a recoverable error. CameraX will attempt to recover from the error.";
case CameraState.ERROR_STREAM_CONFIG:
return cameraStateErrorDescription + "Configuring the camera has failed.";
case CameraState.ERROR_CAMERA_DISABLED:
return cameraStateErrorDescription
+ "The camera device could not be opened due to a device policy. Thia may be caused by a client from a background process attempting to open the camera.";
case CameraState.ERROR_CAMERA_FATAL_ERROR:
return cameraStateErrorDescription
+ "The camera was closed due to a fatal error. This may require the Android device be shut down and restarted to restore camera function or may indicate a persistent camera hardware problem.";
case CameraState.ERROR_DO_NOT_DISTURB_MODE_ENABLED:
return cameraStateErrorDescription
+ "The camera could not be opened because 'Do Not Disturb' mode is enabled. Please disable this mode, and try opening the camera again.";
default:
return cameraStateErrorDescription + "There was an unspecified issue with the current camera state.";
}
}

/**
* Sets the Flutter API used to send messages to Dart.
*
* <p>This is only visible for testing.

@reidbaker reidbaker Apr 18, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is redundant with the annotation. Consider removing or adding context for why test methods would want to set it or maybe why real apps would not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is generated, so maybe this can be feedback for the generator? @bparrishMines

*/
@VisibleForTesting
void setApi(@NonNull CameraStateFlutterApi api) {
this.cameraStateFlutterApi = api;
}
}
Loading