Skip to content

Commit ad8e48a

Browse files
authored
Merge branch 'main' into adaptive-scaffold-breakpoints-prevent-unnecessary-rebuilds
2 parents c06c236 + 912abb5 commit ad8e48a

File tree

56 files changed

+1510
-597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1510
-597
lines changed

.ci.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,14 @@ targets:
322322
version_file: flutter_master.version
323323
target_file: linux_custom_package_tests.yaml
324324
# Pigeon tests need Andoid deps (thus the Linux_android base), emulator,
325-
# and clang-format.
325+
# and Linux desktop deps.
326326
# web_benchmarks needs Chrome.
327327
dependencies: >-
328328
[
329329
{"dependency": "android_virtual_device", "version": "android_34_google_apis_x64.textpb"},
330330
{"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"},
331+
{"dependency": "cmake", "version": "build_id:8787856497187628321"},
332+
{"dependency": "ninja", "version": "version:1.9.0"},
331333
{"dependency": "chrome_and_driver", "version": "version:114.0"}
332334
]
333335
channel: master
@@ -349,6 +351,8 @@ targets:
349351
[
350352
{"dependency": "android_virtual_device", "version": "android_34_google_apis_x64.textpb"},
351353
{"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"},
354+
{"dependency": "cmake", "version": "build_id:8787856497187628321"},
355+
{"dependency": "ninja", "version": "version:1.9.0"},
352356
{"dependency": "chrome_and_driver", "version": "version:114.0"}
353357
]
354358
channel: stable

.ci/targets/ios_build_all_packages.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ tasks:
22
- name: prepare tool
33
script: .ci/scripts/prepare_tool.sh
44
infra_step: true # Note infra steps failing prevents "always" from running.
5+
- name: download Dart and iOS deps
6+
script: .ci/scripts/tool_runner.sh
7+
args: ["fetch-deps", "--ios", "--supporting-target-platforms-only"]
8+
infra_step: true
59
- name: create all_packages app
610
script: .ci/scripts/create_all_packages_app.sh
711
infra_step: true # Note infra steps failing prevents "always" from running.

.ci/targets/macos_build_all_packages.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ tasks:
22
- name: prepare tool
33
script: .ci/scripts/prepare_tool.sh
44
infra_step: true # Note infra steps failing prevents "always" from running.
5+
- name: download Dart and macOS deps
6+
script: .ci/scripts/tool_runner.sh
7+
args: ["fetch-deps", "--macos", "--supporting-target-platforms-only"]
8+
infra_step: true
59
- name: create all_packages app
610
script: .ci/scripts/create_all_packages_app.sh
711
infra_step: true # Note infra steps failing prevents "always" from running.

packages/camera/camera_avfoundation/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.9.15+2
2+
3+
* Converts camera query to Pigeon.
4+
15
## 0.9.15+1
26

37
* Simplifies internal handling of method channel responses.

packages/camera/camera_avfoundation/example/ios/RunnerTests/AvailableCamerasTest.m

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ @implementation AvailableCamerasTest
1515

1616
- (void)testAvailableCamerasShouldReturnAllCamerasOnMultiCameraIPhone {
1717
CameraPlugin *camera = [[CameraPlugin alloc] initWithRegistry:nil messenger:nil];
18-
XCTestExpectation *expectation =
19-
[[XCTestExpectation alloc] initWithDescription:@"Result finished"];
18+
XCTestExpectation *expectation = [self expectationWithDescription:@"Result finished"];
2019

2120
// iPhone 13 Cameras:
2221
AVCaptureDevice *wideAngleCamera = OCMClassMock([AVCaptureDevice class]);
@@ -55,29 +54,26 @@ - (void)testAvailableCamerasShouldReturnAllCamerasOnMultiCameraIPhone {
5554
}
5655
OCMStub([discoverySessionMock devices]).andReturn([NSArray arrayWithArray:cameras]);
5756

58-
// Set up method call
59-
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"availableCameras"
60-
arguments:nil];
61-
62-
__block id resultValue;
63-
[camera handleMethodCallAsync:call
64-
result:^(id _Nullable result) {
65-
resultValue = result;
66-
[expectation fulfill];
67-
}];
57+
__block NSArray<FCPPlatformCameraDescription *> *resultValue;
58+
[camera
59+
availableCamerasWithCompletion:^(NSArray<FCPPlatformCameraDescription *> *_Nullable result,
60+
FlutterError *_Nullable error) {
61+
XCTAssertNil(error);
62+
resultValue = result;
63+
[expectation fulfill];
64+
}];
65+
[self waitForExpectationsWithTimeout:30 handler:nil];
6866

