117 lines
4.6 KiB
Java
117 lines
4.6 KiB
Java
package io.flutter.embedding.engine.systemchannels;
|
|
|
|
import io.flutter.Log;
|
|
import io.flutter.embedding.engine.dart.DartExecutor;
|
|
import io.flutter.plugin.common.MethodCall;
|
|
import io.flutter.plugin.common.MethodChannel;
|
|
import io.flutter.plugin.common.StandardMethodCodec;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class RestorationChannel {
|
|
private static final String TAG = "RestorationChannel";
|
|
private MethodChannel channel;
|
|
private boolean engineHasProvidedData;
|
|
private boolean frameworkHasRequestedData;
|
|
private final MethodChannel.MethodCallHandler handler;
|
|
private MethodChannel.Result pendingFrameworkRestorationChannelRequest;
|
|
private byte[] restorationData;
|
|
public final boolean waitForRestorationData;
|
|
|
|
public void clearData() {
|
|
this.restorationData = null;
|
|
}
|
|
|
|
public byte[] getRestorationData() {
|
|
return this.restorationData;
|
|
}
|
|
|
|
public RestorationChannel(DartExecutor dartExecutor, boolean z) {
|
|
this(new MethodChannel(dartExecutor, "flutter/restoration", StandardMethodCodec.INSTANCE), z);
|
|
}
|
|
|
|
RestorationChannel(MethodChannel methodChannel, boolean z) {
|
|
this.engineHasProvidedData = false;
|
|
this.frameworkHasRequestedData = false;
|
|
MethodChannel.MethodCallHandler methodCallHandler = new MethodChannel.MethodCallHandler(this) { // from class: io.flutter.embedding.engine.systemchannels.RestorationChannel.2
|
|
final RestorationChannel this$0;
|
|
|
|
{
|
|
this.this$0 = this;
|
|
}
|
|
|
|
@Override // io.flutter.plugin.common.MethodChannel.MethodCallHandler
|
|
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
|
|
String str = methodCall.method;
|
|
Object obj = methodCall.arguments;
|
|
str.hashCode();
|
|
if (!str.equals("get")) {
|
|
if (str.equals("put")) {
|
|
this.this$0.restorationData = (byte[]) obj;
|
|
result.success(null);
|
|
return;
|
|
}
|
|
result.notImplemented();
|
|
return;
|
|
}
|
|
this.this$0.frameworkHasRequestedData = true;
|
|
if (this.this$0.engineHasProvidedData || !this.this$0.waitForRestorationData) {
|
|
RestorationChannel restorationChannel = this.this$0;
|
|
result.success(restorationChannel.packageData(restorationChannel.restorationData));
|
|
} else {
|
|
this.this$0.pendingFrameworkRestorationChannelRequest = result;
|
|
}
|
|
}
|
|
};
|
|
this.handler = methodCallHandler;
|
|
this.channel = methodChannel;
|
|
this.waitForRestorationData = z;
|
|
methodChannel.setMethodCallHandler(methodCallHandler);
|
|
}
|
|
|
|
public void setRestorationData(byte[] bArr) {
|
|
this.engineHasProvidedData = true;
|
|
MethodChannel.Result result = this.pendingFrameworkRestorationChannelRequest;
|
|
if (result != null) {
|
|
result.success(packageData(bArr));
|
|
this.pendingFrameworkRestorationChannelRequest = null;
|
|
this.restorationData = bArr;
|
|
} else if (this.frameworkHasRequestedData) {
|
|
this.channel.invokeMethod("push", packageData(bArr), new MethodChannel.Result(this, bArr) { // from class: io.flutter.embedding.engine.systemchannels.RestorationChannel.1
|
|
final RestorationChannel this$0;
|
|
final byte[] val$data;
|
|
|
|
@Override // io.flutter.plugin.common.MethodChannel.Result
|
|
public void notImplemented() {
|
|
}
|
|
|
|
{
|
|
this.this$0 = this;
|
|
this.val$data = bArr;
|
|
}
|
|
|
|
@Override // io.flutter.plugin.common.MethodChannel.Result
|
|
public void success(Object obj) {
|
|
this.this$0.restorationData = this.val$data;
|
|
}
|
|
|
|
@Override // io.flutter.plugin.common.MethodChannel.Result
|
|
public void error(String str, String str2, Object obj) {
|
|
Log.e(RestorationChannel.TAG, "Error " + str + " while sending restoration data to framework: " + str2);
|
|
}
|
|
});
|
|
} else {
|
|
this.restorationData = bArr;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public Map<String, Object> packageData(byte[] bArr) {
|
|
HashMap hashMap = new HashMap();
|
|
hashMap.put("enabled", true);
|
|
hashMap.put("data", bArr);
|
|
return hashMap;
|
|
}
|
|
}
|