Skip to content

Commit b135e2a

Browse files
authored
[many] More v1 embedding deletion that was missed in #6494 (#6923)
There were some additional v1 Android embedding references missed by #6494. This PR aims to remove those missed references. I built the android example app of each plugin affected here on the [deletion branch](flutter/engine#52022) to be completely sure: Final testing, I tested that the `all_packages` app builds on the v1 embedding deletion branch: ``` $ ./.ci/scripts/create_all_packages_app.sh && cd all_packages ... $ flutter build apk --debug --local-engine-src-path=/Users/mackall/development/engine/src --local-engine=android_debug_arm64 --local-engine-host=host_debug Running Gradle task 'assembleDebug'... 4.8s � Built build/app/outputs/flutter-apk/app-debug.apk ``` � Linux repo checks are failing ``` The following packages had errors: packages/google_maps_flutter/google_maps_flutter: Missing CHANGELOG change packages/palette_generator: Missing CHANGELOG change packages/quick_actions/quick_actions: Missing CHANGELOG change packages/webview_flutter/webview_flutter: Missing CHANGELOG change ``` The only changes to these packages are `xml` changes to example apps which won't cause build failures even when the v1 embedding is deleted (they will just be unused). So I believe these changes should be version exempt.
1 parent 5ba990b commit b135e2a

File tree

24 files changed

+58
-191
lines changed

24 files changed

+58
-191
lines changed

packages/espresso/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.3.0+10
2+
3+
* Removes additional references to v1 Android embedding.
4+
15
## 0.3.0+9
26

37
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.

packages/espresso/android/src/main/java/androidx/test/espresso/flutter/action/FlutterViewAction.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.util.concurrent.ExecutorService;
3939
import java.util.concurrent.TimeUnit;
4040
import java.util.concurrent.TimeoutException;
41+
import javax.annotation.Nonnull;
4142
import okhttp3.OkHttpClient;
4243
import org.hamcrest.Matcher;
4344

