Author Topic: Use case for silver button  (Read 4616 times)

yoram

  • Newbie
  • *
  • Posts: 20
    • View Profile
Use case for silver button
« on: September 13, 2018, 02:46:39 pm »
beware: this is not a real solution for silver button utilization it's only a hack, poof of concept if you will.

one of the most annoying parts of having Gemini as Sailfish OS smartphone is the need to open it in order to answer a call on the touch screen and then close it to speak conveniently... the natural way would be to use the silver button, but I could not change voicecall-ui or lipstick compositor to read it's events from /dev/input/event1. why ? needs more investigation...

so here is how I did hack to make it happen:
I created mce configuration file with the collowing line:
[div class=\'codetop\']CODE[/div][div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']
[EVDEV]
KEY_SEND=KEY_HOME
[/div]

that will tell mce to translate silver button event to "home" key event, which makes it raise a powerkey signal with "home-key" argument

in /usr/share/voicecall-ui-jolla I added the following patch
[div class=\'codetop\']CODE[/div][div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']--- main.qml.orig       2018-09-13 21:40:34.440266047 +0300
+++ /usr/share/voicecall-ui-jolla/main.qml      2018-09-13 17:07:11.751154474 +0300
@@ -336,6 +336,24 @@
         }
     }
 
+    NemoDBus.DBusInterface {
+        bus: NemoDBus.DBus.SystemBus
+        service: 'com.nokia.mce'
+        path: '/com/nokia/mce/signal'
+        iface: 'com.nokia.mce.signal'
+        signalsEnabled: true
+
+        function power_button_trigger(event) {
+            if (event == "home-key") {
+            if (main.state === 'incoming') {
+                telephony.incomingCall.answer()
+            } else if (telephony.primaryCall) {
+                telephony.primaryCall.hangup()
+            }
+            }
+        }
+    }
+
     MessagesInterface { id: messaging }
 
     VoiceCallManager {
[/div]    
this patch tells the application to handle dbus signal (the one we raised from mce) by answer/hangup according to call state.

this is bad engineering and it sends  all running application to "cover" state, which is not nice, but it works.
I'm hoping to create a better solution soon, will be happy to get any leads for Sailfish QML documentation and specific Gemini PDA modifications (if any) in order to do a good job.

have fun

epninety

  • Newbie
  • *
  • Posts: 18
    • View Profile
Use case for silver button
« Reply #1 on: September 14, 2018, 09:12:48 am »
Thanks for your efforts, I've been hoping someone would come up with a patch for this - it's one of my very few bugbears with SFOS on Gemini.

One question (ok, two!) , where does the mce configuration file need to be placed? (and does it need a specific name?) (I don't know anything about mce)

yoram

  • Newbie
  • *
  • Posts: 20
    • View Profile
Use case for silver button
« Reply #2 on: September 14, 2018, 01:56:35 pm »
Quote from: epninety
Thanks for your efforts, I've been hoping someone would come up with a patch for this - it's one of my very few bugbears with SFOS on Gemini.

One question (ok, two!) , where does the mce configuration file need to be placed? (and does it need a specific name?) (I don't know anything about mce)

mce configuration files are scanned  in /etc/mce
the name is only important for order, i use /etc/mce/20-evdev.ini

yoram

  • Newbie
  • *
  • Posts: 20
    • View Profile
Use case for silver button
« Reply #3 on: September 15, 2018, 05:09:40 pm »
BTW, every feedback and suggestion on how to do it better, is welcome

epninety

  • Newbie
  • *
  • Posts: 18
    • View Profile
Use case for silver button
« Reply #4 on: September 16, 2018, 08:00:07 am »
I tried it out quickly on Friday but it didn't work and I didn't have time to investigate.

It looks like my mce file went missing somehow, I've replaced it and now the silver button sends all apps to cover state as expected.
I can't make it answer the call though, it simply mutes the ringing for some reason.
I will play some more when I have some free time.

yoram

  • Newbie
  • *
  • Posts: 20
    • View Profile
Use case for silver button
« Reply #5 on: September 16, 2018, 08:19:23 am »
Quote from: epninety
I tried it out quickly on Friday but it didn't work and I didn't have time to investigate.

It looks like my mce file went missing somehow, I've replaced it and now the silver button sends all apps to cover state as expected.
I can't make it answer the call though, it simply mutes the ringing for some reason.
I will play some more when I have some free time.

I'm sorry, I forgot to mention that for patching voicecall-ui you should:
killall voicecall-ui
do the patching
run voicecall-ui again

I also prefer to kill mce (it is triggered back right away) after chanign it's configuration

yoram

  • Newbie
  • *
  • Posts: 20
    • View Profile
Use case for silver button
« Reply #6 on: September 19, 2018, 02:11:43 pm »
Quote from: yoram
Quote from: epninety
I tried it out quickly on Friday but it didn't work and I didn't have time to investigate.

It looks like my mce file went missing somehow, I've replaced it and now the silver button sends all apps to cover state as expected.
I can't make it answer the call though, it simply mutes the ringing for some reason.
I will play some more when I have some free time.

I'm sorry, I forgot to mention that for patching voicecall-ui you should:
killall voicecall-ui
do the patching
run voicecall-ui again

I also prefer to kill mce (it is triggered back right away) after chanign it's configuration

Looks like I'm not very good at giving the full details. here is the full patch to voicecall-ui-jolla
[div class=\'codetop\']CODE[/div][div class=\'codemain\' style=\'height:200px;white-space:pre;overflow:auto\']--- main.qml.orig       2018-09-19 21:09:09.981556905 +0300
+++ /usr/share/voicecall-ui-jolla/main.qml      2018-09-19 21:09:37.170700448 +0300
@@ -9,6 +9,7 @@
 import org.nemomobile.contacts 1.0
 import org.nemomobile.notifications 1.0
 import org.nemomobile.voicecall 1.0 as VoiceCall
+import org.nemomobile.dbus 2.0 as NemoDBus
 
 import "common/CallLog.js" as CallLog
 import "common"
@@ -334,6 +335,24 @@
         }
     }
 
+    NemoDBus.DBusInterface {
+        bus: NemoDBus.DBus.SystemBus
+        service: 'com.nokia.mce'
+        path: '/com/nokia/mce/signal'
+        iface: 'com.nokia.mce.signal'
+        signalsEnabled: true
+
+        function power_button_trigger(event) {
+            if (event == "home-key") {
+            if (main.state === 'incoming') {
+                telephony.incomingCall.answer()
+            } else if (telephony.primaryCall) {
+                telephony.primaryCall.hangup()
+            }
+            }
+        }
+    }
+
     MessagesInterface { id: messaging }
 
     VoiceCallManager {
[/div]

sorry for the mess.
please comment on how (if at all) did it work for you.