]> git.saurik.com Git - apple/security.git/blob - keychain/TrustedPeersHelper/Container_UserSync.swift
Security-59754.41.1.tar.gz
[apple/security.git] / keychain / TrustedPeersHelper / Container_UserSync.swift
1 import Foundation
2
3 // Apple TVs and watches have no UI to enable or disable this status.
4 // So, help them out by ignoring all efforts.
5 extension TPPBPeerStableInfo_UserControllableViewStatus {
6 func sanitizeForPlatform(permanentInfo: TPPeerPermanentInfo) -> TPPBPeerStableInfo_UserControllableViewStatus {
7 // Unknown is the unknown for any platform
8 if self == .UNKNOWN {
9 return .UNKNOWN
10 }
11
12 if permanentInfo.modelID.hasPrefix("AppleTV") ||
13 permanentInfo.modelID.hasPrefix("AudioAccessory") {
14 // Apple TVs, and HomePods don't have UI to set this bit. So, they should always sync the
15 // user-controlled views to which they have access.
16 //
17 // Some watches don't have UI to set the bit, but some do.
18 //
19 // Note that we want this sanitization behavior to be baked into the local OS, which is what owns
20 // the UI software, and not in the Policy, which can change.
21 return .FOLLOWING
22 } else {
23 // All other platforms can choose their own fate
24 return self
25 }
26 }
27 }
28
29 extension StableChanges {
30 static func change(viewStatus: TPPBPeerStableInfo_UserControllableViewStatus?) -> StableChanges? {
31 if viewStatus == nil {
32 return nil
33 }
34 return StableChanges(deviceName: nil,
35 serialNumber: nil,
36 osVersion: nil,
37 policyVersion: nil,
38 policySecrets: nil,
39 setSyncUserControllableViews: viewStatus)
40 }
41 }