I searched the internet and solved the problem in two ways:
1. Reflection calls the system's underlying method and obtains system permissions
The code for the reflection call is as follows:
Class Phonefactoryclass = Class.forName ("Com.android.internal.telephony.PhoneFactory");
Method Makedefaultphones=phonefactoryclass.getmethod ("Makedefaultphones", Context.class);
Makedefaultphones.invoke (Null,context);
Method Getdefaultphone = Phonefactoryclass.getmethod ("Getdefaultphone");
Object p = getdefaultphone.invoke (null);
Class Classcallmanager = Class.forName ("Com.android.internal.telephony.CallManager");
Object Callmanagerinstance=classcallmanager.getdeclaredmethod ("getinstance");
Classcallmanager.getmethod ("Registerphone", Object.class). Invoke (Callmanagerinstance, p);
Method newgetdefaultphone =classcallmanager.getmethod ("Getdefaultphone");
Object Phone=newgetdefaultphone.invoke (callmanagerinstance);
String phonename = "Com.android.internal.telephony.Phone";
Class Phoneclass = Class.forName (phonename);
Phoneclass.getmethod ("Dial", String.class). Invoke (phone, number);
The idea of a normal call:
Phonefactory.makedefaultphones (context);
Phone p = phonefactory.getdefaultphone ();
CallManager cm = Callmanager.getinstance ();
Cm.registerphone (P);
Phone phone = Cm.getdefaultphone ();
Phone.dial (number);
After the code is finished, you also need to get system permissions.
Of course, if you have a source environment, then don't be so troublesome, directly put your program into the source environment to compile. The premise of the following discussion is that we have a system of signature procedures, but there is no system source environment, but there are online source code, such as http://androidxref.com/website, specific reference:
http://gqdy365.iteye.com/blog/2111949
To begin the process of getting system permissions:
(1) Get platform.pk8 and Platform.x509.pem
Usually in the source environment of the Build\target\product\security directory, different system version to find the corresponding file (I use the 4.4.2 version)
(2) Get Signapk,.jar
Usually in the source environment of the build\tools\signapk directory, I am directly on the Internet to download the 4.4.2 version
(3) Put the files obtained in (1) (2) and the generated apk in a folder, go to this directory, perform the signature operation:
Java-jar Signapk.jar Platform.x509.pem platform.pk8 original apk new. apk
2. Refer to the JAR package project compiled by Android source code, directly using the call
Methods to invoke directly:
Phonefactory.makedefaultphones (context);
Phone p = phonefactory.getdefaultphone ();
CallManager cm = Callmanager.getinstance ();
Cm.registerphone (P);
Phone phone = Cm.getdefaultphone ();
Phone.dial (number);
In the Build.pradle file, set:
Defaultconfig {
...
multidexenabled true
}
dexoptions {
Javamaxheapsize "4g"
Incremental true
}
Summary, I found on the internet in the article said can be achieved, but concrete I practice down is not successful, the online implementation of this feature of the system version is relatively low, and I practice the version is 4.4.2
can refer to:
http://blog.csdn.net/u013401219/article/details/45887193
Http://blog.sina.com.cn/s/blog_65977dde0100uu7b.html
Android phone calls do not eject system dial-up Interface summary