forked from github/cordova-android
feat: InspectableWebview preference (#1589)
This commit is contained in:
parent
b91639dbb5
commit
a78fad1783
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user