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

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into image_picker_came…
Browse files Browse the repository at this point in the history
…ra_on_android11
  • Loading branch information
Bubu committed Jul 26, 2021
2 parents 3ef5852 + 1dce6ab commit fdb4c24
Show file tree
Hide file tree
Showing 380 changed files with 10,055 additions and 3,295 deletions.
40 changes: 18 additions & 22 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ task:
- cd script/tool
- dart analyze --fatal-infos
script:
- ./script/tool_runner.sh analyze
- ./script/tool_runner.sh analyze --custom-analysis=script/configs/custom_analysis.yaml
### Android tasks ###
- name: build_all_plugins_apk
env:
Expand Down Expand Up @@ -125,7 +125,7 @@ task:
memory: 12G
matrix:
### Android tasks ###
- name: build-apks+java-test+firebase-test-lab
- name: build-apks+android-unit+firebase-test-lab
env:
matrix:
PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4"
Expand All @@ -144,13 +144,15 @@ task:
- export CIRRUS_CHANGE_MESSAGE=""
- export CIRRUS_COMMIT_MESSAGE=""
- ./script/tool_runner.sh build-examples --apk
java_test_script:
native_unit_test_script:
# Unsetting CIRRUS_CHANGE_MESSAGE and CIRRUS_COMMIT_MESSAGE as they
# might include non-ASCII characters which makes Gradle crash.
# TODO(stuartmorgan): See https://github.com/flutter/flutter/issues/24935
- export CIRRUS_CHANGE_MESSAGE=""
- export CIRRUS_COMMIT_MESSAGE=""
- ./script/tool_runner.sh java-test # must come after apk build
# Native integration tests are handled by firebase-test-lab below, so
# only run unit tests.
- ./script/tool_runner.sh native-test --android --no-integration # must come after apk build
firebase_test_lab_script:
# Unsetting CIRRUS_CHANGE_MESSAGE and CIRRUS_COMMIT_MESSAGE as they
# might include non-ASCII characters which makes Gradle crash.
Expand All @@ -159,16 +161,13 @@ 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
- ./script/tool_runner.sh firebase-test-lab --device model=flame,version=29 --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
### Web tasks ###
- name: build-web+drive-examples
env:
# Currently missing; see https://github.com/flutter/flutter/issues/81982
# and https://github.com/flutter/flutter/issues/82211
PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS: "file_selector,image_picker_for_web,shared_preferences_web"
matrix:
CHANNEL: "master"
CHANNEL: "stable"
Expand All @@ -181,7 +180,7 @@ task:
build_script:
- ./script/tool_runner.sh build-examples --web
drive_script:
- ./script/tool_runner.sh drive-examples --web --exclude $PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS
- ./script/tool_runner.sh drive-examples --web --exclude=script/configs/exclude_integration_web.yaml

# macOS tasks.
task:
Expand All @@ -203,10 +202,6 @@ task:
- name: build-ipas+drive-examples
env:
PATH: $PATH:/usr/local/bin
# in_app_purchase_ios is currently missing tests; see https://github.com/flutter/flutter/issues/81695
# ios_platform_images is currently missing tests; see https://github.com/flutter/flutter/issues/82208
# sensor hangs on CI.
PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS: "in_app_purchase_ios,ios_platform_images,sensors"
matrix:
PLUGIN_SHARDING: "--shardIndex 0 --shardCount 4"
PLUGIN_SHARDING: "--shardIndex 1 --shardCount 4"
Expand All @@ -221,13 +216,15 @@ task:
- xcrun simctl create Flutter-iPhone com.apple.CoreSimulator.SimDeviceType.iPhone-11 com.apple.CoreSimulator.SimRuntime.iOS-14-5 | xargs xcrun simctl boot
build_script:
- ./script/tool_runner.sh build-examples --ios
xctest_script:
- ./script/tool_runner.sh xctest --ios --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=latest"
xcode_analyze_script:
- ./script/tool_runner.sh xcode-analyze --ios
native_test_script:
- ./script/tool_runner.sh native-test --ios --ios-destination "platform=iOS Simulator,name=iPhone 11,OS=latest"
drive_script:
# `drive-examples` contains integration tests, which changes the UI of the application.
# This UI change sometimes affects `xctest`.
# So we run `drive-examples` after `xctest`, changing the order will result ci failure.
- ./script/tool_runner.sh drive-examples --ios --exclude $PLUGINS_TO_EXCLUDE_INTEGRATION_TESTS
# So we run `drive-examples` after `native-test`; changing the order will result ci failure.
- ./script/tool_runner.sh drive-examples --ios --exclude=script/configs/exclude_integration_ios.yaml
### macOS desktop tasks ###
- name: build_all_plugins_macos
env:
Expand All @@ -239,17 +236,16 @@ task:
- ./script/build_all_plugins_app.sh macos
- name: build-macos+drive-examples
env:
# conncectivity_macos is deprecated, so is not getting unit test backfill.
# package_info is deprecated, so is not getting unit test backfill.
PLUGINS_TO_EXCLUDE_MACOS_XCTESTS: "connectivity_macos,package_info"
matrix:
CHANNEL: "master"
CHANNEL: "stable"
PATH: $PATH:/usr/local/bin
build_script:
- flutter config --enable-macos-desktop
- ./script/tool_runner.sh build-examples --macos
xctest_script:
- ./script/tool_runner.sh xctest --macos --exclude $PLUGINS_TO_EXCLUDE_MACOS_XCTESTS
xcode_analyze_script:
- ./script/tool_runner.sh xcode-analyze --macos
native_test_script:
- ./script/tool_runner.sh native-test --macos --exclude=script/configs/exclude_native_macos.yaml
drive_script:
- ./script/tool_runner.sh drive-examples --macos
4 changes: 4 additions & 0 deletions packages/android_alarm_manager/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## NEXT

