You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by bo...@apache.org on 2014/08/14 23:21:09 UTC

[01/10] android commit: CB-7172 Force window to have focus after resume

Repository: cordova-android
Updated Branches:
  refs/heads/4.0.x f9b8f9a45 -> a7ccb9243


CB-7172 Force window to have focus after resume

Workaround for some devices (Samsung Galaxy Note 3 at least)

github: close #108


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

Branch: refs/heads/4.0.x
Commit: c2cafb4b45fcbb307a113828dfc9f723f8a6433b
Parents: 67f474e
Author: Andrey Kurdyumov <ka...@gmail.com>
Authored: Sun Jul 20 00:28:44 2014 +0600
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Tue Jul 22 22:33:53 2014 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/CordovaActivity.java | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c2cafb4b/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaActivity.java b/framework/src/org/apache/cordova/CordovaActivity.java
index 4a46c80..2fdb9a7 100755
--- a/framework/src/org/apache/cordova/CordovaActivity.java
+++ b/framework/src/org/apache/cordova/CordovaActivity.java
@@ -604,6 +604,9 @@ public class CordovaActivity extends Activity implements CordovaInterface {
         if (this.appView == null) {
             return;
         }
+        // Force window to have focus, so application always
+        // receive user input. Workaround for some devices (Samsung Galaxy Note 3 at least)
+        this.getWindow().getDecorView().requestFocus();
 
         this.appView.handleResume(this.keepRunning, this.activityResultKeepRunning);
 


[07/10] android commit: CB-7265 Fix crash when navigating to custom protocol (introduced in 3.5.1)

Posted by bo...@apache.org.
CB-7265 Fix crash when navigating to custom protocol (introduced in 3.5.1)

Conflicts:
	framework/src/org/apache/cordova/CordovaUriHelper.java

Github: close #111


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

Branch: refs/heads/4.0.x
Commit: 73219bf2d22a7057f19b6dd9cd8fd24632316d90
Parents: d6eb723
Author: Martin Bektchiev <ma...@telerik.com>
Authored: Wed Aug 6 15:24:51 2014 +0300
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Aug 7 09:58:40 2014 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/CordovaUriHelper.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/73219bf2/framework/src/org/apache/cordova/CordovaUriHelper.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaUriHelper.java b/framework/src/org/apache/cordova/CordovaUriHelper.java
index dcbaeb5..bb78592 100644
--- a/framework/src/org/apache/cordova/CordovaUriHelper.java
+++ b/framework/src/org/apache/cordova/CordovaUriHelper.java
@@ -19,8 +19,10 @@
 
 package org.apache.cordova;
 
+import android.annotation.TargetApi;
 import android.content.Intent;
 import android.net.Uri;
+import android.os.Build;
 import android.webkit.WebView;
 
 class CordovaUriHelper {
@@ -44,6 +46,7 @@ class CordovaUriHelper {
      * @param url           The url to be loaded.
      * @return              true to override, false for default behavior
      */
+    @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
     boolean shouldOverrideUrlLoading(WebView view, String url) {
         // The WebView should support http and https when going on the Internet
         if(url.startsWith("http:") || url.startsWith("https:"))
@@ -71,7 +74,9 @@ class CordovaUriHelper {
                 intent.setData(Uri.parse(url));
                 intent.addCategory(Intent.CATEGORY_BROWSABLE);
                 intent.setComponent(null);
-                intent.setSelector(null);
+                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
+                    intent.setSelector(null);
+                }
                 this.cordova.getActivity().startActivity(intent);
             } catch (android.content.ActivityNotFoundException e) {
                 LOG.e(TAG, "Error loading url " + url, e);


[10/10] android commit: Merging latest master, including new tests

Posted by bo...@apache.org.
Merging latest master, including new tests


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

Branch: refs/heads/4.0.x
Commit: a7ccb9243daf3dfaa0f2538492dccaa4d140ba58
Parents: f9b8f9a 320e31b
Author: Joe Bowser <bo...@apache.org>
Authored: Thu Aug 14 14:20:49 2014 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Aug 14 14:20:49 2014 -0700

----------------------------------------------------------------------
 .../apache/cordova/AndroidWebViewClient.java    | 14 +++-
 .../src/org/apache/cordova/CordovaActivity.java |  3 +
 .../org/apache/cordova/CordovaUriHelper.java    |  9 +++
 .../apache/cordova/NativeToJsMessageQueue.java  | 13 ++--
 framework/src/org/apache/cordova/Whitelist.java |  8 +--
 test/assets/www/error.html                      |  8 +++
 .../test/CordovaWebViewTestActivity.java        |  9 ++-
 .../apache/cordova/test/SabotagedActivity.java  | 73 ++++++++++++++++++++
 .../test/junit/IntentUriOverrideTest.java       | 73 ++++++++++++++++++++
 9 files changed, 198 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a7ccb924/framework/src/org/apache/cordova/AndroidWebViewClient.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/AndroidWebViewClient.java
index 44862a6,0000000..c017177
mode 100755,000000..100755
--- a/framework/src/org/apache/cordova/AndroidWebViewClient.java
+++ b/framework/src/org/apache/cordova/AndroidWebViewClient.java
@@@ -1,318 -1,0 +1,330 @@@
 +/*
 +       Licensed to the Apache Software Foundation (ASF) under one
 +       or more contributor license agreements.  See the NOTICE file
 +       distributed with this work for additional information
 +       regarding copyright ownership.  The ASF licenses this file
 +       to you under the Apache License, Version 2.0 (the
 +       "License"); you may not use this file except in compliance
 +       with the License.  You may obtain a copy of the License at
 +
 +         http://www.apache.org/licenses/LICENSE-2.0
 +
 +       Unless required by applicable law or agreed to in writing,
 +       software distributed under the License is distributed on an
 +       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 +       KIND, either express or implied.  See the License for the
 +       specific language governing permissions and limitations
 +       under the License.
 +*/
 +package org.apache.cordova;
 +
 +import java.util.Hashtable;
 +
 +import org.json.JSONException;
 +import org.json.JSONObject;
 +
 +import android.annotation.TargetApi;
 +import android.content.pm.ApplicationInfo;
 +import android.content.pm.PackageManager;
 +import android.content.pm.PackageManager.NameNotFoundException;
 +import android.graphics.Bitmap;
 +import android.net.http.SslError;
 +import android.view.View;
 +import android.webkit.HttpAuthHandler;
 +import android.webkit.SslErrorHandler;
 +import android.webkit.WebView;
 +import android.webkit.WebViewClient;
 +
 +
 +/**
 + * This class is the WebViewClient that implements callbacks for our web view.
 + * The kind of callbacks that happen here are regarding the rendering of the
 + * document instead of the chrome surrounding it, such as onPageStarted(), 
 + * shouldOverrideUrlLoading(), etc. Related to but different than
 + * CordovaChromeClient.
 + *
 + * @see <a href="http://developer.android.com/reference/android/webkit/WebViewClient.html">WebViewClient</a>
 + * @see <a href="http://developer.android.com/guide/webapps/webview.html">WebView guide</a>
 + * @see CordovaChromeClient
 + * @see CordovaWebView
 + */
 +public class AndroidWebViewClient extends WebViewClient {
 +
 +    private static final String TAG = "AndroidWebViewClient";
 +    protected final CordovaInterface cordova;
 +    protected final AndroidWebView appView;
 +    protected final CordovaUriHelper helper;
 +    private boolean doClearHistory = false;
 +    boolean isCurrentlyLoading;
 +
 +    /** The authorization tokens. */
 +    private Hashtable<String, AuthenticationToken> authenticationTokens = new Hashtable<String, AuthenticationToken>();
 +
 +    public AndroidWebViewClient(CordovaInterface cordova, AndroidWebView view) {
 +        this.cordova = cordova;
 +        this.appView = view;
 +        helper = new CordovaUriHelper(cordova, view);
 +    }
 +
 +    /**
 +     * Give the host application a chance to take over the control when a new url
 +     * is about to be loaded in the current WebView.
 +     *
 +     * @param view          The WebView that is initiating the callback.
 +     * @param url           The url to be loaded.
 +     * @return              true to override, false for default behavior
 +     */
 +	@Override
 +    public boolean shouldOverrideUrlLoading(WebView view, String url) {
 +        return helper.shouldOverrideUrlLoading(url);
 +    }
 +    
 +    /**
 +     * On received http auth request.
 +     * The method reacts on all registered authentication tokens. There is one and only one authentication token for any host + realm combination
 +     */
 +    @Override
 +    public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
 +
 +        // Get the authentication token
 +        AuthenticationToken token = this.getAuthenticationToken(host, realm);
 +        if (token != null) {
 +            handler.proceed(token.getUserName(), token.getPassword());
 +        }
 +        else {
 +            // Handle 401 like we'd normally do!
 +            super.onReceivedHttpAuthRequest(view, handler, host, realm);
 +        }
 +    }
 +
 +    /**
 +     * Notify the host application that a page has started loading.
 +     * This method is called once for each main frame load so a page with iframes or framesets will call onPageStarted
 +     * one time for the main frame. This also means that onPageStarted will not be called when the contents of an
 +     * embedded frame changes, i.e. clicking a link whose target is an iframe.
 +     *
 +     * @param view          The webview initiating the callback.
 +     * @param url           The url of the page.
 +     */
 +    @Override
 +    public void onPageStarted(WebView view, String url, Bitmap favicon) {
 +        super.onPageStarted(view, url, favicon);
 +        isCurrentlyLoading = true;
 +        LOG.d(TAG, "onPageStarted(" + url + ")");
 +        // Flush stale messages & reset plugins.
 +        this.appView.onPageReset();
 +
 +        // Broadcast message that page has loaded
 +        this.appView.getPluginManager().postMessage("onPageStarted", url);
 +    }
 +
 +    /**
 +     * Notify the host application that a page has finished loading.
 +     * This method is called only for main frame. When onPageFinished() is called, the rendering picture may not be updated yet.
 +     *
 +     *
 +     * @param view          The webview initiating the callback.
 +     * @param url           The url of the page.
 +     */
 +    @Override
 +    public void onPageFinished(WebView view, String url) {
 +        super.onPageFinished(view, url);
 +        // Ignore excessive calls.
 +        if (!isCurrentlyLoading) {
 +            return;
 +        }
 +        isCurrentlyLoading = false;
 +        LOG.d(TAG, "onPageFinished(" + url + ")");
 +
 +        /**
 +         * Because of a timing issue we need to clear this history in onPageFinished as well as
 +         * onPageStarted. However we only want to do this if the doClearHistory boolean is set to
 +         * true. You see when you load a url with a # in it which is common in jQuery applications
 +         * onPageStared is not called. Clearing the history at that point would break jQuery apps.
 +         */
 +        if (this.doClearHistory) {
 +            view.clearHistory();
 +            this.doClearHistory = false;
 +        }
 +
 +        // Clear timeout flag
 +        appView.loadUrlTimeout++;
 +
 +        // Broadcast message that page has loaded
 +        this.appView.getPluginManager().postMessage("onPageFinished", url);
 +
 +        // Make app visible after 2 sec in case there was a JS error and Cordova JS never initialized correctly
 +        if (this.appView.getVisibility() == View.INVISIBLE) {
 +            Thread t = new Thread(new Runnable() {
 +                public void run() {
 +                    try {
 +                        Thread.sleep(2000);
 +                        cordova.getActivity().runOnUiThread(new Runnable() {
 +                            public void run() {
 +                                appView.getPluginManager().postMessage("spinner", "stop");
 +                            }
 +                        });
 +                    } catch (InterruptedException e) {
 +                    }
 +                }
 +            });
 +            t.start();
 +        }
 +
 +        // Shutdown if blank loaded
 +        if (url.equals("about:blank")) {
 +            appView.getPluginManager().postMessage("exit", null);
 +        }
 +    }
 +
 +    /**
 +     * Report an error to the host application. These errors are unrecoverable (i.e. the main resource is unavailable).
 +     * The errorCode parameter corresponds to one of the ERROR_* constants.
 +     *
 +     * @param view          The WebView that is initiating the callback.
 +     * @param errorCode     The error code corresponding to an ERROR_* value.
 +     * @param description   A String describing the error.
 +     * @param failingUrl    The url that failed to load.
 +     */
 +    @Override
 +    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
 +        // Ignore error due to stopLoading().
 +        if (!isCurrentlyLoading) {
 +            return;
 +        }
 +        LOG.d(TAG, "CordovaWebViewClient.onReceivedError: Error code=%s Description=%s URL=%s", errorCode, description, failingUrl);
 +
 +        // Clear timeout flag
 +        appView.loadUrlTimeout++;
 +
-         // Handle error
++        // If this is a "Protocol Not Supported" error, then revert to the previous
++        // page. If there was no previous page, then punt. The application's config
++        // is likely incorrect (start page set to sms: or something like that)
++        if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
++            if (view.canGoBack()) {
++                view.goBack();
++                return;
++            } else {
++                super.onReceivedError(view, errorCode, description, failingUrl);
++            }
++        }
++
++        // Handle other errors by passing them to the webview in JS
 +        JSONObject data = new JSONObject();
 +        try {
 +            data.put("errorCode", errorCode);
 +            data.put("description", description);
 +            data.put("url", failingUrl);
 +        } catch (JSONException e) {
 +            e.printStackTrace();
 +        }
 +        this.appView.getPluginManager().postMessage("onReceivedError", data);
 +    }
 +
 +    /**
 +     * Notify the host application that an SSL error occurred while loading a resource.
 +     * The host application must call either handler.cancel() or handler.proceed().
 +     * Note that the decision may be retained for use in response to future SSL errors.
 +     * The default behavior is to cancel the load.
 +     *
 +     * @param view          The WebView that is initiating the callback.
 +     * @param handler       An SslErrorHandler object that will handle the user's response.
 +     * @param error         The SSL error object.
 +     */
 +    @TargetApi(8)
 +    @Override
 +    public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
 +
 +        final String packageName = this.cordova.getActivity().getPackageName();
 +        final PackageManager pm = this.cordova.getActivity().getPackageManager();
 +
 +        ApplicationInfo appInfo;
 +        try {
 +            appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
 +            if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
 +                // debug = true
 +                handler.proceed();
 +                return;
 +            } else {
 +                // debug = false
 +                super.onReceivedSslError(view, handler, error);
 +            }
 +        } catch (NameNotFoundException e) {
 +            // When it doubt, lock it out!
 +            super.onReceivedSslError(view, handler, error);
 +        }
 +    }
 +
 +
 +    /**
 +     * Sets the authentication token.
 +     *
 +     * @param authenticationToken
 +     * @param host
 +     * @param realm
 +     */
 +    public void setAuthenticationToken(AuthenticationToken authenticationToken, String host, String realm) {
 +        if (host == null) {
 +            host = "";
 +        }
 +        if (realm == null) {
 +            realm = "";
 +        }
 +        this.authenticationTokens.put(host.concat(realm), authenticationToken);
 +    }
 +
 +    /**
 +     * Removes the authentication token.
 +     *
 +     * @param host
 +     * @param realm
 +     *
 +     * @return the authentication token or null if did not exist
 +     */
 +    public AuthenticationToken removeAuthenticationToken(String host, String realm) {
 +        return this.authenticationTokens.remove(host.concat(realm));
 +    }
 +
 +    /**
 +     * Gets the authentication token.
 +     *
 +     * In order it tries:
 +     * 1- host + realm
 +     * 2- host
 +     * 3- realm
 +     * 4- no host, no realm
 +     *
 +     * @param host
 +     * @param realm
 +     *
 +     * @return the authentication token
 +     */
 +    public AuthenticationToken getAuthenticationToken(String host, String realm) {
 +        AuthenticationToken token = null;
 +        token = this.authenticationTokens.get(host.concat(realm));
 +
 +        if (token == null) {
 +            // try with just the host
 +            token = this.authenticationTokens.get(host);
 +
 +            // Try the realm
 +            if (token == null) {
 +                token = this.authenticationTokens.get(realm);
 +            }
 +
 +            // if no host found, just query for default
 +            if (token == null) {
 +                token = this.authenticationTokens.get("");
 +            }
 +        }
 +
 +        return token;
 +    }
 +
 +    /**
 +     * Clear all authentication tokens.
 +     */
 +    public void clearAuthenticationTokens() {
 +        this.authenticationTokens.clear();
 +    }
 +}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a7ccb924/framework/src/org/apache/cordova/CordovaActivity.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a7ccb924/framework/src/org/apache/cordova/CordovaUriHelper.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/CordovaUriHelper.java
