In Android M, changing the ringer mode while the incoming call is ringing doesn't have any effect

I made an app a while ago that changes the ring mode whenever certain paople call. So, when one of those people call, it changes the ring mode to make the call ring at full volume. I use

am.setStreamVolume(AudioManager.STREAM_RING, am.getStreamMaxVolume(AudioManager.STREAM_RING), 0);

The app also changes the interrupt filter to INTERRUPTION_FILTER_ALL, but to make things easier, let's assume that Do Not Disturb isn't enabled. So, for example, if the phone was set to vibrate, when there is an incoming call from a matching contact, it switches the ringer on, and sets the volume to max.

Everything worked fine before I got a phone with Marshmallow (Nexus 6P). Now, if there is an incoming call, my app changes the ring mode and volume as usual, but the incoming call doesn't get affected. It still behaves the same way, even thought the ringer settings got changed. I can verify that my app is defnintely making the changes -- after the call is finished, the ring volume settings are exactly as they should be. And if another call comes in, that one rings properly. It just seems like the ring mode changes aren't being applied to an incoming call that's already in progress.

Does anyone have anu suggestions as to what's changes in Marshmallow that's causing this, and if there is a way around it?


So, I found a way around this. I still have no idea how to fix this bug (or why it exists in the first place), but my workaround works pretty well. In addition to telling the OS to change the ring mode, I'm manually retrieving the default ringtone, and playing it in the app when a call comes in:

Uri alertUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
Ringtone r = RingtoneManager.getRingtone(getApplicationContext(), alertUri);
if(r != null && !r.isPlaying()){;

And then, when the incoming call stops ringing, I manually stop that Ringtone.

I had same problem on Marshmallow, I found solution with Xposed Framework. This module fixes this problem:

Need Your Help

"java.lang.RuntimeException: Could not launch intent" for UI with indeterminate ProgressBar

android android-intent android-progressbar android-espresso android-instrumentation

Are there any known issues with displaying indeterminate ProgressBars with the AndroidJUnitRunner?  I'm hitting this error during tests:

How to print (using cout) the way a number is stored in memory?

c++ binary iostream outputstream

I'm following a college course about operating systems and we're learning how to convert from binary to hexadecimal, decimal to hexadecimal, etc. and today we just learned how signed/unsigned numbe...