You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/06/26 18:07:52 UTC

[GitHub] [cordova-plugin-file] Lindsay-Needs-Sleep opened a new issue #329: cdvfile:// Channel not fired: onFileSystemPathsReady on Android OS 4.4

Lindsay-Needs-Sleep opened a new issue #329: cdvfile://  Channel not fired: onFileSystemPathsReady on Android OS 4.4
URL: https://github.com/apache/cordova-plugin-file/issues/329
 
 
   # Bug Report
   
   ## Problem
   
   ### What is expected to happen?
   Expect that the onFileSystemPathsReady fires.  (And that deviceready fires)
   
   
   ### What does actually happen?
   It does not fire.
   
   
   ## Information
   Navigate to a cdvfile:// url:
   ```
   window.open("cdvfile:///assets/www/index.html")
   ```
   You can see all the plugins load.
   
   
   ### Command or Code
   The problem lies deep in the Android Platform code I believe.
   Sequence trigger: line 975
   `cordova.js`
   ```
   androidExec.init = function() {
       bridgeSecret = +prompt('', 'gap_init:' + nativeToJsBridgeMode);
       channel.onNativeReady.fire();
   };
   ```
   This triggers:
   `MyCordovaApp\platforms\android\CordovaLib\src\org\apache\cordova\engine\SystemWebChromeClient.java`
   ```
   @Override
   public boolean onJsPrompt(WebView view, String origin, String message, String defaultValue, final JsPromptResult result) {
   ```
   
   In working version of Android the "origin" comes in as:
   "cdvfile:///assets/www/index.html"
   In Android OS 4.4, "origin" is "".
   
   Which calls:
   
   ```
       public String promptOnJsPrompt(String origin, String message, String defaultValue) {
   ...
           else if (defaultValue != null && defaultValue.startsWith("gap_init:")) {
               // Protect against random iframes being able to talk through the bridge.
               // Trust only pages which the app would have been allowed to navigate to anyway.
               if (pluginManager.shouldAllowBridgeAccess(origin)) {
   
   ...
   
       public boolean shouldAllowBridgeAccess(String url) {
           for (PluginEntry entry : this.entryMap.values()) {
               CordovaPlugin plugin = pluginMap.get(entry.service);
               if (plugin != null) {
                   Boolean result = plugin.shouldAllowBridgeAccess(url);
                   if (result != null) {
                       return result;
                   }
               }
           }
   
           // Default policy:
           return url.startsWith("file://");
       }
   
   ```
   This is significant because if the origin is "" and not "cdvfile://" it won't match any of our plguin's shouldAllowBridgeAccess functions.
   
   If no matches are found you get:
   LOG.e(LOG_TAG, "gap_init called from restricted origin: " + origin);
   and no plugins are allowed to "exec" from the js side.
   This prevents cordova-plugin-file from getting a response from `exec(after, null, 'File', 'requestAllPaths', []);`, hence no firing of "onFileSystemPathsReady"
   
   
   ### Environment, Platform, Device
   Android OS 4.4
   
   
   ### Version information
   Cordova 9.0.0
   
           "cordova-android": "git+https://github.com/apache/cordova-android.git#4cf3dcfaae6dc82ddb1ccf439d209cbcc2f474a0",
           "cordova-plugin-file": "^6.0.1",
           "cordova-plugin-whitelist": "1.3.3"
   
   
   
   ## Checklist
   
   - [x] I searched for existing GitHub issues
   - [x] I updated all Cordova tooling to most recent version
   - [x] I included all the necessary information above
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org