-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f089cce
Showing
18 changed files
with
1,334 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.theos/ | ||
packages/ | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"configurations": [ | ||
{ | ||
"name": "Mac", | ||
"includePath": [ | ||
"${workspaceFolder}/**", | ||
"/Users/nebula/theos/vendor/include/**" | ||
], | ||
"defines": [], | ||
"macFrameworkPath": [ | ||
"/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/System/Library/Frameworks" | ||
], | ||
"cStandard": "c17", | ||
"cppStandard": "c++17", | ||
"intelliSenseMode": "macos-clang-arm64", | ||
"configurationProvider": "ms-vscode.makefile-tools" | ||
} | ||
], | ||
"version": 4 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#ifndef DING_H | ||
#define DING_H | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
#import <Cephei/HBPreferences.h> | ||
|
||
@interface SBRingerPillView : UIView | ||
@property (nonatomic,retain) UIView * materialView; | ||
@property (nonatomic,retain) UIView * silentModeLabel; | ||
@property (nonatomic,retain) UIView * ringerLabel; | ||
@property (nonatomic,retain) UIView * onLabel; | ||
@property (nonatomic,retain) UIView * offLabel; | ||
@property (nonatomic,retain) UIView * slider; | ||
@property (nonatomic,retain) UIColor * glyphTintColor; | ||
@property (nonatomic,copy) NSArray * glyphTintBackgroundLayers; | ||
@property (nonatomic,copy) NSArray * glyphTintShapeLayers; | ||
@property (assign,nonatomic) unsigned long long state; | ||
@end | ||
|
||
@interface SBWiFiManager : NSObject | ||
+ (id)sharedInstance; | ||
- (void)setWiFiEnabled:(BOOL)enabled; | ||
- (void)setMobileDataEnabled:(BOOL)enabled; | ||
@end | ||
|
||
@interface BluetoothManager : NSObject | ||
+ (id)sharedInstance; | ||
- (void)setEnabled:(BOOL)enabled; | ||
- (void)setPowered:(BOOL)powered; | ||
@end | ||
|
||
@interface SBUIFlashlightController : NSObject | ||
+ (id)sharedInstance; | ||
- (void)setLevel:(unsigned long long)arg1; | ||
@end | ||
|
||
@interface RadiosPreferences : NSObject | ||
- (id)init; | ||
- (void)setAirplaneMode:(BOOL)arg1; | ||
@end | ||
|
||
@interface _PMLowPowerMode : NSObject | ||
+ (id)sharedInstance; | ||
- (NSInteger)getPowerMode; | ||
- (void)setPowerMode:(NSInteger)arg0 fromSource:(id)arg1; | ||
@end | ||
|
||
// LPM for iOS 13+ | ||
@interface _CDBatterySaver | ||
- (id)batterySaver; | ||
- (BOOL)setPowerMode:(long long)arg1 error:(id *)arg2; | ||
@end | ||
|
||
@interface SBOrientationLockManager : NSObject | ||
+ (id)sharedInstance; | ||
- (void)lock; | ||
- (void)unlock; | ||
@end | ||
|
||
@interface SBRingerControl | ||
+ (id)sharedInstance; | ||
- (BOOL)isRingerMuted; | ||
- (void)setRingerMuted:(BOOL)arg1; | ||
@end | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ Filter = { Bundles = ( "com.apple.springboard" ); }; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
#import "Ding.h" | ||
|
||
HBPreferences *preferences; | ||
|
||
BOOL isEnabled; | ||
BOOL bannerActive = NO; | ||
BOOL prevIsRingerMuted = NO; | ||
BOOL alwaysRingtone; | ||
BOOL hapticFeedback; | ||
BOOL actionMute; | ||
|
||
NSInteger switchAction; | ||
NSInteger mode; | ||
|
||
BOOL findActionBool(int position) { | ||
// position (arg1) | ||
// --------------- | ||
// 0 = Muted | ||
// 1 = Unmuted | ||
|
||
if (actionMute) { | ||
return (position == 0) ? YES : NO; | ||
} else { | ||
return (position == 0) ? NO : YES; | ||
} | ||
} | ||
|
||
%group CallGroup | ||
%hook SBInCallTransientOverlayViewController | ||
- (void)viewWillAppear:(BOOL)arg1 { | ||
bannerActive = YES; | ||
if (alwaysRingtone) [[%c(SBRingerControl) sharedInstance] setRingerMuted:NO]; | ||
%orig; | ||
} | ||
|
||
- (void)viewWillDisappear:(BOOL)arg1 { | ||
bannerActive = NO; | ||
if (alwaysRingtone) [[%c(SBRingerControl) sharedInstance] setRingerMuted:prevIsRingerMuted]; | ||
%orig; | ||
} | ||
%end | ||
|
||
%hook SBRemoteTransientOverlayHostViewController | ||
- (void)viewWillAppear:(BOOL)arg1 { | ||
bannerActive = YES; | ||
if (alwaysRingtone) [[%c(SBRingerControl) sharedInstance] setRingerMuted:NO]; | ||
%orig; | ||
} | ||
|
||
- (void)viewWillDisappear:(BOOL)arg1 { | ||
bannerActive = NO; | ||
if (alwaysRingtone) [[%c(SBRingerControl) sharedInstance] setRingerMuted:prevIsRingerMuted]; | ||
%orig; | ||
} | ||
%end | ||
|
||
%hook SBInCallBannerPresentableViewController | ||
- (void)presentableWillAppearAsBanner:(id)arg1 { | ||
bannerActive = YES; | ||
if (alwaysRingtone) [[%c(SBRingerControl) sharedInstance] setRingerMuted:NO]; | ||
%orig; | ||
} | ||
|
||
- (void)presentableWillDisappearAsBanner:(id)arg1 withReason:(id)arg2 { | ||
bannerActive = NO; | ||
if (alwaysRingtone) [[%c(SBRingerControl) sharedInstance] setRingerMuted:prevIsRingerMuted]; | ||
%orig; | ||
} | ||
%end | ||
%end | ||
|
||
%hook SpringBoard | ||
- (void)_updateRingerState:(int)arg1 withVisuals:(BOOL)arg2 updatePreferenceRegister:(BOOL)arg3 { | ||
if (!(switchAction == 1) && hapticFeedback) { | ||
UIImpactFeedbackGenerator *feedback = [[UIImpactFeedbackGenerator alloc] initWithStyle:(UIImpactFeedbackStyleMedium)]; | ||
[feedback prepare]; | ||
[feedback impactOccurred]; | ||
} | ||
|
||
prevIsRingerMuted = (arg1 == 0) ? YES : NO; | ||
|
||
// Switch Actions | ||
// -------------- | ||
// 1 = None | ||
// 2 = Flashlight | ||
// 3 = Orientation Lock | ||
// 4 = Airplane Mode | ||
// 5 = Wi-Fi | ||
// 6 = Bluetooth | ||
// 7 = Low Power Mode | ||
switch (switchAction) { | ||
case 1: | ||
break; | ||
case 2: | ||
if (actionMute) { | ||
[[%c(SBUIFlashlightController) sharedInstance] setLevel:(arg1 == 0) ? 4 : 0]; | ||
} else { | ||
[[%c(SBUIFlashlightController) sharedInstance] setLevel:(arg1 == 0) ? 0 : 4]; | ||
} | ||
break; | ||
case 3: | ||
if (arg1 == 0) { | ||
if (actionMute) { | ||
[[%c(SBOrientationLockManager) sharedInstance] lock]; | ||
} else { | ||
[[%c(SBOrientationLockManager) sharedInstance] unlock]; | ||
} | ||
} else { | ||
if (actionMute) { | ||
[[%c(SBOrientationLockManager) sharedInstance] unlock]; | ||
} else { | ||
[[%c(SBOrientationLockManager) sharedInstance] lock]; | ||
} | ||
} | ||
break; | ||
case 4: | ||
[[[%c(RadiosPreferences) alloc] init] setAirplaneMode:findActionBool(arg1)]; | ||
break; | ||
case 5: | ||
[[%c(SBWiFiManager) sharedInstance] setWiFiEnabled:findActionBool(arg1)]; | ||
break; | ||
case 6: | ||
[[%c(BluetoothManager) sharedInstance] setEnabled:findActionBool(arg1)]; | ||
[[%c(BluetoothManager) sharedInstance] setPowered:findActionBool(arg1)]; | ||
break; | ||
case 7: | ||
if (@available(iOS 15.0, *)) { | ||
if (actionMute) { | ||
[[%c(_PMLowPowerMode) sharedInstance] setPowerMode:(arg1 == 0) ? 1 : 0 fromSource:@"SpringBoard"]; | ||
} else { | ||
[[%c(_PMLowPowerMode) sharedInstance] setPowerMode:arg1 fromSource:@"SpringBoard"]; | ||
} | ||
} else { | ||
if (actionMute) { | ||
[[%c(_CDBatterySaver) batterySaver] setPowerMode:(arg1 == 0) ? 1 : 0 error:nil]; | ||
} else { | ||
[[%c(_CDBatterySaver) batterySaver] setPowerMode:arg1 error:nil]; | ||
} | ||
} | ||
break; | ||
default: | ||
NSLog(@"[Ding] Unsure what you did..."); | ||
break; | ||
} | ||
|
||
%orig(arg1, (mode == 2) ? YES : NO, arg3); | ||
} | ||
%end | ||
|
||
%hook SBRingerControl | ||
static SBRingerControl *__strong sharedInstance; | ||
|
||
// Init for iOS 15 and lower | ||
- (id)initWithHUDController:(id)arg1 soundController:(id)arg2 { | ||
id original = %orig; | ||
sharedInstance = original; | ||
return original; | ||
} | ||
|
||
// Init for iOS 16+ | ||
- (id)initWithBannerManager:(id)arg1 soundController:(id)arg2 { | ||
id original = %orig; | ||
sharedInstance = original; | ||
return original; | ||
} | ||
|
||
%new | ||
+ (id)sharedInstance { | ||
return sharedInstance; | ||
} | ||
|
||
- (BOOL)isRingerMuted { | ||
if (bannerActive && alwaysRingtone) { | ||
return NO; | ||
} else { | ||
if (mode == 2) { | ||
return %orig; | ||
} else { | ||
if (mode == 1) { | ||
return YES; | ||
} else { | ||
return NO; | ||
} | ||
} | ||
} | ||
} | ||
|
||
- (void)setRingerMuted:(BOOL)arg1 { | ||
if (bannerActive && alwaysRingtone) { | ||
%orig(NO); | ||
} else { | ||
if (mode == 2) { | ||
%orig; | ||
} else { | ||
if (mode == 1) { | ||
%orig(YES); | ||
} else { | ||
%orig(NO); | ||
} | ||
} | ||
} | ||
} | ||
%end | ||
|
||
%ctor { | ||
NSLog(@"Ding started!"); | ||
|
||
preferences = [[HBPreferences alloc] initWithIdentifier:@"me.nebula.ding.prefs"]; | ||
[preferences registerBool:&isEnabled default:YES forKey:@"isEnabled"]; | ||
[preferences registerInteger:&mode default:1 forKey:@"mode"]; | ||
[preferences registerBool:&alwaysRingtone default:NO forKey:@"alwaysRingtone"]; | ||
[preferences registerBool:&hapticFeedback default:YES forKey:@"hapticFeedback"]; | ||
[preferences registerInteger:&switchAction default:1 forKey:@"switchAction"]; | ||
[preferences registerBool:&actionMute default:NO forKey:@"actionMute"]; | ||
|
||
if (isEnabled) { | ||
%init; | ||
|
||
if (alwaysRingtone) { | ||
%init(CallGroup); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#import <CepheiPrefs/CepheiPrefs.h> | ||
#import <Cephei/HBPreferences.h> | ||
#include "spawn.h" | ||
#include "rootless.h" | ||
|
||
@interface DIRootListController : HBListController | ||
@property (nonatomic, retain) UIBarButtonItem *applyButton; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "DIRootListController.h" | ||
|
||
@implementation DIRootListController | ||
- (NSArray *)specifiers { | ||
if (!_specifiers) { | ||
_specifiers = [self loadSpecifiersFromPlistName:@"Root" target:self]; | ||
} | ||
|
||
return _specifiers; | ||
} | ||
|
||
- (instancetype)init { | ||
self = [super init]; | ||
|
||
if (self) { | ||
HBAppearanceSettings *appearanceSettings = [[HBAppearanceSettings alloc] init]; | ||
appearanceSettings.tintColor = [UIColor colorWithRed: 0.76 green: 0.61 blue: 0.83 alpha: 1.00]; | ||
appearanceSettings.tableViewCellSeparatorColor = [UIColor colorWithWhite:0 alpha:0]; | ||
self.hb_appearanceSettings = appearanceSettings; | ||
|
||
self.applyButton = [[UIBarButtonItem alloc] initWithTitle:@"Apply" | ||
style:UIBarButtonItemStylePlain | ||
target:self | ||
action:@selector(apply:)]; | ||
self.applyButton.tintColor = [UIColor colorWithRed: 0.76 green: 0.61 blue: 0.83 alpha: 1.00]; | ||
self.navigationItem.rightBarButtonItem = self.applyButton; | ||
} | ||
return self; | ||
} | ||
|
||
- (void)apply:(id)sender { | ||
pid_t pid; | ||
const char *args[] = {"sh", "-c", "sbreload", NULL}; | ||
posix_spawn(&pid, ROOT_PATH("/bin/sh"), NULL, NULL, (char *const *)args, NULL); | ||
} | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
BUNDLE_NAME = DingPrefs | ||
|
||
DingPrefs_EXTRA_FRAMEWORKS = Cephei CepheiPrefs | ||
DingPrefs_FILES = DIRootListController.m | ||
DingPrefs_FRAMEWORKS = UIKit | ||
DingPrefs_PRIVATE_FRAMEWORKS = Preferences | ||
DingPrefs_INSTALL_PATH = /Library/PreferenceBundles | ||
DingPrefs_CFLAGS = -fobjc-arc -Wdeprecated-declarations -Wno-deprecated-declarations | ||
|
||
include $(THEOS)/makefiles/common.mk | ||
include $(THEOS_MAKE_PATH)/bundle.mk |
Oops, something went wrong.