KDEConnect: Implement functionality to mute an incoming call.
completed by: Mikhail Ivchenko
mentors: Albert Vaca
KDE Connect has a feature that displays a desktop notification when your phone is ringing. We want to extend this feature, adding a button to these notifications that allows us to mute the phone ringing until the caller hangs. That is: the phone will keep ringing but muted, and we will unmute it afterwards for the next call to be "noisy" again (unless we mute it too). The mute button should only affect the current call, and not set a permanent state in the phone.
To do so, you will have to edit the desktop client of KDE Connect (specifically the Telephony plugin) to add a button that sends a network packet to the Android KDE Connect client. Have a look at the Share plugin to see how to add actionable buttons to a notification. For the Android part, you will need to use some code like this to mute the ringer:
AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
Note that when the call ends you will need to set setStreamMute to false again, so you will need to add a listener for the call status. Moreover, the setStreamMute acts like a stack: so if you set it to true two times, you have to set it to false two times as well to unmute it. This means that probably is sane to keep a counter of the number of times we set it to true (think in edge cases, like receiving a call during another call), to make sure we set it to false the same number of times.