-
Notifications
You must be signed in to change notification settings - Fork 423
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into sam/fix-memory-pressure-monitor
* main: Update Ruby to 3.3.4 (#3547) Onboarding Add To Dock Pixels (#3543) Switch to free runners for tests that run on Maestro (#3546) Fix email protection test (#3539) Update BSK for PixelKit suffix change (#3534) Adding app backgrounded result to rule compilation (#3533) Send pixel on sync secure storage failure (#3542) Onboarding Add to Dock Refactor for Intro scenario (#3538) Update C-S-S to 6.29.0 (#3541) Change save password Never for Site button to Not Now (#3471) Release 7.144.0-1 (#3540) UserDefaults misbehavior monitoring (#3510) Send pixel on sync secure storage read failure (#3530) Remove NewTabPage retain cycles (#3532) Update release notes (#3529)
- Loading branch information
Showing
75 changed files
with
1,471 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
3.0.4 | ||
3.3.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// BoolFileMarker.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2024 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. | ||
// | ||
|
||
public struct BoolFileMarker { | ||
let fileManager = FileManager.default | ||
private let url: URL | ||
|
||
public var isPresent: Bool { | ||
fileManager.fileExists(atPath: url.path) | ||
} | ||
|
||
public func mark() { | ||
if !isPresent { | ||
fileManager.createFile(atPath: url.path, contents: nil, attributes: [.protectionKey: FileProtectionType.none]) | ||
} | ||
} | ||
|
||
public func unmark() { | ||
if isPresent { | ||
try? fileManager.removeItem(at: url) | ||
} | ||
} | ||
|
||
public init?(name: Name) { | ||
guard let applicationSupportDirectory = fileManager.urls(for: .applicationSupportDirectory, in: .userDomainMask).first else { | ||
return nil | ||
} | ||
|
||
self.url = applicationSupportDirectory.appendingPathComponent(name.rawValue) | ||
} | ||
|
||
public struct Name: RawRepresentable { | ||
public let rawValue: String | ||
|
||
public init(rawValue: String) { | ||
self.rawValue = "\(rawValue).marker" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// BoolFileMarkerTests.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2024 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 XCTest | ||
@testable import Core | ||
|
||
final class BoolFileMarkerTests: XCTestCase { | ||
|
||
private let marker = BoolFileMarker(name: .init(rawValue: "test"))! | ||
|
||
override func tearDown() { | ||
super.tearDown() | ||
|
||
marker.unmark() | ||
} | ||
|
||
private var testFileURL: URL? { | ||
FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first?.appendingPathComponent("test.marker") | ||
} | ||
|
||
func testMarkCreatesCorrectFile() throws { | ||
|
||
marker.mark() | ||
|
||
let fileURL = try XCTUnwrap(testFileURL) | ||
|
||
let attributes = try FileManager.default.attributesOfItem(atPath: fileURL.path) | ||
XCTAssertNil(attributes[.protectionKey]) | ||
XCTAssertTrue(FileManager.default.fileExists(atPath: fileURL.path)) | ||
XCTAssertEqual(marker.isPresent, true) | ||
} | ||
|
||
func testUnmarkRemovesFile() throws { | ||
marker.mark() | ||
marker.unmark() | ||
|
||
let fileURL = try XCTUnwrap(testFileURL) | ||
|
||
XCTAssertFalse(marker.isPresent) | ||
XCTAssertFalse(FileManager.default.fileExists(atPath: fileURL.path)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// StorageInconsistencyMonitor.swift | ||
// DuckDuckGo | ||
// | ||
// Copyright © 2024 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 UIKit | ||
|
||
public protocol AppActivationInconsistencyMonitoring { | ||
/// See `StorageInconsistencyMonitor` for details | ||
func didBecomeActive(isProtectedDataAvailable: Bool) | ||
} | ||
|
||
public protocol StatisticsStoreInconsistencyMonitoring { | ||
/// See `StorageInconsistencyMonitor` for details | ||
func statisticsDidLoad(hasFileMarker: Bool, hasInstallStatistics: Bool) | ||
} | ||
|
||
public protocol AdAttributionReporterInconsistencyMonitoring { | ||
/// See `StorageInconsistencyMonitor` for details | ||
func addAttributionReporter(hasFileMarker: Bool, hasCompletedFlag: Bool) | ||
} | ||
|
||
/// Takes care of reporting inconsistency in storage availability and/or state. | ||
/// See https://app.asana.com/0/481882893211075/1208618515043198/f for details. | ||
public struct StorageInconsistencyMonitor: AppActivationInconsistencyMonitoring & StatisticsStoreInconsistencyMonitoring & AdAttributionReporterInconsistencyMonitoring { | ||
|
||
public init() { } | ||
|
||
/// Reports a pixel if data is not available while app is active | ||
public func didBecomeActive(isProtectedDataAvailable: Bool) { | ||
if !isProtectedDataAvailable { | ||
Pixel.fire(pixel: .protectedDataUnavailableWhenBecomeActive) | ||
assertionFailure("This is unexpected state, debug if possible") | ||
} | ||
} | ||
|
||
/// Reports a pixel if file marker exists but installStatistics are missing | ||
public func statisticsDidLoad(hasFileMarker: Bool, hasInstallStatistics: Bool) { | ||
if hasFileMarker == true && hasInstallStatistics == false { | ||
Pixel.fire(pixel: .statisticsLoaderATBStateMismatch) | ||
assertionFailure("This is unexpected state, debug if possible") | ||
} | ||
} | ||
|
||
/// Reports a pixel if file marker exists but completion flag is false | ||
public func addAttributionReporter(hasFileMarker: Bool, hasCompletedFlag: Bool) { | ||
if hasFileMarker == true && hasCompletedFlag == false { | ||
Pixel.fire(pixel: .adAttributionReportStateMismatch) | ||
assertionFailure("This is unexpected state, debug if possible") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.