6967
// Verify the result
70-
NSDictionary *dictionaryResult = (NSDictionary *)resultValue;
7168
if (@available(iOS 13.0, *)) {
72-
XCTAssertTrue([dictionaryResult count] == 4);
69+
XCTAssertEqual(resultValue.count, 4);
7370
} else {
74-
XCTAssertTrue([dictionaryResult count] == 3);
71+
XCTAssertEqual(resultValue.count, 3);
7572
}
7673
}
7774
- (void)testAvailableCamerasShouldReturnOneCameraOnSingleCameraIPhone {
7875
CameraPlugin *camera = [[CameraPlugin alloc] initWithRegistry:nil messenger:nil];
79-
XCTestExpectation *expectation =
80-
[[XCTestExpectation alloc] initWithDescription:@"Result finished"];
76+
XCTestExpectation *expectation = [self expectationWithDescription:@"Result finished"];
8177

8278
// iPhone 8 Cameras:
8379
AVCaptureDevice *wideAngleCamera = OCMClassMock([AVCaptureDevice class]);
@@ -105,20 +101,19 @@ - (void)testAvailableCamerasShouldReturnOneCameraOnSingleCameraIPhone {
105101
[cameras addObjectsFromArray:@[ wideAngleCamera, frontFacingCamera ]];
106102
OCMStub([discoverySessionMock devices]).andReturn([NSArray arrayWithArray:cameras]);
107103

108-
// Set up method call
109-
FlutterMethodCall *call = [FlutterMethodCall methodCallWithMethodName:@"availableCameras"
110-
arguments:nil];
111-
112-
__block id resultValue;
113-
[camera handleMethodCallAsync:call
114-
result:^(id _Nullable result) {
115-
resultValue = result;
116-
[expectation fulfill];
117-
}];
104+
__block NSArray<FCPPlatformCameraDescription *> *resultValue;
105+
[camera
106+
availableCamerasWithCompletion:^(NSArray<FCPPlatformCameraDescription *> *_Nullable result,
107+
FlutterError *_Nullable error) {
108+
XCTAssertNil(error);
109+
resultValue = result;
110+
[expectation fulfill];
111+
}];
112+
[self waitForExpectationsWithTimeout:30 handler:nil];
118113

119114
// Verify the result
120-
NSDictionary *dictionaryResult = (NSDictionary *)resultValue;
121-
XCTAssertTrue([dictionaryResult count] == 2);
115+
XCTAssertEqual(resultValue.count, 2);
116+
;
122117
}
123118

124119
@end

packages/camera/camera_avfoundation/ios/Classes/CameraPlugin.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44

55
#import <Flutter/Flutter.h>
66

7-
@interface CameraPlugin : NSObject <FlutterPlugin>
7+
#import "messages.g.h"
8+
9+
@interface CameraPlugin : NSObject <FlutterPlugin, FCPCameraApi>
810
@end

packages/camera/camera_avfoundation/ios/Classes/CameraPlugin.m

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#import "FLTThreadSafeMethodChannel.h"
1515
#import "FLTThreadSafeTextureRegistry.h"
1616
#import "QueueUtils.h"
17+
#import "messages.g.h"
1718

1819
static FlutterError *FlutterErrorFromNSError(NSError *error) {
1920
return [FlutterError errorWithCode:[NSString stringWithFormat:@"Error %d", (int)error.code]
@@ -35,6 +36,7 @@ + (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
3536
CameraPlugin *instance = [[CameraPlugin alloc] initWithRegistry:[registrar textures]
3637
messenger:[registrar messenger]];
3738
[registrar addMethodCallDelegate:instance channel:channel];
39+
SetUpFCPCameraApi([registrar messenger], instance);
3840
}
3941

4042
- (instancetype)initWithRegistry:(NSObject<FlutterTextureRegistry> *)registry
@@ -104,8 +106,10 @@ - (void)handleMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result
104106
});
105107
}
106108

