I am trying to get a phone object so that I can call and conference two numbers from within my application.
I have tried using the static PhoneFactory.makeDefaultPhones((Context)this)
but have not had any luck.
String phoneFactoryName = "com.android.internal.telephony.PhoneFactory";
String phoneName = "com.android.internal.telephony.Phone";
Class phoneFactoryClass = Class.forName(phoneFactoryName);
Class phoneClass = Class.forName(phoneName);
Method getDefaultPhone = phoneFactoryClass.getMethod("getDefaultPhone");
Object phoneObject = getDefaultPhone.invoke(null);
Error - Caused by java.lang.RuntimeException: PhoneFactory.getDefaultPhone must be called from Looper thread
Yes it can be instantiated. But you have to overcome a couple of hurdles:
In your AndroidManifest.xml
set
android:sharedUserId="android.uid.phone"
within the <manifest>
tag. This is required to prevent a SecurityException
from being thrown when protected Intents are sent by the methods you may invoke (like android.intent.action.SIM_STATE_CHANGED
).
Set
android:process="com.android.phone"
in your <application>
tag. This is required to allow the invocation of getDefaultPhone()
/ makeDefaultPhone()
.
To do all this your app must be signed with the system signature key.
Al least we can answer or ignore calls =) let me copy-paste my post
OMG!!! YES, WE CAN DO THAT!!!
I was going to kill myself after severe 24 hours of investigating and discovering... But I've found a "fresh" solution!
// "cheat" with Java reflection to gain access
// to TelephonyManager's ITelephony getter
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
telephonyService = (ITelephony)m.invoke(tm);
People who want to develop their call-control software visit this start point: http://www.google.com/codesearch/p?hl=en#zvQ8rp58BUs/trunk/phone/src/i4nc4mp/myLock/phone/CallPrompt.java&q=itelephony%20package:http://mylockforandroid%5C.googlecode%5C.com&d=0
There is a project. and there are important comments (and credits).
In short: copy AIDL file, add permissions to manifest, copy-paste source for telephony management.
Some more info for you. AT commands you can send only if you are rooted. Than you can kill system process and send commands but you will need a reboot to allow your phone to receive and send calls.
I'm very happy! =) Now my Shake2MuteCall will get an update !
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With