Skip to content

Commit

Permalink
feat: InspectableWebview preference (#1589)
Browse files Browse the repository at this point in the history
  • Loading branch information
breautek committed Apr 9, 2023
1 parent b91639d commit a78fad1
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions framework/src/org/apache/cordova/engine/SystemWebViewEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,20 @@ private void initWebViewSettings() {
String databasePath = webView.getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
settings.setDatabaseEnabled(true);

//Determine whether we're in debug or release mode, and turn on Debugging!
ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo();
if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
// The default is to use the module's debuggable state to decide if the webview inspecter
// should be enabled. However, users can configure InspectableWebview preference to forcefully enable
// 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();
}

Expand Down

0 comments on commit a78fad1

Please sign in to comment.