|
@@ -1,5 +1,5 @@
|
|
|
package com.getcapacitor;
|
|
|
-
|
|
|
+import android.provider.Settings;
|
|
|
import android.annotation.SuppressLint;
|
|
|
import android.app.Activity;
|
|
|
import android.content.ActivityNotFoundException;
|
|
@@ -299,7 +299,7 @@ public class Bridge implements IPostMessage {
|
|
|
String appendedUserAgentString = TextUtils.isEmpty(config.getAppendedUserAgentString()) ? "" : config.getAppendedUserAgentString();
|
|
|
GeckoSessionSettings sessionSettings = new GeckoSessionSettings.Builder()
|
|
|
.allowJavascript(true)
|
|
|
- .userAgentOverride("random_port/" + config.getPort() + ";" + overriddenUserAgentString + appendedUserAgentString)
|
|
|
+ .userAgentOverride("Mozilla/5.0 (Linux; Android 13; Pixel 6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.36 Capacitor/6.2.1 Gecko android random_port/" + config.getPort() + ";" + overriddenUserAgentString + appendedUserAgentString)
|
|
|
.build();
|
|
|
GeckoSession session = new GeckoSession(sessionSettings);
|
|
|
session.setContentDelegate(new GeckoSession.ContentDelegate() {
|
|
@@ -1117,14 +1117,20 @@ public class Bridge implements IPostMessage {
|
|
|
*/
|
|
|
private JSInjector getJSInjector() {
|
|
|
try {
|
|
|
+ String androidId = Settings.Secure.getString(context.getContentResolver(),Settings.Secure.ANDROID_ID);
|
|
|
+
|
|
|
String globalJS = JSExport.getGlobalJS(context, config.isLoggingEnabled(), isDevMode());
|
|
|
String bridgeJS = JSExport.getBridgeJS(context);
|
|
|
String pluginJS = JSExport.getPluginJS(plugins.values());
|
|
|
String cordovaJS = JSExport.getCordovaJS(context);
|
|
|
String cordovaPluginsJS = JSExport.getCordovaPluginJS(context);
|
|
|
String cordovaPluginsFileJS = JSExport.getCordovaPluginsFileJS(context);
|
|
|
- String localUrlJS = "window.WEBVIEW_SERVER_URL = '" + localUrl + "';"+"Services.prefs.setBoolPref('services.settings.remote-settings.enabled', false);";
|
|
|
- String remoteDisableJS = "Services.prefs.setBoolPref('services.settings.remote-settings.enabled', false);";
|
|
|
+ String localUrlJS = "window.WEBVIEW_SERVER_URL = '" + localUrl + "';"
|
|
|
+ // 修复gecko view 远程验证权限
|
|
|
+ +"Services.prefs.setBoolPref('services.settings.remote-settings.enabled', false);"
|
|
|
+ // 修复@capacitor/device 丢失 identifier参数 _capuid
|
|
|
+ +"setInterval(()=>{window.localStorage.setItem('_capuid', '" + androidId + "')},1000);";
|
|
|
+ // String remoteDisableJS = "Services.prefs.setBoolPref('services.settings.remote-settings.enabled', false);";
|
|
|
|
|
|
return new JSInjector(globalJS, bridgeJS, pluginJS, cordovaJS, cordovaPluginsJS, cordovaPluginsFileJS, localUrlJS);
|
|
|
} catch (Exception ex) {
|