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

Commit f75cfb4

Browse files
Revert "[camera] Add ProcessCameraProvider class to CameraX plugin (#6469)" (#6506)
This reverts commit 1c47c3b.
1 parent 1c47c3b commit f75cfb4

15 files changed

+7
-818
lines changed

packages/camera/camera_android_camerax/CHANGELOG.md

-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
* Creates camera_android_camerax plugin for development.
44
* Adds CameraInfo class and removes unnecessary code from plugin.
55
* Adds CameraSelector class.
6-
* Adds ProcessCameraProvider class.

packages/camera/camera_android_camerax/android/build.gradle

+1-3
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,13 @@ android {
3838

3939
dependencies {
4040
// CameraX core library using the camera2 implementation must use same version number.
41-
def camerax_version = "1.2.0-beta02"
41+
def camerax_version = "1.2.0-beta01"
4242
implementation "androidx.camera:camera-core:${camerax_version}"
4343
implementation "androidx.camera:camera-camera2:${camerax_version}"
4444
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
45-
implementation 'com.google.guava:guava:28.1-android'
4645
testImplementation 'junit:junit:4.13.2'
4746
testImplementation 'org.mockito:mockito-inline:4.7.0'
4847
testImplementation 'androidx.test:core:1.4.0'
49-
testImplementation 'org.robolectric:robolectric:4.3'
5048
}
5149
testOptions {
5250
unitTests.includeAndroidResources = true

packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/CameraAndroidCameraxPlugin.java

+4-27
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
public final class CameraAndroidCameraxPlugin implements FlutterPlugin, ActivityAware {
1616
private InstanceManager instanceManager;
1717
private FlutterPluginBinding pluginBinding;
18-
private ProcessCameraProviderHostApiImpl processCameraProviderHostApi;
1918

2019
/**
2120
* Initialize this within the {@code #configureFlutterEngine} of a Flutter activity or fragment.
@@ -40,10 +39,6 @@ void setUp(BinaryMessenger binaryMessenger, Context context) {
4039
binaryMessenger, new JavaObjectHostApiImpl(instanceManager));
4140
GeneratedCameraXLibrary.CameraSelectorHostApi.setup(
4241
binaryMessenger, new CameraSelectorHostApiImpl(binaryMessenger, instanceManager));
43-
processCameraProviderHostApi =
44-
new ProcessCameraProviderHostApiImpl(binaryMessenger, instanceManager, context);
45-
GeneratedCameraXLibrary.ProcessCameraProviderHostApi.setup(
46-
binaryMessenger, processCameraProviderHostApi);
4742
}
4843

4944
@Override
@@ -65,33 +60,15 @@ public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {
6560
// Activity Lifecycle methods:
6661

6762
@Override
68-
public void onAttachedToActivity(@NonNull ActivityPluginBinding activityPluginBinding) {
69-
updateContext(activityPluginBinding.getActivity());
70-
}
63+
public void onAttachedToActivity(@NonNull ActivityPluginBinding activityPluginBinding) {}
7164

7265
@Override
73-
public void onDetachedFromActivityForConfigChanges() {
74-
updateContext(pluginBinding.getApplicationContext());
75-
}
66+
public void onDetachedFromActivityForConfigChanges() {}
7667

7768
@Override
7869
public void onReattachedToActivityForConfigChanges(
79-
@NonNull ActivityPluginBinding activityPluginBinding) {
80-
updateContext(activityPluginBinding.getActivity());
81-
}
70+
@NonNull ActivityPluginBinding activityPluginBinding) {}
8271

8372
@Override
84-
public void onDetachedFromActivity() {
85-
updateContext(pluginBinding.getApplicationContext());
86-
}
87-
88-
/**
89-
* Updates context that is used to fetch the corresponding instance of a {@code
90-
* ProcessCameraProvider}.
91-
*/
92-
private void updateContext(Context context) {
93-
if (processCameraProviderHostApi != null) {
94-
processCameraProviderHostApi.setContext(context);
95-
}
96-
}
73+
public void onDetachedFromActivity() {}
9774
}

packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/CameraInfoFlutterApiImpl.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public CameraInfoFlutterApiImpl(
1818
}
1919

2020
void create(CameraInfo cameraInfo, Reply<Void> reply) {
21-
create(instanceManager.addHostCreatedInstance(cameraInfo), reply);
21+
instanceManager.addHostCreatedInstance(cameraInfo);
22+
create(instanceManager.getIdentifierForStrongReference(cameraInfo), reply);
2223
}
2324
}

packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/GeneratedCameraXLibrary.java

-134
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@
2222
/** Generated class from Pigeon. */
2323
@SuppressWarnings({"unused", "unchecked", "CodeBlock2Expr", "RedundantSuppression"})
2424
public class GeneratedCameraXLibrary {
25-
26-
public interface Result<T> {
27-
void success(T result);
28-
29-
void error(Throwable error);
30-
}
31-
3225
private static class JavaObjectHostApiCodec extends StandardMessageCodec {
3326
public static final JavaObjectHostApiCodec INSTANCE = new JavaObjectHostApiCodec();
3427

@@ -318,133 +311,6 @@ public void create(
318311
}
319312
}
320313

321-
private static class ProcessCameraProviderHostApiCodec extends StandardMessageCodec {
322-
public static final ProcessCameraProviderHostApiCodec INSTANCE =
323-
new ProcessCameraProviderHostApiCodec();
324-
325-
private ProcessCameraProviderHostApiCodec() {}
326-
}
327-
328-
/** Generated interface from Pigeon that represents a handler of messages from Flutter. */
329-
public interface ProcessCameraProviderHostApi {
330-
void getInstance(Result<Long> result);
331-
332-
@NonNull
333-
List<Long> getAvailableCameraInfos(@NonNull Long identifier);
334-
335-
/** The codec used by ProcessCameraProviderHostApi. */
336-
static MessageCodec<Object> getCodec() {
337-
return ProcessCameraProviderHostApiCodec.INSTANCE;
338-
}
339-
340-
/**
341-
* Sets up an instance of `ProcessCameraProviderHostApi` to handle messages through the
342-
* `binaryMessenger`.
343-
*/
344-
static void setup(BinaryMessenger binaryMessenger, ProcessCameraProviderHostApi api) {
345-
{
346-
BasicMessageChannel<Object> channel =
347-
new BasicMessageChannel<>(
348-
binaryMessenger,
349-
"dev.flutter.pigeon.ProcessCameraProviderHostApi.getInstance",
350-
getCodec());
351-
if (api != null) {
352-
channel.setMessageHandler(
353-
(message, reply) -> {
354-
Map<String, Object> wrapped = new HashMap<>();
355-
try {
356-
Result<Long> resultCallback =
357-
new Result<Long>() {
358-
public void success(Long result) {
359-
wrapped.put("result", result);
360-
reply.reply(wrapped);
361-
}
362-
363-
public void error(Throwable error) {
364-
wrapped.put("error", wrapError(error));
365-
reply.reply(wrapped);
366-
}
367-
};
368-
369-
api.getInstance(resultCallback);
370-
} catch (Error | RuntimeException exception) {
371-
wrapped.put("error", wrapError(exception));
372-
reply.reply(wrapped);
373-
}
374-
});
375-
} else {
376-
channel.setMessageHandler(null);
377-
}
378-
}
379-
{
380-
BasicMessageChannel<Object> channel =
381-
new BasicMessageChannel<>(
382-
binaryMessenger,
383-
"dev.flutter.pigeon.ProcessCameraProviderHostApi.getAvailableCameraInfos",
384-
getCodec());
385-
if (api != null) {
386-
channel.setMessageHandler(
387-
(message, reply) -> {
388-
Map<String, Object> wrapped = new HashMap<>();
389-
try {
390-
ArrayList<Object> args = (ArrayList<Object>) message;
391-
Number identifierArg = (Number) args.get(0);
392-
if (identifierArg == null) {
393-
throw new NullPointerException("identifierArg unexpectedly null.");
394-
}
395-
List<Long> output =
396-
api.getAvailableCameraInfos(
397-
(identifierArg == null) ? null : identifierArg.longValue());
398-
wrapped.put("result", output);
399-
} catch (Error | RuntimeException exception) {
400-
wrapped.put("error", wrapError(exception));
401-
}
402-
reply.reply(wrapped);
403-
});
404-
} else {
405-
channel.setMessageHandler(null);
406-
}
407-
}
408-
}
409-
}
410-
411-
private static class ProcessCameraProviderFlutterApiCodec extends StandardMessageCodec {
412-
public static final ProcessCameraProviderFlutterApiCodec INSTANCE =
413-
new ProcessCameraProviderFlutterApiCodec();
414-
415-
private ProcessCameraProviderFlutterApiCodec() {}
416-
}
417-
418-
/** Generated class from Pigeon that represents Flutter messages that can be called from Java. */
419-
public static class ProcessCameraProviderFlutterApi {
420-
private final BinaryMessenger binaryMessenger;
421-
422-
public ProcessCameraProviderFlutterApi(BinaryMessenger argBinaryMessenger) {
423-
this.binaryMessenger = argBinaryMessenger;
424-
}
425-
426-
public interface Reply<T> {
427-
void reply(T reply);
428-
}
429-
430-
static MessageCodec<Object> getCodec() {
431-
return ProcessCameraProviderFlutterApiCodec.INSTANCE;
432-
}
433-
434-
public void create(@NonNull Long identifierArg, Reply<Void> callback) {
435-
BasicMessageChannel<Object> channel =
436-
new BasicMessageChannel<>(
437-
binaryMessenger,
438-
"dev.flutter.pigeon.ProcessCameraProviderFlutterApi.create",
439-
getCodec());
440-
channel.send(
441-
new ArrayList<Object>(Arrays.asList(identifierArg)),
442-
channelReply -> {
443-
callback.reply(null);
444-
});
445-
}
446-
}
447-
448314
private static Map<String, Object> wrapError(Throwable exception) {
449315
Map<String, Object> errorMap = new HashMap<>();
450316
errorMap.put("message", exception.toString());

packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/ProcessCameraProviderFlutterApiImpl.java

-23
This file was deleted.

packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/ProcessCameraProviderHostApiImpl.java

-87
This file was deleted.

0 commit comments

Comments
 (0)