Skip to content

Commit

Permalink
Merge branch 'master' into implement_zoomEnabled_for_ios_and_android
Browse files Browse the repository at this point in the history
* master:
  [webview] Fix typos in the README (flutter#4249)
  [google_sign_in] add serverAuthCode to GoogleSignInAccount (flutter#4180)
  [ci] Update macOS Cirrus image to Xcode 13 (flutter#4429)
  [shared_preferences] Switch to new analysis options (flutter#4384)
  [flutter_plugin_android_lifecycle] remove placeholder dart file (flutter#4413)
  [camera] Run iOS methods on UI thread by default (flutter#4140)
  [ci] Always run all `format` steps (flutter#4427)
  [flutter_plugin_tools] Fix license-check on Windows (flutter#4425)
  [google_maps_flutter] Clean Java test, consolidate Marker example. (flutter#4400)
  [image_picker][android] suppress unchecked warning (flutter#4408)
  [ci] Replace Firebase Test Lab deprecated Pixel 4 device with Pixel 5 (flutter#4436)
  [image_picker_for_web] Added support for maxWidth, maxHeight and imageQuality  (flutter#4389)
  Bump compileSdkVersion to 31 (flutter#4432)
  [camera] Update [CameraOrientationTests testOrientationNotifications] unit test to work on Xcode 13 (flutter#4426)
  Update integration_test README  (flutter#3824)
  [webview_flutter] Adjust test URLs again (flutter#4407)
  [google_sign_in] Add serverAuthCode attribute to google_sign_in_platform_interface user data (flutter#4179)
  [camera] Add filter for unsupported cameras on Android (flutter#4418)
  • Loading branch information
NickalasB committed Oct 21, 2021
2 parents f2dd5ad + 99fbfbd commit 6672b4f
Show file tree
Hide file tree
Showing 94 changed files with 1,724 additions and 902 deletions.
17 changes: 9 additions & 8 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ macos_template: &MACOS_TEMPLATE
# PRs on macOS.
use_compute_credits: $CIRRUS_USER_COLLABORATOR == 'true'
osx_instance:
image: big-sur-xcode-12.5
image: big-sur-xcode-13

# Light-workload Linux tasks.
# These use default machines, with fewer CPUs, to reduce pressure on the
Expand All @@ -69,8 +69,8 @@ task:
- dart pub run test
- name: publishable
env:
# TODO (mvanbeusekom): Temporary override to "stable" because of failure on "master".
# Remove override once https://github.com/dart-lang/pub/issues/3152 is resolved.
# TODO (mvanbeusekom): Temporary override to "stable" because of failure on "master".
# Remove override once https://github.com/dart-lang/pub/issues/3152 is resolved.
CHANNEL: stable
CHANGE_DESC: "$TMPDIR/change-description.txt"
version_check_script:
Expand All @@ -88,9 +88,10 @@ task:
- fi
publish_check_script: ./script/tool_runner.sh publish-check
- name: format
format_script: ./script/tool_runner.sh format --fail-on-change
pubspec_script: ./script/tool_runner.sh pubspec-check
license_script: dart $PLUGIN_TOOL license-check
always:
format_script: ./script/tool_runner.sh format --fail-on-change
pubspec_script: ./script/tool_runner.sh pubspec-check
license_script: dart $PLUGIN_TOOL license-check
- name: federated_safety
# This check is only meaningful for PRs, as it validates changes
# rather than state.
Expand Down Expand Up @@ -214,7 +215,7 @@ task:
- export CIRRUS_COMMIT_MESSAGE=""
- if [[ -n "$GCLOUD_FIREBASE_TESTLAB_KEY" ]]; then
- echo $GCLOUD_FIREBASE_TESTLAB_KEY > ${HOME}/gcloud-service-key.json
- ./script/tool_runner.sh firebase-test-lab --device model=flame,version=29 --device model=starqlteue,version=26 --exclude=script/configs/exclude_integration_android.yaml
- ./script/tool_runner.sh firebase-test-lab --device model=redfin,version=30 --device model=starqlteue,version=26 --exclude=script/configs/exclude_integration_android.yaml
- else
- echo "This user does not have permission to run Firebase Test Lab tests."
- fi
Expand Down Expand Up @@ -274,7 +275,7 @@ task:
SIMCTL_CHILD_MAPS_API_KEY: ENCRYPTED[596a9f6bca436694625ac50851dc5da6b4d34cba8025f7db5bc9465142e8cd44e15f69e3507787753accebfc4910d550]
create_simulator_script:
- xcrun simctl list
- xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-14-5 | xargs xcrun simctl boot
- xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-15-0 | xargs xcrun simctl boot
build_script:
- ./script/tool_runner.sh build-examples --ios
xcode_analyze_script:
Expand Down
9 changes: 7 additions & 2 deletions packages/camera/camera/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
## NEXT
## 0.9.4+3

* Updated package description.
* Fix registerTexture and result being called on background thread on iOS.

## 0.9.4+2

* Updated package description;
* Refactor unit test on iOS to make it compatible with new restrictions in Xcode 13 which only supports the use of the `XCUIDevice` in Xcode UI tests.

## 0.9.4+1

Expand Down
2 changes: 1 addition & 1 deletion packages/camera/camera/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
group 'io.flutter.plugins.camera'
version '1.0-SNAPSHOT'
def args = ["-Xlint:deprecation","-Xlint:unchecked","-Werror"]
def args = ["-Xlint:deprecation","-Xlint:unchecked"]

buildscript {
repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ public static List<Map<String, Object>> getAvailableCameras(Activity activity)
String[] cameraNames = cameraManager.getCameraIdList();
List<Map<String, Object>> cameras = new ArrayList<>();
for (String cameraName : cameraNames) {
int cameraId;
try {
cameraId = Integer.parseInt(cameraName, 10);
} catch (NumberFormatException e) {
cameraId = -1;
}
if (cameraId < 0) {
continue;
}

HashMap<String, Object> details = new HashMap<>();
CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraName);
details.put("name", cameraName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@
package io.flutter.plugins.camera;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import android.app.Activity;
import android.content.Context;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CameraMetadata;
import io.flutter.embedding.engine.systemchannels.PlatformChannel;
import java.util.List;
import java.util.Map;
import org.junit.Test;

public class CameraUtilsTest {
Expand Down Expand Up @@ -52,4 +64,37 @@ public void deserializeDeviceOrientation_deserializesCorrectly() {
public void deserializeDeviceOrientation_throwsForNull() {
CameraUtils.deserializeDeviceOrientation(null);
}

@Test
public void getAvailableCameras_retrievesValidCameras()
throws CameraAccessException, NumberFormatException {
final Activity mockActivity = mock(Activity.class);
final CameraManager mockCameraManager = mock(CameraManager.class);
final CameraCharacteristics mockCameraCharacteristics = mock(CameraCharacteristics.class);
final String[] mockCameraIds = {"1394902", "-192930", "0283835", "foobar"};
final int mockSensorOrientation0 = 90;
final int mockSensorOrientation2 = 270;
final int mockLensFacing0 = CameraMetadata.LENS_FACING_FRONT;
final int mockLensFacing2 = CameraMetadata.LENS_FACING_EXTERNAL;

when(mockActivity.getSystemService(Context.CAMERA_SERVICE)).thenReturn(mockCameraManager);
when(mockCameraManager.getCameraIdList()).thenReturn(mockCameraIds);
when(mockCameraManager.getCameraCharacteristics(anyString()))
.thenReturn(mockCameraCharacteristics);
when(mockCameraCharacteristics.get(any()))
.thenReturn(mockSensorOrientation0)
.thenReturn(mockLensFacing0)
.thenReturn(mockSensorOrientation2)
.thenReturn(mockLensFacing2);

List<Map<String, Object>> availableCameras = CameraUtils.getAvailableCameras(mockActivity);

assertEquals(availableCameras.size(), 2);
assertEquals(availableCameras.get(0).get("name"), "1394902");
assertEquals(availableCameras.get(0).get("sensorOrientation"), mockSensorOrientation0);
assertEquals(availableCameras.get(0).get("lensFacing"), "front");
assertEquals(availableCameras.get(1).get("name"), "0283835");
assertEquals(availableCameras.get(1).get("sensorOrientation"), mockSensorOrientation2);
assertEquals(availableCameras.get(1).get("lensFacing"), "external");
}
}
Loading

0 comments on commit 6672b4f

Please sign in to comment.