0

I am creating a system application which can modify the phone state variable to ringing or idle.

The permission MODIFY_PHONE_STATE is available only to system applications. After creating a system application, how can I access that variable?

Are there any setter and getter methods for this variable?

Anuj Arora
  • 21
  • 8
  • Are you sure you’re referring to the right _variable_? The permission `MODIFY_PHONE_STATE` is used to guard apps against using the API, which is not what you’re looking for. Also, what do you mean by “ringing”? As in you want the phone’s ringtone to ring? – Edric Jun 22 '19 at 14:09
  • By ringing i mean that my phone is receiving a call. I want to mock a call. My application has a phone state receiver registered which fires some events when my phone receives a call. So i want those events to be fired without actually a call being received by someone. If i could change the variable to RINGING state then my events will be fired. – Anuj Arora Jun 22 '19 at 15:44

1 Answers1

0

If all you want is to fake a broadcast receiver, you're trying much to hard. The easiest thing to do in your app is to refactor so that the BroadcastReceiver just calls a function on another class, and call that function yourself when you want to fake one. Alternatively, you can create the BroadcastReceiver class yourself via new, then call its onReceive.

Faking the phone state would have a negative effect on all the other apps on the device which may take different actions when the phone state changes. It should be avoided.

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127