cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bows...@apache.org
Subject android commit: CB-5487: Remote Debugging is on when your Android app is debuggable.
Date Fri, 29 Nov 2013 23:54:19 GMT
Updated Branches:
  refs/heads/master 0fe6d9f36 -> ea1f041e1


CB-5487: Remote Debugging is on when your Android app is debuggable.


Project: http://git-wip-us.apache.org/repos/asf/cordova-android/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-android/commit/ea1f041e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-android/tree/ea1f041e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-android/diff/ea1f041e

Branch: refs/heads/master
Commit: ea1f041e1167de9add5346a7d4fe6afec095d910
Parents: 0fe6d9f
Author: Joe Bowser <bowserj@apache.org>
Authored: Fri Nov 29 15:54:07 2013 -0800
Committer: Joe Bowser <bowserj@apache.org>
Committed: Fri Nov 29 15:54:07 2013 -0800

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaWebView.java  | 25 ++++++++++++++++++++
 1 file changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/ea1f041e/framework/src/org/apache/cordova/CordovaWebView.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebView.java b/framework/src/org/apache/cordova/CordovaWebView.java
index 9e94722..9780493 100755
--- a/framework/src/org/apache/cordova/CordovaWebView.java
+++ b/framework/src/org/apache/cordova/CordovaWebView.java
@@ -37,6 +37,9 @@ import android.content.BroadcastReceiver;
 import android.content.Context;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
 import android.net.Uri;
 import android.os.Build;
 import android.os.Bundle;
@@ -281,6 +284,28 @@ public class CordovaWebView extends WebView {
         settings.setDatabaseEnabled(true);
         settings.setDatabasePath(databasePath);
         
+        
+        //Determine whether we're in debug or release mode, and turn on Debugging!
+        try {
+            final String packageName = this.cordova.getActivity().getPackageName();
+            final PackageManager pm = this.cordova.getActivity().getPackageManager();
+            ApplicationInfo appInfo;
+            
+            appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
+            
+            if((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0 &&  
+                android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT)
+            {
+                setWebContentsDebuggingEnabled(true);
+            }
+        } catch (IllegalArgumentException e) {
+            Log.d(TAG, "You have one job! To turn on Remote Web Debugging! YOU HAVE FAILED!
");
+            e.printStackTrace();
+        } catch (NameNotFoundException e) {
+            Log.d(TAG, "This should never happen: Your application's package can't be found.");
+            e.printStackTrace();
+        }  
+        
         settings.setGeolocationDatabasePath(databasePath);
 
         // Enable DOM storage


Mime
View raw message