You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2012/02/03 16:43:09 UTC

[2/15] Rename to Cordova

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/664a061d/framework/assets/js/cordova.js.base
----------------------------------------------------------------------
diff --git a/framework/assets/js/cordova.js.base b/framework/assets/js/cordova.js.base
new file mode 100755
index 0000000..bb32580
--- /dev/null
+++ b/framework/assets/js/cordova.js.base
@@ -0,0 +1,920 @@
+/*
+ *     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.
+ */
+
+if (typeof Cordova === "undefined") {
+
+/**
+ * The order of events during page load and Cordova startup is as follows:
+ *
+ * onDOMContentLoaded         Internal event that is received when the web page is loaded and parsed.
+ * window.onload              Body onload event.
+ * onNativeReady              Internal event that indicates the Cordova native side is ready.
+ * onCordovaInit             Internal event that kicks off creation of all Cordova JavaScript objects (runs constructors).
+ * onCordovaReady            Internal event fired when all Cordova JavaScript objects have been created
+ * onCordovaInfoReady        Internal event fired when device properties are available
+ * onDeviceReady              User event fired to indicate that Cordova is ready
+ * onResume                   User event fired to indicate a start/resume lifecycle event
+ * onPause                    User event fired to indicate a pause lifecycle event
+ * onDestroy                  Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
+ *
+ * The only Cordova events that user code should register for are:
+ *      deviceready           Cordova native code is initialized and Cordova APIs can be called from JavaScript
+ *      pause                 App has moved to background
+ *      resume                App has returned to foreground
+ *
+ * Listeners can be registered as:
+ *      document.addEventListener("deviceready", myDeviceReadyListener, false);
+ *      document.addEventListener("resume", myResumeListener, false);
+ *      document.addEventListener("pause", myPauseListener, false);
+ *
+ * The DOM lifecycle events should be used for saving and restoring state
+ *      window.onload
+ *      window.onunload
+ */
+
+/**
+ * This represents the Cordova API itself, and provides a global namespace for accessing
+ * information about the state of Cordova.
+ * @class
+ */
+var Cordova = {
+    documentEventHandler: {},   // Collection of custom document event handlers
+    windowEventHandler: {}      // Collection of custom window event handlers
+};
+
+/**
+ * List of resource files loaded by Cordova.
+ * This is used to ensure JS and other files are loaded only once.
+ */
+Cordova.resources = {base: true};
+
+/**
+ * Determine if resource has been loaded by Cordova
+ *
+ * @param name
+ * @return
+ */
+Cordova.hasResource = function(name) {
+    return Cordova.resources[name];
+};
+
+/**
+ * Add a resource to list of loaded resources by Cordova
+ *
+ * @param name
+ */
+Cordova.addResource = function(name) {
+    Cordova.resources[name] = true;
+};
+
+/**
+ * Custom pub-sub channel that can have functions subscribed to it
+ * @constructor
+ */
+Cordova.Channel = function (type)
+{
+    this.type = type;
+    this.handlers = {};
+    this.guid = 0;
+    this.fired = false;
+    this.enabled = true;
+};
+
+/**
+ * Subscribes the given function to the channel. Any time that
+ * Channel.fire is called so too will the function.
+ * Optionally specify an execution context for the function
+ * and a guid that can be used to stop subscribing to the channel.
+ * Returns the guid.
+ */
+Cordova.Channel.prototype.subscribe = function(f, c, g) {
+    // need a function to call
+    if (f === null) { return; }
+
+    var func = f;
+    if (typeof c === "object" && typeof f === "function") { func = Cordova.close(c, f); }
+
+    g = g || func.observer_guid || f.observer_guid || this.guid++;
+    func.observer_guid = g;
+    f.observer_guid = g;
+    this.handlers[g] = func;
+    return g;
+};
+
+/**
+ * Like subscribe but the function is only called once and then it
+ * auto-unsubscribes itself.
+ */
+Cordova.Channel.prototype.subscribeOnce = function(f, c) {
+    var g = null;
+    var _this = this;
+    var m = function() {
+        f.apply(c || null, arguments);
+        _this.unsubscribe(g);
+    };
+    if (this.fired) {
+        if (typeof c === "object" && typeof f === "function") { f = Cordova.close(c, f); }
+        f.apply(this, this.fireArgs);
+    } else {
+        g = this.subscribe(m);
+    }
+    return g;
+};
+
+/**
+ * Unsubscribes the function with the given guid from the channel.
+ */
+Cordova.Channel.prototype.unsubscribe = function(g) {
+    if (typeof g === "function") { g = g.observer_guid; }
+    this.handlers[g] = null;
+    delete this.handlers[g];
+};
+
+/**
+ * Calls all functions subscribed to this channel.
+ */
+Cordova.Channel.prototype.fire = function(e) {
+    if (this.enabled) {
+        var fail = false;
+        var item, handler, rv;
+        for (item in this.handlers) {
+            if (this.handlers.hasOwnProperty(item)) {
+                handler = this.handlers[item];
+                if (typeof handler === "function") {
+                    rv = (handler.apply(this, arguments) === false);
+                    fail = fail || rv;
+                }
+            }
+        }
+        this.fired = true;
+        this.fireArgs = arguments;
+        return !fail;
+    }
+    return true;
+};
+
+/**
+ * Calls the provided function only after all of the channels specified
+ * have been fired.
+ */
+Cordova.Channel.join = function(h, c) {
+    var i = c.length;
+    var f = function() {
+        if (!(--i)) {
+            h();
+        }
+    };
+    var len = i;
+    var j;
+    for (j=0; j<len; j++) {
+        if (!c[j].fired) {
+            c[j].subscribeOnce(f);
+        }
+        else {
+            i--;
+        }
+    }
+    if (!i) {
+        h();
+    }
+};
+
+/**
+ * Add an initialization function to a queue that ensures it will run and initialize
+ * application constructors only once Cordova has been initialized.
+ * @param {Function} func The function callback you want run once Cordova is initialized
+ */
+Cordova.addConstructor = function(func) {
+    Cordova.onCordovaInit.subscribeOnce(function() {
+        try {
+            func();
+        } catch(e) {
+            console.log("Failed to run constructor: " + e);
+        }
+    });
+};
+
+/**
+ * Plugins object
+ */
+if (!window.plugins) {
+    window.plugins = {};
+}
+
+/**
+ * Adds a plugin object to window.plugins.
+ * The plugin is accessed using window.plugins.<name>
+ *
+ * @param name          The plugin name
+ * @param obj           The plugin object
+ */
+Cordova.addPlugin = function(name, obj) {
+    if (!window.plugins[name]) {
+        window.plugins[name] = obj;
+    }
+    else {
+        console.log("Error: Plugin "+name+" already exists.");
+    }
+};
+
+/**
+ * onDOMContentLoaded channel is fired when the DOM content
+ * of the page has been parsed.
+ */
+Cordova.onDOMContentLoaded = new Cordova.Channel('onDOMContentLoaded');
+
+/**
+ * onNativeReady channel is fired when the Cordova native code
+ * has been initialized.
+ */
+Cordova.onNativeReady = new Cordova.Channel('onNativeReady');
+
+/**
+ * onCordovaInit channel is fired when the web page is fully loaded and
+ * Cordova native code has been initialized.
+ */
+Cordova.onCordovaInit = new Cordova.Channel('onCordovaInit');
+
+/**
+ * onCordovaReady channel is fired when the JS Cordova objects have been created.
+ */
+Cordova.onCordovaReady = new Cordova.Channel('onCordovaReady');
+
+/**
+ * onCordovaInfoReady channel is fired when the Cordova device properties
+ * has been set.
+ */
+Cordova.onCordovaInfoReady = new Cordova.Channel('onCordovaInfoReady');
+
+/**
+ * onCordovaConnectionReady channel is fired when the Cordova connection properties
+ * has been set.
+ */
+Cordova.onCordovaConnectionReady = new Cordova.Channel('onCordovaConnectionReady');
+
+/**
+ * onDestroy channel is fired when the Cordova native code
+ * is destroyed.  It is used internally.
+ * Window.onunload should be used by the user.
+ */
+Cordova.onDestroy = new Cordova.Channel('onDestroy');
+Cordova.onDestroy.subscribeOnce(function() {
+    Cordova.shuttingDown = true;
+});
+Cordova.shuttingDown = false;
+
+// _nativeReady is global variable that the native side can set
+// to signify that the native code is ready. It is a global since
+// it may be called before any Cordova JS is ready.
+if (typeof _nativeReady !== 'undefined') { Cordova.onNativeReady.fire(); }
+
+/**
+ * onDeviceReady is fired only after all Cordova objects are created and
+ * the device properties are set.
+ */
+Cordova.onDeviceReady = new Cordova.Channel('onDeviceReady');
+
+
+// Array of channels that must fire before "deviceready" is fired
+Cordova.deviceReadyChannelsArray = [ Cordova.onCordovaReady, Cordova.onCordovaInfoReady, Cordova.onCordovaConnectionReady];
+
+// Hashtable of user defined channels that must also fire before "deviceready" is fired
+Cordova.deviceReadyChannelsMap = {};
+
+/**
+ * Indicate that a feature needs to be initialized before it is ready to be used.
+ * This holds up Cordova's "deviceready" event until the feature has been initialized
+ * and Cordova.initComplete(feature) is called.
+ *
+ * @param feature {String}     The unique feature name
+ */
+Cordova.waitForInitialization = function(feature) {
+    if (feature) {
+        var channel = new Cordova.Channel(feature);
+        Cordova.deviceReadyChannelsMap[feature] = channel;
+        Cordova.deviceReadyChannelsArray.push(channel);
+    }
+};
+
+/**
+ * Indicate that initialization code has completed and the feature is ready to be used.
+ *
+ * @param feature {String}     The unique feature name
+ */
+Cordova.initializationComplete = function(feature) {
+    var channel = Cordova.deviceReadyChannelsMap[feature];
+    if (channel) {
+        channel.fire();
+    }
+};
+
+/**
+ * Create all Cordova objects once page has fully loaded and native side is ready.
+ */
+Cordova.Channel.join(function() {
+
+    // Start listening for XHR callbacks
+    setTimeout(function() {
+            if (Cordova.UsePolling) {
+                Cordova.JSCallbackPolling();
+            }
+            else {
+                var polling = prompt("usePolling", "gap_callbackServer:");
+                Cordova.UsePolling = polling;
+                if (polling == "true") {
+                    Cordova.UsePolling = true;
+                    Cordova.JSCallbackPolling();
+                }
+                else {
+                    Cordova.UsePolling = false;
+                    Cordova.JSCallback();
+                }
+            }
+        }, 1);
+
+    // Run Cordova constructors
+    Cordova.onCordovaInit.fire();
+
+    // Fire event to notify that all objects are created
+    Cordova.onCordovaReady.fire();
+
+    // Fire onDeviceReady event once all constructors have run and Cordova info has been
+    // received from native side, and any user defined initialization channels.
+    Cordova.Channel.join(function() {
+        // Let native code know we are inited on JS side
+        prompt("", "gap_init:");
+
+        Cordova.onDeviceReady.fire();
+    }, Cordova.deviceReadyChannelsArray);
+
+}, [ Cordova.onDOMContentLoaded, Cordova.onNativeReady ]);
+
+// Listen for DOMContentLoaded and notify our channel subscribers
+document.addEventListener('DOMContentLoaded', function() {
+    Cordova.onDOMContentLoaded.fire();
+}, false);
+
+// Intercept calls to document.addEventListener and watch for deviceready
+Cordova.m_document_addEventListener = document.addEventListener;
+
+// Intercept calls to window.addEventListener
+Cordova.m_window_addEventListener = window.addEventListener;
+
+/**
+ * Add a custom window event handler.
+ *
+ * @param {String} event            The event name that callback handles
+ * @param {Function} callback       The event handler
+ */
+Cordova.addWindowEventHandler = function(event, callback) {
+    Cordova.windowEventHandler[event] = callback;
+};
+
+/**
+ * Add a custom document event handler.
+ *
+ * @param {String} event            The event name that callback handles
+ * @param {Function} callback       The event handler
+ */
+Cordova.addDocumentEventHandler = function(event, callback) {
+    Cordova.documentEventHandler[event] = callback;
+};
+
+/**
+ * Intercept adding document event listeners and handle our own
+ *
+ * @param {Object} evt
+ * @param {Function} handler
+ * @param capture
+ */
+document.addEventListener = function(evt, handler, capture) {
+    var e = evt.toLowerCase();
+    if (e === 'deviceready') {
+        Cordova.onDeviceReady.subscribeOnce(handler);
+    }
+    else {
+        // If subscribing to Android backbutton
+        if (e === 'backbutton') {
+            Cordova.exec(null, null, "App", "overrideBackbutton", [true]);
+        }
+        
+        // If subscribing to an event that is handled by a plugin
+        else if (typeof Cordova.documentEventHandler[e] !== "undefined") {
+            if (Cordova.documentEventHandler[e](e, handler, true)) {
+                return; // Stop default behavior
+            }
+        }
+        
+        Cordova.m_document_addEventListener.call(document, evt, handler, capture);
+    }
+};
+
+/**
+ * Intercept adding window event listeners and handle our own
+ *
+ * @param {Object} evt
+ * @param {Function} handler
+ * @param capture
+ */
+window.addEventListener = function(evt, handler, capture) {
+    var e = evt.toLowerCase();
+        
+    // If subscribing to an event that is handled by a plugin
+    if (typeof Cordova.windowEventHandler[e] !== "undefined") {
+        if (Cordova.windowEventHandler[e](e, handler, true)) {
+            return; // Stop default behavior
+        }
+    }
+        
+    Cordova.m_window_addEventListener.call(window, evt, handler, capture);
+};
+
+// Intercept calls to document.removeEventListener and watch for events that
+// are generated by Cordova native code
+Cordova.m_document_removeEventListener = document.removeEventListener;
+
+// Intercept calls to window.removeEventListener
+Cordova.m_window_removeEventListener = window.removeEventListener;
+
+/**
+ * Intercept removing document event listeners and handle our own
+ *
+ * @param {Object} evt
+ * @param {Function} handler
+ * @param capture
+ */
+document.removeEventListener = function(evt, handler, capture) {
+    var e = evt.toLowerCase();
+
+    // If unsubscribing to Android backbutton
+    if (e === 'backbutton') {
+        Cordova.exec(null, null, "App", "overrideBackbutton", [false]);
+    }
+
+    // If unsubcribing from an event that is handled by a plugin
+    if (typeof Cordova.documentEventHandler[e] !== "undefined") {
+        if (Cordova.documentEventHandler[e](e, handler, false)) {
+            return; // Stop default behavior
+        }
+    }
+
+    Cordova.m_document_removeEventListener.call(document, evt, handler, capture);
+};
+
+/**
+ * Intercept removing window event listeners and handle our own
+ *
+ * @param {Object} evt
+ * @param {Function} handler
+ * @param capture
+ */
+window.removeEventListener = function(evt, handler, capture) {
+    var e = evt.toLowerCase();
+
+    // If unsubcribing from an event that is handled by a plugin
+    if (typeof Cordova.windowEventHandler[e] !== "undefined") {
+        if (Cordova.windowEventHandler[e](e, handler, false)) {
+            return; // Stop default behavior
+        }
+    }
+
+    Cordova.m_window_removeEventListener.call(window, evt, handler, capture);
+};
+
+/**
+ * Method to fire document event
+ *
+ * @param {String} type             The event type to fire
+ * @param {Object} data             Data to send with event
+ */
+Cordova.fireDocumentEvent = function(type, data) {
+    var e = document.createEvent('Events');
+    e.initEvent(type);
+    if (data) {
+        for (var i in data) {
+            e[i] = data[i];
+        }
+    }
+    document.dispatchEvent(e);
+};
+
+/**
+ * Method to fire window event
+ *
+ * @param {String} type             The event type to fire
+ * @param {Object} data             Data to send with event
+ */
+Cordova.fireWindowEvent = function(type, data) {
+    var e = document.createEvent('Events');
+    e.initEvent(type);
+    if (data) {
+        for (var i in data) {
+            e[i] = data[i];
+        }
+    }
+    window.dispatchEvent(e);
+};
+
+/**
+ * Does a deep clone of the object.
+ *
+ * @param obj
+ * @return {Object}
+ */
+Cordova.clone = function(obj) {
+    var i, retVal;
+    if(!obj) { 
+        return obj;
+    }
+    
+    if(obj instanceof Array){
+        retVal = [];
+        for(i = 0; i < obj.length; ++i){
+            retVal.push(Cordova.clone(obj[i]));
+        }
+        return retVal;
+    }
+    
+    if (typeof obj === "function") {
+        return obj;
+    }
+    
+    if(!(obj instanceof Object)){
+        return obj;
+    }
+    
+    if (obj instanceof Date) {
+        return obj;
+    }
+    
+    retVal = {};
+    for(i in obj){
+        if(!(i in retVal) || retVal[i] !== obj[i]) {
+            retVal[i] = Cordova.clone(obj[i]);
+        }
+    }
+    return retVal;
+};
+
+Cordova.callbackId = 0;
+Cordova.callbacks = {};
+Cordova.callbackStatus = {
+    NO_RESULT: 0,
+    OK: 1,
+    CLASS_NOT_FOUND_EXCEPTION: 2,
+    ILLEGAL_ACCESS_EXCEPTION: 3,
+    INSTANTIATION_EXCEPTION: 4,
+    MALFORMED_URL_EXCEPTION: 5,
+    IO_EXCEPTION: 6,
+    INVALID_ACTION: 7,
+    JSON_EXCEPTION: 8,
+    ERROR: 9
+    };
+
+
+/**
+ * Execute a Cordova command.  It is up to the native side whether this action is synch or async.
+ * The native side can return:
+ *      Synchronous: PluginResult object as a JSON string
+ *      Asynchrounous: Empty string ""
+ * If async, the native side will Cordova.callbackSuccess or Cordova.callbackError,
+ * depending upon the result of the action.
+ *
+ * @param {Function} success    The success callback
+ * @param {Function} fail       The fail callback
+ * @param {String} service      The name of the service to use
+ * @param {String} action       Action to be run in Cordova
+ * @param {Array.<String>} [args]     Zero or more arguments to pass to the method
+ */
+Cordova.exec = function(success, fail, service, action, args) {
+    try {
+        var callbackId = service + Cordova.callbackId++;
+        if (success || fail) {
+            Cordova.callbacks[callbackId] = {success:success, fail:fail};
+        }
+
+        var r = prompt(JSON.stringify(args), "gap:"+JSON.stringify([service, action, callbackId, true]));
+
+        // If a result was returned
+        if (r.length > 0) {
+            eval("var v="+r+";");
+
+            // If status is OK, then return value back to caller
+            if (v.status === Cordova.callbackStatus.OK) {
+
+                // If there is a success callback, then call it now with
+                // returned value
+                if (success) {
+                    try {
+                        success(v.message);
+                    } catch (e) {
+                        console.log("Error in success callback: " + callbackId  + " = " + e);
+                    }
+
+                    // Clear callback if not expecting any more results
+                    if (!v.keepCallback) {
+                        delete Cordova.callbacks[callbackId];
+                    }
+                }
+                return v.message;
+            }
+
+            // If no result
+            else if (v.status === Cordova.callbackStatus.NO_RESULT) {
+
+                // Clear callback if not expecting any more results
+                if (!v.keepCallback) {
+                    delete Cordova.callbacks[callbackId];
+                }
+            }
+
+            // If error, then display error
+            else {
+                console.log("Error: Status="+v.status+" Message="+v.message);
+
+                // If there is a fail callback, then call it now with returned value
+                if (fail) {
+                    try {
+                        fail(v.message);
+                    }
+                    catch (e1) {
+                        console.log("Error in error callback: "+callbackId+" = "+e1);
+                    }
+
+                    // Clear callback if not expecting any more results
+                    if (!v.keepCallback) {
+                        delete Cordova.callbacks[callbackId];
+                    }
+                }
+                return null;
+            }
+        }
+    } catch (e2) {
+        console.log("Error: "+e2);
+    }
+};
+
+/**
+ * Called by native code when returning successful result from an action.
+ *
+ * @param callbackId
+ * @param args
+ */
+Cordova.callbackSuccess = function(callbackId, args) {
+    if (Cordova.callbacks[callbackId]) {
+
+        // If result is to be sent to callback
+        if (args.status === Cordova.callbackStatus.OK) {
+            try {
+                if (Cordova.callbacks[callbackId].success) {
+                    Cordova.callbacks[callbackId].success(args.message);
+                }
+            }
+            catch (e) {
+                console.log("Error in success callback: "+callbackId+" = "+e);
+            }
+        }
+
+        // Clear callback if not expecting any more results
+        if (!args.keepCallback) {
+            delete Cordova.callbacks[callbackId];
+        }
+    }
+};
+
+/**
+ * Called by native code when returning error result from an action.
+ *
+ * @param callbackId
+ * @param args
+ */
+Cordova.callbackError = function(callbackId, args) {
+    if (Cordova.callbacks[callbackId]) {
+        try {
+            if (Cordova.callbacks[callbackId].fail) {
+                Cordova.callbacks[callbackId].fail(args.message);
+            }
+        }
+        catch (e) {
+            console.log("Error in error callback: "+callbackId+" = "+e);
+        }
+
+        // Clear callback if not expecting any more results
+        if (!args.keepCallback) {
+            delete Cordova.callbacks[callbackId];
+        }
+    }
+};
+
+Cordova.JSCallbackPort = null;
+Cordova.JSCallbackToken = null;
+
+/**
+ * This is only for Android.
+ *
+ * Internal function that uses XHR to call into Cordova Java code and retrieve
+ * any JavaScript code that needs to be run.  This is used for callbacks from
+ * Java to JavaScript.
+ */
+Cordova.JSCallback = function() {
+
+    // Exit if shutting down app
+    if (Cordova.shuttingDown) {
+        return;
+    }
+
+    // If polling flag was changed, start using polling from now on
+    if (Cordova.UsePolling) {
+        Cordova.JSCallbackPolling();
+        return;
+    }
+
+    var xmlhttp = new XMLHttpRequest();
+
+    // Callback function when XMLHttpRequest is ready
+    xmlhttp.onreadystatechange=function(){
+        if(xmlhttp.readyState === 4){
+
+            // Exit if shutting down app
+            if (Cordova.shuttingDown) {
+                return;
+            }
+
+            // If callback has JavaScript statement to execute
+            if (xmlhttp.status === 200) {
+
+                // Need to url decode the response
+                var msg = decodeURIComponent(xmlhttp.responseText);
+                setTimeout(function() {
+                    try {
+                        var t = eval(msg);
+                    }
+                    catch (e) {
+                        // If we're getting an error here, seeing the message will help in debugging
+                        console.log("JSCallback: Message from Server: " + msg);
+                        console.log("JSCallback Error: "+e);
+                    }
+                }, 1);
+                setTimeout(Cordova.JSCallback, 1);
+            }
+
+            // If callback ping (used to keep XHR request from timing out)
+            else if (xmlhttp.status === 404) {
+                setTimeout(Cordova.JSCallback, 10);
+            }
+
+            // If security error
+            else if (xmlhttp.status === 403) {
+                console.log("JSCallback Error: Invalid token.  Stopping callbacks.");
+            }
+
+            // If server is stopping
+            else if (xmlhttp.status === 503) {
+                console.log("JSCallback Server Closed: Stopping callbacks.");
+            }
+
+            // If request wasn't GET
+            else if (xmlhttp.status === 400) {
+                console.log("JSCallback Error: Bad request.  Stopping callbacks.");
+            }
+
+            // If error, revert to polling
+            else {
+                console.log("JSCallback Error: Request failed.");
+                Cordova.UsePolling = true;
+                Cordova.JSCallbackPolling();
+            }
+        }
+    };
+
+    if (Cordova.JSCallbackPort === null) {
+        Cordova.JSCallbackPort = prompt("getPort", "gap_callbackServer:");
+    }
+    if (Cordova.JSCallbackToken === null) {
+        Cordova.JSCallbackToken = prompt("getToken", "gap_callbackServer:");
+    }
+    xmlhttp.open("GET", "http://127.0.0.1:"+Cordova.JSCallbackPort+"/"+Cordova.JSCallbackToken , true);
+    xmlhttp.send();
+};
+
+/**
+ * The polling period to use with JSCallbackPolling.
+ * This can be changed by the application.  The default is 50ms.
+ */
+Cordova.JSCallbackPollingPeriod = 50;
+
+/**
+ * Flag that can be set by the user to force polling to be used or force XHR to be used.
+ */
+Cordova.UsePolling = false;    // T=use polling, F=use XHR
+
+/**
+ * This is only for Android.
+ *
+ * Internal function that uses polling to call into Cordova Java code and retrieve
+ * any JavaScript code that needs to be run.  This is used for callbacks from
+ * Java to JavaScript.
+ */
+Cordova.JSCallbackPolling = function() {
+
+    // Exit if shutting down app
+    if (Cordova.shuttingDown) {
+        return;
+    }
+
+    // If polling flag was changed, stop using polling from now on
+    if (!Cordova.UsePolling) {
+        Cordova.JSCallback();
+        return;
+    }
+
+    var msg = prompt("", "gap_poll:");
+    if (msg) {
+        setTimeout(function() {
+            try {
+                var t = eval(""+msg);
+            }
+            catch (e) {
+                console.log("JSCallbackPolling: Message from Server: " + msg);
+                console.log("JSCallbackPolling Error: "+e);
+            }
+        }, 1);
+        setTimeout(Cordova.JSCallbackPolling, 1);
+    }
+    else {
+        setTimeout(Cordova.JSCallbackPolling, Cordova.JSCallbackPollingPeriod);
+    }
+};
+
+/**
+ * Create a UUID
+ *
+ * @return {String}
+ */
+Cordova.createUUID = function() {
+    return Cordova.UUIDcreatePart(4) + '-' +
+        Cordova.UUIDcreatePart(2) + '-' +
+        Cordova.UUIDcreatePart(2) + '-' +
+        Cordova.UUIDcreatePart(2) + '-' +
+        Cordova.UUIDcreatePart(6);
+};
+
+Cordova.UUIDcreatePart = function(length) {
+    var uuidpart = "";
+    var i, uuidchar;
+    for (i=0; i<length; i++) {
+        uuidchar = parseInt((Math.random() * 256),0).toString(16);
+        if (uuidchar.length === 1) {
+            uuidchar = "0" + uuidchar;
+        }
+        uuidpart += uuidchar;
+    }
+    return uuidpart;
+};
+
+Cordova.close = function(context, func, params) {
+    if (typeof params === 'undefined') {
+        return function() {
+            return func.apply(context, arguments);
+        };
+    } else {
+        return function() {
+            return func.apply(context, params);
+        };
+    }
+};
+
+/**
+ * Load a JavaScript file after page has loaded.
+ *
+ * @param {String} jsfile               The url of the JavaScript file to load.
+ * @param {Function} successCallback    The callback to call when the file has been loaded.
+ */
+Cordova.includeJavascript = function(jsfile, successCallback) {
+    var id = document.getElementsByTagName("head")[0];
+    var el = document.createElement('script');
+    el.type = 'text/javascript';
+    if (typeof successCallback === 'function') {
+        el.onload = successCallback;
+    }
+    el.src = jsfile;
+    id.appendChild(el);
+};
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/664a061d/framework/assets/js/crypto.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/crypto.js b/framework/assets/js/crypto.js
index 295f21e..31c991f 100755
--- a/framework/assets/js/crypto.js
+++ b/framework/assets/js/crypto.js
@@ -19,8 +19,8 @@
 
 // TODO: Needs to be commented
 
-if (!PhoneGap.hasResource("crypto")) {
-PhoneGap.addResource("crypto");
+if (!Cordova.hasResource("crypto")) {
+Cordova.addResource("crypto");
 
 /**
 * @constructor
@@ -30,12 +30,12 @@ var Crypto = function() {
 
 Crypto.prototype.encrypt = function(seed, string, callback) {
     this.encryptWin = callback;
-    PhoneGap.exec(null, null, "Crypto", "encrypt", [seed, string]);
+    Cordova.exec(null, null, "Crypto", "encrypt", [seed, string]);
 };
 
 Crypto.prototype.decrypt = function(seed, string, callback) {
     this.decryptWin = callback;
-    PhoneGap.exec(null, null, "Crypto", "decrypt", [seed, string]);
+    Cordova.exec(null, null, "Crypto", "decrypt", [seed, string]);
 };
 
 Crypto.prototype.gotCryptedString = function(string) {
@@ -46,7 +46,7 @@ Crypto.prototype.getPlainString = function(string) {
     this.decryptWin(string);
 };
 
-PhoneGap.addConstructor(function() {
+Cordova.addConstructor(function() {
     if (typeof navigator.Crypto === "undefined") {
         navigator.Crypto = new Crypto();
     }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/664a061d/framework/assets/js/device.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/device.js b/framework/assets/js/device.js
index 3ef24d9..71fd7b8 100755
--- a/framework/assets/js/device.js
+++ b/framework/assets/js/device.js
@@ -17,8 +17,8 @@
  *     under the License.
  */
 
-if (!PhoneGap.hasResource("device")) {
-PhoneGap.addResource("device");
+if (!Cordova.hasResource("device")) {
+Cordova.addResource("device");
 
 /**
  * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
@@ -26,12 +26,12 @@ PhoneGap.addResource("device");
  * @constructor
  */
 var Device = function() {
-    this.available = PhoneGap.available;
+    this.available = Cordova.available;
     this.platform = null;
     this.version = null;
     this.name = null;
     this.uuid = null;
-    this.phonegap = null;
+    this.cordova = null;
 
     var me = this;
     this.getInfo(
@@ -41,13 +41,13 @@ var Device = function() {
             me.version = info.version;
             me.name = info.name;
             me.uuid = info.uuid;
-            me.phonegap = info.phonegap;
-            PhoneGap.onPhoneGapInfoReady.fire();
+            me.cordova = info.cordova;
+            Cordova.onCordovaInfoReady.fire();
         },
         function(e) {
             me.available = false;
-            console.log("Error initializing PhoneGap: " + e);
-            alert("Error initializing PhoneGap: "+e);
+            console.log("Error initializing Cordova: " + e);
+            alert("Error initializing Cordova: "+e);
         });
 };
 
@@ -72,10 +72,10 @@ Device.prototype.getInfo = function(successCallback, errorCallback) {
     }
 
     // Get info
-    PhoneGap.exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
+    Cordova.exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
 };
 
-PhoneGap.addConstructor(function() {
+Cordova.addConstructor(function() {
     if (typeof navigator.device === "undefined") {
         navigator.device = window.device = new Device();
     }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/664a061d/framework/assets/js/file.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/file.js b/framework/assets/js/file.js
index de6b672..1a7cfad 100755
--- a/framework/assets/js/file.js
+++ b/framework/assets/js/file.js
@@ -17,8 +17,8 @@
  *     under the License.
  */
 
-if (!PhoneGap.hasResource("file")) {
-PhoneGap.addResource("file");
+if (!Cordova.hasResource("file")) {
+Cordova.addResource("file");
 
 /**
  * This class provides some useful information about a file.
@@ -162,7 +162,7 @@ FileReader.prototype.readAsText = function(file, encoding) {
     var me = this;
 
     // Read file
-    PhoneGap.exec(
+    Cordova.exec(
         // Success callback
         function(r) {
             var evt;
@@ -241,7 +241,7 @@ FileReader.prototype.readAsDataURL = function(file) {
     var me = this;
 
     // Read file
-    PhoneGap.exec(
+    Cordova.exec(
         // Success callback
         function(r) {
             var evt;
@@ -412,7 +412,7 @@ FileWriter.prototype.write = function(text) {
     }
 
     // Write file
-    PhoneGap.exec(
+    Cordova.exec(
         // Success callback
         function(r) {
             var evt;
@@ -523,7 +523,7 @@ FileWriter.prototype.truncate = function(size) {
     }
 
     // Write file
-    PhoneGap.exec(
+    Cordova.exec(
         // Success callback
         function(r) {
             var evt;
@@ -624,7 +624,7 @@ var DirectoryReader = function(fullPath){
  * @param {Function} errorCallback is called with a FileError
  */
 DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "readEntries", [this.fullPath]);
+    Cordova.exec(successCallback, errorCallback, "File", "readEntries", [this.fullPath]);
 };
 
 /**
@@ -654,7 +654,7 @@ var DirectoryEntry = function() {
  * @param {Function} errorCallback is called with a FileError
  */
 DirectoryEntry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
+    Cordova.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
 };
 
 /**
@@ -664,7 +664,7 @@ DirectoryEntry.prototype.copyTo = function(parent, newName, successCallback, err
  * @param {Function} errorCallback is called with a FileError
  */
 DirectoryEntry.prototype.getMetadata = function(successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
+    Cordova.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
 };
 
 /**
@@ -674,7 +674,7 @@ DirectoryEntry.prototype.getMetadata = function(successCallback, errorCallback)
  * @param {Function} errorCallback is called with a FileError
  */
 DirectoryEntry.prototype.getParent = function(successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
+    Cordova.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
 };
 
 /**
@@ -686,7 +686,7 @@ DirectoryEntry.prototype.getParent = function(successCallback, errorCallback) {
  * @param {Function} errorCallback is called with a FileError
  */
 DirectoryEntry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
+    Cordova.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
 };
 
 /**
@@ -696,7 +696,7 @@ DirectoryEntry.prototype.moveTo = function(parent, newName, successCallback, err
  * @param {Function} errorCallback is called with a FileError
  */
 DirectoryEntry.prototype.remove = function(successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "remove", [this.fullPath]);
+    Cordova.exec(successCallback, errorCallback, "File", "remove", [this.fullPath]);
 };
 
 /**
@@ -725,7 +725,7 @@ DirectoryEntry.prototype.createReader = function(successCallback, errorCallback)
  * @param {Function} errorCallback is called with a FileError
  */
 DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "getDirectory", [this.fullPath, path, options]);
+    Cordova.exec(successCallback, errorCallback, "File", "getDirectory", [this.fullPath, path, options]);
 };
 
 /**
@@ -737,7 +737,7 @@ DirectoryEntry.prototype.getDirectory = function(path, options, successCallback,
  * @param {Function} errorCallback is called with a FileError
  */
 DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "getFile", [this.fullPath, path, options]);
+    Cordova.exec(successCallback, errorCallback, "File", "getFile", [this.fullPath, path, options]);
 };
 
 /**
@@ -747,7 +747,7 @@ DirectoryEntry.prototype.getFile = function(path, options, successCallback, erro
  * @param {Function} errorCallback is called with a FileError
  */
 DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "removeRecursively", [this.fullPath]);
