Bug 1542286 - Show proper runtime name for Fenix in about:debugging r=daisuke
☠☠ backed out by bb9ad1e63c26 ☠ ☠
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 06 May 2019 20:56:47 +0000
changeset 534740 38220ee5ab0c01215c9662d57bef5f7432b39081
parent 534739 2f1af0a1f129d6af5073c1b53fd15bc5bacb50b0
child 534741 8a220edc2db39df54337dc2a0b92847d0f2cb6b9
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdaisuke
bugs1542286
milestone68.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 1542286 - Show proper runtime name for Fenix in about:debugging r=daisuke Differential Revision: https://phabricator.services.mozilla.com/D29376
devtools/client/aboutdebugging-new/src/actions/runtimes.js
devtools/client/aboutdebugging-new/src/modules/usb-runtimes.js
devtools/client/aboutdebugging-new/src/types/runtime.js
devtools/shared/adb/adb-runtime.js
--- a/devtools/client/aboutdebugging-new/src/actions/runtimes.js
+++ b/devtools/client/aboutdebugging-new/src/actions/runtimes.js
@@ -124,25 +124,33 @@ function connectRuntime(id) {
             await clientWrapper.getPreference(REMOTE_DEBUG_ENABLED, true)
           : true;
       const privateBrowsing =
         await clientWrapper.getPreference(PERMANENT_PRIVATE_BROWSING, false);
       const serviceWorkersEnabled =
         await clientWrapper.getPreference(SERVICE_WORKERS_ENABLED, true);
       const serviceWorkersAvailable = serviceWorkersEnabled && !privateBrowsing;
 
+      // Fenix specific workarounds are needed until we can get proper server side APIs
+      // to detect Fenix and get the proper application names and versions.
+      // See https://github.com/mozilla-mobile/fenix/issues/2016.
+
+      // For Fenix runtimes, the ADB runtime name is more accurate than the one returned
+      // by the Device actor.
+      const runtimeName = runtime.isFenix ? runtime.name : deviceDescription.name;
+
       const runtimeDetails = {
         clientWrapper,
         compatibilityReport,
         connectionPromptEnabled,
         extensionDebugEnabled,
         info: {
           deviceName: deviceDescription.deviceName,
           icon,
-          name: deviceDescription.name,
+          name: runtimeName,
           os: deviceDescription.os,
           type: runtime.type,
           version: deviceDescription.version,
         },
         isMultiE10s: deviceDescription.isMultiE10s,
         serviceWorkersAvailable,
       };
 
@@ -340,16 +348,17 @@ function updateNetworkRuntimes(locations
       id: location,
       extra: {
         connectionParameters: { host, port: parseInt(port, 10) },
       },
       isConnecting: false,
       isConnectionFailed: false,
       isConnectionNotResponding: false,
       isConnectionTimeout: false,
+      isFenix: false,
       isUnavailable: false,
       isUnplugged: false,
       isUnknown: false,
       name: location,
       type: RUNTIMES.NETWORK,
     };
   });
   return updateRemoteRuntimes(runtimes, RUNTIMES.NETWORK);
@@ -366,16 +375,17 @@ function updateUSBRuntimes(adbRuntimes) 
       extra: {
         connectionParameters,
         deviceName: adbRuntime.deviceName,
       },
       isConnecting: false,
       isConnectionFailed: false,
       isConnectionNotResponding: false,
       isConnectionTimeout: false,
+      isFenix: adbRuntime.isFenix,
       isUnavailable: adbRuntime.isUnavailable,
       isUnplugged: adbRuntime.isUnplugged,
       name: adbRuntime.shortName,
       type: RUNTIMES.USB,
     };
   });
   return updateRemoteRuntimes(runtimes, RUNTIMES.USB);
 }
