Neither user 10056 nor the current process have android.permission.MODIFY_PHONE_STATE

I want to create such an application in which I want to open the dialer with the specified number during a call.

I successfully opened the dialer during a conversation with confirmation of this LINK , but could not dial the number, and another problem is that the code does not work on Android 2.2. is there any other way to make this work on all devices.

Code:

TelephonyManager tm = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
Class c = Class.forName(tm.getClass().getName());
Method m = c.getDeclaredMethod("getITelephony");
m.setAccessible(true);
ITelephony telephonyService;
telephonyService = (ITelephony)m.invoke(tm);

// Silence the ringer and answer the call!
telephonyService.silenceRinger();
telephonyService.answerRingingCall();
telephonyService.showCallScreen();
telephonyService.showCallScreenWithDialpad(true);

MISTAKE:

01-09 17:35:41.065: W/Resources(367): Converting to string: TypedValue{t=0x10/d=0x2 a=-1}
01-09 17:38:23.446: W/System.err(367): java.lang.SecurityException: Neither user 10056 nor current process has android.permission.MODIFY_PHONE_STATE.
01-09 17:38:23.446: W/System.err(367):  at android.os.Parcel.readException(Parcel.java:1322)
01-09 17:38:23.446: W/System.err(367):  at android.os.Parcel.readException(Parcel.java:1276)
01-09 17:38:23.446: W/System.err(367):  at com.android.internal.telephony.ITelephony$Stub$Proxy.silenceRinger(ITelephony.java:549)
01-09 17:38:23.446: W/System.err(367):  at com.everysoft.autoanswer.AutoAnswerIntentService.answerPhoneAidl(AutoAnswerIntentService.java:137)
01-09 17:38:23.446: W/System.err(367):  at com.everysoft.autoanswer.AutoAnswerIntentService.onHandleIntent(AutoAnswerIntentService.java:94)
01-09 17:38:23.446: W/System.err(367):  at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:59)
01-09 17:38:23.446: W/System.err(367):  at android.os.Handler.dispatchMessage(Handler.java:99)
01-09 17:38:23.446: W/System.err(367):  at android.os.Looper.loop(Looper.java:123)
01-09 17:38:23.446: W/System.err(367):  at android.os.HandlerThread.run(HandlerThread.java:60)

Manifest.xml

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

EDIT

I can automatically answer the call on all devices, but the problem is with opening only dialing.

+4
source share
5 answers

Remove this line and your code should work:

telephonyService.silenceRinger();

Android 2.2.

+2

, ?

Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse("tel:1231231234"));
startActivity(intent);
+2

MODIFY_PHONE_STATE

+1

MODIFY_PHONE_STATE, , .

answerRingingCall() . :

Intent buttonDown = new Intent(Intent.ACTION_MEDIA_BUTTON);
buttonDown.putExtra(Intent.EXTRA_KEY_EVENT, 
new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_HEADSETHOOK));
context.sendOrderedBroadcast(buttonDown, "android.permission.CALL_PRIVILEGED");
+1

hiden library com.android.internal.telephony.

 <uses-permission android:name="android.permission.INSTALL_PACKAGES"/>

, 4.4.2

0
source

All Articles