+    Cordova.exec(successCallback, errorCallback, "File", "removeRecursively", [this.fullPath]);
 };
 
 /**
@@ -777,7 +777,7 @@ var FileEntry = function() {
  * @param {Function} errorCallback is called with a FileError
  */
 FileEntry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
+    Cordova.exec(successCallback, errorCallback, "File", "copyTo", [this.fullPath, parent, newName]);
 };
 
 /**
@@ -787,7 +787,7 @@ FileEntry.prototype.copyTo = function(parent, newName, successCallback, errorCal
  * @param {Function} errorCallback is called with a FileError
  */
 FileEntry.prototype.getMetadata = function(successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
+    Cordova.exec(successCallback, errorCallback, "File", "getMetadata", [this.fullPath]);
 };
 
 /**
@@ -797,7 +797,7 @@ FileEntry.prototype.getMetadata = function(successCallback, errorCallback) {
  * @param {Function} errorCallback is called with a FileError
  */
 FileEntry.prototype.getParent = function(successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
+    Cordova.exec(successCallback, errorCallback, "File", "getParent", [this.fullPath]);
 };
 
 /**
@@ -809,7 +809,7 @@ FileEntry.prototype.getParent = function(successCallback, errorCallback) {
  * @param {Function} errorCallback is called with a FileError
  */
 FileEntry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
