5package io.flutter.embedding.engine.systemchannels;
7import androidx.annotation.NonNull;
8import androidx.annotation.Nullable;
10import io.flutter.embedding.engine.dart.DartExecutor;
11import io.flutter.plugin.common.MethodCall;
12import io.flutter.plugin.common.MethodChannel;
13import io.flutter.plugin.common.StandardMethodCodec;
14import java.util.HashMap;
35 private static final String TAG =
"RestorationChannel";
45 this.channel = channel;
69 private byte[] restorationData;
71 private MethodChannel.Result pendingFrameworkRestorationChannelRequest;
72 private boolean engineHasProvidedData =
false;
73 private boolean frameworkHasRequestedData =
false;
78 return restorationData;
83 engineHasProvidedData =
true;
84 if (pendingFrameworkRestorationChannelRequest !=
null) {
86 pendingFrameworkRestorationChannelRequest.success(packageData(
data));
87 pendingFrameworkRestorationChannelRequest =
null;
88 restorationData =
data;
89 }
else if (frameworkHasRequestedData) {
100 public void success(Object result) {
101 restorationData = data;
105 public void error(String errorCode, String errorMessage, Object errorDetails) {
110 +
" while sending restoration data to framework: "
115 public void notImplemented() {
121 restorationData =
data;
132 restorationData =
null;
135 private final MethodChannel.MethodCallHandler handler =
139 final String method =
call.method;
143 restorationData = (
byte[])
args;
147 frameworkHasRequestedData =
true;
148 if (engineHasProvidedData || !waitForRestorationData) {
149 result.success(packageData(restorationData));
155 pendingFrameworkRestorationChannelRequest =
result;
165 private Map<String, Object> packageData(
byte[]
data) {
166 final Map<String, Object> packaged =
new HashMap<String, Object>();
167 packaged.put(
"enabled",
true);
168 packaged.put(
"data",
data);
static void e(@NonNull String tag, @NonNull String message)
RestorationChannel( @NonNull DartExecutor dartExecutor, @NonNull boolean waitForRestorationData)
byte[] getRestorationData()
RestorationChannel(MethodChannel channel, @NonNull boolean waitForRestorationData)
final boolean waitForRestorationData
void setRestorationData(@NonNull byte[] data)
void setMethodCallHandler(final @Nullable MethodCallHandler handler)
void invokeMethod(@NonNull String method, @Nullable Object arguments)
static final StandardMethodCodec INSTANCE
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
const uint8_t uint32_t uint32_t GError ** error
std::shared_ptr< const fml::Mapping > data