Skip to content

Commit

Permalink
Bugfix FXIOS-10906 [Default Browser] Beta detect build and don't run …
Browse files Browse the repository at this point in the history
…API (backport #23820) (#23824)

Bugfix FXIOS-10906 [Default Browser] Beta detect build and don't run API (#23820)

* Beta detect build and don't run API

* NOT on the block list

* Adding logs

(cherry picked from commit a5df3e2)

Co-authored-by: lmarceau <[email protected]>
  • Loading branch information
mergify[bot] and lmarceau authored Dec 17, 2024
1 parent d9cf607 commit be550d9
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions firefox-ios/Client/Application/DefaultBrowserUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,36 @@ struct DefaultBrowserUtil {
let application: UIApplicationInterface
let dmaCountries = ["BE", "BG", "CZ", "DK", "DE", "EE", "IE", "EL", "ES", "FR", "HR", "IT", "CY", "LV",
"LT", "LU", "HU", "MT", "NL", "AT", "PL", "PT", "RO", "SI", "SK", "FI", "SE", "GR"]
private let logger: Logger
init(userDefault: UserDefaultsInterface = UserDefaults.standard,
telemetryWrapper: TelemetryWrapperProtocol = TelemetryWrapper.shared,
locale: LocaleInterface = Locale.current,
application: UIApplicationInterface = UIApplication.shared) {
application: UIApplicationInterface = UIApplication.shared,
logger: Logger = DefaultLogger.shared) {
self.userDefault = userDefault
self.telemtryWrapper = telemetryWrapper
self.locale = locale
self.application = application
self.logger = logger
}

func processUserDefaultState(isFirstRun: Bool) {
guard #available(iOS 18.2, *),
let isDefault = try? application.isDefault(.webBrowser)
else { return }
guard #available(iOS 18.2, *) else { return }

guard !isRunningOnBlockListBetaOS() else {
logger.log("Cannot run the isDefault since the device running a Beta on the block list",
level: .info,
category: .setup)
return
}

logger.log("Going to try UIApplicationInterface.isDefault", level: .info, category: .setup)
guard let isDefault = try? application.isDefault(.webBrowser) else {
logger.log("UIApplicationInterface.isDefault was not present", level: .info, category: .setup)
return
}

logger.log("UIApplicationInterface.isDefault was successful", level: .info, category: .setup)
trackIfUserIsDefault(isDefault)

if isFirstRun {
Expand All @@ -41,6 +56,13 @@ struct DefaultBrowserUtil {
}
}

private func isRunningOnBlockListBetaOS() -> Bool {
let systemVersion = ProcessInfo.processInfo.operatingSystemVersionString
let betaBlockLists: [String] = ["22C5109p", "22C5125e", "22C5131e", "22C5142a"]

return betaBlockLists.contains { systemVersion.contains($0) }
}

private func trackIfUserIsDefault(_ isDefault: Bool) {
userDefault.set(isDefault, forKey: PrefsKeys.AppleConfirmedUserIsDefaultBrowser)

Expand Down

1 comment on commit be550d9

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error!

InterpreterError at template.tasks[0].extra[0].treeherder[1].symbol: unknown context value cron

Please sign in to comment.