@@ -97,14 +98,19 @@ public String getDescription() {
9798

9899
@ExperimentalTestApi
99100
@Override
100-
public void perform(UiController uiController, View flutterView) {
101+
public void perform(UiController uiController, View view) {
102+
checkNotNull(view, "The Flutter View instance cannot be null.");
103+
if (!(view instanceof FlutterView)) {
104+
throw new FlutterProtocolException(
105+
String.format("This is not a Flutter View instance [id: %d].", view.getId()));
106+
}
107+
FlutterView flutterView = (FlutterView) view;
101108
// There could be a gap between when the Flutter view is available in the view hierarchy and the
102109
// engine & Dart isolates are actually up and running. Check whether the first frame has been
103110
// rendered before proceeding in an unblocking way.
104111
loopUntilFlutterViewRendered(flutterView, uiController);
105112
// The url {@code FlutterNativeView} returns is the http url that the Dart VM Observatory http
106113
// server serves at. Need to convert to the one that the WebSocket uses.
107-
108114
URI dartVmServiceProtocolUrl =
109115
DartVmServiceUtil.getServiceProtocolUri(FlutterJNI.getVMServiceUri());
110116
String isolateId = DartVmServiceUtil.getDartIsolateId(flutterView);
@@ -171,7 +177,8 @@ public T waitUntilCompleted(long timeout, TimeUnit unit)
171177
return resultFuture.get(timeout, unit);
172178
}
173179

174-
private static void loopUntilFlutterViewRendered(View flutterView, UiController uiController) {
180+
private static void loopUntilFlutterViewRendered(
181+
@Nonnull FlutterView flutterView, UiController uiController) {
175182
FlutterViewRenderedIdlingResource idlingResource =
176183
new FlutterViewRenderedIdlingResource(flutterView);
177184
try {
@@ -188,31 +195,22 @@ private static void loopUntilFlutterViewRendered(View flutterView, UiController
188195
*/
189196
static final class FlutterViewRenderedIdlingResource implements IdlingResource {
190197

191-
private final View flutterView;
198+
private final FlutterView flutterView;
192199
// Written from main thread, read from any thread.
193200
private volatile ResourceCallback resourceCallback;
194201

195-
FlutterViewRenderedIdlingResource(View flutterView) {
196-
this.flutterView = checkNotNull(flutterView);
202+
FlutterViewRenderedIdlingResource(@Nonnull FlutterView flutterView) {
203+
this.flutterView = flutterView;
197204
}
198205

199206
@Override
200207
public String getName() {
201208
return FlutterViewRenderedIdlingResource.class.getSimpleName();
202209
}
203210

204-
@SuppressWarnings("deprecation")
205211
@Override
206212
public boolean isIdleNow() {
207-
boolean isIdle = false;
208-
if (flutterView instanceof FlutterView) {
209-
isIdle = ((FlutterView) flutterView).hasRenderedFirstFrame();
210-
} else if (flutterView instanceof io.flutter.view.FlutterView) {
211-
isIdle = ((io.flutter.view.FlutterView) flutterView).hasRenderedFirstFrame();
212-
} else {
213-
throw new FlutterProtocolException(
214-
String.format("This is not a Flutter View instance [id: %d].", flutterView.getId()));
215-
}
213+
boolean isIdle = flutterView.hasRenderedFirstFrame();
216214
if (isIdle) {
217215
resourceCallback.onTransitionToIdle();
218216
}

packages/espresso/android/src/main/java/androidx/test/espresso/flutter/api/SyntheticAction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* action that's performed via Flutter engine. It's supposed to be used for complex interactions or
2121
* those that are brittle if performed through Android system. Most of the actions should be
2222
* associated with a {@link WidgetMatcher}, but some may not, e.g. an action that checks the
23-
* rendering status of the entire {@link io.flutter.view.FlutterView}.
23+
* rendering status of the entire {@link io.flutter.embedding.android.FlutterView}.
2424
*/
2525
@Beta
2626
public abstract class SyntheticAction {

packages/espresso/android/src/main/java/androidx/test/espresso/flutter/internal/protocol/impl/DartVmServiceUtil.java

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44

55
package androidx.test.espresso.flutter.internal.protocol.impl;
66

7-
import static com.google.common.base.Preconditions.checkNotNull;
87
import static com.google.common.base.Strings.isNullOrEmpty;
98

109
import android.util.Log;
11-
import android.view.View;
10+
import io.flutter.embedding.android.FlutterView;
1211
import io.flutter.embedding.engine.FlutterEngine;
1312
import io.flutter.embedding.engine.dart.DartExecutor;
1413
import java.net.MalformedURLException;
1514
import java.net.URI;
1615
import java.net.URISyntaxException;
1716
import java.net.URL;
17+
import javax.annotation.Nonnull;
1818

1919
/** Util class for dealing with Dart VM service protocols. */
2020
public final class DartVmServiceUtil {
@@ -59,8 +59,7 @@ public static URI getServiceProtocolUri(String observatoryUrl) {
5959
}
6060

6161
/** Gets the Dart isolate ID for the given {@code flutterView}. */
62-
public static String getDartIsolateId(View flutterView) {
63-
checkNotNull(flutterView, "The Flutter View instance cannot be null.");
62+
public static String getDartIsolateId(FlutterView flutterView) {
6463
String uiIsolateId = getDartExecutor(flutterView).getIsolateServiceId();
6564
Log.d(
6665
TAG,
@@ -71,25 +70,13 @@ public static String getDartIsolateId(View flutterView) {
7170
}
7271

7372
/** Gets the Dart executor for the given {@code flutterView}. */
74-
@SuppressWarnings("deprecation")
75-
public static DartExecutor getDartExecutor(View flutterView) {
76-
checkNotNull(flutterView, "The Flutter View instance cannot be null.");
77-
// Flutter's embedding is in the phase of rewriting/refactoring. Let's be compatible with both
78-
// the old and the new FlutterView classes.
79-
if (flutterView instanceof io.flutter.view.FlutterView) {
80-
return ((io.flutter.view.FlutterView) flutterView).getDartExecutor();
81-
} else if (flutterView instanceof io.flutter.embedding.android.FlutterView) {
82-
FlutterEngine flutterEngine =
83-
((io.flutter.embedding.android.FlutterView) flutterView).getAttachedFlutterEngine();
84-
if (flutterEngine == null) {
85-
throw new FlutterProtocolException(
86-
String.format(
87-
"No Flutter engine attached to the Flutter view [id: %d].", flutterView.getId()));
88-
}
89-
return flutterEngine.getDartExecutor();
90-
} else {
73+
public static DartExecutor getDartExecutor(@Nonnull FlutterView flutterView) {
74+
FlutterEngine flutterEngine = flutterView.getAttachedFlutterEngine();
75+
if (flutterEngine == null) {
9176
throw new FlutterProtocolException(
92-
String.format("This is not a Flutter View instance [id: %d].", flutterView.getId()));
77+
String.format(
78+
"No Flutter engine attached to the Flutter view [id: %d].", flutterView.getId()));
9379
}
80+
return flutterEngine.getDartExecutor();
9481
}
9582
}

packages/espresso/android/src/main/java/androidx/test/espresso/flutter/matcher/FlutterMatchers.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,9 @@ public void describeTo(Description description) {
9696
description.appendText("is a FlutterView");
9797
}
9898

99-
@SuppressWarnings("deprecation")
10099
@Override
101100
public boolean matchesSafely(View flutterView) {
102-
return flutterView instanceof FlutterView
103-
|| (flutterView instanceof io.flutter.view.FlutterView);
101+
return flutterView instanceof FlutterView;
104102
}
105103
}
106104
}

packages/espresso/example/android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

packages/espresso/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Java classes for testing Flutter apps using Espresso.
33
Allows driving Flutter widgets from a native Espresso test.
44
repository: https://github.com/flutter/packages/tree/main/packages/espresso
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+espresso%22
6-
version: 0.3.0+9
6+
version: 0.3.0+10
77

88
environment:
99
sdk: ^3.4.0

packages/google_maps_flutter/google_maps_flutter/example/android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@
1616
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
1717
android:hardwareAccelerated="true"
1818
android:windowSoftInputMode="adjustResize">
19-
<meta-data
20-
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
21-
android:value="true" />
2219
<intent-filter>
2320
<action android:name="android.intent.action.MAIN"/>
2421
<category android:name="android.intent.category.LAUNCHER"/>

packages/google_maps_flutter/google_maps_flutter_android/example/android/app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale"
1818
android:hardwareAccelerated="true"
1919
android:windowSoftInputMode="adjustResize">
20-
<meta-data
21-
android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
22-
android:value="true" />
2320
<intent-filter>
2421
<action android:name="android.intent.action.MAIN"/>
2522
<category android:name="android.intent.category.LAUNCHER"/>

packages/google_sign_in/google_sign_in_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 6.1.26
2+
3+
* Removes additional references to the v1 Android embedding.
4+
15
## 6.1.25
26

37
* Updates Guava to version 33.2.1.

0 commit comments

Comments
 (0)