Reland isolate platform channels with conditional compilation (#111712)

This commit is contained in:
gaaclarke
2022-09-19 09:52:33 -07:00
committed by GitHub
parent cb8c72545c
commit a7166e7a4e
10 changed files with 217 additions and 11 deletions

View File

@@ -18,6 +18,7 @@ found in the LICENSE file. -->
Application and put your custom class here. -->
<application android:name="${applicationName}" android:label="channels" android:icon="@mipmap/ic_launcher">
<activity android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Black.NoTitleBar"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"

View File

@@ -29,6 +29,15 @@ public class MainActivity extends FlutterActivity {
setupMessageHandshake(new BasicMessageChannel<>(dartExecutor, "std-msg", ExtendedStandardMessageCodec.INSTANCE));
setupMethodHandshake(new MethodChannel(dartExecutor, "json-method", JSONMethodCodec.INSTANCE));
setupMethodHandshake(new MethodChannel(dartExecutor, "std-method", new StandardMethodCodec(ExtendedStandardMessageCodec.INSTANCE)));
BasicMessageChannel echoChannel =
new BasicMessageChannel(dartExecutor, "std-echo", ExtendedStandardMessageCodec.INSTANCE);
echoChannel.setMessageHandler(new BasicMessageChannel.MessageHandler(){
@Override
public void onMessage(final Object message, final BasicMessageChannel.Reply reply) {
reply.reply(message);
}
});
}
private <T> void setupMessageHandshake(final BasicMessageChannel<T> channel) {