зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1533861 - Add a telemetry to detect disk type r=chutten,froydnj,bdekoz
Differential Revision: https://phabricator.services.mozilla.com/D29383 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
e6f13e5d86
Коммит
f7c6cfd3d0
|
@ -1717,14 +1717,17 @@ EnvironmentCache.prototype = {
|
|||
profile: { // hdd where the profile folder is located
|
||||
model: getSysinfoProperty("profileHDDModel", null),
|
||||
revision: getSysinfoProperty("profileHDDRevision", null),
|
||||
type: getSysinfoProperty("profileHDDType", null),
|
||||
},
|
||||
binary: { // hdd where the application binary is located
|
||||
model: getSysinfoProperty("binHDDModel", null),
|
||||
revision: getSysinfoProperty("binHDDRevision", null),
|
||||
type: getSysinfoProperty("binHDDType", null),
|
||||
},
|
||||
system: { // hdd where the system files are located
|
||||
model: getSysinfoProperty("winHDDModel", null),
|
||||
revision: getSysinfoProperty("winHDDRevision", null),
|
||||
type: getSysinfoProperty("winHDDType", null),
|
||||
},
|
||||
};
|
||||
},
|
||||
|
|
|
@ -141,14 +141,17 @@ Structure:
|
|||
profile: { // hdd where the profile folder is located
|
||||
model: <string>, // windows only or null on failure
|
||||
revision: <string>, // windows only or null on failure
|
||||
type: <string>, // "SSD" or "HDD" windows only or null on failure
|
||||
},
|
||||
binary: { // hdd where the application binary is located
|
||||
model: <string>, // windows only or null on failure
|
||||
revision: <string>, // windows only or null on failure
|
||||
type: <string>, // "SSD" or "HDD" windows only or null on failure
|
||||
},
|
||||
system: { // hdd where the system files are located
|
||||
model: <string>, // windows only or null on failure
|
||||
revision: <string>, // windows only or null on failure
|
||||
type: <string>, // "SSD" or "HDD" windows only or null on failure
|
||||
},
|
||||
},
|
||||
gfx: {
|
||||
|
|
|
@ -606,6 +606,7 @@ function checkSystemSection(data) {
|
|||
for (let disk of EXPECTED_HDD_FIELDS) {
|
||||
Assert.ok(check(data.system.hdd[disk].model));
|
||||
Assert.ok(check(data.system.hdd[disk].revision));
|
||||
Assert.ok(check(data.system.hdd[disk].type));
|
||||
}
|
||||
|
||||
let gfxData = data.system.gfx;
|
||||
|
|
|
@ -101,9 +101,10 @@ static void SimpleParseKeyValuePairs(
|
|||
#if defined(XP_WIN)
|
||||
namespace {
|
||||
nsresult GetHDDInfo(const char* aSpecialDirName, nsAutoCString& aModel,
|
||||
nsAutoCString& aRevision) {
|
||||
nsAutoCString& aRevision, nsAutoCString& aType) {
|
||||
aModel.Truncate();
|
||||
aRevision.Truncate();
|
||||
aType.Truncate();
|
||||
|
||||
nsCOMPtr<nsIFile> profDir;
|
||||
nsresult rv =
|
||||
|
@ -149,6 +150,15 @@ nsresult GetHDDInfo(const char* aSpecialDirName, nsAutoCString& aModel,
|
|||
free(deviceOutput);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
queryParameters.PropertyId = StorageDeviceTrimProperty;
|
||||
bytesRead = 0;
|
||||
DEVICE_TRIM_DESCRIPTOR trimDescriptor = {sizeof(DEVICE_TRIM_DESCRIPTOR)};
|
||||
if (!::DeviceIoControl(handle, IOCTL_STORAGE_QUERY_PROPERTY, &queryParameters,
|
||||
sizeof(queryParameters), &trimDescriptor,
|
||||
sizeof(trimDescriptor), &bytesRead, nullptr)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// Some HDDs are including product ID info in the vendor field. Since PNP
|
||||
// IDs include vendor info and product ID concatenated together, we'll do
|
||||
// that here and interpret the result as a unique ID for the HDD model.
|
||||
|
@ -166,6 +176,11 @@ nsresult GetHDDInfo(const char* aSpecialDirName, nsAutoCString& aModel,
|
|||
deviceOutput->ProductRevisionOffset;
|
||||
aRevision.CompressWhitespace();
|
||||
}
|
||||
if (trimDescriptor.TrimEnabled) {
|
||||
aType = "SSD";
|
||||
} else {
|
||||
aType = "HDD";
|
||||
}
|
||||
free(deviceOutput);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -782,20 +797,25 @@ nsresult nsSystemInfo::Init() {
|
|||
return rv;
|
||||
}
|
||||
}
|
||||
nsAutoCString hddModel, hddRevision;
|
||||
if (NS_SUCCEEDED(GetHDDInfo(NS_GRE_DIR, hddModel, hddRevision))) {
|
||||
nsAutoCString hddModel, hddRevision, hddType;
|
||||
if (NS_SUCCEEDED(GetHDDInfo(NS_GRE_DIR, hddModel, hddRevision, hddType))) {
|
||||
rv = SetPropertyAsACString(NS_LITERAL_STRING("binHDDModel"), hddModel);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv =
|
||||
SetPropertyAsACString(NS_LITERAL_STRING("binHDDRevision"), hddRevision);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = SetPropertyAsACString(NS_LITERAL_STRING("binHDDType"), hddType);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
if (NS_SUCCEEDED(GetHDDInfo(NS_WIN_WINDOWS_DIR, hddModel, hddRevision))) {
|
||||
if (NS_SUCCEEDED(
|
||||
GetHDDInfo(NS_WIN_WINDOWS_DIR, hddModel, hddRevision, hddType))) {
|
||||
rv = SetPropertyAsACString(NS_LITERAL_STRING("winHDDModel"), hddModel);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv =
|
||||
SetPropertyAsACString(NS_LITERAL_STRING("winHDDRevision"), hddRevision);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = SetPropertyAsACString(NS_LITERAL_STRING("winHDDType"), hddType);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsAutoString countryCode;
|
||||
|
@ -1062,8 +1082,9 @@ nsSystemInfo::Observe(nsISupports* aSubject, const char* aTopic,
|
|||
}
|
||||
|
||||
nsresult nsSystemInfo::GetProfileHDDInfo() {
|
||||
nsAutoCString hddModel, hddRevision;
|
||||
nsresult rv = GetHDDInfo(NS_APP_USER_PROFILE_50_DIR, hddModel, hddRevision);
|
||||
nsAutoCString hddModel, hddRevision, hddType;
|
||||
nsresult rv =
|
||||
GetHDDInfo(NS_APP_USER_PROFILE_50_DIR, hddModel, hddRevision, hddType);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1073,6 +1094,10 @@ nsresult nsSystemInfo::GetProfileHDDInfo() {
|
|||
}
|
||||
rv = SetPropertyAsACString(NS_LITERAL_STRING("profileHDDRevision"),
|
||||
hddRevision);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
rv = SetPropertyAsACString(NS_LITERAL_STRING("profileHDDType"), hddType);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче