Difference between revisions of "BackBoardServices.framework"

From iPhone Development Wiki
Jump to: navigation, search
(BKSHIDServicesAmbientLightSensorExists().)
m (Killing an application)
 
(2 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
}}
 
}}
  
'''BackBoardServices''' is a framework that was introduced in iOS 6.0. It serves as a communication bridge between [[SpringBoard]] and [[backboardd]]. The framework itself has absolutely no function other than to communicate between SpringBoard's Mach messaging server and backboardd's XPC server. It is solely a small wrapper around the XPC API, to keep SpringBoard and backboardd from having to deal with it directly.
+
'''BackBoardServices''' is a framework that was introduced in iOS 6.0. It serves as a communication bridge between [[SpringBoard]] and [[backboardd]]. The framework itself has no function other than to communicate between SpringBoard's Mach messaging server and backboardd's XPC server. It is solely a small wrapper around the XPC API, to keep SpringBoard and backboardd from having to deal with it directly.
  
The innards of BackBoardServices are actually quite simple. Almost every function in BackBoardServices creates an XPC connection with the opposing process, and then sends an XPC object identifying the function called. Then, the destination (being either SpringBoard or backboardd) receives the object, and performs the actual function, sending back a return value if necessary.
+
The innards of BackBoardServices are quite simple. Almost every function in BackBoardServices creates an XPC connection with the opposing process, and then sends an XPC object identifying the function called. Then, the destination (being either SpringBoard or backboardd) receives the object, and performs the actual function, sending back a return value if necessary.
  
 
BackBoardServices can be used for many system and hardware functions, including launching/closing applications, setting the backlight level and more.
 
BackBoardServices can be used for many system and hardware functions, including launching/closing applications, setting the backlight level and more.
Line 12: Line 12:
 
== Killing an application ==
 
== Killing an application ==
  
Replace '''com.apple.mobilesafari''' with the application's bundle identifier.
 
 
<source lang=c>
 
<source lang=c>
extern "C" void BKSTerminateApplicationForReasonAndReportWithDescription(NSString *app, int a, int b, NSString *description);
+
extern "C" void BKSTerminateApplicationForReasonAndReportWithDescription(NSString *bundleID, int reasonID, bool report, NSString *description);
 
...
 
...
BKSTerminateApplicationForReasonAndReportWithDescription(@"com.apple.mobilesafari", 5, 0, NULL);
+
BKSTerminateApplicationForReasonAndReportWithDescription(@"com.apple.mobilesafari", 5, false, NULL);
 
</source>
 
</source>
  
The last two arguments are used for the description, where the first is an unknown integer (use 1), and the second is your reason. These two arguments are not compulsory, but are followed by good practice.
+
You can specify the reason of terminating application (last argument) and choose whether to report this crash to system crash reporter (3rd argument).
 
<source lang=c>
 
<source lang=c>
BKSTerminateApplicationForReasonAndReportWithDescription(@"com.apple.mobilesafari", 5, 1, @"Killed because X.");
+
BKSTerminateApplicationForReasonAndReportWithDescription(@"com.apple.mobilesafari", 5, true, @"Killed because X.");
 
</source>
 
</source>
  
Line 27: Line 26:
 
Again, it is not mandatory to specify a description but it is a good thing to consider doing.
 
Again, it is not mandatory to specify a description but it is a good thing to consider doing.
 
<source lang=c>
 
<source lang=c>
extern "C" void BKSTerminateApplicationGroupForReasonAndReportWithDescription(int a, int b, int c, NSString *description);
+
extern "C" void BKSTerminateApplicationGroupForReasonAndReportWithDescription(int applicationGroupID, int reasonID, bool report, NSString *description);
 
...
 
...
 
BKSTerminateApplicationGroupForReasonAndReportWithDescription(1, 5, 21, @"Kill ALL the apps!");
 
BKSTerminateApplicationGroupForReasonAndReportWithDescription(1, 5, 21, @"Kill ALL the apps!");
Line 52: Line 51:
 
</source>
 
</source>
  
 +
{{Navbox Classes}}
 
{{Navbox Frameworks}}
 
{{Navbox Frameworks}}

Latest revision as of 03:56, 18 July 2016

BackBoardServices.framework
Private Framework
Availabile 6.0 – present


BackBoardServices is a framework that was introduced in iOS 6.0. It serves as a communication bridge between SpringBoard and backboardd. The framework itself has no function other than to communicate between SpringBoard's Mach messaging server and backboardd's XPC server. It is solely a small wrapper around the XPC API, to keep SpringBoard and backboardd from having to deal with it directly.

The innards of BackBoardServices are quite simple. Almost every function in BackBoardServices creates an XPC connection with the opposing process, and then sends an XPC object identifying the function called. Then, the destination (being either SpringBoard or backboardd) receives the object, and performs the actual function, sending back a return value if necessary.

BackBoardServices can be used for many system and hardware functions, including launching/closing applications, setting the backlight level and more.

Killing an application

extern "C" void BKSTerminateApplicationForReasonAndReportWithDescription(NSString *bundleID, int reasonID, bool report, NSString *description);
...
BKSTerminateApplicationForReasonAndReportWithDescription(@"com.apple.mobilesafari", 5, false, NULL);

You can specify the reason of terminating application (last argument) and choose whether to report this crash to system crash reporter (3rd argument).

BKSTerminateApplicationForReasonAndReportWithDescription(@"com.apple.mobilesafari", 5, true, @"Killed because X.");

Killing all applications

Again, it is not mandatory to specify a description but it is a good thing to consider doing.

extern "C" void BKSTerminateApplicationGroupForReasonAndReportWithDescription(int applicationGroupID, int reasonID, bool report, NSString *description);
...
BKSTerminateApplicationGroupForReasonAndReportWithDescription(1, 5, 21, @"Kill ALL the apps!");

Setting Backlight Level

The factor should be a number from 0.0 to 1.0, inclusive.

extern "C" void BKSHIDServicesSetBacklightFactorWithFadeDuration(float factor, int duration);
...
BKSHIDServicesSetBacklightFactorWithFadeDuration(0.5, 0);

Detecting Ambient Light Sensor

Check if Ambient Light Sensor exists or not. return 1 if exists.

extern "C" int BKSHIDServicesAmbientLightSensorExists();
...
NSLog(@"Ambient Light Sensor exists: %i", BKSHIDServicesAmbientLightSensorExists());