Bug 1722086 - Part 2: Centralize check for minimum Windows build. r=bytesized

This allows the check from bug 1719189 to be used by the WDBA without
duplication, and keeps it close to the rest of the UserChoice logic.

Differential Revision: https://phabricator.services.mozilla.com/D121559
This commit is contained in:
Adam Gashlin
2021-08-03 22:49:20 +00:00
parent c7fd521159
commit 2f2e2d3ce9
3 changed files with 12 additions and 13 deletions

View File

@@ -154,19 +154,6 @@ let ShellServiceInternal = {
throw new Error("checkBrowserUserChoiceHashes() failed");
}
// We can't set the hash consistently until Win 10 1703 (build 15063).
// This check is after the hash check so that telemetry can indicate
// when the hash check unexpectedly succeeds on an early build.
if (
!(
AppConstants.isPlatformAndVersionAtLeast("win", "10") &&
parseInt(Services.sysinfo.getProperty("build")) >= 15063
)
) {
telemetryResult = "ErrBuild";
throw new Error("Windows build is unsupported");
}
const wdba = Services.dirsvc.get("XREExeF", Ci.nsIFile);
wdba.leafName = "default-browser-agent.exe";
const aumi = XreDirProvider.getInstallHash();
@@ -184,6 +171,7 @@ let ShellServiceInternal = {
const MOZ_E_NO_PROGID = 0xa0000001;
const MOZ_E_HASH_CHECK = 0xa0000002;
const MOZ_E_REJECTED = 0xa0000003;
const MOZ_E_BUILD = 0xa0000004;
const exeWaitTimeoutMs = 2000; // 2 seconds
const exeWaitPromise = exeProcess.wait();
@@ -199,6 +187,7 @@ let ShellServiceInternal = {
[MOZ_E_NO_PROGID, "ErrExeProgID"],
[MOZ_E_HASH_CHECK, "ErrExeHash"],
[MOZ_E_REJECTED, "ErrExeRejected"],
[MOZ_E_BUILD, "ErrBuild"],
]).get(exitCode) ?? "ErrExeOther";
throw new Error(
`WDBA nonzero exit code ${exitCode}: ${telemetryResult}`

View File

@@ -9,6 +9,7 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/RefPtr.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/WindowsVersion.h"
#include "mozilla/WinHeaderOnlyUtils.h"
#include "WindowsUserChoice.h"
@@ -217,6 +218,11 @@ HRESULT SetDefaultBrowserUserChoice(const wchar_t* aAumi) {
return MOZ_E_HASH_CHECK;
}
if (!mozilla::IsWin10CreatorsUpdateOrLater()) {
LOG_ERROR_MESSAGE(L"UserChoice hash matched, but Windows build is too old");
return MOZ_E_BUILD;
}
auto sid = GetCurrentUserStringSid();
if (!sid) {
return E_FAIL;

View File

@@ -21,6 +21,9 @@
* MOZ_E_HASH_CHECK The existing UserChoice Hash could not be verified.
* MOZ_E_REJECTED UserChoice was set, but checking the default
* did not return our ProgID.
* MOZ_E_BUILD The existing UserChoice Hash was verified, but
* we're on an older, unsupported Windows build,
* so do not attempt to update the UserChoice hash.
* E_FAIL other failure
*/
HRESULT SetDefaultBrowserUserChoice(const wchar_t* aAumi);
@@ -33,5 +36,6 @@ HRESULT SetDefaultBrowserUserChoice(const wchar_t* aAumi);
const HRESULT MOZ_E_NO_PROGID = 0xa0000001L;
const HRESULT MOZ_E_HASH_CHECK = 0xa0000002L;
const HRESULT MOZ_E_REJECTED = 0xa0000003L;
const HRESULT MOZ_E_BUILD = 0xa0000004L;
#endif // DEFAULT_BROWSER_SET_DEFAULT_BROWSER_H__