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 2012/05/24 18:31:08 UTC

[1/15] android commit: Merge commit and fix.

Updated Branches:
  refs/heads/CordovaWebView c8a521c18 -> c37b2d236


Merge commit and fix.


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

Branch: refs/heads/CordovaWebView
Commit: c37b2d236bc51f5fddd558fab4179e63ece84b1b
Parents: c8a521c 2d77bcf
Author: Joe Bowser <bo...@apache.org>
Authored: Thu May 24 09:31:11 2012 -0700
Committer: Joe Bowser <bo...@apache.org>
Committed: Thu May 24 09:31:11 2012 -0700

----------------------------------------------------------------------
 bin/create.bat                                     |    2 +-
 bin/create.js                                      |  111 +++-
 bin/templates/project/cordova/create.bat           |    2 +
 bin/templates/project/cordova/create.js            |   69 ++
 .../cordova/templates/project/assets/www/main.js   |    2 +-
 .../templates/project/res/drawable-hdpi/icon.png   |  Bin 0 -> 6080 bytes
 .../templates/project/res/drawable-ldpi/icon.png   |  Bin 0 -> 3096 bytes
 .../templates/project/res/drawable-mdpi/icon.png   |  Bin 0 -> 4090 bytes
 .../templates/project/res/drawable-xhdpi/icon.png  |  Bin 0 -> 7685 bytes
 .../templates/project/res/drawable/icon.png        |  Bin 5800 -> 7685 bytes
 framework/assets/js/cordova.android.js             |  561 +++++++++++++--
 .../src/org/apache/cordova/AccelListener.java      |  273 +++----
 framework/src/org/apache/cordova/FileTransfer.java |  579 ++++++++-------
 13 files changed, 1114 insertions(+), 485 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c37b2d23/framework/assets/js/cordova.android.js
----------------------------------------------------------------------
diff --cc framework/assets/js/cordova.android.js
index 3b5c7d9,cdf619d..dc716fd
--- a/framework/assets/js/cordova.android.js
+++ b/framework/assets/js/cordova.android.js
@@@ -1,6 -1,6 +1,6 @@@
- // commit 55e46cecd73e06a4866f084ffa8513219ef68421
 -// commit 4a4ba9985c920850fe3f229abc60de984e196ab5
++// commit 68eebbca4a3691fed773d7599dd77c0030beabe6
  
- // File generated at :: Fri May 11 2012 10:34:50 GMT-0700 (PDT)
 -// File generated at :: Fri May 18 2012 13:43:11 GMT-0700 (PDT)
