Files
rr3-apk/decompiled/sources/androidx/webkit/internal/WebMessagePortImpl.java
Daniel Elliott f9d20bb3fc Add decompiled APK source code (JADX)
- 28,932 files
- Full Java source code
- Smali files
- Resources

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-18 14:52:23 -08:00

152 lines
6.5 KiB
Java

package androidx.webkit.internal;
import android.os.Handler;
import android.webkit.WebMessage;
import android.webkit.WebMessagePort;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.webkit.WebMessageCompat;
import androidx.webkit.WebMessagePortCompat;
import androidx.webkit.internal.ApiFeature;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;
import org.chromium.support_lib_boundary.WebMessagePortBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;
/* loaded from: classes.dex */
public class WebMessagePortImpl extends WebMessagePortCompat {
private WebMessagePortBoundaryInterface mBoundaryInterface;
private WebMessagePort mFrameworksImpl;
public WebMessagePortImpl(@NonNull WebMessagePort webMessagePort) {
this.mFrameworksImpl = webMessagePort;
}
public WebMessagePortImpl(@NonNull InvocationHandler invocationHandler) {
this.mBoundaryInterface = (WebMessagePortBoundaryInterface) BoundaryInterfaceReflectionUtil.castToSuppLibClass(WebMessagePortBoundaryInterface.class, invocationHandler);
}
@RequiresApi(23)
private WebMessagePort getFrameworksImpl() {
if (this.mFrameworksImpl == null) {
this.mFrameworksImpl = WebViewGlueCommunicator.getCompatConverter().convertWebMessagePort(Proxy.getInvocationHandler(this.mBoundaryInterface));
}
return this.mFrameworksImpl;
}
private WebMessagePortBoundaryInterface getBoundaryInterface() {
if (this.mBoundaryInterface == null) {
this.mBoundaryInterface = (WebMessagePortBoundaryInterface) BoundaryInterfaceReflectionUtil.castToSuppLibClass(WebMessagePortBoundaryInterface.class, WebViewGlueCommunicator.getCompatConverter().convertWebMessagePort(this.mFrameworksImpl));
}
return this.mBoundaryInterface;
}
@Override // androidx.webkit.WebMessagePortCompat
public void postMessage(@NonNull WebMessageCompat webMessageCompat) {
ApiFeature.M m = WebViewFeatureInternal.WEB_MESSAGE_PORT_POST_MESSAGE;
if (m.isSupportedByFramework() && webMessageCompat.getType() == 0) {
ApiHelperForM.postMessage(getFrameworksImpl(), compatToFrameworkMessage(webMessageCompat));
} else {
if (m.isSupportedByWebView() && WebMessageAdapter.isMessagePayloadTypeSupportedByWebView(webMessageCompat.getType())) {
getBoundaryInterface().postMessage(BoundaryInterfaceReflectionUtil.createInvocationHandlerFor(new WebMessageAdapter(webMessageCompat)));
return;
}
throw WebViewFeatureInternal.getUnsupportedOperationException();
}
}
@Override // androidx.webkit.WebMessagePortCompat
public void close() {
ApiFeature.M m = WebViewFeatureInternal.WEB_MESSAGE_PORT_CLOSE;
if (m.isSupportedByFramework()) {
ApiHelperForM.close(getFrameworksImpl());
} else {
if (m.isSupportedByWebView()) {
getBoundaryInterface().close();
return;
}
throw WebViewFeatureInternal.getUnsupportedOperationException();
}
}
@Override // androidx.webkit.WebMessagePortCompat
public void setWebMessageCallback(@NonNull WebMessagePortCompat.WebMessageCallbackCompat webMessageCallbackCompat) {
ApiFeature.M m = WebViewFeatureInternal.WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK;
if (m.isSupportedByWebView()) {
getBoundaryInterface().setWebMessageCallback(BoundaryInterfaceReflectionUtil.createInvocationHandlerFor(new WebMessageCallbackAdapter(webMessageCallbackCompat)));
} else {
if (m.isSupportedByFramework()) {
ApiHelperForM.setWebMessageCallback(getFrameworksImpl(), webMessageCallbackCompat);
return;
}
throw WebViewFeatureInternal.getUnsupportedOperationException();
}
}
@Override // androidx.webkit.WebMessagePortCompat
public void setWebMessageCallback(@Nullable Handler handler, @NonNull WebMessagePortCompat.WebMessageCallbackCompat webMessageCallbackCompat) {
ApiFeature.M m = WebViewFeatureInternal.CREATE_WEB_MESSAGE_CHANNEL;
if (m.isSupportedByWebView()) {
getBoundaryInterface().setWebMessageCallback(BoundaryInterfaceReflectionUtil.createInvocationHandlerFor(new WebMessageCallbackAdapter(webMessageCallbackCompat)), handler);
} else {
if (m.isSupportedByFramework()) {
ApiHelperForM.setWebMessageCallback(getFrameworksImpl(), webMessageCallbackCompat, handler);
return;
}
throw WebViewFeatureInternal.getUnsupportedOperationException();
}
}
@Override // androidx.webkit.WebMessagePortCompat
@NonNull
@RequiresApi(23)
public WebMessagePort getFrameworkPort() {
return getFrameworksImpl();
}
@Override // androidx.webkit.WebMessagePortCompat
@NonNull
public InvocationHandler getInvocationHandler() {
return Proxy.getInvocationHandler(getBoundaryInterface());
}
@Nullable
public static WebMessagePortCompat[] portsToCompat(@Nullable WebMessagePort[] webMessagePortArr) {
if (webMessagePortArr == null) {
return null;
}
WebMessagePortCompat[] webMessagePortCompatArr = new WebMessagePortCompat[webMessagePortArr.length];
for (int i = 0; i < webMessagePortArr.length; i++) {
webMessagePortCompatArr[i] = new WebMessagePortImpl(webMessagePortArr[i]);
}
return webMessagePortCompatArr;
}
@Nullable
@RequiresApi(23)
public static WebMessagePort[] compatToPorts(@Nullable WebMessagePortCompat[] webMessagePortCompatArr) {
if (webMessagePortCompatArr == null) {
return null;
}
int length = webMessagePortCompatArr.length;
WebMessagePort[] webMessagePortArr = new WebMessagePort[length];
for (int i = 0; i < length; i++) {
webMessagePortArr[i] = webMessagePortCompatArr[i].getFrameworkPort();
}
return webMessagePortArr;
}
@NonNull
@RequiresApi(23)
public static WebMessage compatToFrameworkMessage(@NonNull WebMessageCompat webMessageCompat) {
return ApiHelperForM.createWebMessage(webMessageCompat);
}
@NonNull
@RequiresApi(23)
public static WebMessageCompat frameworkMessageToCompat(@NonNull WebMessage webMessage) {
return ApiHelperForM.createWebMessageCompat(webMessage);
}
}