Bug 1409468: Add a property to telemetry's environment data to detect when a device has an Apple touchbar. r=mstange,francois
☠☠ backed out by 7ae1c0108e98 ☠ ☠
authorStephen A Pohl <spohl.mozilla.bugs@gmail.com>
Tue, 17 Oct 2017 15:33:22 -0400
changeset 386678 7a6b39895ac2393514d2fba5cb60d0e2b9c47c72
parent 386677 8b0c016826e027fad395b6e6e11d8fe178080489
child 386679 7cb727e675319191e4e86a7b3c1348cabd30af3b
push id96291
push userspohl@mozilla.com
push dateTue, 17 Oct 2017 19:33:35 +0000
treeherdermozilla-inbound@7cb727e67531 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, francois
bugs1409468
milestone58.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 1409468: Add a property to telemetry's environment data to detect when a device has an Apple touchbar. r=mstange,francois
toolkit/components/telemetry/TelemetryEnvironment.jsm
toolkit/components/telemetry/docs/data/environment.rst
xpcom/base/nsSystemInfo.cpp
--- a/toolkit/components/telemetry/TelemetryEnvironment.jsm
+++ b/toolkit/components/telemetry/TelemetryEnvironment.jsm
@@ -1661,16 +1661,17 @@ EnvironmentCache.prototype = {
 
     let data = {
       memoryMB,
       virtualMaxMB: virtualMB,
       cpu: this._getCpuData(),
       os: this._getOSData(),
       hdd: this._getHDDData(),
       gfx: this._getGFXData(),
+      hasTouchbar: getSysinfoProperty("hasTouchbar", false),
     };
 
     if (AppConstants.platform === "win") {
       data.isWow64 = getSysinfoProperty("isWow64", null);
     } else if (AppConstants.platform == "android") {
       data.device = this._getDeviceData();
     }
 
--- a/toolkit/components/telemetry/docs/data/environment.rst
+++ b/toolkit/components/telemetry/docs/data/environment.rst
@@ -198,16 +198,17 @@ Structure:
               gpuProcess: { // Out-of-process compositing ("GPU process") feature
                 status: <string>, // "Available" means currently in use
               },
               advancedLayers: { // Advanced Layers compositing. Only present if D3D11 enabled.
                 status: <string>,    // See the status codes above.
               },
             },
           },
+        hasTouchbar: <bool>, // Mac only
       },
       addons: {
         activeAddons: { // the currently enabled add-ons
           <addon id>: {
             blocklisted: <bool>,
             description: <string>, // null if not available
             name: <string>,
             userDisabled: <bool>,
--- a/xpcom/base/nsSystemInfo.cpp
+++ b/xpcom/base/nsSystemInfo.cpp
@@ -675,16 +675,32 @@ nsSystemInfo::Init()
 #endif
 
 #if defined(XP_MACOSX)
   nsAutoString countryCode;
   if (NS_SUCCEEDED(GetSelectedCityInfo(countryCode))) {
     rv = SetPropertyAsAString(NS_LITERAL_STRING("countryCode"), countryCode);
     NS_ENSURE_SUCCESS(rv, rv);
   }
+
+  bool hasTouchbar = false;
+  len = 0;
+  sysctlbyname("hw.model", nullptr, &len, nullptr, 0);
+  if (len) {
+    char* model = (char*)malloc(len * sizeof(char));
+    sysctlbyname("hw.model", model, &len, nullptr, 0);
+    if (strcmp(model, "MacBookPro13,2") == 0 || // i5, late-2016
+        strcmp(model, "MacBookPro13,3") == 0 || // i7, late-2016
+        strcmp(model, "MacBookPro14,2") == 0 || // i5, mid-2017
+        strcmp(model, "MacBookPro14,3") == 0) { // i7, mid-2017
+      hasTouchbar = true;
+    }
+    free(model);
+  }
+  SetPropertyAsBool(NS_LITERAL_STRING("hasTouchbar"), hasTouchbar);
 #endif
 
 #if defined(MOZ_WIDGET_GTK)
   // This must be done here because NSPR can only separate OS's when compiled, not libraries.
   // 64 bytes is going to be well enough for "GTK " followed by 3 integers
   // separated with dots.
   char gtkver[64];
   ssize_t gtkver_len = 0;