* Remove support for the V1 Android embedding.

## 2.0.2

* Update README to point to Plus Plugins version.
Expand Down
49 changes: 0 additions & 49 deletions packages/android_alarm_manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,55 +74,6 @@ will not run in the same isolate as the main application. Unlike threads, isolat
memory and communication between isolates must be done via message passing (see more documentation on
isolates [here](https://api.dart.dev/stable/2.0.0/dart-isolate/dart-isolate-library.html)).


## Using other plugins in alarm callbacks

If alarm callbacks will need access to other Flutter plugins, including the
alarm manager plugin itself, it may be necessary to inform the background service how
to initialize plugins depending on which Flutter Android embedding the application is
using.

### Flutter Android Embedding V1

For the Flutter Android Embedding V1, the background service must be provided a
callback to register plugins with the background isolate. This is done by giving
the `AlarmService` a callback to call the application's `onCreate` method. See the example's
[Application overrides](https://github.com/flutter/plugins/blob/master/packages/android_alarm_manager/example/android/app/src/main/java/io/flutter/plugins/androidalarmmanagerexample/Application.java).

In particular, its `Application` class is as follows:

```java
public class Application extends FlutterApplication implements PluginRegistrantCallback {
@Override
public void onCreate() {
super.onCreate();
AlarmService.setPluginRegistrant(this);
}

@Override
public void registerWith(PluginRegistry registry) {
GeneratedPluginRegistrant.registerWith(registry);
}
}
```

Which must be reflected in the application's `AndroidManifest.xml`. E.g.:

```xml
<application
android:name=".Application"
...
```

**Note:** Not calling `AlarmService.setPluginRegistrant` will result in an exception being
thrown when an alarm eventually fires.

### Flutter Android Embedding V2

For the Flutter Android Embedding V2, plugins are registered with the background
isolate via reflection so `AlarmService.setPluginRegistrant` does not need to be
called.

For help getting started with Flutter, view our online
[documentation](https://flutter.dev/).

Expand Down
13 changes: 13 additions & 0 deletions packages/android_alarm_manager/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ android {
lintOptions {
disable 'InvalidPackage'
}


testOptions {
unitTests.includeAndroidResources = true
unitTests.returnDefaultValues = true
unitTests.all {
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ public static void enqueueAlarmProcessing(Context context, Intent alarmContext)
* <ul>
* <li>The given {@code callbackHandle} must correspond to a registered Dart callback. If the
* handle does not resolve to a Dart callback then this method does nothing.
* <li>A static {@link #pluginRegistrantCallback} must exist, otherwise a {@link
* PluginRegistrantException} will be thrown.
* </ul>
*/
public static void startBackgroundIsolate(Context context, long callbackHandle) {
Expand Down Expand Up @@ -89,23 +87,6 @@ public static void setCallbackDispatcher(Context context, long callbackHandle) {
FlutterBackgroundExecutor.setCallbackDispatcher(context, callbackHandle);
}

/**
* Sets the {@link io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback} used to
* register the plugins used by an application with the newly spawned background isolate.
*
* <p>This should be invoked in {@link Application.onCreate} with {@link
* GeneratedPluginRegistrant} in applications using the V1 embedding API in order to use other
* plugins in the background isolate. For applications using the V2 embedding API, it is not
* necessary to set a {@link io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback} as
* plugins are registered automatically.
*/
@SuppressWarnings("deprecation")
public static void setPluginRegistrant(
io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback callback) {
// Indirectly set in FlutterBackgroundExecutor for backwards compatibility.
FlutterBackgroundExecutor.setPluginRegistrant(callback);
}

private static void scheduleAlarm(
Context context,
int requestCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ public void onMethodCall(MethodCall call, Result result) {
}
} catch (JSONException e) {
result.error("error", "JSON error: " + e.getMessage(), null);
} catch (PluginRegistrantException e) {
result.error("error", "AlarmManager error: " + e.getMessage(), null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,6 @@ public class FlutterBackgroundExecutor implements MethodCallHandler {

private AtomicBoolean isCallbackDispatcherReady = new AtomicBoolean(false);

/**
* Sets the {@code io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback} used to
* register plugins with the newly spawned isolate.
*
* <p>Note: this is only necessary for applications using the V1 engine embedding API as plugins
* are automatically registered via reflection in the V2 engine embedding API. If not set, alarm
* callbacks will not be able to utilize functionality from other plugins.
*/
@SuppressWarnings("deprecation")
public static void setPluginRegistrant(
io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback callback) {
pluginRegistrantCallback = callback;
}

/**
* Sets the Dart callback handle for the Dart method that is responsible for initializing the
* background Dart isolate, preparing it to receive Dart callback tasks requests.
Expand All @@ -81,19 +67,15 @@ private void onInitialized() {
@Override
public void onMethodCall(MethodCall call, Result result) {
String method = call.method;
try {
if (method.equals("AlarmService.initialized")) {
// This message is sent by the background method channel as soon as the background isolate
// is running. From this point forward, the Android side of this plugin can send
// callback handles through the background method channel, and the Dart side will execute
// the Dart methods corresponding to those callback handles.
onInitialized();
result.success(true);
} else {
result.notImplemented();
}
} catch (PluginRegistrantException e) {
result.error("error", "AlarmManager error: " + e.getMessage(), null);
if (method.equals("AlarmService.initialized")) {
// This message is sent by the background method channel as soon as the background isolate
// is running. From this point forward, the Android side of this plugin can send
// callback handles through the background method channel, and the Dart side will execute
// the Dart methods corresponding to those callback handles.
onInitialized();
result.success(true);
} else {
result.notImplemented();
}
}

Expand All @@ -115,8 +97,6 @@ public void onMethodCall(MethodCall call, Result result) {
* <ul>
* <li>The given callback must correspond to a registered Dart callback. If the handle does not
* resolve to a Dart callback then this method does nothing.
* <li>A static {@link #pluginRegistrantCallback} must exist, otherwise a {@link
* PluginRegistrantException} will be thrown.
* </ul>
*/
public void startBackgroundIsolate(Context context) {
Expand All @@ -143,8 +123,6 @@ public void startBackgroundIsolate(Context context) {
* <ul>
* <li>The given {@code callbackHandle} must correspond to a registered Dart callback. If the
* handle does not resolve to a Dart callback then this method does nothing.
* <li>A static {@link #pluginRegistrantCallback} must exist, otherwise a {@link
* PluginRegistrantException} will be thrown.
* </ul>
*/
public void startBackgroundIsolate(Context context, long callbackHandle) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,8 @@
<uses-permission android:name="android.permission.INTERNET"/>

<application
android:name=".Application"
android:label="android_alarm_manager_example"
android:icon="@mipmap/ic_launcher">
<activity
android:name="io.flutter.plugins.androidalarmmanagerexample.EmbeddingV1Activity"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"
android:exported="true">
</activity>
<activity
android:name="io.flutter.embedding.android.FlutterActivity"
android:launchMode="singleTop"
Expand Down

This file was deleted.

This file was deleted.

4 changes: 4 additions & 0 deletions packages/android_intent/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## NEXT

* Remove references to the V1 Android embedding.

## 2.0.2

* Update README to point to Plus Plugins version.
Expand Down
Loading

0 comments on commit fdb4c24

Please sign in to comment.