/* * Atoll (DynamicIsland) * Copyright (C) 2024-2026 Atoll Contributors * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ import Foundation class SystemHUDDebugger { /// Test system HUD functionality and print status public static func testSystemHUD() { print("\nšŸ” === System HUD Debug Report ===") // Check current OSDUIHelper status let isRunning = SystemOSDManager.isOSDUIHelperRunning() print("šŸ“Š OSDUIHelper Status: \(isRunning ? "āœ… Running" : "āŒ Not running")") // Test disable print("šŸ”‡ Testing disable...") SystemOSDManager.disableSystemHUD() // Wait and check usleep(500000) let isRunningAfterDisable = SystemOSDManager.isOSDUIHelperRunning() print("šŸ“Š After disable: \(isRunningAfterDisable ? "āœ… Running (stopped)" : "āŒ Not running")") // Test enable print("šŸ”Š Testing re-enable...") SystemOSDManager.enableSystemHUD() // Wait and check usleep(1000000) let isRunningAfterEnable = SystemOSDManager.isOSDUIHelperRunning() print("šŸ“Š After re-enable: \(isRunningAfterEnable ? "āœ… Running" : "āŒ Not running")") print("šŸ” === End Debug Report ===\n") if !isRunningAfterEnable { print("āš ļø WARNING: System HUD may not be working properly!") print("šŸ’” Try pressing volume keys to test system HUD functionality") } } /// Force restart OSDUIHelper using multiple methods public static func forceRestartOSDUIHelper() { print("šŸ”„ Force restarting OSDUIHelper...") // Method 1: Kill and kickstart SystemOSDManager.enableSystemHUD() // Method 2: Try launchctl bootstrap (more aggressive) do { let bootstrap = Process() bootstrap.executableURL = URL(fileURLWithPath: "/bin/launchctl") bootstrap.arguments = ["bootstrap", "gui/\(getuid())", "/System/Library/LaunchAgents/com.apple.OSDUIHelper.plist"] try bootstrap.run() bootstrap.waitUntilExit() print("āœ… Bootstrap method completed") } catch { print("āŒ Bootstrap method failed: \(error)") } // Method 3: Try direct service restart do { let restart = Process() restart.executableURL = URL(fileURLWithPath: "/bin/launchctl") restart.arguments = ["restart", "gui/\(getuid())/com.apple.OSDUIHelper"] try restart.run() restart.waitUntilExit() print("āœ… Restart method completed") } catch { print("āŒ Restart method failed: \(error)") } // Check final status usleep(1000000) let finalStatus = SystemOSDManager.isOSDUIHelperRunning() print("šŸ“Š Final OSDUIHelper status: \(finalStatus ? "āœ… Running" : "āŒ Not running")") } }