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.

packages/google_sign_in/google_sign_in_android/android/src/main/java/io/flutter/plugins/googlesignin/GoogleSignInPlugin.java

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ public void initInstance(
5959
GoogleSignInApi.setup(messenger, delegate);
6060
}
6161

62-
@VisibleForTesting
63-
@SuppressWarnings("deprecation")
64-
public void setUpRegistrar(@NonNull PluginRegistry.Registrar registrar) {
65-
delegate.setUpRegistrar(registrar);
66-
}
67-
6862
private void dispose() {
6963
delegate = null;
7064
if (messenger != null) {
@@ -346,9 +340,6 @@ public static class Delegate
346340
private static final String DEFAULT_GAMES_SIGN_IN = "SignInOption.games";
347341

348342
private final @NonNull Context context;
349-
// Only set registrar for v1 embedder.
350-
@SuppressWarnings("deprecation")
351-
private PluginRegistry.Registrar registrar;
352343
// Only set activity for v2 embedder. Always access activity from getActivity() method.
353344
private @Nullable Activity activity;
354345
// TODO(stuartmorgan): See whether this can be replaced with background channels.
@@ -364,19 +355,13 @@ public Delegate(@NonNull Context context, @NonNull GoogleSignInWrapper googleSig
364355
this.googleSignInWrapper = googleSignInWrapper;
365356
}
366357

367-
@SuppressWarnings("deprecation")
368-
public void setUpRegistrar(@NonNull PluginRegistry.Registrar registrar) {
369-
this.registrar = registrar;
370-
registrar.addActivityResultListener(this);
371-
}
372-
373358
public void setActivity(@Nullable Activity activity) {
374359
this.activity = activity;
375360
}
376361

377362
// Only access activity with this method.
378363
public @Nullable Activity getActivity() {
379-
return registrar != null ? registrar.activity() : activity;
364+
return activity;
380365
}
381366

382367
private void checkAndSetPendingOperation(

packages/google_sign_in/google_sign_in_android/android/src/test/java/io/flutter/plugins/googlesignin/GoogleSignInLegacyMethodChannelTest.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.google.android.gms.common.api.Scope;
2323
import com.google.android.gms.common.api.Status;
2424
import com.google.android.gms.tasks.Task;
25+
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding;
2526
import io.flutter.plugin.common.BinaryMessenger;
2627
import io.flutter.plugin.common.MethodCall;
2728
import io.flutter.plugin.common.MethodChannel;
@@ -48,24 +49,19 @@ public class GoogleSignInLegacyMethodChannelTest {
4849
@Mock GoogleSignInAccount account;
4950
@Mock GoogleSignInClient mockClient;
5051
@Mock Task<GoogleSignInAccount> mockSignInTask;
51-
52-
@SuppressWarnings("deprecation")
53-
@Mock
54-
PluginRegistry.Registrar mockRegistrar;
52+
@Mock ActivityPluginBinding mockActivityPluginBinding;
5553

5654
private GoogleSignInPlugin plugin;
5755
private AutoCloseable mockCloseable;
5856

5957
@Before
6058
public void setUp() {
6159
mockCloseable = MockitoAnnotations.openMocks(this);
62-
when(mockRegistrar.messenger()).thenReturn(mockMessenger);
63-
when(mockRegistrar.context()).thenReturn(mockContext);
64-
when(mockRegistrar.activity()).thenReturn(mockActivity);
6560
when(mockContext.getResources()).thenReturn(mockResources);
61+
when(mockActivityPluginBinding.getActivity()).thenReturn(mockActivity);
6662
plugin = new GoogleSignInPlugin();
67-
plugin.initInstance(mockRegistrar.messenger(), mockRegistrar.context(), mockGoogleSignIn);
68-
plugin.setUpRegistrar(mockRegistrar);
63+
plugin.initInstance(mockMessenger, mockContext, mockGoogleSignIn);
64+
plugin.onAttachedToActivity(mockActivityPluginBinding);
6965
}
7066

7167
@After
@@ -124,7 +120,7 @@ public void requestScopes_ReturnsFalseIfPermissionDenied() {
124120

125121
ArgumentCaptor<PluginRegistry.ActivityResultListener> captor =
126122
ArgumentCaptor.forClass(PluginRegistry.ActivityResultListener.class);
127-
verify(mockRegistrar).addActivityResultListener(captor.capture());
123+
verify(mockActivityPluginBinding).addActivityResultListener(captor.capture());
128124
PluginRegistry.ActivityResultListener listener = captor.getValue();
129125

130126
when(mockGoogleSignIn.getLastSignedInAccount(mockContext)).thenReturn(account);
@@ -149,7 +145,7 @@ public void requestScopes_ReturnsTrueIfPermissionGranted() {
149145

150146
ArgumentCaptor<PluginRegistry.ActivityResultListener> captor =
151147
ArgumentCaptor.forClass(PluginRegistry.ActivityResultListener.class);
152-
verify(mockRegistrar).addActivityResultListener(captor.capture());
148+
verify(mockActivityPluginBinding).addActivityResultListener(captor.capture());
153149
PluginRegistry.ActivityResultListener listener = captor.getValue();
154150

155151
when(mockGoogleSignIn.getLastSignedInAccount(mockContext)).thenReturn(account);
@@ -172,7 +168,7 @@ public void requestScopes_mayBeCalledRepeatedly_ifAlreadyGranted() {
172168

173169
ArgumentCaptor<PluginRegistry.ActivityResultListener> captor =
174170
ArgumentCaptor.forClass(PluginRegistry.ActivityResultListener.class);
175-
verify(mockRegistrar).addActivityResultListener(captor.capture());
171+
verify(mockActivityPluginBinding).addActivityResultListener(captor.capture());
176172
PluginRegistry.ActivityResultListener listener = captor.getValue();
177173

178174
when(mockGoogleSignIn.getLastSignedInAccount(mockContext)).thenReturn(account);
@@ -198,7 +194,7 @@ public void requestScopes_mayBeCalledRepeatedly_ifNotSignedIn() {
198194

199195
ArgumentCaptor<PluginRegistry.ActivityResultListener> captor =
200196
ArgumentCaptor.forClass(PluginRegistry.ActivityResultListener.class);
201-
verify(mockRegistrar).addActivityResultListener(captor.capture());
197+
verify(mockActivityPluginBinding).addActivityResultListener(captor.capture());
202198
PluginRegistry.ActivityResultListener listener = captor.getValue();
203199

204200
when(mockGoogleSignIn.getLastSignedInAccount(mockContext)).thenReturn(null);

0 commit comments

Comments
 (0)