Update stuff

This commit is contained in:
Hariharan Mudaliar 2026-01-18 01:46:35 +05:30
commit 9214c61544
No known key found for this signature in database
GPG key ID: 025583EB0BE5640E
18 changed files with 985 additions and 118 deletions

View file

@ -12,6 +12,7 @@ final class ExtensionXPCService: NSObject, AtollXPCServiceProtocol {
private let authorizationManager = ExtensionAuthorizationManager.shared
private let liveActivityManager = ExtensionLiveActivityManager.shared
private let widgetManager = ExtensionLockScreenWidgetManager.shared
private let notchExperienceManager = ExtensionNotchExperienceManager.shared
private let decoder = JSONDecoder()
init(bundleIdentifier: String, host: ExtensionXPCServiceHost, connection: NSXPCConnection) {
@ -127,6 +128,40 @@ final class ExtensionXPCService: NSObject, AtollXPCServiceProtocol {
}
}
// MARK: Notch Experiences
func presentNotchExperience(descriptorData: Data, reply: @escaping (Bool, Error?) -> Void) {
respond(reply: reply) { service in
let descriptor = try service.decoder.decode(AtollNotchExperienceDescriptor.self, from: descriptorData)
try ExtensionDescriptorValidator.validate(descriptor)
service.logDiagnostics("Received notch experience payload from \(service.bundleIdentifier) (id: \(descriptor.id), priority: \(descriptor.priority.rawValue))")
try service.notchExperienceManager.present(descriptor: descriptor, bundleIdentifier: service.bundleIdentifier)
service.logDiagnostics("Notch experience \(descriptor.id) stored for \(service.bundleIdentifier); active experiences: \(service.notchExperienceManager.activeExperiences.count)")
}
}
func updateNotchExperience(descriptorData: Data, reply: @escaping (Bool, Error?) -> Void) {
respond(reply: reply) { service in
let descriptor = try service.decoder.decode(AtollNotchExperienceDescriptor.self, from: descriptorData)
try ExtensionDescriptorValidator.validate(descriptor)
service.logDiagnostics("Received notch experience update from \(service.bundleIdentifier) (id: \(descriptor.id))")
try service.notchExperienceManager.update(descriptor: descriptor, bundleIdentifier: service.bundleIdentifier)
service.logDiagnostics("Notch experience \(descriptor.id) updated for \(service.bundleIdentifier)")
}
}
func dismissNotchExperience(experienceID: String, bundleIdentifier providedBundleIdentifier: String, reply: @escaping (Bool, Error?) -> Void) {
Task { @MainActor [weak self] in
guard let self else { return }
guard self.validate(bundleIdentifier: providedBundleIdentifier, reply: reply) else { return }
self.logDiagnostics("Received notch experience dismissal from \(self.bundleIdentifier) (id: \(experienceID))")
self.notchExperienceManager.dismiss(experienceID: experienceID, bundleIdentifier: self.bundleIdentifier)
self.logDiagnostics("Notch experience \(experienceID) dismissed for \(self.bundleIdentifier)")
reply(true, nil)
}
}
// MARK: Diagnostics
func getVersion(reply: @escaping (String) -> Void) {

View file

@ -91,6 +91,12 @@ final class ExtensionXPCServiceHost: NSObject, NSXPCListenerDelegate {
}
}
func notifyNotchExperienceDismiss(bundleIdentifier: String, experienceID: String) {
deliver(to: bundleIdentifier) { client in
client.notchExperienceDidDismiss(experienceID: experienceID)
}
}
private func resolveBundleIdentifier(for connection: NSXPCConnection) -> String? {
let processIdentifier = connection.processIdentifier
guard processIdentifier != 0 else { return nil }