diff options
Diffstat (limited to 'tools/addon-sdk-1.7/python-lib/cuddlefish/mobile-utils')
-rw-r--r-- | tools/addon-sdk-1.7/python-lib/cuddlefish/mobile-utils/bootstrap.js | 78 | ||||
-rw-r--r-- | tools/addon-sdk-1.7/python-lib/cuddlefish/mobile-utils/install.rdf | 39 |
2 files changed, 117 insertions, 0 deletions
diff --git a/tools/addon-sdk-1.7/python-lib/cuddlefish/mobile-utils/bootstrap.js b/tools/addon-sdk-1.7/python-lib/cuddlefish/mobile-utils/bootstrap.js new file mode 100644 index 0000000..7bf6d84 --- /dev/null +++ b/tools/addon-sdk-1.7/python-lib/cuddlefish/mobile-utils/bootstrap.js @@ -0,0 +1,78 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +const Cc = Components.classes; +const Ci = Components.interfaces; +const Cu = Components.utils; +const Cr = Components.results; + +Components.utils.import("resource://gre/modules/Services.jsm"); + +const DEBUG = false; + +let log = DEBUG ? dump : function (){}; + + +function startup(data, reason) { + // This code allow to make all stdIO work + try { + Components.utils.import("resource://gre/modules/ctypes.jsm"); + let libdvm = ctypes.open("libdvm.so"); + let dvmStdioConverterStartup = libdvm.declare("dvmStdioConverterStartup", ctypes.default_abi, ctypes.void_t); + dvmStdioConverterStartup(); + log("MU: console redirected to adb logcat.\n"); + } catch(e) { + Cu.reportError("MU: unable to execute jsctype hack: "+e); + } + + // This code allow to kill firefox from adb + try { + let Watcher = { + window: null, + onOpenWindow: function(window) { + window = window.docShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow); + window.addEventListener("keydown", this, true); + }, + onCloseWindow: function (window) {}, + onWindowTitleChange: function () {}, + handleEvent: function(event) { + // This event is dispatched via: abd shell input keycode 19 + // KEYCODE_DPAD_UP = 19, UP can't be fired by virtual keyboard, + // so it should be safe to take this event as a kill signal. + // `adb shell input` and `JS keyCode` values doesn't map to same values + // In JS, KeyUp maps to DOM_VK_UP = 38: + // https://developer.mozilla.org/en/DOM/KeyboardEvent + if (event.keyCode == 38 && event.which == 38) { + Cu.reportError("Mobile killer triggered!"); + let appStartup = Cc['@mozilla.org/toolkit/app-startup;1']. + getService(Ci.nsIAppStartup); + appStartup.quit(Ci.nsIAppStartup.eForceQuit); + } + } + }; + Services.wm.addListener(Watcher); + log("MU: key listener to close firefox set.\n"); + } + catch(e) { + log("MU: Unable to register window watcher: " + e + "\n"); + } + + try { + let QuitObserver = { + observe: function (aSubject, aTopic, aData) { + Services.obs.removeObserver(QuitObserver, "quit-application", false); + dump("MU: APPLICATION-QUIT\n"); + } + }; + Services.obs.addObserver(QuitObserver, "quit-application", false); + log("MU: ready to watch firefox exit.\n"); + } catch(e) { + log("MU: unable to register quit-application observer: " + e + "\n"); + } +} + +function install() {} +function shutdown() {} diff --git a/tools/addon-sdk-1.7/python-lib/cuddlefish/mobile-utils/install.rdf b/tools/addon-sdk-1.7/python-lib/cuddlefish/mobile-utils/install.rdf new file mode 100644 index 0000000..0b81a0e --- /dev/null +++ b/tools/addon-sdk-1.7/python-lib/cuddlefish/mobile-utils/install.rdf @@ -0,0 +1,39 @@ +<?xml version="1.0"?> +<!-- This Source Code Form is subject to the terms of the Mozilla Public + - License, v. 2.0. If a copy of the MPL was not distributed with this + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> + + +<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:em="http://www.mozilla.org/2004/em-rdf#"> + <Description about="urn:mozilla:install-manifest"> + <em:id>mobile-utils@mozilla.com</em:id> + <em:version>1.0</em:version> + <em:type>2</em:type> + <em:bootstrap>true</em:bootstrap> + + <!-- Fennec-XUL --> + <em:targetApplication> + <Description> + <em:id>{a23983c0-fd0e-11dc-95ff-0800200c9a66}</em:id> + <em:minVersion>1</em:minVersion> + <em:maxVersion>*</em:maxVersion> + </Description> + </em:targetApplication> + + <!-- Fennec-NativeUI --> + <em:targetApplication> + <Description> + <em:id>{aa3c5121-dab2-40e2-81ca-7ea25febc110}</em:id> + <em:minVersion>1</em:minVersion> + <em:maxVersion>*</em:maxVersion> + </Description> + </em:targetApplication> + + <!-- Front End MetaData --> + <em:name>Mobile Addon-SDK utility addon</em:name> + <em:description>Allow better integration with cfx tool.</em:description> + <em:creator>Mozilla Corporation</em:creator> + + </Description> +</RDF> |