++// File generated at :: Thu May 24 2012 09:30:21 GMT-0700 (PDT)
  
  /*
   Licensed to the Apache Software Foundation (ASF) under one
@@@ -711,6 -711,6 +711,9 @@@ module.exports = 
              children: {
                  exec: {
                      path: 'cordova/exec'
++                },
++                logger: {
++                    path: 'cordova/plugin/logger'
                  }
              }
          },
@@@ -1169,7 -1170,7 +1173,7 @@@ for (var key in Camera) 
   * Gets a picture from source defined by "options.sourceType", and returns the
   * image as defined by the "options.destinationType" option.
  
-- * The defaults are sourceType=CAMERA and destinationType=FILE_URL.
++ * The defaults are sourceType=CAMERA and destinationType=FILE_URI.
   *
   * @param {Function} successCallback
   * @param {Function} errorCallback
@@@ -2115,7 -2116,7 +2119,7 @@@ Entry.prototype.toURL = function() 
  Entry.prototype.toURI = function(mimeType) {
      console.log("DEPRECATED: Update your code to use 'toURL'");
      // fullPath attribute contains the full URI
--    return this.fullPath;
++    return this.toURL();
  };
  
  /**
@@@ -4471,6 -4530,6 +4533,177 @@@ var exec = require('cordova/exec')
  module.exports = compass;
  });
  
++// file: lib/common/plugin/console-via-logger.js
++define("cordova/plugin/console-via-logger", function(require, exports, module) {
++//------------------------------------------------------------------------------
++
++var logger = require("cordova/plugin/logger");
++var utils  = require("cordova/utils");
++
++//------------------------------------------------------------------------------
++// object that we're exporting
++//------------------------------------------------------------------------------
++var console = module.exports;
++
++//------------------------------------------------------------------------------
++// copy of the original console object
++//------------------------------------------------------------------------------
++var WinConsole = window.console;
++
++//------------------------------------------------------------------------------
++// whether to use the logger
++//------------------------------------------------------------------------------
++var UseLogger = false;
++
++//------------------------------------------------------------------------------
++// Timers
++//------------------------------------------------------------------------------
++var Timers = {};
++
++//------------------------------------------------------------------------------
++// used for unimplemented methods
++//------------------------------------------------------------------------------
++function noop() {}
++
++//------------------------------------------------------------------------------
++// used for unimplemented methods
++//------------------------------------------------------------------------------
++console.useLogger = function (value) {
++    if (arguments.length) UseLogger = !!value;
++
++    if (UseLogger) {
++        if (logger.useConsole()) {
++            throw new Error("console and logger are too intertwingly");
++        }
++    }
++
++    return UseLogger;
++};
++
++//------------------------------------------------------------------------------
++console.log = function() {
++    if (logger.useConsole()) return;
++    logger.log.apply(logger, [].slice.call(arguments));
++};
++
++//------------------------------------------------------------------------------
++console.error = function() {
++    if (logger.useConsole()) return;
++    logger.error.apply(logger, [].slice.call(arguments));
++};
++
++//------------------------------------------------------------------------------
++console.warn = function() {
++    if (logger.useConsole()) return;
++    logger.warn.apply(logger, [].slice.call(arguments));
++};
++
++//------------------------------------------------------------------------------
++console.info = function() {
++    if (logger.useConsole()) return;
++    logger.info.apply(logger, [].slice.call(arguments));
++};
++
++//------------------------------------------------------------------------------
++console.debug = function() {
++    if (logger.useConsole()) return;
++    logger.debug.apply(logger, [].slice.call(arguments));
++};
++
++//------------------------------------------------------------------------------
++console.assert = function(expression) {
++    if (expression) return;
++
++    var message = utils.vformat(arguments[1], [].slice.call(arguments, 2));
++    console.log("ASSERT: " + message);
++};
++
++//------------------------------------------------------------------------------
++console.clear = function() {};
++
++//------------------------------------------------------------------------------
++console.dir = function(object) {
++    console.log("%o", object);
++};
++
++//------------------------------------------------------------------------------
++console.dirxml = function(node) {
++    console.log(node.innerHTML);
++};
++
++//------------------------------------------------------------------------------
++console.trace = noop;
++
++//------------------------------------------------------------------------------
++console.group = console.log;
++
++//------------------------------------------------------------------------------
++console.groupCollapsed = console.log;
++
++//------------------------------------------------------------------------------
++console.groupEnd = noop;
++
++//------------------------------------------------------------------------------
++console.time = function(name) {
++    Timers[name] = new Date().valueOf();
++};
++
++//------------------------------------------------------------------------------
++console.timeEnd = function(name) {
++    var timeStart = Timers[name];
++    if (!timeStart) {
++        console.warn("unknown timer: " + name);
++        return;
++    }
++
++    var timeElapsed = new Date().valueOf() - timeStart;
++    console.log(name + ": " + timeElapsed + "ms");
++};
++
++//------------------------------------------------------------------------------
++console.timeStamp = noop;
++
++//------------------------------------------------------------------------------
++console.profile = noop;
++
++//------------------------------------------------------------------------------
++console.profileEnd = noop;
++
++//------------------------------------------------------------------------------
++console.count = noop;
++
++//------------------------------------------------------------------------------
++console.exception = console.log;
++
++//------------------------------------------------------------------------------
++console.table = function(data, columns) {
++    console.log("%o", data);
++};
++
++//------------------------------------------------------------------------------
++// return a new function that calls both functions passed as args
++//------------------------------------------------------------------------------
++function wrapperedOrigCall(orgFunc, newFunc) {
++    return function() {
++        var args = [].slice.call(arguments);
++        try { orgFunc.apply(WinConsole, args); } catch (e) {}
++        try { newFunc.apply(console,    args); } catch (e) {}
++    };
++}
++
++//------------------------------------------------------------------------------
++// For every function that exists in the original console object, that
++// also exists in the new console object, wrap the new console method
++// with one that calls both
++//------------------------------------------------------------------------------
++for (var key in console) {
++    if (typeof WinConsole[key] == "function") {
++        console[key] = wrapperedOrigCall(WinConsole[key], console[key]);
++    }
++}
++
++});
++
  // file: lib/common/plugin/contacts.js
  define("cordova/plugin/contacts", function(require, exports, module) {
  var exec = require('cordova/exec'),
@@@ -4732,6 -4791,6 +4965,233 @@@ module.exports = geolocation
  
  });
  
++// file: lib/common/plugin/logger.js
++define("cordova/plugin/logger", function(require, exports, module) {
++//------------------------------------------------------------------------------
++// The logger module exports the following properties/functions:
++//
++// LOG                          - constant for the level LOG
++// ERROR                        - constant for the level ERROR
++// WARN                         - constant for the level WARN
++// INFO                         - constant for the level INFO
++// DEBUG                        - constant for the level DEBUG
++// logLevel()                   - returns current log level
++// logLevel(value)              - sets and returns a new log level
++// useConsole()                 - returns whether logger is using console
++// useConsole(value)            - sets and returns whether logger is using console
++// log(message,...)             - logs a message at level LOG
++// error(message,...)           - logs a message at level ERROR
++// warn(message,...)            - logs a message at level WARN
++// info(message,...)            - logs a message at level INFO
++// debug(message,...)           - logs a message at level DEBUG
++// logLevel(level,message,...)  - logs a message specified level
++//
++//------------------------------------------------------------------------------
++
++var logger = exports;
++
++var exec    = require('cordova/exec');
++var utils   = require('cordova/utils');
++
++var UseConsole   = true;
++var Queued       = [];
++var DeviceReady  = false;
++var CurrentLevel;
++
++/**
++ * Logging levels
++ */
++
++var Levels = [
++    "LOG",
++    "ERROR",
++    "WARN",
++    "INFO",
++    "DEBUG"
++];
++
++/*
++ * add the logging levels to the logger object and
++ * to a separate levelsMap object for testing
++ */
++
++var LevelsMap = {};
++for (var i=0; i<Levels.length; i++) {
++    var level = Levels[i];
++    LevelsMap[level] = i;
++    logger[level]    = level;
++}
++
++CurrentLevel = LevelsMap.WARN;
++
++/**
++ * Getter/Setter for the logging level
++ *
++ * Returns the current logging level.
++ *
++ * When a value is passed, sets the logging level to that value.
++ * The values should be one of the following constants:
++ *    logger.LOG
++ *    logger.ERROR
++ *    logger.WARN
++ *    logger.INFO
++ *    logger.DEBUG
++ *
++ * The value used determines which messages get printed.  The logging
++ * values above are in order, and only messages logged at the logging
++ * level or above will actually be displayed to the user.  Eg, the
++ * default level is WARN, so only messages logged with LOG, ERROR, or
++ * WARN will be displayed; INFO and DEBUG messages will be ignored.
++ */
++logger.level = function (value) {
++    if (arguments.length) {
++        if (LevelsMap[value] === null) {
++            throw new Error("invalid logging level: " + value);
++        }
++        CurrentLevel = LevelsMap[value];
++    }
++
++    return Levels[CurrentLevel];
++};
++
++/**
++ * Getter/Setter for the useConsole functionality
++ *
++ * When useConsole is true, the logger will log via the
++ * browser 'console' object.  Otherwise, it will use the
++ * native Logger plugin.
++ */
++logger.useConsole = function (value) {
++    if (arguments.length) UseConsole = !!value;
++
++    if (UseConsole) {
++        if (typeof console == "undefined") {
++            throw new Error("global console object is not defined");
++        }
++
++        if (typeof console.log != "function") {
++            throw new Error("global console object does not have a log function");
++        }
++
++        if (typeof console.useLogger == "function") {
++            if (console.useLogger()) {
++                throw new Error("console and logger are too intertwingly");
++            }
++        }
++    }
++
++    return UseConsole;
++};
++
++/**
++ * Logs a message at the LOG level.
++ *
++ * Parameters passed after message are used applied to
++ * the message with utils.format()
++ */
++logger.log   = function(message) { logWithArgs("LOG",   arguments); };
++
++/**
++ * Logs a message at the ERROR level.
++ *
++ * Parameters passed after message are used applied to
++ * the message with utils.format()
++ */
++logger.error = function(message) { logWithArgs("ERROR", arguments); };
++
++/**
++ * Logs a message at the WARN level.
++ *
++ * Parameters passed after message are used applied to
++ * the message with utils.format()
++ */
++logger.warn  = function(message) { logWithArgs("WARN",  arguments); };
++
++/**
++ * Logs a message at the INFO level.
++ *
++ * Parameters passed after message are used applied to
++ * the message with utils.format()
++ */
++logger.info  = function(message) { logWithArgs("INFO",  arguments); };
++
++/**
++ * Logs a message at the DEBUG level.
++ *
++ * Parameters passed after message are used applied to
++ * the message with utils.format()
++ */
++logger.debug = function(message) { logWithArgs("DEBUG", arguments); };
++
++// log at the specified level with args
++function logWithArgs(level, args) {
++    args = [level].concat([].slice.call(args));
++    logger.logLevel.apply(logger, args);
++}
++
++/**
++ * Logs a message at the specified level.
++ *
++ * Parameters passed after message are used applied to
++ * the message with utils.format()
++ */
++logger.logLevel = function(level, message /* , ... */) {
++    // format the message with the parameters
++    var formatArgs = [].slice.call(arguments, 2);
++    message    = utils.vformat(message, formatArgs);
++
++    if (LevelsMap[level] === null) {
++        throw new Error("invalid logging level: " + level);
++    }
++
++    if (LevelsMap[level] > CurrentLevel) return;
++
++    // queue the message if not yet at deviceready
++    if (!DeviceReady && !UseConsole) {
++        Queued.push([level, message]);
++        return;
++    }
++
++    // if not using the console, use the native logger
++    if (!UseConsole) {
++        exec(null, null, "Logger", "logLevel", [level, message]);
++        return;
++    }
++
++    // make sure console is not using logger
++    if (console.__usingCordovaLogger) {
++        throw new Error("console and logger are too intertwingly");
++    }
++
++    // log to the console
++    switch (level) {
++        case logger.LOG:   console.log(message); break;
++        case logger.ERROR: console.log("ERROR: " + message); break;
++        case logger.WARN:  console.log("WARN: "  + message); break;
++        case logger.INFO:  console.log("INFO: "  + message); break;
++        case logger.DEBUG: console.log("DEBUG: " + message); break;
++    }
++};
++
++// when deviceready fires, log queued messages
++logger.__onDeviceReady = function() {
++    if (DeviceReady) return;
++
++    DeviceReady = true;
++
++    for (var i=0; i<Queued.length; i++) {
++        var messageArgs = Queued[i];
++        logger.logLevel(messageArgs[0], messageArgs[1]);
++    }
++
++    Queued = null;
++};
++
++// add a deviceready event to log queued messages
++document.addEventListener("deviceready", logger.__onDeviceReady, false);
++
++});
++
  // file: lib/common/plugin/network.js
  define("cordova/plugin/network", function(require, exports, module) {
  var exec = require('cordova/exec'),
@@@ -5061,6 -5120,6 +5521,16 @@@ utils.alert = function(msg) 
  /**
   * Formats a string and arguments following it ala sprintf()
   *
++ * see utils.vformat() for more information
++ */
++utils.format = function(formatString /* ,... */) {
++    var args = [].slice.call(arguments, 1);
++    return utils.vformat(formatString, args);
++};
++
++/**
++ * Formats a string and arguments following it ala vsprintf()
++ *
   * format chars:
   *   %j - format arg as JSON
   *   %o - format arg as JSON
@@@ -5072,14 -5131,14 +5542,13 @@@
   * for rationale, see FireBug's Console API:
   *    http://getfirebug.com/wiki/index.php/Console_API
   */
--utils.format = function(formatString /* ,... */) {
++utils.vformat = function(formatString, args) {
      if (formatString === null || formatString === undefined) return "";
      if (arguments.length == 1) return formatString.toString();
  
      var pattern = /(.*?)%(.)(.*)/;
      var rest    = formatString.toString();
      var result  = [];
--    var args    = [].slice.call(arguments,1);
  
      while (args.length) {
          var arg   = args.shift();

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c37b2d23/framework/src/org/apache/cordova/AccelListener.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/AccelListener.java
index dbda3fe,9e19d75..1574f08
--- a/framework/src/org/apache/cordova/AccelListener.java
+++ b/framework/src/org/apache/cordova/AccelListener.java
@@@ -43,16 -50,16 +49,16 @@@ public class AccelListener extends Plug
      public static int STARTING = 1;
      public static int RUNNING = 2;
      public static int ERROR_FAILED_TO_START = 3;
+     
 -    private float x,y,z;						        // most recent acceleration values
 -    private long timestamp;					        // time of most recent value
 -    private int status;							        // status of listener
++    private float x,y,z;                                // most recent acceleration values
++    private long timestamp;                         // time of most recent value
++    private int status;                                 // status of listener
+     private int accuracy = SensorManager.SENSOR_STATUS_UNRELIABLE;
  
-     public float TIMEOUT = 30000;		// Timeout in msec to shut off listener
+     private SensorManager sensorManager;    // Sensor manager
 -    private Sensor mSensor;						      // Acceleration sensor returned by sensor manager
++    private Sensor mSensor;                           // Acceleration sensor returned by sensor manager
  
-     float x, y, z;						// most recent acceleration values
-     long timestamp;						// time of most recent value
-     int status;							// status of listener
-     long lastAccessTime;				// time the value was last retrieved
- 
-     private SensorManager sensorManager;// Sensor manager
-     Sensor mSensor;						// Acceleration sensor returned by sensor manager
+     private String callbackId;              // Keeps track of the single "start" callback ID passed in from JS
  
      /**
       * Create an accelerometer listener.
@@@ -80,106 -86,36 +86,36 @@@
      /**
       * Executes the request and returns PluginResult.
       * 
--     * @param action 		The action to execute.
--     * @param args 			JSONArry of arguments for the plugin.
--     * @param callbackId	The callback id used when calling back into JavaScript.
--     * @return 				A PluginResult object with a status and message.
++     * @param action        The action to execute.
++     * @param args          JSONArry of arguments for the plugin.
++     * @param callbackId    The callback id used when calling back into JavaScript.
++     * @return              A PluginResult object with a status and message.
       */
      public PluginResult execute(String action, JSONArray args, String callbackId) {
-         PluginResult.Status status = PluginResult.Status.OK;
-         String result = "";
- 
-         try {
-             if (action.equals("getStatus")) {
-                 int i = this.getStatus();
-                 return new PluginResult(status, i);
-             }
-             else if (action.equals("start")) {
-                 int i = this.start();
-                 return new PluginResult(status, i);
-             }
-             else if (action.equals("stop")) {
-                 this.stop();
-                 return new PluginResult(status, 0);
-             }
-             else if (action.equals("getAcceleration")) {
+         PluginResult.Status status = PluginResult.Status.NO_RESULT;
+         String message = "";
+         PluginResult result = new PluginResult(status, message);
 -        result.setKeepCallback(true);	
++        result.setKeepCallback(true);   
+ 
+         if (action.equals("start")) {
+             this.callbackId = callbackId;
+             if (this.status != AccelListener.RUNNING) {
                  // If not running, then this is an async call, so don't worry about waiting
-                 if (this.status != AccelListener.RUNNING) {
-                     int r = this.start();
-                     if (r == AccelListener.ERROR_FAILED_TO_START) {
-                         return new PluginResult(PluginResult.Status.IO_EXCEPTION, AccelListener.ERROR_FAILED_TO_START);
-                     }
-                     // Wait until running
-                     long timeout = 2000;
-                     while ((this.status == STARTING) && (timeout > 0)) {
-                         timeout = timeout - 100;
-                         try {
-                             Thread.sleep(100);
-                         } catch (InterruptedException e) {
-                             e.printStackTrace();
-                         }
-                     }
-                     if (timeout == 0) {
-                         return new PluginResult(PluginResult.Status.IO_EXCEPTION, AccelListener.ERROR_FAILED_TO_START);
-                     }
-                 }
-                 this.lastAccessTime = System.currentTimeMillis();
-                 JSONObject r = new JSONObject();
-                 r.put("x", this.x);
-                 r.put("y", this.y);
-                 r.put("z", this.z);
-                 // TODO: Should timestamp be sent?
-                 r.put("timestamp", this.timestamp);
-                 return new PluginResult(status, r);
-             }
-             else if (action.equals("setTimeout")) {
-                 try {
-                     float timeout = Float.parseFloat(args.getString(0));
-                     this.setTimeout(timeout);
-                     return new PluginResult(status, 0);
-                 } catch (NumberFormatException e) {
-                     status = PluginResult.Status.INVALID_ACTION;
-                     e.printStackTrace();
-                 } catch (JSONException e) {
-                     status = PluginResult.Status.JSON_EXCEPTION;
-                     e.printStackTrace();
-                 }
+                 // We drop the callback onto our stack, call start, and let start and the sensor callback fire off the callback down the road
+                 this.start();
              }
-             else if (action.equals("getTimeout")) {
-                 float f = this.getTimeout();
-                 return new PluginResult(status, f);
-             } else {
-                 // Unsupported action
-                 return new PluginResult(PluginResult.Status.INVALID_ACTION);
-             }
-             return new PluginResult(status, result);
-         } catch (JSONException e) {
-             return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
-         }
-     }
- 
-     /**
-      * Identifies if action to be executed returns a value and should be run synchronously.
-      * 
-      * @param action	The action to execute
-      * @return			T=returns value
-      */
-     public boolean isSynch(String action) {
-         if (action.equals("getStatus")) {
-             return true;
          }
-         else if (action.equals("getAcceleration")) {
-             // Can only return value if RUNNING
+         else if (action.equals("stop")) {
              if (this.status == AccelListener.RUNNING) {
-                 return true;
+                 this.stop();
              }
+         } else {
+           // Unsupported action
+             return new PluginResult(PluginResult.Status.INVALID_ACTION);
          }
-         else if (action.equals("getTimeout")) {
-             return true;
-         }
-         return false;
+         return result;
      }
- 
+     
      /**
       * Called by AccelBroker when listener is to be shut down.
       * Stop listener.
@@@ -195,32 -131,45 +131,45 @@@
      /**
       * Start listening for acceleration sensor.
       * 
--     * @return 			status of listener
++     * @return          status of listener
       */
-     public int start() {
- 
+     private int start() {
 -    	// If already starting or running, then just return
 -    	if ((this.status == AccelListener.RUNNING) || (this.status == AccelListener.STARTING)) {
 +        // If already starting or running, then just return
 +        if ((this.status == AccelListener.RUNNING) || (this.status == AccelListener.STARTING)) {
-             return this.status;
+           return this.status;
 -    	}
 -    	
 -    	this.setStatus(AccelListener.STARTING);
 -    	
 -    	// Get accelerometer from sensor manager
 -    	List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
 +        }
- 
++        
++        this.setStatus(AccelListener.STARTING);
++        
 +        // Get accelerometer from sensor manager
 +        List<Sensor> list = this.sensorManager.getSensorList(Sensor.TYPE_ACCELEROMETER);
  
 -    	// If found, then register as listener
 -    	if ((list != null) && (list.size() > 0)) {
 +        // If found, then register as listener
 +        if ((list != null) && (list.size() > 0)) {
-             this.mSensor = list.get(0);
-             this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_FASTEST);
-             this.setStatus(AccelListener.STARTING);
-             this.lastAccessTime = System.currentTimeMillis();
+           this.mSensor = list.get(0);
+           this.sensorManager.registerListener(this, this.mSensor, SensorManager.SENSOR_DELAY_UI);
+           this.setStatus(AccelListener.STARTING);
 -    	} else {
++        } else {
+           this.setStatus(AccelListener.ERROR_FAILED_TO_START);
+           this.fail(AccelListener.ERROR_FAILED_TO_START, "No sensors found to register accelerometer listening to.");
+           return this.status;
 -    	}
 -    	
 -    	// Wait until running
 -    	long timeout = 2000;
 -    	while ((this.status == STARTING) && (timeout > 0)) {
 +        }
- 
-         // If error, then set status to error
-         else {
-             this.setStatus(AccelListener.ERROR_FAILED_TO_START);
++        
++        // Wait until running
++        long timeout = 2000;
++        while ((this.status == STARTING) && (timeout > 0)) {
+           timeout = timeout - 100;
+           try {
+               Thread.sleep(100);
+           } catch (InterruptedException e) {
+               e.printStackTrace();
+           }
 -    	}
 -    	if (timeout == 0) {
++        }
++        if (timeout == 0) {
+           this.setStatus(AccelListener.ERROR_FAILED_TO_START);
+           this.fail(AccelListener.ERROR_FAILED_TO_START, "Accelerometer could not be started.");
 -    	}
 -    	return this.status;
 +        }
- 
 +        return this.status;
      }
  
      /**
@@@ -240,6 -190,16 +190,16 @@@
       * @param accuracy
       */
      public void onAccuracyChanged(Sensor sensor, int accuracy) {
 -    	// Only look at accelerometer events
++        // Only look at accelerometer events
+         if (sensor.getType() != Sensor.TYPE_ACCELEROMETER) {
+             return;
+         }
+         
+         // If not running, then just return
+         if (this.status == AccelListener.STOPPED) {
+             return;
+         }
+         this.accuracy = accuracy;
      }
  
      /**
@@@ -258,18 -217,18 +217,17 @@@
          if (this.status == AccelListener.STOPPED) {
              return;
          }
- 
-         // Save time that event was received
-         this.timestamp = System.currentTimeMillis();
-         this.x = event.values[0];
-         this.y = event.values[1];
-         this.z = event.values[2];
- 
 -        
          this.setStatus(AccelListener.RUNNING);
+         
+         if (this.accuracy >= SensorManager.SENSOR_STATUS_ACCURACY_MEDIUM) {
+ 
+             // Save time that event was received
+             this.timestamp = System.currentTimeMillis();
+             this.x = event.values[0];
+             this.y = event.values[1];
+             this.z = event.values[2];
  
-         // If values haven't been read for TIMEOUT time, then turn off accelerometer sensor to save power
-         if ((this.timestamp - this.lastAccessTime) > this.TIMEOUT) {
-             this.stop();
+             this.win();
          }
      }
  
@@@ -303,9 -259,17 +258,17 @@@
      private void setStatus(int status) {
          this.status = status;
      }
- 
 -	
++    
+     private JSONObject getAccelerationJSON() {
+         JSONObject r = new JSONObject();
+         try {
+             r.put("x", this.x);
+             r.put("y", this.y);
+             r.put("z", this.z);
+             r.put("timestamp", this.timestamp);
+         } catch (JSONException e) {
+             e.printStackTrace();
+         }
+         return r;
+     }
  }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/c37b2d23/framework/src/org/apache/cordova/FileTransfer.java
----------------------------------------------------------------------
diff --cc framework/src/org/apache/cordova/FileTransfer.java
index e006230,368d97a..a040f47
--- a/framework/src/org/apache/cordova/FileTransfer.java
+++ b/framework/src/org/apache/cordova/FileTransfer.java
@@@ -206,201 -428,8 +426,7 @@@ public class FileTransfer extends Plugi
          return arg;
      }
  
 -
      /**
-      * Uploads the specified file to the server URL provided using an HTTP
-      * multipart request.
-      * @param file      Full path of the file on the file system
-      * @param server        URL of the server to receive the file
-      * @param fileKey       Name of file request parameter
-      * @param fileName      File name to be used on server
-      * @param mimeType      Describes file content type
-      * @param params        key:value pairs of user-defined parameters
-      * @return FileUploadResult containing result of upload request
-      */
-     @SuppressWarnings("deprecation")
-     public FileUploadResult upload(String file, String server, final String fileKey, final String fileName,
-             final String mimeType, JSONObject params, boolean trustEveryone, boolean chunkedMode) throws IOException, SSLException {
-         // Create return object
-         FileUploadResult result = new FileUploadResult();
- 
-         // Get a input stream of the file on the phone
-         FileInputStream fileInputStream = (FileInputStream) getPathFromUri(file);
- 
-         HttpURLConnection conn = null;
-         DataOutputStream dos = null;
- 
-         int bytesRead, bytesAvailable, bufferSize;
-         long totalBytes;
-         byte[] buffer;
-         int maxBufferSize = 8096;
- 
-         //------------------ CLIENT REQUEST
-         // open a URL connection to the server
-         URL url = new URL(server);
- 
-         // Open a HTTP connection to the URL based on protocol
-         if (url.getProtocol().toLowerCase().equals("https")) {
-             // Using standard HTTPS connection. Will not allow self signed certificate
-             if (!trustEveryone) {
-                 conn = (HttpsURLConnection) url.openConnection();
-             }
-             // Use our HTTPS connection that blindly trusts everyone.
-             // This should only be used in debug environments
-             else {
-                 // Setup the HTTPS connection class to trust everyone
-                 trustAllHosts();
-                 HttpsURLConnection https = (HttpsURLConnection) url.openConnection();
-                 // Save the current hostnameVerifier
-                 defaultHostnameVerifier = https.getHostnameVerifier();
-                 // Setup the connection not to verify hostnames
-                 https.setHostnameVerifier(DO_NOT_VERIFY);
-                 conn = https;
-             }
-         }
-         // Return a standard HTTP connection
-         else {
-             conn = (HttpURLConnection) url.openConnection();
-         }
- 
-         // Allow Inputs
-         conn.setDoInput(true);
- 
-         // Allow Outputs
-         conn.setDoOutput(true);
- 
-         // Don't use a cached copy.
-         conn.setUseCaches(false);
- 
-         // Use a post method.
-         conn.setRequestMethod("POST");
-         conn.setRequestProperty("Connection", "Keep-Alive");
-         conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + BOUNDRY);
- 
-         // Handle the other headers
-         try {
-             JSONObject headers = params.getJSONObject("headers");
-             for (@SuppressWarnings("rawtypes")
-             Iterator iter = headers.keys(); iter.hasNext();)
-             {
-                 String headerKey = iter.next().toString();
-                 conn.setRequestProperty(headerKey, headers.getString(headerKey));
-             }
-         } catch (JSONException e1) {
-             // No headers to be manipulated!
-         }
- 
-         // Set the cookies on the response
-         String cookie = CookieManager.getInstance().getCookie(server);
-         if (cookie != null) {
-             conn.setRequestProperty("Cookie", cookie);
-         }
- 
-         /*
-          * Store the non-file portions of the multipart data as a string, so that we can add it 
-          * to the contentSize, since it is part of the body of the HTTP request.
-          */
-         String extraParams = "";
-         try {
-             for (@SuppressWarnings("rawtypes")
-             Iterator iter = params.keys(); iter.hasNext();) {
-                 Object key = iter.next();
-                 if (key.toString() != "headers")
-                 {
-                     extraParams += LINE_START + BOUNDRY + LINE_END;
-                     extraParams += "Content-Disposition: form-data; name=\"" + key.toString() + "\";";
-                     extraParams += LINE_END + LINE_END;
-                     extraParams += params.getString(key.toString());
-                     extraParams += LINE_END;
-                 }
-             }
-         } catch (JSONException e) {
-             Log.e(LOG_TAG, e.getMessage(), e);
-         }
- 
-         extraParams += LINE_START + BOUNDRY + LINE_END;
-         extraParams += "Content-Disposition: form-data; name=\"" + fileKey + "\";" + " filename=\"";
- 
-         String midParams = "\"" + LINE_END + "Content-Type: " + mimeType + LINE_END + LINE_END;
-         String tailParams = LINE_END + LINE_START + BOUNDRY + LINE_START + LINE_END;
- 
-         // Should set this up as an option
-         if (chunkedMode) {
-             conn.setChunkedStreamingMode(maxBufferSize);
-         }
-         else
-         {
-             int stringLength = extraParams.length() + midParams.length() + tailParams.length() + fileName.getBytes("UTF-8").length;
-             Log.d(LOG_TAG, "String Length: " + stringLength);
-             int fixedLength = (int) fileInputStream.getChannel().size() + stringLength;
-             Log.d(LOG_TAG, "Content Length: " + fixedLength);
-             conn.setFixedLengthStreamingMode(fixedLength);
-         }
- 
-         dos = new DataOutputStream(conn.getOutputStream());
-         dos.writeBytes(extraParams);
-         //We don't want to chagne encoding, we just want this to write for all Unicode.
-         dos.write(fileName.getBytes("UTF-8"));
-         dos.writeBytes(midParams);
- 
-         // create a buffer of maximum size
-         bytesAvailable = fileInputStream.available();
-         bufferSize = Math.min(bytesAvailable, maxBufferSize);
-         buffer = new byte[bufferSize];
- 
-         // read file and write it into form...
-         bytesRead = fileInputStream.read(buffer, 0, bufferSize);
-         totalBytes = 0;
- 
-         while (bytesRead > 0) {
-             totalBytes += bytesRead;
-             result.setBytesSent(totalBytes);
-             dos.write(buffer, 0, bufferSize);
-             bytesAvailable = fileInputStream.available();
-             bufferSize = Math.min(bytesAvailable, maxBufferSize);
-             bytesRead = fileInputStream.read(buffer, 0, bufferSize);
-         }
- 
-         // send multipart form data necesssary after file data...
-         dos.writeBytes(tailParams);
- 
-         // close streams
-         fileInputStream.close();
-         dos.flush();
-         dos.close();
- 
-         //------------------ read the SERVER RESPONSE
-         StringBuffer responseString = new StringBuffer("");
-         DataInputStream inStream;
-         try {
-             inStream = new DataInputStream(conn.getInputStream());
-         } catch (FileNotFoundException e) {
-             throw new IOException("Received error from server");
-         }
- 
-         String line;
-         while ((line = inStream.readLine()) != null) {
-             responseString.append(line);
-         }
-         Log.d(LOG_TAG, "got response from server");
-         Log.d(LOG_TAG, responseString.toString());
- 
-         // send request and retrieve response
-         result.setResponseCode(conn.getResponseCode());
-         result.setResponse(responseString.toString());
- 
-         inStream.close();
-         conn.disconnect();
- 
-         // Revert back to the proper verifier and socket factories
-         if (trustEveryone && url.getProtocol().toLowerCase().equals("https")) {
-             ((HttpsURLConnection) conn).setHostnameVerifier(defaultHostnameVerifier);
-             HttpsURLConnection.setDefaultSSLSocketFactory(defaultSSLSocketFactory);
-         }
- 
-         return result;
-     }
- 
-     /**
       * Downloads a file form a given URL and saves it to the specified directory.
       *
       * @param source        URL of the server to receive the file
@@@ -415,42 -447,43 +444,47 @@@
              file.getParentFile().mkdirs();
  
              // connect to server
 -            if(this.ctx.isUrlWhiteListed(source))
 +            if (webView.isUrlWhiteListed(source))
              {
-                 URL url = new URL(source);
-                 HttpURLConnection connection = (HttpURLConnection) url.openConnection();
-                 connection.setRequestMethod("GET");
- 
-                 //Add cookie support
-                 String cookie = CookieManager.getInstance().getCookie(source);
-                 if (cookie != null)
-                 {
-                     connection.setRequestProperty("cookie", cookie);
-                 }
+               URL url = new URL(source);
+               connection = (HttpURLConnection) url.openConnection();
+               connection.setRequestMethod("GET");
+               
+               //Add cookie support
+               String cookie = CookieManager.getInstance().getCookie(source);
+               if(cookie != null)
+               {
+                 connection.setRequestProperty("cookie", cookie);
+               }
+               
+               connection.connect();
+ 
+               Log.d(LOG_TAG, "Download file: " + url);
  
 -              InputStream inputStream = connection.getInputStream();
 -              byte[] buffer = new byte[1024];
 -              int bytesRead = 0;
 +                connection.connect();
  
 -              FileOutputStream outputStream = new FileOutputStream(file);
 +                Log.d(LOG_TAG, "Download file:" + url);
  
 -              // write bytes to file
 -              while ( (bytesRead = inputStream.read(buffer)) > 0 ) {
 -                outputStream.write(buffer,0, bytesRead);
 -              }
 +                InputStream inputStream = connection.getInputStream();
 +                byte[] buffer = new byte[1024];
 +                int bytesRead = 0;
 +
 +                FileOutputStream outputStream = new FileOutputStream(file);
 +
 +                // write bytes to file
 +                while ((bytesRead = inputStream.read(buffer)) > 0) {
 +                    outputStream.write(buffer, 0, bytesRead);
 +                }
  
 -              outputStream.close();
 +                outputStream.close();
  
 -              Log.d(LOG_TAG, "Saved file: " + target);
 +                Log.d(LOG_TAG, "Saved file: " + target);
  
-                 // create FileEntry object
-                 FileUtils fileUtil = new FileUtils();
+               // create FileEntry object
+               FileUtils fileUtil = new FileUtils();
+               JSONObject fileEntry = fileUtil.getEntry(file);
  
-                 return fileUtil.getEntry(file);
+               return new PluginResult(PluginResult.Status.OK, fileEntry);
              }
              else
              {