index 077e425,bb78592..f7d22da
--- a/framework/src/org/apache/cordova/CordovaUriHelper.java
+++ b/framework/src/org/apache/cordova/CordovaUriHelper.java
@@@ -19,10 -19,13 +19,13 @@@
  
  package org.apache.cordova;
  
+ import android.annotation.TargetApi;
  import android.content.Intent;
  import android.net.Uri;
+ import android.os.Build;
+ import android.webkit.WebView;
  
 -class CordovaUriHelper {
 +public class CordovaUriHelper {
      
      private static final String TAG = "CordovaUriHelper";
      
@@@ -43,7 -46,8 +46,8 @@@
       * @param url           The url to be loaded.
       * @return              true to override, false for default behavior
       */
+     @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
 -    boolean shouldOverrideUrlLoading(WebView view, String url) {
 +    public boolean shouldOverrideUrlLoading(String url) {
          // The WebView should support http and https when going on the Internet
          if(url.startsWith("http:") || url.startsWith("https:"))
          {

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a7ccb924/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a7ccb924/test/assets/www/error.html
----------------------------------------------------------------------
diff --cc test/assets/www/error.html
index 0000000,0000000..aad167d
new file mode 100644
--- /dev/null
+++ b/test/assets/www/error.html
@@@ -1,0 -1,0 +1,8 @@@
++<html>
++    <head>
++        <title>OH NOES!</title>
++    </head>
++    <body>
++        <h1>Things went terribly wrong!</h1>
++    </body>
++</html>

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/a7ccb924/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
----------------------------------------------------------------------
diff --cc test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
index 6f96e83,1c1789e..b143521
--- a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
+++ b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
@@@ -22,7 -22,8 +22,9 @@@ package org.apache.cordova.test
  import java.util.concurrent.ExecutorService;
  import java.util.concurrent.Executors;
  
++import org.apache.cordova.AndroidChromeClient;
++import org.apache.cordova.AndroidWebViewClient;
  import org.apache.cordova.Config;
 -import org.apache.cordova.CordovaChromeClient;
  import org.apache.cordova.CordovaWebView;
  import org.apache.cordova.CordovaInterface;
  import org.apache.cordova.CordovaPlugin;
@@@ -45,10 -47,12 +47,11 @@@ public class CordovaWebViewTestActivit
  
          setContentView(R.layout.main);
  
-         cordovaWebView = (CordovaWebView) findViewById(R.id.cordovaWebView);
+         //CB-7238: This has to be added now, because it got removed from somewhere else
          Config.init(this);
-         cordovaWebView.init(this,
-                 Config.getPluginEntries(), Config.getWhitelist(), Config.getPreferences());
+         
+         cordovaWebView = (CordovaWebView) findViewById(R.id.cordovaWebView);
 -        cordovaWebView.init(this, new CordovaWebViewClient(this, cordovaWebView), new CordovaChromeClient(this, cordovaWebView),
 -                Config.getPluginEntries(), Config.getWhitelist(), Config.getPreferences());
++        cordovaWebView.init(this, Config.getPluginEntries(), Config.getWhitelist(), Config.getPreferences());
  
          cordovaWebView.loadUrl("file:///android_asset/www/index.html");
  


[06/10] android commit: Handle unsupported protocol errors in webview better

Posted by bo...@apache.org.
Handle unsupported protocol errors in webview better


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

Branch: refs/heads/4.0.x
Commit: 993d73762caaf02e2d5045fb9e60345e2a8bf6ac
Parents: 48b51c4
Author: Ian Clelland <ic...@chromium.org>
Authored: Mon Jul 21 09:20:49 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Wed Aug 6 09:55:03 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/CordovaWebViewClient.java  | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/993d7376/framework/src/org/apache/cordova/CordovaWebViewClient.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaWebViewClient.java b/framework/src/org/apache/cordova/CordovaWebViewClient.java
index a2cf0be..f65a976 100755
--- a/framework/src/org/apache/cordova/CordovaWebViewClient.java
+++ b/framework/src/org/apache/cordova/CordovaWebViewClient.java
@@ -231,7 +231,19 @@ public class CordovaWebViewClient extends WebViewClient {
         // Clear timeout flag
         this.appView.loadUrlTimeout++;
 
-        // Handle error
+        // If this is a "Protocol Not Supported" error, then revert to the previous
+        // page. If there was no previous page, then punt. The application's config
+        // is likely incorrect (start page set to sms: or something like that)
+        if (errorCode == WebViewClient.ERROR_UNSUPPORTED_SCHEME) {
+            if (view.canGoBack()) {
+                view.goBack();
+                return;
+            } else {
+                super.onReceivedError(view, errorCode, description, failingUrl);
+            }
+        }
+
+        // Handle other errors by passing them to the webview in JS
         JSONObject data = new JSONObject();
         try {
             data.put("errorCode", errorCode);


[03/10] android commit: CB-7238: Minor band-aid to get tests running again, this has to go away before 3.6.0 is released, since this is an API change.

Posted by bo...@apache.org.
CB-7238: Minor band-aid to get tests running again, this has to go away before 3.6.0 is released, since this is an API change.


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

Branch: refs/heads/4.0.x
Commit: 3d191d5884ef66d97cbf89bd1347cf2da1d4dacf
Parents: 955133f
Author: Joe Bowser <bo...@apache.org>
Authored: Thu Jul 31 08:17:31 2014 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Jul 31 08:17:31 2014 -0700

----------------------------------------------------------------------
 test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/3d191d58/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
index 06070cc..f9382d9 100644
--- a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
+++ b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
@@ -47,6 +47,9 @@ public class CordovaWebViewTestActivity extends Activity implements CordovaInter
 
         setContentView(R.layout.main);
 
+        //CB-7238: This has to be added now, because it got removed from somewhere else
+        Config.init(this);
+        
         cordovaWebView = (CordovaWebView) findViewById(R.id.cordovaWebView);
         Config.init(this);
         cordovaWebView.init(this, new CordovaWebViewClient(this, cordovaWebView), new CordovaChromeClient(this, cordovaWebView),


[08/10] android commit: CB-7261 Fix setNativeToJsBridgeMode sometimes crashing when switching to ONLINE_EVENT

Posted by bo...@apache.org.
CB-7261 Fix setNativeToJsBridgeMode sometimes crashing when switching to ONLINE_EVENT


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

Branch: refs/heads/4.0.x
Commit: 41125ea1e2ce9bff3191f57d88c10c277cbb3e94
Parents: 73219bf
Author: Andrew Grieve <ag...@chromium.org>
Authored: Thu Aug 7 16:18:56 2014 -0400
Committer: Andrew Grieve <ag...@chromium.org>
Committed: Thu Aug 7 16:18:56 2014 -0400

----------------------------------------------------------------------
 .../src/org/apache/cordova/NativeToJsMessageQueue.java | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/41125ea1/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
index d05eed8..497366f 100755
--- a/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
+++ b/framework/src/org/apache/cordova/NativeToJsMessageQueue.java
@@ -321,11 +321,16 @@ public class NativeToJsMessageQueue {
                 }
             }
         };
+        final Runnable resetNetworkRunnable = new Runnable() {
+            public void run() {
+                online = false;
+                // If the following call triggers a notifyOfFlush, then ignore it.
+                ignoreNextFlush = true;
+                webView.setNetworkAvailable(true);
+            }
+        };
         @Override void reset() {
-            online = false;
-            // If the following call triggers a notifyOfFlush, then ignore it.
-            ignoreNextFlush = true;
-            webView.setNetworkAvailable(true);
+            cordova.getActivity().runOnUiThread(resetNetworkRunnable);
         }
         @Override void onNativeToJsMessageAvailable() {
             cordova.getActivity().runOnUiThread(toggleNetworkRunnable);


[09/10] android commit: Adding tests related to 3.5.1

Posted by bo...@apache.org.
Adding tests related to 3.5.1


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

Branch: refs/heads/4.0.x
Commit: 320e31bb105cf6401e646f45810ef3c136bf5ab9
Parents: 41125ea
Author: Joe Bowser <bo...@apache.org>
Authored: Tue Aug 12 11:09:53 2014 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Tue Aug 12 11:09:53 2014 -0700

----------------------------------------------------------------------
 .../apache/cordova/test/SabotagedActivity.java  | 73 ++++++++++++++++++++
 .../test/junit/IntentUriOverrideTest.java       | 73 ++++++++++++++++++++
 2 files changed, 146 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/320e31bb/test/src/org/apache/cordova/test/SabotagedActivity.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/SabotagedActivity.java b/test/src/org/apache/cordova/test/SabotagedActivity.java
new file mode 100644
index 0000000..e1170ba
--- /dev/null
+++ b/test/src/org/apache/cordova/test/SabotagedActivity.java
@@ -0,0 +1,73 @@
+package org.apache.cordova.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.FileOutputStream;
+
+import org.apache.cordova.Config;
+import org.apache.cordova.CordovaActivity;
+
+import android.content.res.AssetManager;
+import android.os.Bundle;
+import android.os.Environment;
+import android.util.Log;
+
+public class SabotagedActivity extends CordovaActivity {
+
+    private String BAD_ASSET = "www/error.html";
+    private String LOG_TAG = "SabotagedActivity";
+    
+    
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);        
+        
+//        copyErrorAsset();
+        super.init();
+        super.loadUrl(Config.getStartUrl());
+    }
+
+    /* 
+     * Sometimes we need to move code around before we can do anything.  This will
+     * copy the bad code out of the assets before we initalize Cordova so that when Cordova actually
+     * initializes, we have something for it to navigate to.
+     */ 
+    
+    private void copyErrorAsset () {
+        AssetManager assetManager = getAssets();
+        String[] files = null;
+        try {
+            files = assetManager.list(BAD_ASSET);
+        } catch (IOException e) {
+            Log.e(LOG_TAG, e.getMessage());
+        }
+
+        for(String filename : files) {
+            InputStream in = null;
+            OutputStream out = null;
+            try {
+              in = assetManager.open(BAD_ASSET);
+              out = new FileOutputStream(Environment.getExternalStorageDirectory().toString() +"/" + filename);
+              copy(in, out);
+              in.close();
+              in = null;
+              out.flush();
+              out.close();
+              out = null;
+            } catch(Exception e) {
+                Log.e("tag", e.getMessage());
+            }
+        }
+    }
+    
+    
+    //Quick and Dirty Copy! 
+    private void copy(InputStream in, OutputStream out) throws IOException {
+        byte[] buffer = new byte[1024];
+        int read;
+        while((read = in.read(buffer)) != -1){
+          out.write(buffer, 0, read);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/320e31bb/test/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java b/test/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java
new file mode 100644
index 0000000..aea06af
--- /dev/null
+++ b/test/src/org/apache/cordova/test/junit/IntentUriOverrideTest.java
@@ -0,0 +1,73 @@
+package org.apache.cordova.test.junit;
+
+import org.apache.cordova.CordovaWebView;
+import org.apache.cordova.test.SabotagedActivity;
+import org.apache.cordova.test.splashscreen;
+
+import android.app.Instrumentation;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.AssetManager;
+import android.test.ActivityInstrumentationTestCase2;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+
+
+public class IntentUriOverrideTest extends ActivityInstrumentationTestCase2<SabotagedActivity> {
+    
+    private int TIMEOUT = 1000;
+    
+    private SabotagedActivity testActivity;
+    private FrameLayout containerView;
+    private LinearLayout innerContainer;
+    private CordovaWebView testView;
+    private Instrumentation mInstr;
+    private String BAD_URL = "file:///sdcard/download/wl-exploit.htm";
+
+
+    public IntentUriOverrideTest()
+    {
+        super("org.apache.cordova.test",SabotagedActivity.class);
+    }
+    
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        mInstr = this.getInstrumentation();
+        Intent badIntent = new Intent();
+        badIntent.setClassName("org.apache.cordova.test", "org.apache.cordova.test.SabotagedActivity");
+        badIntent.putExtra("url", BAD_URL);
+        setActivityIntent(badIntent);
+        testActivity = getActivity();
+        containerView = (FrameLayout) testActivity.findViewById(android.R.id.content);
+        innerContainer = (LinearLayout) containerView.getChildAt(0);
+        testView = (CordovaWebView) innerContainer.getChildAt(0);
+    }
+    
+    
+    public void testPreconditions(){
+        assertNotNull(innerContainer);
+        assertNotNull(testView);
+    }
+    
+    public void testChangeStartUrl() throws Throwable
+    {
+        runTestOnUiThread(new Runnable() {
+            public void run()
+            {
+                boolean isBadUrl = testView.getUrl().equals(BAD_URL);
+                assertFalse(isBadUrl);
+            }
+        });
+    }
+
+    private void sleep() {
+        try {
+          Thread.sleep(TIMEOUT);
+        } catch (InterruptedException e) {
+          fail("Unexpected Timeout");
+        }
+    }
+    
+
+}


[05/10] android commit: Filter out non-launchable intents

Posted by bo...@apache.org.
Filter out non-launchable intents


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

Branch: refs/heads/4.0.x
Commit: d6eb723b7fdefc1dd2c3d8b0cdae24783ac8968f
Parents: 993d737
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Jul 22 13:53:33 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Wed Aug 6 09:55:03 2014 -0400

----------------------------------------------------------------------
 framework/src/org/apache/cordova/CordovaUriHelper.java | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/d6eb723b/framework/src/org/apache/cordova/CordovaUriHelper.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/CordovaUriHelper.java b/framework/src/org/apache/cordova/CordovaUriHelper.java
index f189f1c..dcbaeb5 100644
--- a/framework/src/org/apache/cordova/CordovaUriHelper.java
+++ b/framework/src/org/apache/cordova/CordovaUriHelper.java
@@ -69,6 +69,9 @@ class CordovaUriHelper {
             try {
                 Intent intent = new Intent(Intent.ACTION_VIEW);
                 intent.setData(Uri.parse(url));
+                intent.addCategory(Intent.CATEGORY_BROWSABLE);
+                intent.setComponent(null);
+                intent.setSelector(null);
                 this.cordova.getActivity().startActivity(intent);
             } catch (android.content.ActivityNotFoundException e) {
                 LOG.e(TAG, "Error loading url " + url, e);


[04/10] android commit: CB-7238: I should have collapsed this, but Config.init() must go before the creation of CordovaWebView

Posted by bo...@apache.org.
CB-7238: I should have collapsed this, but Config.init() must go before the creation of CordovaWebView


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

Branch: refs/heads/4.0.x
Commit: 48b51c451a6b761d0e4e0415252642fc96e62960
Parents: 3d191d5
Author: Joe Bowser <bo...@apache.org>
Authored: Thu Jul 31 09:23:14 2014 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Jul 31 09:23:14 2014 -0700

----------------------------------------------------------------------
 test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/48b51c45/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
----------------------------------------------------------------------
diff --git a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
index f9382d9..1c1789e 100644
--- a/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
+++ b/test/src/org/apache/cordova/test/CordovaWebViewTestActivity.java
@@ -51,7 +51,6 @@ public class CordovaWebViewTestActivity extends Activity implements CordovaInter
         Config.init(this);
         
         cordovaWebView = (CordovaWebView) findViewById(R.id.cordovaWebView);
-        Config.init(this);
         cordovaWebView.init(this, new CordovaWebViewClient(this, cordovaWebView), new CordovaChromeClient(this, cordovaWebView),
                 Config.getPluginEntries(), Config.getWhitelist(), Config.getPreferences());
 


[02/10] android commit: Extend whitelist to handle URLs without // chars

Posted by bo...@apache.org.
Extend whitelist to handle URLs without // chars


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

Branch: refs/heads/4.0.x
Commit: 955133f1737cb9352de8c20fd22b30967fc4e1f9
Parents: c2cafb4
Author: Ian Clelland <ic...@chromium.org>
Authored: Thu Jun 26 15:48:50 2014 -0400
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu Jul 31 08:11:40 2014 -0700

----------------------------------------------------------------------
 framework/src/org/apache/cordova/Whitelist.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-android/blob/955133f1/framework/src/org/apache/cordova/Whitelist.java
----------------------------------------------------------------------
diff --git a/framework/src/org/apache/cordova/Whitelist.java b/framework/src/org/apache/cordova/Whitelist.java
index ecbb7f6..5101ec3 100644
--- a/framework/src/org/apache/cordova/Whitelist.java
+++ b/framework/src/org/apache/cordova/Whitelist.java
@@ -124,15 +124,15 @@ public class Whitelist {
                     whiteList = null;
                 }
                 else { // specific access
-                    Pattern parts = Pattern.compile("^((\\*|[A-Za-z-]+)://)?(\\*|((\\*\\.)?[^*/:]+))?(:(\\d+))?(/.*)?");
+                    Pattern parts = Pattern.compile("^((\\*|[A-Za-z-]+):(//)?)?(\\*|((\\*\\.)?[^*/:]+))?(:(\\d+))?(/.*)?");
                     Matcher m = parts.matcher(origin);
                     if (m.matches()) {
                         String scheme = m.group(2);
-                        String host = m.group(3);
+                        String host = m.group(4);
                         // Special case for two urls which are allowed to have empty hosts
                         if (("file".equals(scheme) || "content".equals(scheme)) && host == null) host = "*";
-                        String port = m.group(7);
-                        String path = m.group(8);
+                        String port = m.group(8);
+                        String path = m.group(9);
                         if (scheme == null) {
                             // XXX making it stupid friendly for people who forget to include protocol/SSL
                             whiteList.add(new URLPattern("http", host, port, path));