2015-06-19 23:56:59 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
"use strict";
|
|
|
|
|
2016-12-02 20:32:04 +03:00
|
|
|
const { Cc, Ci } = require("chrome");
|
2015-06-19 23:56:59 +03:00
|
|
|
|
|
|
|
loader.lazyRequireGetter(this, "Services");
|
|
|
|
loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
|
|
|
|
loader.lazyRequireGetter(this, "AppConstants",
|
|
|
|
"resource://gre/modules/AppConstants.jsm", true);
|
2017-09-06 17:35:11 +03:00
|
|
|
loader.lazyGetter(this, "hostname", () => {
|
|
|
|
try {
|
|
|
|
// On some platforms (Linux according to try), this service does not exist and fails.
|
|
|
|
return Cc["@mozilla.org/network/dns-service;1"]
|
|
|
|
.getService(Ci.nsIDNSService).myHostName;
|
|
|
|
} catch (e) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
});
|
|
|
|
loader.lazyGetter(this, "endianness", () => {
|
|
|
|
if ((new Uint32Array((new Uint8Array([1, 2, 3, 4])).buffer))[0] === 0x04030201) {
|
|
|
|
return "LE";
|
|
|
|
}
|
|
|
|
return "BE";
|
|
|
|
});
|
2015-06-19 23:56:59 +03:00
|
|
|
|
|
|
|
const APP_MAP = {
|
|
|
|
"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}": "firefox",
|
|
|
|
"{3550f703-e582-4d05-9a08-453d09bdfdc6}": "thunderbird",
|
|
|
|
"{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}": "seamonkey",
|
|
|
|
"{718e30fb-e89b-41dd-9da7-e25a45638b28}": "sunbird",
|
2018-03-19 12:43:17 +03:00
|
|
|
"{aa3c5121-dab2-40e2-81ca-7ea25febc110}": "mobile/android"
|
2015-06-19 23:56:59 +03:00
|
|
|
};
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var CACHED_INFO = null;
|
2015-06-19 23:56:59 +03:00
|
|
|
|
2018-02-22 11:49:06 +03:00
|
|
|
async function getSystemInfo() {
|
2015-06-19 23:56:59 +03:00
|
|
|
if (CACHED_INFO) {
|
|
|
|
return CACHED_INFO;
|
|
|
|
}
|
|
|
|
|
2018-06-01 13:36:09 +03:00
|
|
|
const appInfo = Services.appinfo;
|
|
|
|
const win = Services.wm.getMostRecentWindow(DebuggerServer.chromeWindowType);
|
|
|
|
const [processor, compiler] = appInfo.XPCOMABI.split("-");
|
2016-05-06 19:04:00 +03:00
|
|
|
let dpi,
|
|
|
|
useragent,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
physicalWidth,
|
|
|
|
physicalHeight,
|
|
|
|
brandName;
|
2018-06-01 13:36:09 +03:00
|
|
|
const appid = appInfo.ID;
|
|
|
|
const apptype = APP_MAP[appid];
|
|
|
|
const geckoVersion = appInfo.platformVersion;
|
|
|
|
const hardware = "unknown";
|
2015-09-17 21:59:35 +03:00
|
|
|
let version = "unknown";
|
2015-06-19 23:56:59 +03:00
|
|
|
|
2018-06-01 13:19:35 +03:00
|
|
|
const os = appInfo.OS;
|
2018-03-19 12:45:29 +03:00
|
|
|
version = appInfo.version;
|
2015-06-19 23:56:59 +03:00
|
|
|
|
2018-06-01 13:36:09 +03:00
|
|
|
const bundle = Services.strings.createBundle("chrome://branding/locale/brand.properties");
|
2015-06-19 23:56:59 +03:00
|
|
|
if (bundle) {
|
|
|
|
brandName = bundle.GetStringFromName("brandFullName");
|
|
|
|
} else {
|
|
|
|
brandName = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (win) {
|
2018-07-25 02:47:41 +03:00
|
|
|
const utils = win.windowUtils;
|
2015-06-19 23:56:59 +03:00
|
|
|
dpi = utils.displayDPI;
|
|
|
|
useragent = win.navigator.userAgent;
|
|
|
|
width = win.screen.width;
|
|
|
|
height = win.screen.height;
|
2016-05-06 19:04:00 +03:00
|
|
|
physicalWidth = win.screen.width * win.devicePixelRatio;
|
|
|
|
physicalHeight = win.screen.height * win.devicePixelRatio;
|
2015-06-19 23:56:59 +03:00
|
|
|
}
|
|
|
|
|
2018-06-01 13:36:09 +03:00
|
|
|
const info = {
|
2015-06-19 23:56:59 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Information from nsIXULAppInfo, regarding
|
|
|
|
* the application itself.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// The XUL application's UUID.
|
|
|
|
appid,
|
|
|
|
|
|
|
|
// Name of the app, "firefox", "thunderbird", etc., listed in APP_MAP
|
|
|
|
apptype,
|
|
|
|
|
|
|
|
// Mixed-case or empty string of vendor, like "Mozilla"
|
|
|
|
vendor: appInfo.vendor,
|
|
|
|
|
|
|
|
// Name of the application, like "Firefox", "Thunderbird".
|
|
|
|
name: appInfo.name,
|
|
|
|
|
|
|
|
// The application's version, for example "0.8.0+" or "3.7a1pre".
|
|
|
|
// Typically, the version of Firefox, for example.
|
|
|
|
// It is different than the version of Gecko or the XULRunner platform.
|
|
|
|
version,
|
|
|
|
|
|
|
|
// The application's build ID/date, for example "2004051604".
|
|
|
|
appbuildid: appInfo.appBuildID,
|
|
|
|
|
|
|
|
// The build ID/date of Gecko and the XULRunner platform.
|
|
|
|
platformbuildid: appInfo.platformBuildID,
|
|
|
|
geckobuildid: appInfo.platformBuildID,
|
|
|
|
|
|
|
|
// The version of Gecko or XULRunner platform, for example "1.8.1.19" or
|
|
|
|
// "1.9.3pre". In "Firefox 3.7 alpha 1" the application version is "3.7a1pre"
|
|
|
|
// while the platform version is "1.9.3pre"
|
|
|
|
platformversion: geckoVersion,
|
|
|
|
geckoversion: geckoVersion,
|
|
|
|
|
|
|
|
// Locale used in this build
|
2018-09-21 18:30:37 +03:00
|
|
|
locale: Services.locale.appLocaleAsLangTag,
|
2015-06-19 23:56:59 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Information regarding the operating system.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Returns the endianness of the architecture: either "LE" or "BE"
|
2017-09-06 17:35:11 +03:00
|
|
|
endianness: endianness,
|
2015-06-19 23:56:59 +03:00
|
|
|
|
|
|
|
// Returns the hostname of the machine
|
2017-09-06 17:35:11 +03:00
|
|
|
hostname: hostname,
|
2015-06-19 23:56:59 +03:00
|
|
|
|
|
|
|
// Name of the OS type. Typically the same as `uname -s`. Possible values:
|
|
|
|
// https://developer.mozilla.org/en/OS_TARGET
|
|
|
|
os,
|
|
|
|
platform: os,
|
|
|
|
|
|
|
|
// hardware and version info from `deviceinfo.hardware`
|
|
|
|
// and `deviceinfo.os`.
|
|
|
|
hardware,
|
|
|
|
|
|
|
|
// Type of process architecture running:
|
|
|
|
// "arm", "ia32", "x86", "x64"
|
|
|
|
// Alias to both `arch` and `processor` for node/deviceactor compat
|
|
|
|
arch: processor,
|
|
|
|
processor,
|
|
|
|
|
|
|
|
// Name of compiler used for build:
|
|
|
|
// `'msvc', 'n32', 'gcc2', 'gcc3', 'sunc', 'ibmc'...`
|
|
|
|
compiler,
|
|
|
|
|
|
|
|
// Location for the current profile
|
|
|
|
profile: getProfileLocation(),
|
|
|
|
|
|
|
|
// Update channel
|
|
|
|
channel: AppConstants.MOZ_UPDATE_CHANNEL,
|
|
|
|
|
|
|
|
dpi,
|
|
|
|
useragent,
|
|
|
|
width,
|
|
|
|
height,
|
2016-05-06 19:04:00 +03:00
|
|
|
physicalWidth,
|
|
|
|
physicalHeight,
|
2015-06-19 23:56:59 +03:00
|
|
|
brandName,
|
|
|
|
};
|
|
|
|
|
|
|
|
CACHED_INFO = info;
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
2016-05-17 21:25:54 +03:00
|
|
|
function getProfileLocation() {
|
2015-09-11 19:37:20 +03:00
|
|
|
// In child processes, we cannot access the profile location.
|
|
|
|
try {
|
2018-06-01 13:36:09 +03:00
|
|
|
const profd = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
|
|
|
const profservice = Cc["@mozilla.org/toolkit/profile-service;1"]
|
2016-12-02 20:32:04 +03:00
|
|
|
.getService(Ci.nsIToolkitProfileService);
|
2018-08-19 05:28:37 +03:00
|
|
|
for (const profile of profservice.profiles) {
|
2015-09-11 19:37:20 +03:00
|
|
|
if (profile.rootDir.path == profd.path) {
|
2016-12-02 20:32:04 +03:00
|
|
|
return profile.name;
|
2015-09-11 19:37:20 +03:00
|
|
|
}
|
2015-06-19 23:56:59 +03:00
|
|
|
}
|
2015-09-11 10:05:21 +03:00
|
|
|
|
2015-09-11 19:37:20 +03:00
|
|
|
return profd.leafName;
|
|
|
|
} catch (e) {
|
|
|
|
return "";
|
|
|
|
}
|
2015-06-19 23:56:59 +03:00
|
|
|
}
|
|
|
|
|
2018-02-22 11:49:06 +03:00
|
|
|
exports.getSystemInfo = getSystemInfo;
|