107-
- (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FlutterResult)result {
108-
if ([@"availableCameras" isEqualToString:call.method]) {
109+
- (void)availableCamerasWithCompletion:
110+
(nonnull void (^)(NSArray<FCPPlatformCameraDescription *> *_Nullable,
111+
FlutterError *_Nullable))completion {
112+
dispatch_async(self.captureSessionQueue, ^{
109113
NSMutableArray *discoveryDevices =
110114
[@[ AVCaptureDeviceTypeBuiltInWideAngleCamera, AVCaptureDeviceTypeBuiltInTelephotoCamera ]
111115
mutableCopy];
@@ -117,29 +121,30 @@ - (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FlutterResult)re
117121
mediaType:AVMediaTypeVideo
118122
position:AVCaptureDevicePositionUnspecified];
119123
NSArray<AVCaptureDevice *> *devices = discoverySession.devices;
120-
NSMutableArray<NSDictionary<NSString *, NSObject *> *> *reply =
124+
NSMutableArray<FCPPlatformCameraDescription *> *reply =
121125
[[NSMutableArray alloc] initWithCapacity:devices.count];
122126
for (AVCaptureDevice *device in devices) {
123-
NSString *lensFacing;
124-
switch ([device position]) {
127+
FCPPlatformCameraLensDirection lensFacing;
128+
switch (device.position) {
125129
case AVCaptureDevicePositionBack:
126-
lensFacing = @"back";
130+
lensFacing = FCPPlatformCameraLensDirectionBack;
127131
break;
128132
case AVCaptureDevicePositionFront:
129-
lensFacing = @"front";
133+
lensFacing = FCPPlatformCameraLensDirectionFront;
130134
break;
131135
case AVCaptureDevicePositionUnspecified:
132-
lensFacing = @"external";
136+
lensFacing = FCPPlatformCameraLensDirectionExternal;
133137
break;
134138
}
135-
[reply addObject:@{
136-
@"name" : [device uniqueID],
137-
@"lensFacing" : lensFacing,
138-
@"sensorOrientation" : @90,
139-
}];
139+
[reply addObject:[FCPPlatformCameraDescription makeWithName:device.uniqueID
140+
lensDirection:lensFacing]];
140141
}
141-
result(reply);
142-
} else if ([@"create" isEqualToString:call.method]) {
142+
completion(reply, nil);
143+
});
144+
}
145+
146+
- (void)handleMethodCallAsync:(FlutterMethodCall *)call result:(FlutterResult)result {
147+
if ([@"create" isEqualToString:call.method]) {
143148
[self handleCreateMethodCall:call result:result];
144149
} else if ([@"startImageStream" isEqualToString:call.method]) {
145150
[_camera startImageStreamWithMessenger:_messenger];
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
// Autogenerated from Pigeon (v18.0.0), do not edit directly.
5+
// See also: https://pub.dev/packages/pigeon
6+
7+
#import <Foundation/Foundation.h>
8+
9+
@protocol FlutterBinaryMessenger;
10+
@protocol FlutterMessageCodec;
11+
@class FlutterError;
12+
@class FlutterStandardTypedData;
13+
14+
NS_ASSUME_NONNULL_BEGIN
15+
16+
typedef NS_ENUM(NSUInteger, FCPPlatformCameraLensDirection) {
17+
/// Front facing camera (a user looking at the screen is seen by the camera).
18+
FCPPlatformCameraLensDirectionFront = 0,
19+
/// Back facing camera (a user looking at the screen is not seen by the camera).
20+
FCPPlatformCameraLensDirectionBack = 1,
21+
/// External camera which may not be mounted to the device.
22+
FCPPlatformCameraLensDirectionExternal = 2,
23+
};
24+
25+
/// Wrapper for FCPPlatformCameraLensDirection to allow for nullability.
26+
@interface FCPPlatformCameraLensDirectionBox : NSObject
27+
@property(nonatomic, assign) FCPPlatformCameraLensDirection value;
28+
- (instancetype)initWithValue:(FCPPlatformCameraLensDirection)value;
29+
@end
30+
31+
@class FCPPlatformCameraDescription;
32+
33+
@interface FCPPlatformCameraDescription : NSObject
34+
/// `init` unavailable to enforce nonnull fields, see the `make` class method.
35+
- (instancetype)init NS_UNAVAILABLE;
36+
+ (instancetype)makeWithName:(NSString *)name
37+
lensDirection:(FCPPlatformCameraLensDirection)lensDirection;
38+
/// The name of the camera device.
39+
@property(nonatomic, copy) NSString *name;
40+
/// The direction the camera is facing.
41+
@property(nonatomic, assign) FCPPlatformCameraLensDirection lensDirection;
42+
@end
43+
44+
/// The codec used by FCPCameraApi.
45+
NSObject<FlutterMessageCodec> *FCPCameraApiGetCodec(void);
46+
47+
@protocol FCPCameraApi
48+
/// Returns the list of available cameras.
49+
- (void)availableCamerasWithCompletion:(void (^)(NSArray<FCPPlatformCameraDescription *> *_Nullable,
50+
FlutterError *_Nullable))completion;
51+
@end
52+
53+
extern void SetUpFCPCameraApi(id<FlutterBinaryMessenger> binaryMessenger,
54+
NSObject<FCPCameraApi> *_Nullable api);
55+
56+
extern void SetUpFCPCameraApiWithSuffix(id<FlutterBinaryMessenger> binaryMessenger,
57+
NSObject<FCPCameraApi> *_Nullable api,
58+
NSString *messageChannelSuffix);
59+
60+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)