Skip to content

Commit

Permalink
Merge branch 'develop' into fcappelli/breakage_report_improvements
Browse files Browse the repository at this point in the history
# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
  • Loading branch information
federicocappelli committed Nov 27, 2023
2 parents 0cab625 + c2b7161 commit f334cf6
Show file tree
Hide file tree
Showing 56 changed files with 3,027 additions and 168 deletions.
35 changes: 27 additions & 8 deletions .maestro/sync_tests/03_recover_account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,39 @@ tags:
- tapOn:
id: searchEntry
- inputText: ${CODE}

- evalScript: ${output.counter = 0}
- repeat:
while:
notVisible: "Select All"
true: ${output.counter < 3}
notVisible: Select All
commands:
- tapOn:
id: searchEntry
- tapOn: Select All
- longPressOn:
id: "searchEntry"
- evalScript: ${output.counter = output.counter + 1}

- tapOn: 'Select All'
- tapOn: Cut
- tapOn:
id: searchEntry
- longPressOn:
id: searchEntry
- evalScript: ${output.counter = 0}
- repeat:
while:
true: ${output.counter < 3}
notVisible: Paste
commands:
- tapOn:
id: "searchEntry"
- evalScript: ${output.counter = output.counter + 1}
- tapOn: Paste
- tapOn: Cancel

- tapOn: Close Tabs and Clear Data
- tapOn: Close Tabs and Clear Data
- runFlow:
when:
visible:
text: Cancel
commands:
- tapOn: Cancel
#</WORKAROUND>

# Recover Account test
Expand Down
42 changes: 33 additions & 9 deletions .maestro/sync_tests/04_sync_data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,28 @@ tags:
- tapOn:
id: searchEntry
- inputText: ${CODE}

- evalScript: ${output.counter = 0}
- repeat:
while:
notVisible: "Select All"
true: ${output.counter < 3}
notVisible: Select All
commands:
- tapOn:
id: searchEntry
- tapOn: Select All
- longPressOn:
id: "searchEntry"
- evalScript: ${output.counter = output.counter + 1}

- tapOn: 'Select All'
- tapOn: Cut
- tapOn:
id: searchEntry
- longPressOn:
id: searchEntry
- evalScript: ${output.counter = 0}
- repeat:
while:
true: ${output.counter < 3}
notVisible: Paste
commands:
- tapOn:
id: "searchEntry"
- evalScript: ${output.counter = output.counter + 1}
- tapOn: Paste
- tapOn: Cancel

Expand All @@ -76,7 +86,7 @@ tags:
- runFlow:
when:
visible:
text: "Cancel"
text: Cancel
commands:
- tapOn: Cancel
#</WORKAROUND>
Expand Down Expand Up @@ -119,8 +129,22 @@ tags:
- assertVisible: NFL.com | Official Site of the National Football League
- assertVisible: AS.com - Diario online deportivo. Fútbol, motor y mucho más
- tapOn: Bookmarks

# Only expect local favorites when Share Favorites is off
- tapOn: Favorites
- assertVisible: DuckDuckGo — Privacy, simplified.

# Enable Share Favorites and expect all favorites
- tapOn: Done
- tapOn: Settings
- tapOn: Sync & Back Up
- scroll
- assertVisible: Share Favorites
- tapOn: "0"
- tapOn: Settings
- tapOn: Done
- tapOn: Bookmarks
- tapOn: Favorites
- assertVisible: NFL.com | Official Site of the National Football League
- assertVisible: DuckDuckGo · GitHub
- assertVisible: Stack Overflow - Where Developers Learn, Share, & Build Careers
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Version.xcconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MARKETING_VERSION = 7.98.0
MARKETING_VERSION = 7.97.1
4 changes: 3 additions & 1 deletion Core/FeatureFlag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ public enum FeatureFlag: String {
case incontextSignup
case appTrackingProtection
case networkProtection
case networkProtectionWaitlistAccess
case networkProtectionWaitlistActive
}