--- a/devtools/client/aboutdebugging-new/src/modules/usb-runtimes.js
+++ b/devtools/client/aboutdebugging-new/src/modules/usb-runtimes.js
@@ -11,48 +11,51 @@ loader.lazyRequireGetter(this, "adb", "d
  */
 class UsbRuntime {
   constructor(adbRuntime) {
     this.id = adbRuntime.id;
     this.deviceId = adbRuntime.deviceId;
     this.deviceName = adbRuntime.deviceName;
     this.shortName = adbRuntime.shortName;
     this.socketPath = adbRuntime.socketPath;
+    this.isFenix = adbRuntime.isFenix;
     this.isUnavailable = false;
     this.isUnplugged = false;
   }
 }
 
 /**
  * Used when a device was detected, meaning USB debugging is enabled on the device, but no
  * runtime/browser is available for connection.
  */
 class UnavailableUsbRuntime {
   constructor(adbDevice) {
     this.id = adbDevice.id + "|unavailable";
     this.deviceId = adbDevice.id;
     this.deviceName = adbDevice.name;
     this.shortName = "Unavailable runtime";
     this.socketPath = null;
+    this.isFenix = false;
     this.isUnavailable = true;
     this.isUnplugged = false;
   }
 }
 
 /**
  * Used to represent USB devices that were previously connected but are now missing
  * (presumably after being unplugged/disconnected from the computer).
  */
 class UnpluggedUsbRuntime {
   constructor(deviceId, deviceName) {
     this.id = deviceId + "|unplugged";
     this.deviceId = deviceId;
     this.deviceName = deviceName;
     this.shortName = "Unplugged runtime";
     this.socketPath = null;
+    this.isFenix = false;
     this.isUnavailable = true;
     this.isUnplugged = true;
   }
 }
 
 /**
  * Map used to keep track of discovered usb devices. Will be used to create the unplugged
  * usb runtimes.
--- a/devtools/client/aboutdebugging-new/src/types/runtime.js
+++ b/devtools/client/aboutdebugging-new/src/types/runtime.js
@@ -124,16 +124,21 @@ const runtime = {
 
   // will be true if connecting to runtime is taking time, will be false after connecting
   // or failing.
   isConnectionNotResponding: PropTypes.bool.isRequired,
 
   // this flag will be true when the connection was timeout.
   isConnectionTimeout: PropTypes.bool.isRequired,
 
+  // this flag will be true when the detected runtime is Fenix (Firefox Preview).
+  // Fenix need specific logic to get their display name, version and logos.
+  // Discussion ongoing in https://github.com/mozilla-mobile/fenix/issues/2016
+  isFenix: PropTypes.bool.isRequired,
+
   // unavailable runtimes are placeholders for devices where the runtime has not been
   // started yet. For instance an ADB device connected without a compatible runtime
   // running.
   isUnavailable: PropTypes.bool.isRequired,
 
   // unplugged runtimes are placeholders for devices that are no longer available. For
   // instance a USB device that was unplugged from the computer.
   isUnplugged: PropTypes.bool.isRequired,
--- a/devtools/shared/adb/adb-runtime.js
+++ b/devtools/shared/adb/adb-runtime.js
@@ -14,26 +14,53 @@ class AdbRuntime {
     this._adbDevice = adbDevice;
     this._socketPath = socketPath;
   }
 
   get id() {
     return this._adbDevice.id + "|" + this._socketPath;
   }
 
+  get isFenix() {
+    return this._packageName().includes("org.mozilla.fenix");
+  }
+
   get deviceId() {
     return this._adbDevice.id;
   }
 
   get deviceName() {
     return this._adbDevice.name;
   }
 
   get shortName() {
-    return `Firefox ${this._channel()}`;
+    const packageName = this._packageName();
+
+    switch (packageName) {
+      case "org.mozilla.firefox":
+        return "Firefox";
+      case "org.mozilla.firefox_beta":
+        return "Firefox Beta";
+      case "org.mozilla.fennec":
+      case "org.mozilla.fennec_aurora":
+        // This package name is now the one for Firefox Nightly distributed
+        // through the Google Play Store since "dawn project"
+        // cf. https://bugzilla.mozilla.org/show_bug.cgi?id=1357351#c8
+        return "Firefox Nightly";
+      case "org.mozilla.fenix":
+        // The current Nightly build for Fenix is available under this package name
+        // but the official packages will use fenix, fenix.beta and fenix.nightly.
+        return "Firefox Preview";
+      case "org.mozilla.fenix.beta":
+        return "Firefox Preview Beta";
+      case "org.mozilla.fenix.nightly":
+        return "Firefox Preview Nightly";
+      default:
+        return "Firefox Custom";
+    }
   }
 
   get socketPath() {
     return this._socketPath;
   }
 
   get name() {
     return `${this.shortName} on Android (${this.deviceName})`;
@@ -42,35 +69,16 @@ class AdbRuntime {
   connect(connection) {
     return prepareTCPConnection(this.deviceId, this._socketPath).then(port => {
       connection.host = "localhost";
       connection.port = port;
       connection.connect();
     });
   }
 
-  _channel() {
-    const packageName = this._packageName();
-
-    switch (packageName) {
-      case "org.mozilla.firefox":
-        return "";
-      case "org.mozilla.firefox_beta":
-        return "Beta";
-      case "org.mozilla.fennec":
-      case "org.mozilla.fennec_aurora":
-        // This package name is now the one for Firefox Nightly distributed
-        // through the Google Play Store since "dawn project"
-        // cf. https://bugzilla.mozilla.org/show_bug.cgi?id=1357351#c8
-        return "Nightly";
-      default:
-        return "Custom";
-    }
-  }
-
   _packageName() {
     // If using abstract socket address, it is "@org.mozilla.firefox/..."
     // If using path base socket, it is "/data/data/<package>...""
     // Until Fennec 62 only supports path based UNIX domain socket, but
     // Fennec 63+ supports both path based and abstract socket.
     return this._socketPath.startsWith("@") ?
       this._socketPath.substr(1).split("/")[0] :
       this._socketPath.split("/")[3];