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?

2
  • 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? Commented Jun 22, 2019 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. Commented Jun 22, 2019 at 15:44

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.