extension FeatureFlag: FeatureFlagSourceProviding {
public var source: FeatureFlagSource {
switch self {
case .debugMenu, .sync, .appTrackingProtection, .networkProtection:
case .debugMenu, .sync, .appTrackingProtection, .networkProtection, .networkProtectionWaitlistAccess, .networkProtectionWaitlistActive:
return .internalOnly
case .autofillCredentialInjecting:
return .remoteReleasable(.subfeature(AutofillSubfeature.credentialsAutofill))
Expand Down
1 change: 1 addition & 0 deletions Core/UserDefaultsPropertyWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public struct UserDefaultsWrapper<T> {
case syncCredentialsPausedErrorDisplayed = "com.duckduckgo.ios.sync-credentialsPausedErrorDisplayed"

case networkProtectionDebugOptionAlwaysOnDisabled = "com.duckduckgo.network-protection.always-on.disabled"
case networkProtectionWaitlistTermsAndConditionsAccepted = "com.duckduckgo.ios.vpn.terms-and-conditions-accepted"

case addressBarPosition = "com.duckduckgo.ios.addressbarposition"
case showFullSiteAddress = "com.duckduckgo.ios.showfullsiteaddress"
Expand Down
98 changes: 77 additions & 21 deletions DuckDuckGo.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

97 changes: 97 additions & 0 deletions DuckDuckGo/AppDelegate+Waitlists.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
//
// AppDelegate+Waitlists.swift
// DuckDuckGo
//
// Copyright © 2023 DuckDuckGo. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

import Foundation
import BackgroundTasks
import NetworkProtection

extension AppDelegate {

func checkWaitlists() {
checkWindowsWaitlist()

#if NETWORK_PROTECTION
checkNetworkProtectionWaitlist()
#endif
checkWaitlistBackgroundTasks()

}

private func checkWindowsWaitlist() {
WindowsBrowserWaitlist.shared.fetchInviteCodeIfAvailable { error in
guard error == nil else { return }
WindowsBrowserWaitlist.shared.sendInviteCodeAvailableNotification()
}
}

#if NETWORK_PROTECTION
private func checkNetworkProtectionWaitlist() {
VPNWaitlist.shared.fetchInviteCodeIfAvailable { [weak self] error in
guard error == nil else {
#if !DEBUG
// If the user already has an invite code but their auth token has gone missing, attempt to redeem it again.
let tokenStore = NetworkProtectionKeychainTokenStore()
let waitlistStorage = VPNWaitlist.shared.waitlistStorage
if error == .alreadyHasInviteCode,
let inviteCode = waitlistStorage.getWaitlistInviteCode(),
!tokenStore.isFeatureActivated {
self?.fetchVPNWaitlistAuthToken(inviteCode: inviteCode)
}
#endif
return

}

guard let inviteCode = VPNWaitlist.shared.waitlistStorage.getWaitlistInviteCode() else {
return
}

self?.fetchVPNWaitlistAuthToken(inviteCode: inviteCode)
}
}
#endif

private func checkWaitlistBackgroundTasks() {
BGTaskScheduler.shared.getPendingTaskRequests { tasks in
let hasWindowsBrowserWaitlistTask = tasks.contains { $0.identifier == WindowsBrowserWaitlist.backgroundRefreshTaskIdentifier }
if !hasWindowsBrowserWaitlistTask {
WindowsBrowserWaitlist.shared.scheduleBackgroundRefreshTask()
}

#if NETWORK_PROTECTION
let hasVPNWaitlistTask = tasks.contains { $0.identifier == VPNWaitlist.backgroundRefreshTaskIdentifier }
if !hasVPNWaitlistTask {
VPNWaitlist.shared.scheduleBackgroundRefreshTask()
}
#endif
}
}

#if NETWORK_PROTECTION
func fetchVPNWaitlistAuthToken(inviteCode: String) {
Task {
do {
try await NetworkProtectionCodeRedemptionCoordinator().redeem(inviteCode)
VPNWaitlist.shared.sendInviteCodeAvailableNotification()
} catch {}
}
}
#endif

}
60 changes: 46 additions & 14 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import UIKit
import Combine
import Common
import Core
import CoreData
import UserNotifications
import Kingfisher
import WidgetKit
Expand Down Expand Up @@ -167,6 +168,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var shouldResetBookmarksSyncTimestamp = false

let preMigrationErrorHandling = EventMapping<BookmarkFormFactorFavoritesMigration.MigrationErrors> { _, error, _, _ in
if let error = error {
Pixel.fire(pixel: .bookmarksCouldNotLoadDatabase,
error: error)
} else {
Pixel.fire(pixel: .bookmarksCouldNotLoadDatabase)
}

if shouldPresentInsufficientDiskSpaceAlertAndCrash {
return
} else {
Thread.sleep(forTimeInterval: 1)
fatalError("Could not create Bookmarks database stack: \(error?.localizedDescription ?? "err")")
}
}

let oldFavoritesOrder = BookmarkFormFactorFavoritesMigration
.getFavoritesOrderFromPreV4Model(
dbContainerLocation: BookmarksDatabase.defaultDBLocation,
dbFileURL: BookmarksDatabase.defaultDBFileURL,
errorEvents: preMigrationErrorHandling
)

bookmarksDatabase.loadStore { [weak self] context, error in
guard let context = context else {
if let error = error {
Expand All @@ -191,7 +215,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
legacyStorage?.removeStore()

do {
BookmarkUtils.migrateToFormFactorSpecificFavorites(byCopyingExistingTo: .mobile, in: context)
BookmarkFormFactorFavoritesMigration.migrateToFormFactorSpecificFavorites(byCopyingExistingTo: .mobile,
preservingOrderOf: oldFavoritesOrder,
in: context)
if context.hasChanges {
try context.save(onErrorFire: .bookmarksMigrationCouldNotPrepareMultipleFavoriteFolders)
if let syncDataProviders = self?.syncDataProviders {
Expand Down Expand Up @@ -304,6 +330,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
// Having both in `didBecomeActive` can sometimes cause the exception when running on a physical device, so registration happens here.
AppConfigurationFetch.registerBackgroundRefreshTaskHandler()
WindowsBrowserWaitlist.shared.registerBackgroundRefreshTaskHandler()

#if NETWORK_PROTECTION
VPNWaitlist.shared.registerBackgroundRefreshTaskHandler()
#endif

RemoteMessaging.registerBackgroundRefreshTaskHandler(
bookmarksDatabase: bookmarksDatabase,
favoritesDisplayMode: AppDependencyProvider.shared.appSettings.favoritesDisplayMode
Expand All @@ -323,6 +354,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

#if NETWORK_PROTECTION
widgetRefreshModel.beginObservingVPNStatus()
NetworkProtectionAccessController().refreshNetworkProtectionAccess()
#endif

return true
Expand Down Expand Up @@ -405,18 +437,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
}

WindowsBrowserWaitlist.shared.fetchInviteCodeIfAvailable { error in
guard error == nil else { return }
WindowsBrowserWaitlist.shared.sendInviteCodeAvailableNotification()
}

BGTaskScheduler.shared.getPendingTaskRequests { tasks in
let hasWindowsBrowserWaitlistTask = tasks.contains { $0.identifier == WindowsBrowserWaitlist.backgroundRefreshTaskIdentifier }
if !hasWindowsBrowserWaitlistTask {
WindowsBrowserWaitlist.shared.scheduleBackgroundRefreshTask()
}
}

checkWaitlists()
syncService.scheduler.notifyAppLifecycleEvent()
fireFailedCompilationsPixelIfNeeded()
refreshShortcuts()
Expand Down Expand Up @@ -812,14 +833,18 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
withCompletionHandler completionHandler: @escaping () -> Void) {
if response.actionIdentifier == UNNotificationDefaultActionIdentifier {
let identifier = response.notification.request.identifier
if identifier == WindowsBrowserWaitlist.notificationIdentitier {
if identifier == WindowsBrowserWaitlist.notificationIdentifier {
presentWindowsBrowserWaitlistSettingsModal()
}

#if NETWORK_PROTECTION
if NetworkProtectionNotificationIdentifier(rawValue: identifier) != nil {
presentNetworkProtectionStatusSettingsModal()
}

if identifier == VPNWaitlist.notificationIdentifier {
presentNetworkProtectionWaitlistModal()
}
#endif
}

Expand All @@ -832,6 +857,13 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
}

#if NETWORK_PROTECTION
private func presentNetworkProtectionWaitlistModal() {
if #available(iOS 15, *) {
let networkProtectionRoot = VPNWaitlistViewController(nibName: nil, bundle: nil)
presentSettings(with: networkProtectionRoot)
}
}

func presentNetworkProtectionStatusSettingsModal() {
if #available(iOS 15, *) {
let networkProtectionRoot = NetworkProtectionRootViewController()
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"images" : [
{
"filename" : "Card-16.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
},
"properties" : {
"template-rendering-intent" : "template"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit f334cf6

Please sign in to comment.