Skip to content

Commit 472a8e0

Browse files
authored
Revert "Fix ensureInitializationCompleteAsync callback when already initialized. (flutter#39675) (flutter#16503)"
This reverts commit 59b1650.
1 parent 9506021 commit 472a8e0

File tree

2 files changed

+1
-60
lines changed

2 files changed

+1
-60
lines changed

shell/platform/android/io/flutter/embedding/engine/loader/FlutterLoader.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ public void ensureInitializationCompleteAsync(
234234
"ensureInitializationComplete must be called after startInitialization");
235235
}
236236
if (initialized) {
237-
callbackHandler.post(callback);
238237
return;
239238
}
240239
new Thread(
Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
package dev.flutter.scenarios;
22

33
import android.Manifest;
4-
import android.content.Context;
54
import android.content.Intent;
65
import android.net.Uri;
76
import android.os.Build;
87
import android.os.Bundle;
98
import android.os.Handler;
10-
import android.os.Looper;
119
import android.support.annotation.NonNull;
1210
import io.flutter.Log;
1311
import io.flutter.embedding.android.FlutterActivity;
1412
import io.flutter.embedding.engine.FlutterEngine;
1513
import io.flutter.embedding.engine.FlutterShellArgs;
16-
import io.flutter.embedding.engine.loader.FlutterLoader;
1714
import io.flutter.plugin.common.BasicMessageChannel;
1815
import io.flutter.plugin.common.BinaryCodec;
1916
import java.io.FileDescriptor;
2017
import java.io.FileOutputStream;
2118
import java.io.IOException;
2219
import java.nio.ByteBuffer;
23-
import java.util.concurrent.atomic.AtomicBoolean;
2420

2521
public class TextPlatformViewActivity extends FlutterActivity {
2622
static final String TAG = "Scenarios";
@@ -35,19 +31,7 @@ protected void onCreate(Bundle savedInstanceState) {
3531
}
3632
// Run for one minute, get the timeline data, write it, and finish.
3733
final Uri logFileUri = launchIntent.getData();
38-
new Handler()
39-
.postDelayed(
40-
new Runnable() {
41-
@Override
42-
public void run() {
43-
writeTimelineData(logFileUri);
44-
45-
testFlutterLoaderCallbackWhenInitializedTwice();
46-
}
47-
},
48-
20000);
49-
} else {
50-
testFlutterLoaderCallbackWhenInitializedTwice();
34+
new Handler().postDelayed(() -> writeTimelineData(logFileUri), 20000);
5135
}
5236
}
5337

@@ -96,46 +80,4 @@ private void writeTimelineData(Uri logFile) {
9680
finish();
9781
});
9882
}
99-
100-
/**
101-
* This method verifies that {@link FlutterLoader#ensureInitializationCompleteAsync(Context,
102-
* String[], Handler, Runnable)} invokes its callback when called after initialization.
103-
*/
104-
private void testFlutterLoaderCallbackWhenInitializedTwice() {
105-
FlutterLoader flutterLoader = new FlutterLoader();
106-
107-
// Flutter is probably already loaded in this app based on
108-
// code that ran before this method. Nonetheless, invoke the
109-
// blocking initialization here to ensure it's initialized.
110-
flutterLoader.startInitialization(getApplicationContext());
111-
flutterLoader.ensureInitializationComplete(getApplication(), new String[] {});
112-
113-
// Now that Flutter is loaded, invoke ensureInitializationCompleteAsync with
114-
// a callback and verify that the callback is invoked.
115-
Handler mainHandler = new Handler(Looper.getMainLooper());
116-
117-
final AtomicBoolean didInvokeCallback = new AtomicBoolean(false);
118-
119-
flutterLoader.ensureInitializationCompleteAsync(
120-
getApplication(),
121-
new String[] {},
122-
mainHandler,
123-
new Runnable() {
124-
@Override
125-
public void run() {
126-
didInvokeCallback.set(true);
127-
}
128-
});
129-
130-
mainHandler.post(
131-
new Runnable() {
132-
@Override
133-
public void run() {
134-
if (!didInvokeCallback.get()) {
135-
throw new RuntimeException(
136-
"Failed test: FlutterLoader#ensureInitializationCompleteAsync() did not invoke its callback.");
137-
}
138-
}
139-
});
140-
}
14183
}

0 commit comments

Comments
 (0)