Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 7fa6c2b

Browse files
committed
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
1 parent e151e3d commit 7fa6c2b

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

browser/components/shell/ShellService.jsm

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,6 @@ let ShellServiceInternal = {
154154
throw new Error("checkBrowserUserChoiceHashes() failed");
155155
}
156156

157-
// We can't set the hash consistently until Win 10 1703 (build 15063).
158-
// This check is after the hash check so that telemetry can indicate
159-
// when the hash check unexpectedly succeeds on an early build.
160-
if (
161-
!(
162-
AppConstants.isPlatformAndVersionAtLeast("win", "10") &&
163-
parseInt(Services.sysinfo.getProperty("build")) >= 15063
164-
)
165-
) {
166-
telemetryResult = "ErrBuild";
167-
throw new Error("Windows build is unsupported");
168-
}
169-
170157
const wdba = Services.dirsvc.get("XREExeF", Ci.nsIFile);
171158
wdba.leafName = "default-browser-agent.exe";
172159
const aumi = XreDirProvider.getInstallHash();
@@ -184,6 +171,7 @@ let ShellServiceInternal = {
184171
const MOZ_E_NO_PROGID = 0xa0000001;
185172
const MOZ_E_HASH_CHECK = 0xa0000002;
186173
const MOZ_E_REJECTED = 0xa0000003;
174+
const MOZ_E_BUILD = 0xa0000004;
187175

188176
const exeWaitTimeoutMs = 2000; // 2 seconds
189177
const exeWaitPromise = exeProcess.wait();
@@ -199,6 +187,7 @@ let ShellServiceInternal = {
199187
[MOZ_E_NO_PROGID, "ErrExeProgID"],
200188
[MOZ_E_HASH_CHECK, "ErrExeHash"],
201189
[MOZ_E_REJECTED, "ErrExeRejected"],
190+
[MOZ_E_BUILD, "ErrBuild"],
202191
]).get(exitCode) ?? "ErrExeOther";
203192
throw new Error(
204193
`WDBA nonzero exit code ${exitCode}: ${telemetryResult}`

toolkit/mozapps/defaultagent/SetDefaultBrowser.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "mozilla/ArrayUtils.h"
1010
#include "mozilla/RefPtr.h"
1111
#include "mozilla/UniquePtr.h"
12+
#include "mozilla/WindowsVersion.h"
1213
#include "mozilla/WinHeaderOnlyUtils.h"
1314
#include "WindowsUserChoice.h"
1415

@@ -217,6 +218,11 @@ HRESULT SetDefaultBrowserUserChoice(const wchar_t* aAumi) {
217218
return MOZ_E_HASH_CHECK;
218219
}
219220

221+
if (!mozilla::IsWin10CreatorsUpdateOrLater()) {
222+
LOG_ERROR_MESSAGE(L"UserChoice hash matched, but Windows build is too old");
223+
return MOZ_E_BUILD;
224+
}
225+
220226
auto sid = GetCurrentUserStringSid();
221227
if (!sid) {
222228
return E_FAIL;

toolkit/mozapps/defaultagent/SetDefaultBrowser.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
* MOZ_E_HASH_CHECK The existing UserChoice Hash could not be verified.
2222
* MOZ_E_REJECTED UserChoice was set, but checking the default
2323
* did not return our ProgID.
24+
* MOZ_E_BUILD The existing UserChoice Hash was verified, but
25+
* we're on an older, unsupported Windows build,
26+
* so do not attempt to update the UserChoice hash.
2427
* E_FAIL other failure
2528
*/
2629
HRESULT SetDefaultBrowserUserChoice(const wchar_t* aAumi);
@@ -33,5 +36,6 @@ HRESULT SetDefaultBrowserUserChoice(const wchar_t* aAumi);
3336
const HRESULT MOZ_E_NO_PROGID = 0xa0000001L;
3437
const HRESULT MOZ_E_HASH_CHECK = 0xa0000002L;
3538
const HRESULT MOZ_E_REJECTED = 0xa0000003L;
39+
const HRESULT MOZ_E_BUILD = 0xa0000004L;
3640

3741
#endif // DEFAULT_BROWSER_SET_DEFAULT_BROWSER_H__

0 commit comments

Comments
 (0)