IPhone 4 phone Interception

Source: Internet
Author: User

Development Environment: iphone4 (ios4.3.2)

The hook interception system is used to process notification events, and corresponding processing is performed to achieve the Interception Effect. Currently, the interception is not perfect. When a person in the blacklist calls a phone call, the system prompts that the user is on the call ......

Prerequisites: You need class-dump coretelephony framework and configure the hook development environment.

1. Before interception, let's talk about the use of dlsym.

We usually see some functions on the Internet that have the functions we need, and we can't find them in the class-dump header file, however, you can use grep to search for the corresponding symbols in the framework, causing some trouble. In this case, we can use dlsym to obtain the corresponding functions from the dynamic library.

2. Function for hanging up the phone

1 // coretelephony framework path in the system
2 # define ctpath "/xcode4.0andiphonesdk4.3/platforms/iphoneos. Platform/developer/sdks/iphoneos4.3.sdk/system/library/frameworks/coretelephony. Framework/coretelephony"
3
4 // call the Function
5-(bool) disconnectcall :( ID) Call
6 {
7 void * framework = dlopen (ctpath, rtld_lazy );
8 id (* ctcalldisconnect) (ID) = dlsym (framework, "ctcalldisconnect ");
9 ctcalldisconnect (CALL );
10 dlclose (framework );
11 return yes;
12}
Ctcalldisconnect is the function for hanging up the phone, but it does not find the corresponding declaration in the header file. Therefore, we use dlsym to obtain the function pointer and then use this function.
Disconnectcall is defined in util. M and used as an object clss, but it is better to define it as C type for ease of use.
The disconnectcall function is used in the following interception implementation.
In the # include <dlfcn. h> header file, dlopen and other functions must be closed by dlclose. Otherwise, some problems may occur.
3. Intercepted telephone notification handling events
Some functions in ctcallcenter notify the phone status, so handlenotiffrofromconnection in ctcallcenter is processed. The Code is as follows:
1 extern "C" Void replaced_ctcallcenter_handlenotiffrofromconnection (ctcallcenter * Self, Sel cmd, void * arg1, Id arg2, Id arg3)
2 {
3 // nslog (@ "Reply replaced_ctcallcenter_handlenotiffrofromconnection, arg1 =%@, arg2 =%@, arg3 =%@", arg1, arg2, arg3 );
4
5 // nslog (@ "------------ arg2type = % @, arg3type = % @", nsstringfromclass ([arg2 class]), nsstringfromclass ([arg3 class]);
6
7 nsdictionary * DIC = (nsdictionary *) arg3;
8
9 // obtain the call status, including ctcallstatedialing, ctcallstateincoming, ctcallstateconnected, and ctcallstatedisconnected, which are defined in the ctcallcenter. H (non-class-dump header file ).
10 nslog (@ "------- kctcallstatus =%@", [DIC objectforkey: @ "kctcallstatus"]);
11
12 nslog (@ "-------- currentcall=%@, calleventhandler = % @", self. currentcall, self. calleventhandler );
13
14 // obtain the ctcall object
15 ctcall * Call = [DIC objectforkey: @ "kctcall"];
16
17 // nslog (@ "------ callid = % @, callstate = % @", call. callid, call. callstate );
18
19 // here, you can determine the operation to be performed based on kctcallstatus
20 if (call. callstate = ctcallstatedialing)
21 {
22 nslog (@ "call has been ctcallstatedialing ");
23}
24 else if (call. callstate = ctcallstateincoming)
25 {
26 nslog (@ "call has just been ctcallstateincoming ");
27 // available for mounting
28 // hang up the phone
29 bool flag = [util disconnectcall: Call];
30 nslog (@ "---------------- whether to stop. Flag = % d", flag );
31}
32 else if (call. callstate = ctcallstateconnected)
33 {
34 nslog (@ "call is ctcallstateconnected ");
35}
36 else if (call. callstate = ctcallstatedisconnected)
37 {
38 nslog (@ "call is ctcallstatedisconnected ");
39}
40 else
41 {
42
43 nslog (@ "none of the conditions ");
44
45}
46
47 original_ctcallcenter_handlenotificationfromconnection (self, CMD, arg1, arg2, arg3 );
48}
The above code filters out all the calls, and the calls cannot be called, but a missed call will be left.
Here is just an idea. The specific interception needs to parse the passed parameters and provide some detailed processing.
Coretelephony framework also contains other functions, such as phone status changes, which can be carefully studied. I believe there will be great gains.
 
by yytong 2011-10-24 23:57
 
 
 
You can join the QQ group: 3078698 for discussion.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.