disable carplay on ios 26db4+ and make CarPlayManager

This commit is contained in:
leminlimez committed 2025-08-12 14:45:49 -04:00
1 parent d35636c0be
commit dd902d2c30
8 files changed
+158 -123

No files matched your search

@@ -235,98 +235,6 @@ class PosterBoardManager: ObservableObject {
}
}
func getCarPlayCacheVersion() -> String {
// they started adding numbers to the end in iOS 18, this is to compensate for that
if #available(iOS 19.0, *) {
return "-12"
} else if #available(iOS 18.0, *) {
return "-11"
}
return ""
}
func getCarPlayWallpaperNames() -> [String]? {
dlopen("/System/Library/PrivateFrameworks/CarPlayUIServices.framework/CarPlayUIServices", RTLD_GLOBAL)
if #available(iOS 18.0, *) {
// iOS 18 method (it got moved)
guard let obj = objc_getClass("CRSUISystemWallpaper") as? NSObject else { print("no class"); return nil }
if let success = obj.perform(Selector(("wallpapers"))), let arr = success.takeUnretainedValue() as? [NSObject] {
var namesList: [String] = []
for wp in arr {
if let wpACName = wp.perform(Selector(("wallpaperAssetCatalogName"))), let result = wpACName.takeUnretainedValue() as? String {
namesList.append(result)
}
}
return namesList
}
} else {
// iOS 17-
guard let obj = objc_getClass("CRSUIWallpaperPreferences") as? NSObject else { print("no class"); return nil }
if let success = obj.perform(Selector(("availableWallpapers"))), let arr = success.takeUnretainedValue() as? [NSObject] {
var namesList: [String] = []
for wp in arr {
if let wpACName = wp.perform(Selector(("wallpaperAssetCatalogName"))), let result = wpACName.takeUnretainedValue() as? String {
namesList.append(result)
}
}
return namesList
}
}
return nil
}
func getCarPlayPhotosURL() -> URL {
let cppURL = SymHandler.getDocumentsDirectory().appendingPathComponent("CarPlayPhotos", conformingTo: .directory)
// create it if it doesn't exist
if !FileManager.default.fileExists(atPath: cppURL.path()) {
try? FileManager.default.createDirectory(at: cppURL, withIntermediateDirectories: true)
}
return cppURL
}
func applyCarPlay(appHash: String, wallpapers: [CarPlayWallpaper]) throws {
// write the image
var toRemove: [URL] = []
var activeWP: [String] = UserDefaults.standard.array(forKey: "ActiveCarPlayWallpapers") as? [String] ?? []
let cppURL = getCarPlayPhotosURL()
let cacheVer = getCarPlayCacheVersion()
for wallpaper in wallpapers {
if let data = wallpaper.selectedImageDataLight, let img = UIImage(data: data) {
let imgURL = SymHandler.getDocumentsDirectory().appendingPathComponent("CAR\(wallpaper.name)Dynamic-Light\(cacheVer).cpbitmap")
img.writeToCPBitmapFile(to: imgURL.path() as NSString)
try? data.write(to: cppURL.appendingPathComponent("\(wallpaper.name)-Light"))
toRemove.append(imgURL)
if !activeWP.contains(wallpaper.name) {
activeWP.append(wallpaper.name)
}
}
if let data = wallpaper.selectedImageDataDark, let img = UIImage(data: data) {
let imgURL = SymHandler.getDocumentsDirectory().appendingPathComponent("CAR\(wallpaper.name)Dynamic-Dark\(cacheVer).cpbitmap")
img.writeToCPBitmapFile(to: imgURL.path() as NSString)
try? data.write(to: cppURL.appendingPathComponent("\(wallpaper.name)-Dark"))
toRemove.append(imgURL)
if !activeWP.contains(wallpaper.name) {
activeWP.append(wallpaper.name)
}
}
}
// symlink and apply
let _ = try SymHandler.createAppSymlink(for: "\(appHash)/Library/Caches/MappedImageCache/com.apple.CarPlayApp.wallpaper-images")
defer {
SymHandler.cleanup()
}
for imgURL in toRemove {
try FileManager.default.trashItem(at: imgURL, resultingItemURL: nil)
}
UserDefaults.standard.set(activeWP, forKey: "ActiveCarPlayWallpapers")
let test = SymHandler.getDocumentsDirectory().appendingPathComponent("Caches")
try Data(count: 0).write(to: test)
}
static func clearCache() throws {
SymHandler.cleanup()
let docDir = SymHandler.getDocumentsDirectory()