+    Cordova.exec(successCallback, errorCallback, "File", "moveTo", [this.fullPath, parent, newName]);
 };
 
 /**
@@ -819,7 +819,7 @@ FileEntry.prototype.moveTo = function(parent, newName, successCallback, errorCal
  * @param {Function} errorCallback is called with a FileError
  */
 FileEntry.prototype.remove = function(successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "remove", [this.fullPath]);
+    Cordova.exec(successCallback, errorCallback, "File", "remove", [this.fullPath]);
 };
 
 /**
@@ -863,7 +863,7 @@ FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
  * @param {Function} errorCallback is called with a FileError
  */
 FileEntry.prototype.file = function(successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "getFileMetadata", [this.fullPath]);
+    Cordova.exec(successCallback, errorCallback, "File", "getFileMetadata", [this.fullPath]);
 };
 
 /** @constructor */
@@ -892,7 +892,7 @@ LocalFileSystem.prototype.requestFileSystem = function(type, size, successCallba
         }
     }
     else {
-        PhoneGap.exec(successCallback, errorCallback, "File", "requestFileSystem", [type, size]);
+        Cordova.exec(successCallback, errorCallback, "File", "requestFileSystem", [type, size]);
     }
 };
 
@@ -903,7 +903,7 @@ LocalFileSystem.prototype.requestFileSystem = function(type, size, successCallba
  * @param {Function} errorCallback is called with a FileError
  */
 LocalFileSystem.prototype.resolveLocalFileSystemURI = function(uri, successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, "File", "resolveLocalFileSystemURI", [uri]);
+    Cordova.exec(successCallback, errorCallback, "File", "resolveLocalFileSystemURI", [uri]);
 };
 
 /**
@@ -986,7 +986,7 @@ LocalFileSystem.prototype._castDate = function(pluginResult) {
 /**
  * Add the FileSystem interface into the browser.
  */
