1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/addon-sdk/source/python-lib/cuddlefish/mobile-utils/bootstrap.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +"use strict"; 1.9 + 1.10 +const Cc = Components.classes; 1.11 +const Ci = Components.interfaces; 1.12 +const Cu = Components.utils; 1.13 +const Cr = Components.results; 1.14 + 1.15 +Components.utils.import("resource://gre/modules/Services.jsm"); 1.16 + 1.17 +const DEBUG = false; 1.18 + 1.19 +let log = DEBUG ? dump : function (){}; 1.20 + 1.21 + 1.22 +function startup(data, reason) { 1.23 + // This code allow to make all stdIO work 1.24 + try { 1.25 + Components.utils.import("resource://gre/modules/ctypes.jsm"); 1.26 + let libdvm = ctypes.open("libdvm.so"); 1.27 + let dvmStdioConverterStartup; 1.28 + // Starting with Android ICS, dalvik uses C++. 1.29 + // So that the symbol isn't a simple C one 1.30 + try { 1.31 + dvmStdioConverterStartup = libdvm.declare("_Z24dvmStdioConverterStartupv", ctypes.default_abi, ctypes.bool); 1.32 + } 1.33 + catch(e) { 1.34 + // Otherwise, before ICS, it was a pure C library 1.35 + dvmStdioConverterStartup = libdvm.declare("dvmStdioConverterStartup", ctypes.default_abi, ctypes.void_t); 1.36 + } 1.37 + dvmStdioConverterStartup(); 1.38 + log("MU: console redirected to adb logcat.\n"); 1.39 + } catch(e) { 1.40 + Cu.reportError("MU: unable to execute jsctype hack: "+e); 1.41 + } 1.42 + 1.43 + try { 1.44 + let QuitObserver = { 1.45 + observe: function (aSubject, aTopic, aData) { 1.46 + Services.obs.removeObserver(QuitObserver, "quit-application"); 1.47 + dump("MU: APPLICATION-QUIT\n"); 1.48 + } 1.49 + }; 1.50 + Services.obs.addObserver(QuitObserver, "quit-application", false); 1.51 + log("MU: ready to watch firefox exit.\n"); 1.52 + } catch(e) { 1.53 + log("MU: unable to register quit-application observer: " + e + "\n"); 1.54 + } 1.55 +} 1.56 + 1.57 +function install() {} 1.58 +function shutdown() {}