mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-16 17:42:51 +00:00
replace BluetoothManager calls with SpringBoardAccess
This commit is contained in:
parent
28f654622f
commit
c07efcf512
@ -74,59 +74,13 @@ kern_return_t IOObjectRelease(mach_port_t object);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// minimal BluetoothManager swiped from BigBoss SBSettings Toggle
|
||||
#import <Foundation/Foundation.h>
|
||||
@class UIDevice;
|
||||
@interface BluetoothManager : NSObject
|
||||
+ (BluetoothManager *) sharedInstance;
|
||||
- (void) setPowered:(BOOL)powered;
|
||||
- (void) setEnabled:(BOOL)enabled;
|
||||
- (BOOL) enabled;
|
||||
@end
|
||||
#define kAppBTServer CFSTR("com.apple.BTServer")
|
||||
#define kKeyBTPowered CFSTR("defaultPoweredState")
|
||||
#define kAppNetwork CFSTR("com.apple.preferences.network")
|
||||
#define kKeyBTNetwork CFSTR("bluetooth-network")
|
||||
|
||||
int iphone_system_bt_enabled(){
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
if ([[BluetoothManager sharedInstance] enabled]) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
||||
[pool release];
|
||||
return SBA_getBluetoothEnabled();
|
||||
}
|
||||
|
||||
void iphone_system_bt_set_enabled(int enabled)
|
||||
{
|
||||
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
/* Get a copy of the global bluetooth server */
|
||||
BluetoothManager *bm = [BluetoothManager sharedInstance];
|
||||
if ( [bm enabled] && enabled) return;
|
||||
if (![bm enabled] && !enabled) return;
|
||||
|
||||
if (enabled) {
|
||||
/* Store into preferences that bluetooth should start on system boot */
|
||||
CFPreferencesSetAppValue(kKeyBTNetwork, kCFBooleanTrue, kAppNetwork);
|
||||
|
||||
/* Turn bluetooth on */
|
||||
[bm setPowered:YES];
|
||||
} else {
|
||||
/* Store into preferences taht bluetooth should not start on system boot */
|
||||
CFPreferencesSetAppValue(kKeyBTNetwork, kCFBooleanFalse, kAppNetwork);
|
||||
|
||||
/* Turn bluetooth off */
|
||||
[bm setEnabled:NO];
|
||||
}
|
||||
/* Synchronize to preferences, e.g. write to disk, bluetooth settings */
|
||||
CFPreferencesAppSynchronize(kAppNetwork);
|
||||
|
||||
[pool release];
|
||||
SBA_setBluetoothEnabled(enabled);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user