import DeviceActivity import FamilyControls import Foundation import ManagedSettings final class DeviceActivityMonitorExtension: DeviceActivityMonitor { override func intervalDidStart(for activity: DeviceActivityName) { super.intervalDidStart(for: activity) let tokens = AppRestrictSharedStore.enabledTokens AppRestrictSharedStore.applyShield(for: tokens) } override func intervalDidEnd(for activity: DeviceActivityName) { super.intervalDidEnd(for: activity) // Keep shields while user still has enabled tokens; only clear when empty. let tokens = AppRestrictSharedStore.enabledTokens if tokens.isEmpty { AppRestrictSharedStore.clearShield() } else { AppRestrictSharedStore.applyShield(for: tokens) } } override func eventDidReachThreshold(_ event: DeviceActivityEvent.Name, activity: DeviceActivityName) { super.eventDidReachThreshold(event, activity: activity) } }