Merge lp:~tiagosh/telephony-service/headset-silent-mode into lp:telephony-service

Proposed by Tiago Salem Herrmann
Status: Needs review
Proposed branch: lp:~tiagosh/telephony-service/headset-silent-mode
Merge into: lp:telephony-service
Prerequisite: lp:~tiagosh/telephony-service/audio-route-manager
Diff against target: 63 lines (+22/-5)
1 file modified
libtelephonyservice/ringtone.cpp (+22/-5)
To merge this branch: bzr merge lp:~tiagosh/telephony-service/headset-silent-mode
Reviewer Review Type Date Requested Status
system-apps-ci-bot continuous-integration Needs Fixing
PS Jenkins bot continuous-integration Needs Fixing
Ubuntu Phablet Team Pending
Review via email: mp+285232@code.launchpad.net

This proposal supersedes a proposal from 2016-02-05.

Commit message

Allow playing the ringtone in the wired headset when phone is in silent mode.

Description of the change

Allow playing the ringtone in the wired headset when phone is in silent mode.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
system-apps-ci-bot (system-apps-ci-bot) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

1161. By Tiago Salem Herrmann

Allow playing the ringtone in the headset when phone is in silent mode

1160. By Tiago Salem Herrmann

merge parent branch

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libtelephonyservice/ringtone.cpp'
2--- libtelephonyservice/ringtone.cpp 2015-12-02 13:14:29 +0000
3+++ libtelephonyservice/ringtone.cpp 2016-02-05 19:17:52 +0000
4@@ -19,9 +19,12 @@
5 * along with this program. If not, see <http://www.gnu.org/licenses/>.
6 */
7
8+#include "telepathyhelper.h"
9 #include "greetercontacts.h"
10 #include "ringtone.h"
11
12+#include <QDBusInterface>
13+
14 RingtoneWorker::RingtoneWorker(QObject *parent) :
15 QObject(parent), mCallAudioPlayer(NULL), mCallAudioPlaylist(this),
16 mMessageAudioPlayer(NULL)
17@@ -32,27 +35,41 @@
18
19 void RingtoneWorker::playIncomingCallSound()
20 {
21+ bool shouldPlay = true;
22 if (!qgetenv("PA_DISABLED").isEmpty()) {
23 return;
24 }
25
26- if (GreeterContacts::instance()->silentMode()) {
27- return;
28- }
29-
30 // force delete all media player instances
31 stopIncomingCallSound();
32
33 // pick up the new ringtone in case it changed in the meantime
34 mCallAudioPlaylist.addMedia(QUrl::fromLocalFile(GreeterContacts::instance()->incomingCallSound()));
35 mCallAudioPlayer = new QMediaPlayer(this);
36+
37+ if (GreeterContacts::instance()->silentMode()) {
38+ shouldPlay = false;
39+ // then check if we have the headset plugged in
40+ QDBusInterface *phoneAppHandler = TelepathyHelper::instance()->handlerInterface();
41+ QString activeAudioOutput = phoneAppHandler->property("ActiveAudioOutput").toString();
42+ bool isWiredHeadset = (activeAudioOutput == "wired_headset");
43+ if (isWiredHeadset) {
44+ // by default the stream goes to both speaker and wired_headset. let's change that.
45+ phoneAppHandler->setProperty("ActiveAudioOutput", "wired_headset");
46+ shouldPlay = true;
47+ }
48+ }
49+
50 #if QT_VERSION < QT_VERSION_CHECK(5, 5, 0)
51 mCallAudioPlayer->setAudioRole(QMediaPlayer::AlertRole);
52 #else
53 mCallAudioPlayer->setAudioRole(QAudio::RingtoneRole);
54 #endif
55 mCallAudioPlayer->setPlaylist(&mCallAudioPlaylist);
56- mCallAudioPlayer->play();
57+
58+ if (shouldPlay) {
59+ mCallAudioPlayer->play();
60+ }
61 }
62
63 void RingtoneWorker::stopIncomingCallSound()

Subscribers

People subscribed via source and target branches