feat: InspectableWebview preference (#1589)

This commit is contained in:
Norman Breau 2023-04-09 20:41:00 -03:00 committed by GitHub
parent b91639dbb5
commit a78fad1783
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -175,9 +175,20 @@ public class SystemWebViewEngine implements CordovaWebViewEngine {
String databasePath = webView.getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath(); String databasePath = webView.getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
settings.setDatabaseEnabled(true); settings.setDatabaseEnabled(true);
//Determine whether we're in debug or release mode, and turn on Debugging! // The default is to use the module's debuggable state to decide if the webview inspecter
ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo(); // should be enabled. However, users can configure InspectableWebview preference to forcefully enable
if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { // or disable the webview inspecter.
String inspectableWebview = preferences.getString("InspectableWebview", null);
boolean shouldEnableInspector = false;
if (inspectableWebview == null) {
ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo();
shouldEnableInspector = (appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
}
else if ("true".equals(inspectableWebview)) {
shouldEnableInspector = true;
}
if (shouldEnableInspector) {
enableRemoteDebugging(); enableRemoteDebugging();
} }