Bug 1462019 - Part 2. Use abstract socket address for USB remote debugging. r=jryans
☠☠ backed out by 0f171ed1fd00 ☠ ☠
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Wed, 25 Jul 2018 14:47:49 +0900
changeset 428571 0b0036d13e81d6f1630fa08ab9f02955372380eb
parent 428570 6fb8d7cb6c2915948775fa01703b2c50eab86606
child 428572 bfaf82051dfd4a6605fed0da60f4f934d938bc50
push id34337
push userncsoregi@mozilla.com
push dateThu, 26 Jul 2018 21:58:45 +0000
treeherdermozilla-central@8f2f847b2f9d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1462019
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1462019 - Part 2. Use abstract socket address for USB remote debugging. r=jryans
devtools/shared/security/socket.js
mobile/android/app/mobile.js
mobile/android/modules/geckoview/GeckoViewRemoteDebugger.jsm
--- a/devtools/shared/security/socket.js
+++ b/devtools/shared/security/socket.js
@@ -431,22 +431,25 @@ SocketListener.prototype = {
 
     const self = this;
     return (async function() {
       const backlog = 4;
       self._socket = self._createSocketInstance();
       if (self.isPortBased) {
         const port = Number(self.portOrPath);
         self._socket.initSpecialConnection(port, flags, backlog);
-      } else {
+      } else if (self.portOrPath.startsWith("/")) {
         const file = nsFile(self.portOrPath);
         if (file.exists()) {
           file.remove(false);
         }
         self._socket.initWithFilename(file, parseInt("666", 8), backlog);
+      } else {
+        // Path isn't absolute path, so we use abstract socket address
+        self._socket.initWithAbstractAddress(self.portOrPath, backlog);
       }
       await self._setAdditionalSocketOptions();
       self._socket.asyncListen(self);
       dumpn("Socket listening on: " + (self.port || self.portOrPath));
     })().then(() => {
       this._advertise();
     }).catch(e => {
       dumpn("Could not start debugging listener on '" + this.portOrPath +
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -360,17 +360,17 @@ pref("geo.enabled", true);
 
 pref("javascript.options.mem.high_water_mark", 32);
 
 pref("dom.max_chrome_script_run_time", 0); // disable slow script dialog for chrome
 pref("dom.max_script_run_time", 20);
 
 // Absolute path to the devtools unix domain socket file used
 // to communicate with a usb cable via adb forward.
-pref("devtools.debugger.unix-domain-socket", "/data/data/@ANDROID_PACKAGE_NAME@/firefox-debugger-socket");
+pref("devtools.debugger.unix-domain-socket", "@ANDROID_PACKAGE_NAME@/firefox-debugger-socket");
 
 pref("devtools.remote.usb.enabled", false);
 pref("devtools.remote.wifi.enabled", false);
 
 pref("font.size.inflation.minTwips", 0);
 
 // When true, zooming will be enabled on all sites, even ones that declare user-scalable=no.
 pref("browser.ui.zoom.force-user-scalable", false);
--- a/mobile/android/modules/geckoview/GeckoViewRemoteDebugger.jsm
+++ b/mobile/android/modules/geckoview/GeckoViewRemoteDebugger.jsm
@@ -52,29 +52,36 @@ var GeckoViewRemoteDebugger = {
     debug `onEnable`;
     DebuggerServer.init();
     DebuggerServer.registerAllActors();
     const { createRootActor } = require("resource://gre/modules/dbg-browser-actors.js");
     DebuggerServer.setRootActor(createRootActor);
     DebuggerServer.allowChromeProcess = true;
     DebuggerServer.chromeWindowType = "navigator:geckoview";
 
+    // Socket address for USB remote debugger expects
+    // @ANDROID_PACKAGE_NAME/firefox-debugger-socket.
+    // In /proc/net/unix, it will be outputed as
+    // @org.mozilla.geckoview_example/firefox-debugger-socket
+    //
+    // If package name isn't available, it will be "@firefox-debugger-socket".
+
     const env = Cc["@mozilla.org/process/environment;1"]
               .getService(Ci.nsIEnvironment);
-    const dataDir = env.get("MOZ_ANDROID_DATA_DIR");
-
-    if (!dataDir) {
-      warn `Missing env MOZ_ANDROID_DATA_DIR - aborting debugger server start`;
-      return;
+    let packageName = env.get("MOZ_ANDROID_PACKAGE_NAME");
+    if (packageName) {
+      packageName = packageName + "/";
+    } else {
+      warn `Missing env MOZ_ANDROID_PACKAGE_NAME. Unable to get pacakge name`;
     }
 
     this._isEnabled = true;
     this._usbDebugger.stop();
 
-    const portOrPath = dataDir + "/firefox-debugger-socket";
+    const portOrPath = packageName + "firefox-debugger-socket";
     this._usbDebugger.start(portOrPath);
   },
 
   onDisable() {
     if (!this._isEnabled) {
       return;
     }