-PhoneGap.addConstructor(function() {
+Cordova.addConstructor(function() {
     var pgLocalFileSystem = new LocalFileSystem();
     // Needed for cast methods
     if (typeof window.localFileSystem === "undefined") {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/664a061d/framework/assets/js/filetransfer.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/filetransfer.js b/framework/assets/js/filetransfer.js
index e3e0d99..55d39f4 100644
--- a/framework/assets/js/filetransfer.js
+++ b/framework/assets/js/filetransfer.js
@@ -17,8 +17,8 @@
  *     under the License.
  */
 
-if (!PhoneGap.hasResource("filetransfer")) {
-PhoneGap.addResource("filetransfer");
+if (!Cordova.hasResource("filetransfer")) {
+Cordova.addResource("filetransfer");
 
 /**
  * FileTransfer uploads a file to a remote server.
@@ -80,7 +80,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
         }
     }
 
-    PhoneGap.exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]);
+    Cordova.exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]);
 };
 
 /**
@@ -91,7 +91,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
  * @param errorCallback {Function}    Callback to be invoked upon error
  */
 FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) {
-    PhoneGap.exec(successCallback, errorCallback, 'FileTransfer', 'download', [source, target]);
+    Cordova.exec(successCallback, errorCallback, 'FileTransfer', 'download', [source, target]);
 };
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/664a061d/framework/assets/js/geolocation.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/geolocation.js b/framework/assets/js/geolocation.js
index 87c8a07..29e742a 100755
--- a/framework/assets/js/geolocation.js
+++ b/framework/assets/js/geolocation.js
@@ -17,8 +17,8 @@
  *     under the License.
  */
 
-if (!PhoneGap.hasResource("geolocation")) {
-PhoneGap.addResource("geolocation");
+if (!Cordova.hasResource("geolocation")) {
+Cordova.addResource("geolocation");
 
 /**
  * This class provides access to device GPS data.
@@ -80,7 +80,7 @@ Geolocation.prototype.getCurrentPosition = function(successCallback, errorCallba
         }
     }
     navigator._geo.listeners.global = {"success" : successCallback, "fail" : errorCallback };
-    PhoneGap.exec(null, null, "Geolocation", "getCurrentLocation", [enableHighAccuracy, timeout, maximumAge]);
+    Cordova.exec(null, null, "Geolocation", "getCurrentLocation", [enableHighAccuracy, timeout, maximumAge]);
 };
 
 /**
@@ -110,9 +110,9 @@ Geolocation.prototype.watchPosition = function(successCallback, errorCallback, o
             timeout = options.timeout;
         }
     }
-    var id = PhoneGap.createUUID();
+    var id = Cordova.createUUID();
     navigator._geo.listeners[id] = {"success" : successCallback, "fail" : errorCallback };
-    PhoneGap.exec(null, null, "Geolocation", "start", [id, enableHighAccuracy, timeout, maximumAge]);
+    Cordova.exec(null, null, "Geolocation", "start", [id, enableHighAccuracy, timeout, maximumAge]);
     return id;
 };
 
@@ -173,19 +173,19 @@ Geolocation.prototype.fail = function(id, code, msg) {
  * @param {String} id       The ID of the watch returned from #watchPosition
  */
 Geolocation.prototype.clearWatch = function(id) {
-    PhoneGap.exec(null, null, "Geolocation", "stop", [id]);
+    Cordova.exec(null, null, "Geolocation", "stop", [id]);
     delete navigator._geo.listeners[id];
 };
 
 /**
- * Force the PhoneGap geolocation to be used instead of built-in.
+ * Force the Cordova geolocation to be used instead of built-in.
  */
-Geolocation.usingPhoneGap = false;
-Geolocation.usePhoneGap = function() {
-    if (Geolocation.usingPhoneGap) {
+Geolocation.usingCordova = false;
+Geolocation.useCordova = function() {
+    if (Geolocation.usingCordova) {
         return;
     }
-    Geolocation.usingPhoneGap = true;
+    Geolocation.usingCordova = true;
 
     // Set built-in geolocation methods to our own implementations
     // (Cannot replace entire geolocation, but can replace individual methods)
@@ -197,13 +197,13 @@ Geolocation.usePhoneGap = function() {
     navigator.geolocation.stop = navigator._geo.stop;
 };
 
-PhoneGap.addConstructor(function() {
+Cordova.addConstructor(function() {
     navigator._geo = new Geolocation();
 
-    // No native geolocation object for Android 1.x, so use PhoneGap geolocation
+    // No native geolocation object for Android 1.x, so use Cordova geolocation
     if (typeof navigator.geolocation === 'undefined') {
         navigator.geolocation = navigator._geo;
-        Geolocation.usingPhoneGap = true;
+        Geolocation.usingCordova = true;
     }
 });
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/664a061d/framework/assets/js/media.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/media.js b/framework/assets/js/media.js
index 1f86af7..15cecd9 100755
--- a/framework/assets/js/media.js
+++ b/framework/assets/js/media.js
@@ -17,8 +17,8 @@
  *     under the License.
  */
 
-if (!PhoneGap.hasResource("media")) {
-PhoneGap.addResource("media");
+if (!Cordova.hasResource("media")) {
+Cordova.addResource("media");
 
 /**
  * This class provides access to the device media, interfaces to both sound and video
@@ -60,8 +60,8 @@ var Media = function(src, successCallback, errorCallback, statusCallback, positi
         return;
     }
 
-    this.id = PhoneGap.createUUID();
-    PhoneGap.mediaObjects[this.id] = this;
+    this.id = Cordova.createUUID();
+    Cordova.mediaObjects[this.id] = this;
     this.src = src;
     this.successCallback = successCallback;
     this.errorCallback = errorCallback;
@@ -105,28 +105,28 @@ MediaError.MEDIA_ERR_NONE_SUPPORTED = 4;
  * Start or resume playing audio file.
  */
 Media.prototype.play = function() {
-    PhoneGap.exec(null, null, "Media", "startPlayingAudio", [this.id, this.src]);
+    Cordova.exec(null, null, "Media", "startPlayingAudio", [this.id, this.src]);
 };
 
 /**
  * Stop playing audio file.
  */
 Media.prototype.stop = function() {
-    return PhoneGap.exec(null, null, "Media", "stopPlayingAudio", [this.id]);
+    return Cordova.exec(null, null, "Media", "stopPlayingAudio", [this.id]);
 };
 
 /**
  * Seek or jump to a new time in the track..
  */
 Media.prototype.seekTo = function(milliseconds) {
-    PhoneGap.exec(null, null, "Media", "seekToAudio", [this.id, milliseconds]);
+    Cordova.exec(null, null, "Media", "seekToAudio", [this.id, milliseconds]);
 };
 
 /**
  * Pause playing audio file.
  */
 Media.prototype.pause = function() {
-    PhoneGap.exec(null, null, "Media", "pausePlayingAudio", [this.id]);
+    Cordova.exec(null, null, "Media", "pausePlayingAudio", [this.id]);
 };
 
 /**
@@ -143,49 +143,49 @@ Media.prototype.getDuration = function() {
  * Get position of audio.
  */
 Media.prototype.getCurrentPosition = function(success, fail) {
-    PhoneGap.exec(success, fail, "Media", "getCurrentPositionAudio", [this.id]);
+    Cordova.exec(success, fail, "Media", "getCurrentPositionAudio", [this.id]);
 };
 
 /**
  * Start recording audio file.
  */
 Media.prototype.startRecord = function() {
-    PhoneGap.exec(null, null, "Media", "startRecordingAudio", [this.id, this.src]);
+    Cordova.exec(null, null, "Media", "startRecordingAudio", [this.id, this.src]);
 };
 
 /**
  * Stop recording audio file.
  */
 Media.prototype.stopRecord = function() {
-    PhoneGap.exec(null, null, "Media", "stopRecordingAudio", [this.id]);
+    Cordova.exec(null, null, "Media", "stopRecordingAudio", [this.id]);
 };
 
 /**
  * Release the resources.
  */
 Media.prototype.release = function() {
-    PhoneGap.exec(null, null, "Media", "release", [this.id]);
+    Cordova.exec(null, null, "Media", "release", [this.id]);
 };
 
 /**
  * Adjust the volume.
  */
 Media.prototype.setVolume = function(volume) {
-    PhoneGap.exec(null, null, "Media", "setVolume", [this.id, volume]);
+    Cordova.exec(null, null, "Media", "setVolume", [this.id, volume]);
 };
 
 /**
  * List of media objects.
  * PRIVATE
  */
-PhoneGap.mediaObjects = {};
+Cordova.mediaObjects = {};
 
 /**
  * Object that receives native callbacks.
  * PRIVATE
  * @constructor
  */
-PhoneGap.Media = function() {};
+Cordova.Media = function() {};
 
 /**
  * Get the media object.
@@ -193,8 +193,8 @@ PhoneGap.Media = function() {};
  *
  * @param id            The media object id (string)
  */
-PhoneGap.Media.getMediaObject = function(id) {
-    return PhoneGap.mediaObjects[id];
+Cordova.Media.getMediaObject = function(id) {
+    return Cordova.mediaObjects[id];
 };
 
 /**
@@ -205,8 +205,8 @@ PhoneGap.Media.getMediaObject = function(id) {
  * @param status        The status code (int)
  * @param msg           The status message (string)
  */
-PhoneGap.Media.onStatus = function(id, msg, value) {
-    var media = PhoneGap.mediaObjects[id];
+Cordova.Media.onStatus = function(id, msg, value) {
+    var media = Cordova.mediaObjects[id];
     // If state update
     if (msg === Media.MEDIA_STATE) {
         if (value === Media.MEDIA_STOPPED) {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/664a061d/framework/assets/js/network.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/network.js b/framework/assets/js/network.js
index 007355e..d190069 100755
--- a/framework/assets/js/network.js
+++ b/framework/assets/js/network.js
@@ -18,8 +18,8 @@
  */
 
 
-if (!PhoneGap.hasResource("network")) {
-PhoneGap.addResource("network");
+if (!Cordova.hasResource("network")) {
+Cordova.addResource("network");
 
 /**
  * This class contains information about the current network Connection.
@@ -39,7 +39,7 @@ var Connection = function() {
                 // set a timer if still offline at the end of timer send the offline event
                 me._timer = setTimeout(function(){
                     me.type = type;
-                    PhoneGap.fireDocumentEvent('offline');
+                    Cordova.fireDocumentEvent('offline');
                     me._timer = null;
                     }, me.timeout);
             } else {
@@ -49,21 +49,21 @@ var Connection = function() {
                     me._timer = null;
                 }
                 me.type = type;
-                PhoneGap.fireDocumentEvent('online');
+                Cordova.fireDocumentEvent('online');
             }
             
             // should only fire this once
             if (me._firstRun) {
                 me._firstRun = false;
-                PhoneGap.onPhoneGapConnectionReady.fire();
+                Cordova.onCordovaConnectionReady.fire();
             }            
         },
         function(e) {
-            // If we can't get the network info we should still tell PhoneGap
+            // If we can't get the network info we should still tell Cordova
             // to fire the deviceready event.
             if (me._firstRun) {
                 me._firstRun = false;
-                PhoneGap.onPhoneGapConnectionReady.fire();
+                Cordova.onCordovaConnectionReady.fire();
             }            
             console.log("Error initializing Network Connection: " + e);
         });
@@ -85,11 +85,11 @@ Connection.NONE = "none";
  */
 Connection.prototype.getInfo = function(successCallback, errorCallback) {
     // Get info
-    PhoneGap.exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
+    Cordova.exec(successCallback, errorCallback, "Network Status", "getConnectionInfo", []);
 };
 
 
-PhoneGap.addConstructor(function() {
+Cordova.addConstructor(function() {
     if (typeof navigator.network === "undefined") {
         navigator.network = {};
     }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/664a061d/framework/assets/js/notification.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/notification.js b/framework/assets/js/notification.js
index 166ea44..2a7718b 100755
--- a/framework/assets/js/notification.js
+++ b/framework/assets/js/notification.js
@@ -17,8 +17,8 @@
  *     under the License.
  */
 
-if (!PhoneGap.hasResource("notification")) {
-PhoneGap.addResource("notification");
+if (!Cordova.hasResource("notification")) {
+Cordova.addResource("notification");
 
 /**
  * This class provides access to notifications on the device.
@@ -38,7 +38,7 @@ var Notification = function() {
 Notification.prototype.alert = function(message, completeCallback, title, buttonLabel) {
     var _title = (title || "Alert");
     var _buttonLabel = (buttonLabel || "OK");
-    PhoneGap.exec(completeCallback, null, "Notification", "alert", [message,_title,_buttonLabel]);
+    Cordova.exec(completeCallback, null, "Notification", "alert", [message,_title,_buttonLabel]);
 };
 
 /**
@@ -53,21 +53,21 @@ Notification.prototype.alert = function(message, completeCallback, title, button
 Notification.prototype.confirm = function(message, resultCallback, title, buttonLabels) {
     var _title = (title || "Confirm");
     var _buttonLabels = (buttonLabels || "OK,Cancel");
-    PhoneGap.exec(resultCallback, null, "Notification", "confirm", [message,_title,_buttonLabels]);
+    Cordova.exec(resultCallback, null, "Notification", "confirm", [message,_title,_buttonLabels]);
 };
 
 /**
  * Start spinning the activity indicator on the statusbar
  */
 Notification.prototype.activityStart = function() {
-    PhoneGap.exec(null, null, "Notification", "activityStart", ["Busy","Please wait..."]);
+    Cordova.exec(null, null, "Notification", "activityStart", ["Busy","Please wait..."]);
 };
 
 /**
  * Stop spinning the activity indicator on the statusbar, if it's currently spinning
  */
 Notification.prototype.activityStop = function() {
-    PhoneGap.exec(null, null, "Notification", "activityStop", []);
+    Cordova.exec(null, null, "Notification", "activityStop", []);
 };
 
 /**
@@ -77,7 +77,7 @@ Notification.prototype.activityStop = function() {
  * @param {String} message      Message to display in the dialog.
  */
 Notification.prototype.progressStart = function(title, message) {
-    PhoneGap.exec(null, null, "Notification", "progressStart", [title, message]);
+    Cordova.exec(null, null, "Notification", "progressStart", [title, message]);
 };
 
 /**
@@ -86,14 +86,14 @@ Notification.prototype.progressStart = function(title, message) {
  * @param {Number} value         0-100
  */
 Notification.prototype.progressValue = function(value) {
-    PhoneGap.exec(null, null, "Notification", "progressValue", [value]);
+    Cordova.exec(null, null, "Notification", "progressValue", [value]);
 };
 
 /**
  * Close the progress dialog.
  */
 Notification.prototype.progressStop = function() {
-    PhoneGap.exec(null, null, "Notification", "progressStop", []);
+    Cordova.exec(null, null, "Notification", "progressStop", []);
 };
 
 /**
@@ -112,7 +112,7 @@ Notification.prototype.blink = function(count, colour) {
  * @param {Integer} mills       The number of milliseconds to vibrate for.
  */
 Notification.prototype.vibrate = function(mills) {
-    PhoneGap.exec(null, null, "Notification", "vibrate", [mills]);
+    Cordova.exec(null, null, "Notification", "vibrate", [mills]);
 };
 
 /**
@@ -122,10 +122,10 @@ Notification.prototype.vibrate = function(mills) {
  * @param {Integer} count       The number of beeps.
  */
 Notification.prototype.beep = function(count) {
-    PhoneGap.exec(null, null, "Notification", "beep", [count]);
+    Cordova.exec(null, null, "Notification", "beep", [count]);
 };
 
-PhoneGap.addConstructor(function() {
+Cordova.addConstructor(function() {
     if (typeof navigator.notification === "undefined") {
         navigator.notification = new Notification();
     }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/664a061d/framework/assets/js/phonegap.js.base
----------------------------------------------------------------------
diff --git a/framework/assets/js/phonegap.js.base b/framework/assets/js/phonegap.js.base
deleted file mode 100755
index 2d7c383..0000000
--- a/framework/assets/js/phonegap.js.base
+++ /dev/null
@@ -1,922 +0,0 @@
-/*
- *     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.
- */
-
-// Version 1.2.0
-
-if (typeof PhoneGap === "undefined") {
-
-/**
- * The order of events during page load and PhoneGap startup is as follows:
- *
- * onDOMContentLoaded         Internal event that is received when the web page is loaded and parsed.
- * window.onload              Body onload event.
- * onNativeReady              Internal event that indicates the PhoneGap native side is ready.
- * onPhoneGapInit             Internal event that kicks off creation of all PhoneGap JavaScript objects (runs constructors).
- * onPhoneGapReady            Internal event fired when all PhoneGap JavaScript objects have been created
- * onPhoneGapInfoReady        Internal event fired when device properties are available
- * onDeviceReady              User event fired to indicate that PhoneGap is ready
- * onResume                   User event fired to indicate a start/resume lifecycle event
- * onPause                    User event fired to indicate a pause lifecycle event
- * onDestroy                  Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
- *
- * The only PhoneGap events that user code should register for are:
- *      deviceready           PhoneGap native code is initialized and PhoneGap APIs can be called from JavaScript
- *      pause                 App has moved to background
- *      resume                App has returned to foreground
- *
- * Listeners can be registered as:
- *      document.addEventListener("deviceready", myDeviceReadyListener, false);
- *      document.addEventListener("resume", myResumeListener, false);
- *      document.addEventListener("pause", myPauseListener, false);
- *
- * The DOM lifecycle events should be used for saving and restoring state
- *      window.onload
- *      window.onunload
- */
-
-/**
- * This represents the PhoneGap API itself, and provides a global namespace for accessing
- * information about the state of PhoneGap.
- * @class
- */
-var PhoneGap = {
-    documentEventHandler: {},   // Collection of custom document event handlers
-    windowEventHandler: {}      // Collection of custom window event handlers
-};
-
-/**
- * List of resource files loaded by PhoneGap.
- * This is used to ensure JS and other files are loaded only once.
- */
-PhoneGap.resources = {base: true};
-
-/**
- * Determine if resource has been loaded by PhoneGap
- *
- * @param name
- * @return
- */
-PhoneGap.hasResource = function(name) {
-    return PhoneGap.resources[name];
-};
-
-/**
- * Add a resource to list of loaded resources by PhoneGap
- *
- * @param name
- */
-PhoneGap.addResource = function(name) {
-    PhoneGap.resources[name] = true;
-};
-
-/**
- * Custom pub-sub channel that can have functions subscribed to it
- * @constructor
- */
-PhoneGap.Channel = function (type)
-{
-    this.type = type;
-    this.handlers = {};
-    this.guid = 0;
-    this.fired = false;
-    this.enabled = true;
-};
-
-/**
- * Subscribes the given function to the channel. Any time that
- * Channel.fire is called so too will the function.
- * Optionally specify an execution context for the function
- * and a guid that can be used to stop subscribing to the channel.
- * Returns the guid.
- */
-PhoneGap.Channel.prototype.subscribe = function(f, c, g) {
-    // need a function to call
-    if (f === null) { return; }
-
-    var func = f;
-    if (typeof c === "object" && typeof f === "function") { func = PhoneGap.close(c, f); }
-
-    g = g || func.observer_guid || f.observer_guid || this.guid++;
-    func.observer_guid = g;
-    f.observer_guid = g;
-    this.handlers[g] = func;
-    return g;
-};
-
-/**
- * Like subscribe but the function is only called once and then it
- * auto-unsubscribes itself.
- */
-PhoneGap.Channel.prototype.subscribeOnce = function(f, c) {
-    var g = null;
-    var _this = this;
-    var m = function() {
-        f.apply(c || null, arguments);
-        _this.unsubscribe(g);
-    };
-    if (this.fired) {
-        if (typeof c === "object" && typeof f === "function") { f = PhoneGap.close(c, f); }
-        f.apply(this, this.fireArgs);
-    } else {
-        g = this.subscribe(m);
-    }
-    return g;
-};
-
-/**
- * Unsubscribes the function with the given guid from the channel.
- */
-PhoneGap.Channel.prototype.unsubscribe = function(g) {
-    if (typeof g === "function") { g = g.observer_guid; }
-    this.handlers[g] = null;
-    delete this.handlers[g];
-};
-
-/**
- * Calls all functions subscribed to this channel.
- */
-PhoneGap.Channel.prototype.fire = function(e) {
-    if (this.enabled) {
-        var fail = false;
-        var item, handler, rv;
-        for (item in this.handlers) {
-            if (this.handlers.hasOwnProperty(item)) {
-                handler = this.handlers[item];
-                if (typeof handler === "function") {
-                    rv = (handler.apply(this, arguments) === false);
-                    fail = fail || rv;
-                }
-            }
-        }
-        this.fired = true;
-        this.fireArgs = arguments;
-        return !fail;
-    }
-    return true;
-};
-
-/**
- * Calls the provided function only after all of the channels specified
- * have been fired.
- */
-PhoneGap.Channel.join = function(h, c) {
-    var i = c.length;
-    var f = function() {
-        if (!(--i)) {
-            h();
-        }
-    };
-    var len = i;
-    var j;
-    for (j=0; j<len; j++) {
-        if (!c[j].fired) {
-            c[j].subscribeOnce(f);
-        }
-        else {
-            i--;
-        }
-    }
-    if (!i) {
-        h();
-    }
-};
-
-/**
- * Add an initialization function to a queue that ensures it will run and initialize
- * application constructors only once PhoneGap has been initialized.
- * @param {Function} func The function callback you want run once PhoneGap is initialized
- */
-PhoneGap.addConstructor = function(func) {
-    PhoneGap.onPhoneGapInit.subscribeOnce(function() {
-        try {
-            func();
-        } catch(e) {
-            console.log("Failed to run constructor: " + e);
-        }
-    });
-};
-
-/**
- * Plugins object
- */
-if (!window.plugins) {
-    window.plugins = {};
-}
-
-/**
- * Adds a plugin object to window.plugins.
- * The plugin is accessed using window.plugins.<name>
- *
- * @param name          The plugin name
- * @param obj           The plugin object
- */
-PhoneGap.addPlugin = function(name, obj) {
-    if (!window.plugins[name]) {
-        window.plugins[name] = obj;
-    }
-    else {
-        console.log("Error: Plugin "+name+" already exists.");
-    }
-};
-
-/**
- * onDOMContentLoaded channel is fired when the DOM content
- * of the page has been parsed.
- */
-PhoneGap.onDOMContentLoaded = new PhoneGap.Channel('onDOMContentLoaded');
-
-/**
- * onNativeReady channel is fired when the PhoneGap native code
- * has been initialized.
- */
-PhoneGap.onNativeReady = new PhoneGap.Channel('onNativeReady');
-
-/**
- * onPhoneGapInit channel is fired when the web page is fully loaded and
- * PhoneGap native code has been initialized.
- */
-PhoneGap.onPhoneGapInit = new PhoneGap.Channel('onPhoneGapInit');
-
-/**
- * onPhoneGapReady channel is fired when the JS PhoneGap objects have been created.
- */
-PhoneGap.onPhoneGapReady = new PhoneGap.Channel('onPhoneGapReady');
-
-/**
- * onPhoneGapInfoReady channel is fired when the PhoneGap device properties
- * has been set.
- */
-PhoneGap.onPhoneGapInfoReady = new PhoneGap.Channel('onPhoneGapInfoReady');
-
-/**
- * onPhoneGapConnectionReady channel is fired when the PhoneGap connection properties
- * has been set.
- */
-PhoneGap.onPhoneGapConnectionReady = new PhoneGap.Channel('onPhoneGapConnectionReady');
-
-/**
- * onDestroy channel is fired when the PhoneGap native code
- * is destroyed.  It is used internally.
- * Window.onunload should be used by the user.
- */
-PhoneGap.onDestroy = new PhoneGap.Channel('onDestroy');
-PhoneGap.onDestroy.subscribeOnce(function() {
-    PhoneGap.shuttingDown = true;
-});
-PhoneGap.shuttingDown = false;
-
-// _nativeReady is global variable that the native side can set
-// to signify that the native code is ready. It is a global since
-// it may be called before any PhoneGap JS is ready.
-if (typeof _nativeReady !== 'undefined') { PhoneGap.onNativeReady.fire(); }
-
-/**
- * onDeviceReady is fired only after all PhoneGap objects are created and
- * the device properties are set.
- */
-PhoneGap.onDeviceReady = new PhoneGap.Channel('onDeviceReady');
-
-
-// Array of channels that must fire before "deviceready" is fired
-PhoneGap.deviceReadyChannelsArray = [ PhoneGap.onPhoneGapReady, PhoneGap.onPhoneGapInfoReady, PhoneGap.onPhoneGapConnectionReady];
-
-// Hashtable of user defined channels that must also fire before "deviceready" is fired
-PhoneGap.deviceReadyChannelsMap = {};
-
-/**
- * Indicate that a feature needs to be initialized before it is ready to be used.
- * This holds up PhoneGap's "deviceready" event until the feature has been initialized
- * and PhoneGap.initComplete(feature) is called.
- *
- * @param feature {String}     The unique feature name
- */
-PhoneGap.waitForInitialization = function(feature) {
-    if (feature) {
-        var channel = new PhoneGap.Channel(feature);
-        PhoneGap.deviceReadyChannelsMap[feature] = channel;
-        PhoneGap.deviceReadyChannelsArray.push(channel);
-    }
-};
-
-/**
- * Indicate that initialization code has completed and the feature is ready to be used.
- *
- * @param feature {String}     The unique feature name
- */
-PhoneGap.initializationComplete = function(feature) {
-    var channel = PhoneGap.deviceReadyChannelsMap[feature];
-    if (channel) {
-        channel.fire();
-    }
-};
-
-/**
- * Create all PhoneGap objects once page has fully loaded and native side is ready.
- */
-PhoneGap.Channel.join(function() {
-
-    // Start listening for XHR callbacks
-    setTimeout(function() {
-            if (PhoneGap.UsePolling) {
-                PhoneGap.JSCallbackPolling();
-            }
-            else {
-                var polling = prompt("usePolling", "gap_callbackServer:");
-                PhoneGap.UsePolling = polling;
-                if (polling == "true") {
-                    PhoneGap.UsePolling = true;
-                    PhoneGap.JSCallbackPolling();
-                }
-                else {
-                    PhoneGap.UsePolling = false;
-                    PhoneGap.JSCallback();
-                }
-            }
-        }, 1);
-
-    // Run PhoneGap constructors
-    PhoneGap.onPhoneGapInit.fire();
-
-    // Fire event to notify that all objects are created
-    PhoneGap.onPhoneGapReady.fire();
-
-    // Fire onDeviceReady event once all constructors have run and PhoneGap info has been
-    // received from native side, and any user defined initialization channels.
-    PhoneGap.Channel.join(function() {
-        // Let native code know we are inited on JS side
-        prompt("", "gap_init:");
-
-        PhoneGap.onDeviceReady.fire();
-    }, PhoneGap.deviceReadyChannelsArray);
-
-}, [ PhoneGap.onDOMContentLoaded, PhoneGap.onNativeReady ]);
-
-// Listen for DOMContentLoaded and notify our channel subscribers
-document.addEventListener('DOMContentLoaded', function() {
-    PhoneGap.onDOMContentLoaded.fire();
-}, false);
-
-// Intercept calls to document.addEventListener and watch for deviceready
-PhoneGap.m_document_addEventListener = document.addEventListener;
-
-// Intercept calls to window.addEventListener
-PhoneGap.m_window_addEventListener = window.addEventListener;
-
-/**
- * Add a custom window event handler.
- *
- * @param {String} event            The event name that callback handles
- * @param {Function} callback       The event handler
- */
-PhoneGap.addWindowEventHandler = function(event, callback) {
-    PhoneGap.windowEventHandler[event] = callback;
-};
-
-/**
- * Add a custom document event handler.
- *
- * @param {String} event            The event name that callback handles
- * @param {Function} callback       The event handler
- */
-PhoneGap.addDocumentEventHandler = function(event, callback) {
-    PhoneGap.documentEventHandler[event] = callback;
-};
-
-/**
- * Intercept adding document event listeners and handle our own
- *
- * @param {Object} evt
- * @param {Function} handler
- * @param capture
- */
-document.addEventListener = function(evt, handler, capture) {
-    var e = evt.toLowerCase();
-    if (e === 'deviceready') {
-        PhoneGap.onDeviceReady.subscribeOnce(handler);
-    }
-    else {
-        // If subscribing to Android backbutton
-        if (e === 'backbutton') {
-            PhoneGap.exec(null, null, "App", "overrideBackbutton", [true]);
-        }
-        
-        // If subscribing to an event that is handled by a plugin
-        else if (typeof PhoneGap.documentEventHandler[e] !== "undefined") {
-            if (PhoneGap.documentEventHandler[e](e, handler, true)) {
-                return; // Stop default behavior
-            }
-        }
-        
-        PhoneGap.m_document_addEventListener.call(document, evt, handler, capture);
-    }
-};
-
-/**
- * Intercept adding window event listeners and handle our own
- *
- * @param {Object} evt
- * @param {Function} handler
- * @param capture
- */
-window.addEventListener = function(evt, handler, capture) {
-    var e = evt.toLowerCase();
-        
-    // If subscribing to an event that is handled by a plugin
-    if (typeof PhoneGap.windowEventHandler[e] !== "undefined") {
-        if (PhoneGap.windowEventHandler[e](e, handler, true)) {
-            return; // Stop default behavior
-        }
-    }
-        
-    PhoneGap.m_window_addEventListener.call(window, evt, handler, capture);
-};
-
-// Intercept calls to document.removeEventListener and watch for events that
-// are generated by PhoneGap native code
-PhoneGap.m_document_removeEventListener = document.removeEventListener;
-
-// Intercept calls to window.removeEventListener
-PhoneGap.m_window_removeEventListener = window.removeEventListener;
-
-/**
- * Intercept removing document event listeners and handle our own
- *
- * @param {Object} evt
- * @param {Function} handler
- * @param capture
- */
-document.removeEventListener = function(evt, handler, capture) {
-    var e = evt.toLowerCase();
-
-    // If unsubscribing to Android backbutton
-    if (e === 'backbutton') {
-        PhoneGap.exec(null, null, "App", "overrideBackbutton", [false]);
-    }
-
-    // If unsubcribing from an event that is handled by a plugin
-    if (typeof PhoneGap.documentEventHandler[e] !== "undefined") {
-        if (PhoneGap.documentEventHandler[e](e, handler, false)) {
-            return; // Stop default behavior
-        }
-    }
-
-    PhoneGap.m_document_removeEventListener.call(document, evt, handler, capture);
-};
-
-/**
- * Intercept removing window event listeners and handle our own
- *
- * @param {Object} evt
- * @param {Function} handler
- * @param capture
- */
-window.removeEventListener = function(evt, handler, capture) {
-    var e = evt.toLowerCase();
-
-    // If unsubcribing from an event that is handled by a plugin
-    if (typeof PhoneGap.windowEventHandler[e] !== "undefined") {
-        if (PhoneGap.windowEventHandler[e](e, handler, false)) {
-            return; // Stop default behavior
-        }
-    }
-
-    PhoneGap.m_window_removeEventListener.call(window, evt, handler, capture);
-};
-
-/**
- * Method to fire document event
- *
- * @param {String} type             The event type to fire
- * @param {Object} data             Data to send with event
- */
-PhoneGap.fireDocumentEvent = function(type, data) {
-    var e = document.createEvent('Events');
-    e.initEvent(type);
-    if (data) {
-        for (var i in data) {
-            e[i] = data[i];
-        }
-    }
-    document.dispatchEvent(e);
-};
-
-/**
- * Method to fire window event
- *
- * @param {String} type             The event type to fire
- * @param {Object} data             Data to send with event
- */
-PhoneGap.fireWindowEvent = function(type, data) {
-    var e = document.createEvent('Events');
-    e.initEvent(type);
-    if (data) {
-        for (var i in data) {
-            e[i] = data[i];
-        }
-    }
-    window.dispatchEvent(e);
-};
-
-/**
- * Does a deep clone of the object.
- *
- * @param obj
- * @return {Object}
- */
-PhoneGap.clone = function(obj) {
-    var i, retVal;
-    if(!obj) { 
-        return obj;
-    }
-    
-    if(obj instanceof Array){
-        retVal = [];
-        for(i = 0; i < obj.length; ++i){
-            retVal.push(PhoneGap.clone(obj[i]));
-        }
-        return retVal;
-    }
-    
-    if (typeof obj === "function") {
-        return obj;
-    }
-    
-    if(!(obj instanceof Object)){
-        return obj;
-    }
-    
-    if (obj instanceof Date) {
-        return obj;
-    }
-    
-    retVal = {};
-    for(i in obj){
-        if(!(i in retVal) || retVal[i] !== obj[i]) {
-            retVal[i] = PhoneGap.clone(obj[i]);
-        }
-    }
-    return retVal;
-};
-
-PhoneGap.callbackId = 0;
-PhoneGap.callbacks = {};
-PhoneGap.callbackStatus = {
-    NO_RESULT: 0,
-    OK: 1,
-    CLASS_NOT_FOUND_EXCEPTION: 2,
-    ILLEGAL_ACCESS_EXCEPTION: 3,
-    INSTANTIATION_EXCEPTION: 4,
-    MALFORMED_URL_EXCEPTION: 5,
-    IO_EXCEPTION: 6,
-    INVALID_ACTION: 7,
-    JSON_EXCEPTION: 8,
-    ERROR: 9
-    };
-
-
-/**
- * Execute a PhoneGap command.  It is up to the native side whether this action is synch or async.
- * The native side can return:
- *      Synchronous: PluginResult object as a JSON string
- *      Asynchrounous: Empty string ""
- * If async, the native side will PhoneGap.callbackSuccess or PhoneGap.callbackError,
- * depending upon the result of the action.
- *
- * @param {Function} success    The success callback
- * @param {Function} fail       The fail callback
- * @param {String} service      The name of the service to use
- * @param {String} action       Action to be run in PhoneGap
- * @param {Array.<String>} [args]     Zero or more arguments to pass to the method
- */
-PhoneGap.exec = function(success, fail, service, action, args) {
-    try {
-        var callbackId = service + PhoneGap.callbackId++;
-        if (success || fail) {
-            PhoneGap.callbacks[callbackId] = {success:success, fail:fail};
-        }
-
-        var r = prompt(JSON.stringify(args), "gap:"+JSON.stringify([service, action, callbackId, true]));
-
-        // If a result was returned
-        if (r.length > 0) {
-            eval("var v="+r+";");
-
-            // If status is OK, then return value back to caller
-            if (v.status === PhoneGap.callbackStatus.OK) {
-
-                // If there is a success callback, then call it now with
-                // returned value
-                if (success) {
-                    try {
-                        success(v.message);
-                    } catch (e) {
-                        console.log("Error in success callback: " + callbackId  + " = " + e);
-                    }
-
-                    // Clear callback if not expecting any more results
-                    if (!v.keepCallback) {
-                        delete PhoneGap.callbacks[callbackId];
-                    }
-                }
-                return v.message;
-            }
-
-            // If no result
-            else if (v.status === PhoneGap.callbackStatus.NO_RESULT) {
-
-                // Clear callback if not expecting any more results
-                if (!v.keepCallback) {
-                    delete PhoneGap.callbacks[callbackId];
-                }
-            }
-
-            // If error, then display error
-            else {
-                console.log("Error: Status="+v.status+" Message="+v.message);
-
-                // If there is a fail callback, then call it now with returned value
-                if (fail) {
-                    try {
-                        fail(v.message);
-                    }
-                    catch (e1) {
-                        console.log("Error in error callback: "+callbackId+" = "+e1);
-                    }
-
-                    // Clear callback if not expecting any more results
-                    if (!v.keepCallback) {
-                        delete PhoneGap.callbacks[callbackId];
-                    }
-                }
-                return null;
-            }
-        }
-    } catch (e2) {
-        console.log("Error: "+e2);
-    }
-};
-
-/**
- * Called by native code when returning successful result from an action.
- *
- * @param callbackId
- * @param args
- */
-PhoneGap.callbackSuccess = function(callbackId, args) {
-    if (PhoneGap.callbacks[callbackId]) {
-
-        // If result is to be sent to callback
-        if (args.status === PhoneGap.callbackStatus.OK) {
-            try {
-                if (PhoneGap.callbacks[callbackId].success) {
-                    PhoneGap.callbacks[callbackId].success(args.message);
-                }
-            }
-            catch (e) {
-                console.log("Error in success callback: "+callbackId+" = "+e);
-            }
-        }
-
-        // Clear callback if not expecting any more results
-        if (!args.keepCallback) {
-            delete PhoneGap.callbacks[callbackId];
-        }
-    }
-};
-
-/**
- * Called by native code when returning error result from an action.
- *
- * @param callbackId
- * @param args
- */
-PhoneGap.callbackError = function(callbackId, args) {
-    if (PhoneGap.callbacks[callbackId]) {
-        try {
-            if (PhoneGap.callbacks[callbackId].fail) {
-                PhoneGap.callbacks[callbackId].fail(args.message);
-            }
-        }
-        catch (e) {
-            console.log("Error in error callback: "+callbackId+" = "+e);
-        }
-
-        // Clear callback if not expecting any more results
-        if (!args.keepCallback) {
-            delete PhoneGap.callbacks[callbackId];
-        }
-    }
-};
-
-PhoneGap.JSCallbackPort = null;
-PhoneGap.JSCallbackToken = null;
-
-/**
- * This is only for Android.
- *
- * Internal function that uses XHR to call into PhoneGap Java code and retrieve
- * any JavaScript code that needs to be run.  This is used for callbacks from
- * Java to JavaScript.
- */
-PhoneGap.JSCallback = function() {
-
-    // Exit if shutting down app
-    if (PhoneGap.shuttingDown) {
-        return;
-    }
-
-    // If polling flag was changed, start using polling from now on
-    if (PhoneGap.UsePolling) {
-        PhoneGap.JSCallbackPolling();
-        return;
-    }
-
-    var xmlhttp = new XMLHttpRequest();
-
-    // Callback function when XMLHttpRequest is ready
-    xmlhttp.onreadystatechange=function(){
-        if(xmlhttp.readyState === 4){
-
-            // Exit if shutting down app
-            if (PhoneGap.shuttingDown) {
-                return;
-            }
-
-            // If callback has JavaScript statement to execute
-            if (xmlhttp.status === 200) {
-
-                // Need to url decode the response
-                var msg = decodeURIComponent(xmlhttp.responseText);
-                setTimeout(function() {
-                    try {
-                        var t = eval(msg);
-                    }
-                    catch (e) {
-                        // If we're getting an error here, seeing the message will help in debugging
-                        console.log("JSCallback: Message from Server: " + msg);
-                        console.log("JSCallback Error: "+e);
-                    }
-                }, 1);
-                setTimeout(PhoneGap.JSCallback, 1);
-            }
-
-            // If callback ping (used to keep XHR request from timing out)
-            else if (xmlhttp.status === 404) {
-                setTimeout(PhoneGap.JSCallback, 10);
-            }
-
-            // If security error
-            else if (xmlhttp.status === 403) {
-                console.log("JSCallback Error: Invalid token.  Stopping callbacks.");
-            }
-
-            // If server is stopping
-            else if (xmlhttp.status === 503) {
-                console.log("JSCallback Server Closed: Stopping callbacks.");
-            }
-
-            // If request wasn't GET
-            else if (xmlhttp.status === 400) {
-                console.log("JSCallback Error: Bad request.  Stopping callbacks.");
-            }
-
-            // If error, revert to polling
-            else {
-                console.log("JSCallback Error: Request failed.");
-                PhoneGap.UsePolling = true;
-                PhoneGap.JSCallbackPolling();
-            }
-        }
-    };
-
-    if (PhoneGap.JSCallbackPort === null) {
-        PhoneGap.JSCallbackPort = prompt("getPort", "gap_callbackServer:");
-    }
-    if (PhoneGap.JSCallbackToken === null) {
-        PhoneGap.JSCallbackToken = prompt("getToken", "gap_callbackServer:");
-    }
-    xmlhttp.open("GET", "http://127.0.0.1:"+PhoneGap.JSCallbackPort+"/"+PhoneGap.JSCallbackToken , true);
-    xmlhttp.send();
-};
-
-/**
- * The polling period to use with JSCallbackPolling.
- * This can be changed by the application.  The default is 50ms.
- */
-PhoneGap.JSCallbackPollingPeriod = 50;
-
-/**
- * Flag that can be set by the user to force polling to be used or force XHR to be used.
- */
-PhoneGap.UsePolling = false;    // T=use polling, F=use XHR
-
-/**
- * This is only for Android.
- *
- * Internal function that uses polling to call into PhoneGap Java code and retrieve
- * any JavaScript code that needs to be run.  This is used for callbacks from
- * Java to JavaScript.
- */
-PhoneGap.JSCallbackPolling = function() {
-
-    // Exit if shutting down app
-    if (PhoneGap.shuttingDown) {
-        return;
-    }
-
-    // If polling flag was changed, stop using polling from now on
-    if (!PhoneGap.UsePolling) {
-        PhoneGap.JSCallback();
-        return;
-    }
-
-    var msg = prompt("", "gap_poll:");
-    if (msg) {
-        setTimeout(function() {
-            try {
-                var t = eval(""+msg);
-            }
-            catch (e) {
-                console.log("JSCallbackPolling: Message from Server: " + msg);
-                console.log("JSCallbackPolling Error: "+e);
-            }
-        }, 1);
-        setTimeout(PhoneGap.JSCallbackPolling, 1);
-    }
-    else {
-        setTimeout(PhoneGap.JSCallbackPolling, PhoneGap.JSCallbackPollingPeriod);
-    }
-};
-
-/**
- * Create a UUID
- *
- * @return {String}
- */
-PhoneGap.createUUID = function() {
-    return PhoneGap.UUIDcreatePart(4) + '-' +
-        PhoneGap.UUIDcreatePart(2) + '-' +
-        PhoneGap.UUIDcreatePart(2) + '-' +
-        PhoneGap.UUIDcreatePart(2) + '-' +
-        PhoneGap.UUIDcreatePart(6);
-};
-
-PhoneGap.UUIDcreatePart = function(length) {
-    var uuidpart = "";
-    var i, uuidchar;
-    for (i=0; i<length; i++) {
-        uuidchar = parseInt((Math.random() * 256),0).toString(16);
-        if (uuidchar.length === 1) {
-            uuidchar = "0" + uuidchar;
-        }
-        uuidpart += uuidchar;
-    }
-    return uuidpart;
-};
-
-PhoneGap.close = function(context, func, params) {
-    if (typeof params === 'undefined') {
-        return function() {
-            return func.apply(context, arguments);
-        };
-    } else {
-        return function() {
-            return func.apply(context, params);
-        };
-    }
-};
-
-/**
- * Load a JavaScript file after page has loaded.
- *
- * @param {String} jsfile               The url of the JavaScript file to load.
- * @param {Function} successCallback    The callback to call when the file has been loaded.
- */
-PhoneGap.includeJavascript = function(jsfile, successCallback) {
-    var id = document.getElementsByTagName("head")[0];
-    var el = document.createElement('script');
-    el.type = 'text/javascript';
-    if (typeof successCallback === 'function') {
-        el.onload = successCallback;
-    }
-    el.src = jsfile;
-    id.appendChild(el);
-};
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-android/blob/664a061d/framework/assets/js/position.js
----------------------------------------------------------------------
diff --git a/framework/assets/js/position.js b/framework/assets/js/position.js
index 42cb807..e6b0e8a 100755
--- a/framework/assets/js/position.js
+++ b/framework/assets/js/position.js
@@ -17,8 +17,8 @@
  *     under the License.
  */
 
-if (!PhoneGap.hasResource("position")) {
-PhoneGap.addResource("position");
+if (!Cordova.hasResource("position")) {
+Cordova.addResource("position");
 
 /**
  * This class contains position information.