bootstrap.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. "use strict";
  5. const Cc = Components.classes;
  6. const Ci = Components.interfaces;
  7. const Cu = Components.utils;
  8. const Cr = Components.results;
  9. Components.utils.import("resource://gre/modules/Services.jsm");
  10. const DEBUG = false;
  11. let log = DEBUG ? dump : function (){};
  12. function startup(data, reason) {
  13. // This code allow to make all stdIO work
  14. try {
  15. Components.utils.import("resource://gre/modules/ctypes.jsm");
  16. let libdvm = ctypes.open("libdvm.so");
  17. let dvmStdioConverterStartup;
  18. // Starting with Android ICS, dalvik uses C++.
  19. // So that the symbol isn't a simple C one
  20. try {
  21. dvmStdioConverterStartup = libdvm.declare("_Z24dvmStdioConverterStartupv", ctypes.default_abi, ctypes.bool);
  22. }
  23. catch(e) {
  24. // Otherwise, before ICS, it was a pure C library
  25. dvmStdioConverterStartup = libdvm.declare("dvmStdioConverterStartup", ctypes.default_abi, ctypes.void_t);
  26. }
  27. dvmStdioConverterStartup();
  28. log("MU: console redirected to adb logcat.\n");
  29. } catch(e) {
  30. Cu.reportError("MU: unable to execute jsctype hack: "+e);
  31. }
  32. try {
  33. let QuitObserver = {
  34. observe: function (aSubject, aTopic, aData) {
  35. Services.obs.removeObserver(QuitObserver, "quit-application");
  36. dump("MU: APPLICATION-QUIT\n");
  37. }
  38. };
  39. Services.obs.addObserver(QuitObserver, "quit-application", false);
  40. log("MU: ready to watch firefox exit.\n");
  41. } catch(e) {
  42. log("MU: unable to register quit-application observer: " + e + "\n");
  43. }
  44. }
  45. function install() {}
  46. function shutdown() {}