[go: nahoru, domu]

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

[camerax] Add system services to plugin #6986

Merged
merged 17 commits into from
Jan 31, 2023
Merged

Conversation

camsim99
Copy link
Contributor
@camsim99 camsim99 commented Jan 17, 2023

Adds functionality to request (i) camera permissions and (ii) subscribe to changes in device orientation.

Fixes flutter/flutter#118740.
Fixes flutter/flutter#118742.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

final class CameraPermissionsManager {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the same as CameraPermissions.java in the old plugin.

/**
* Support class to help to determine the media orientation based on the orientation of the device.
*/
public class DeviceOrientationManager {
Copy link
Contributor Author
@camsim99 camsim99 Jan 18, 2023

Choose a reason for hiding this comment

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

This is the same as DeviceOrientationManager.java, with the exception that it notifies changes in device orientation with a DeviceOrientationChangeCallback versus a DartMessenger.

import io.flutter.plugins.camerax.CameraPermissionsManager.ResultCallback;
import org.junit.Test;

public class CameraPermissionsManagerTest {
Copy link
Contributor Author
@camsim99 camsim99 Jan 18, 2023

Choose a reason for hiding this comment

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

This is the same as CameraPermissions.java in the old plugin.

import org.junit.Test;
import org.mockito.MockedStatic;

public class DeviceOrientationManagerTest {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is essentially the same as DeviceOrientationManager.java in the old plugin, with the DartMessenger swapped out for the DeviceOrientationChangeCallback

import 'android_camera_camerax_flutter_api_impls.dart';
import 'camerax_library.pigeon.dart';

// ignore_for_file: avoid_classes_with_only_static_members
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I initially wanted to group all static calls to system services here, so I ignored this lint warning. Open to feedback on this decision.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine since you are just wrapping a native class. Can you also add a comment with this explanation about why it is ignored.

@camsim99 camsim99 marked this pull request as ready for review January 18, 2023 21:42
@camsim99 camsim99 requested review from gmackall and GaryQian and removed request for GaryQian January 18, 2023 21:43
Copy link
Contributor
@bparrishMines bparrishMines left a comment

Choose a reason for hiding this comment

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

LGTM with a few comments

@@ -66,7 +66,15 @@ public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {

@Override
public void onAttachedToActivity(@NonNull ActivityPluginBinding activityPluginBinding) {
updateContext(activityPluginBinding.getActivity());
CameraAndroidCameraxPlugin plugin = new CameraAndroidCameraxPlugin();
plugin.setUp(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as #6939 (comment)

import 'android_camera_camerax_flutter_api_impls.dart';
import 'camerax_library.pigeon.dart';

// ignore_for_file: avoid_classes_with_only_static_members
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine since you are just wrapping a native class. Can you also add a comment with this explanation about why it is ignored.

final MockTestSystemServicesHostApi mockApi =
MockTestSystemServicesHostApi();
TestSystemServicesHostApi.setup(mockApi);
const bool enableAudio = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think we typically test against literals instead of variables in this repo

go/unit-testing-practices

@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 26, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 30, 2023
@auto-submit
Copy link
auto-submit bot commented Jan 30, 2023

auto label is removed for flutter/plugins, pr: 6986, due to - The status or check suite Windows windows-build_all_plugins master has failed. Please fix the issues identified (or deflake) before re-applying this label.

@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 30, 2023
@auto-submit auto-submit bot merged commit 35f0b1a into flutter:main Jan 31, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 31, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Jan 31, 2023
* 90f447313 [ci] Increase timeouts for platform_tests (flutter/plugins#7036)

* f5568e4b1 [google_sign_in] Add doc for iOS auth with SERVER_CLIENT_ID (flutter/plugins#4747)

* 0c05e8d91 Roll Flutter from a815ee6 to 75680ae (58 revisions) (flutter/plugins#7048)

* a4c320902 [camera]: Bump camerax_version from 1.3.0-alpha02 to 1.3.0-alpha03 in /packages/camera/camera_android_camerax/android (flutter/plugins#7061)

* 8f12b27b6 [ci] Add LUCI versions of macOS ARM tests (flutter/plugins#6984)

* 3843b38e2 [tool] Improve main-branch detection (flutter/plugins#7038)

* d39e7569c [in_app_purchase] Prep for more const widgets (flutter/plugins#7030)

* ddb9777ee [ci] Switch remaining macOS host tests to LUCI (flutter/plugins#7063)

* 2edf56324 [ci] Part 1 of swapping iOS platform test arch (flutter/plugins#7064)

* 35f0b1a49 [camerax] Add system services to plugin (flutter/plugins#6986)

* 5dd0f41a2 [webview]: Bump mockito-inline (flutter/plugins#7056)

* 1896f10ca [webview_flutter_wkwebview][webview_flutter_android] Fixes bug where the `WebView`s could not be released (flutter/plugins#6996)

* a494825fa [camerax] Allow instance manager to create identical objects (flutter/plugins#7034)

* 6ef73da26 [ci] Increase heavy workload memory (flutter/plugins#7065)

* 9da327ca3 [various] Update to use sharedDarwinSource (flutter/plugins#7027)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
autosubmit Merge PR when tree becomes green via auto submit App p: camera platform-android
Projects
None yet
2 participants