|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 const Cc = Components.classes; |
|
8 const Ci = Components.interfaces; |
|
9 const Cu = Components.utils; |
|
10 const Cr = Components.results; |
|
11 |
|
12 Components.utils.import("resource://gre/modules/Services.jsm"); |
|
13 |
|
14 const DEBUG = false; |
|
15 |
|
16 let log = DEBUG ? dump : function (){}; |
|
17 |
|
18 |
|
19 function startup(data, reason) { |
|
20 // This code allow to make all stdIO work |
|
21 try { |
|
22 Components.utils.import("resource://gre/modules/ctypes.jsm"); |
|
23 let libdvm = ctypes.open("libdvm.so"); |
|
24 let dvmStdioConverterStartup; |
|
25 // Starting with Android ICS, dalvik uses C++. |
|
26 // So that the symbol isn't a simple C one |
|
27 try { |
|
28 dvmStdioConverterStartup = libdvm.declare("_Z24dvmStdioConverterStartupv", ctypes.default_abi, ctypes.bool); |
|
29 } |
|
30 catch(e) { |
|
31 // Otherwise, before ICS, it was a pure C library |
|
32 dvmStdioConverterStartup = libdvm.declare("dvmStdioConverterStartup", ctypes.default_abi, ctypes.void_t); |
|
33 } |
|
34 dvmStdioConverterStartup(); |
|
35 log("MU: console redirected to adb logcat.\n"); |
|
36 } catch(e) { |
|
37 Cu.reportError("MU: unable to execute jsctype hack: "+e); |
|
38 } |
|
39 |
|
40 try { |
|
41 let QuitObserver = { |
|
42 observe: function (aSubject, aTopic, aData) { |
|
43 Services.obs.removeObserver(QuitObserver, "quit-application"); |
|
44 dump("MU: APPLICATION-QUIT\n"); |
|
45 } |
|
46 }; |
|
47 Services.obs.addObserver(QuitObserver, "quit-application", false); |
|
48 log("MU: ready to watch firefox exit.\n"); |
|
49 } catch(e) { |
|
50 log("MU: unable to register quit-application observer: " + e + "\n"); |
|
51 } |
|
52 } |
|
53 |
|
54 function install() {} |
|
55 function shutdown() {} |