michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: const Cu = Components.utils; michael@0: const Cr = Components.results; michael@0: michael@0: Components.utils.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: const DEBUG = false; michael@0: michael@0: let log = DEBUG ? dump : function (){}; michael@0: michael@0: michael@0: function startup(data, reason) { michael@0: // This code allow to make all stdIO work michael@0: try { michael@0: Components.utils.import("resource://gre/modules/ctypes.jsm"); michael@0: let libdvm = ctypes.open("libdvm.so"); michael@0: let dvmStdioConverterStartup; michael@0: // Starting with Android ICS, dalvik uses C++. michael@0: // So that the symbol isn't a simple C one michael@0: try { michael@0: dvmStdioConverterStartup = libdvm.declare("_Z24dvmStdioConverterStartupv", ctypes.default_abi, ctypes.bool); michael@0: } michael@0: catch(e) { michael@0: // Otherwise, before ICS, it was a pure C library michael@0: dvmStdioConverterStartup = libdvm.declare("dvmStdioConverterStartup", ctypes.default_abi, ctypes.void_t); michael@0: } michael@0: dvmStdioConverterStartup(); michael@0: log("MU: console redirected to adb logcat.\n"); michael@0: } catch(e) { michael@0: Cu.reportError("MU: unable to execute jsctype hack: "+e); michael@0: } michael@0: michael@0: try { michael@0: let QuitObserver = { michael@0: observe: function (aSubject, aTopic, aData) { michael@0: Services.obs.removeObserver(QuitObserver, "quit-application"); michael@0: dump("MU: APPLICATION-QUIT\n"); michael@0: } michael@0: }; michael@0: Services.obs.addObserver(QuitObserver, "quit-application", false); michael@0: log("MU: ready to watch firefox exit.\n"); michael@0: } catch(e) { michael@0: log("MU: unable to register quit-application observer: " + e + "\n"); michael@0: } michael@0: } michael@0: michael@0: function install() {} michael@0: function shutdown() {}