How to block phone numbers?
#1
I don't know your country but in the US you get scam phones almost every day. On many phones you can block certain numbers or even block all unknown phone numbers. Is this possible in any distro? thanks
  Reply
#2
I don't know if any of the existing phone apps do it. It's the obvious place to add it so it can be integrated into the UI, but I think you could implement it as a standalone app too, registering for dbus notification on call and rejecting if it's from a blocked number. To be universal you'd nee to cover both ofono and modemmanager dbus interfaces, but the logic should be more or less the same.
  Reply
#3
It would be great to start a community curated spam/block list and be able to opt in to filtering calls like you can do on Android with apps like Yet Another Call Blocker.
  Reply
#4
(10-24-2020, 10:05 AM)wibble Wrote: I don't know if any of the existing phone apps do it. It's the obvious place to add it so it can be integrated into the UI, but I think you could implement it as a standalone app too, registering for dbus notification on call and rejecting if it's from a blocked number. To be universal you'd nee to cover both ofono and modemmanager dbus interfaces, but the logic should be more or less the same.
Thanks for your answer. I really think this should be included in the phone apps.
Do you know how to officially suggest this to Mobian?

(10-26-2020, 07:24 AM)bilb Wrote: It would be great to start a community curated spam/block list and be able to opt in to filtering calls like you can do on Android with apps like Yet Another Call Blocker.
Do you mean a list of phone numbers to block? it would be gigantic and new numbers being added every day. 
But sure, if a community like this exists, I will add every scam number I get.

(10-24-2020, 10:05 AM)wibble Wrote: I don't know if any of the existing phone apps do it. It's the obvious place to add it so it can be integrated into the UI, but I think you could implement it as a standalone app too, registering for dbus notification on call and rejecting if it's from a blocked number. To be universal you'd nee to cover both ofono and modemmanager dbus interfaces, but the logic should be more or less the same.
Btw, I also like the idea of writing my own code. I do not have the knowledge to communicate to the dbus interfaces. I don't know what are they. 
If I can my own code I could selectively block unkown phones outside my area, but accept from particular areas. So, I could put my own rules.

So, how do I communicate (I am a python person) with the phone communications?
  Reply
#5
(10-28-2020, 04:18 PM)natasha Wrote:
(10-24-2020, 10:05 AM)wibble Wrote: I don't know if any of the existing phone apps do it. It's the obvious place to add it so it can be integrated into the UI, but I think you could implement it as a standalone app too, registering for dbus notification on call and rejecting if it's from a blocked number. To be universal you'd nee to cover both ofono and modemmanager dbus interfaces, but the logic should be more or less the same.
Thanks for your answer. I really think this should be included in the phone apps.
Do you know how to officially suggest this to Mobian?

Btw, I also like the idea of writing my own code. I do not have the knowledge to communicate to the dbus interfaces. I don't know what are they. 
If I can my own code I could selectively block unkown phones outside my area, but accept from particular areas. So, I could put my own rules.

So, how do I communicate (I am a python person) with the phone communications?
Mobian is using and contributing back to Purism's apps I think. You could request through https://gitlab.com/mobian1/issues/-/issues or upstream at https://source.puri.sm/Librem5/calls/-/issues

Have a look at https://dbus.freedesktop.org/doc/dbus-python/index.html for some general coverage of dbus in python, and https://www.freedesktop.org/software/Mod...-dbus.html for the ModemManager interfaces. See in particular the Voice interface - you'll probably listen for the CallAdded signal, check the number against your blocklist, and if it matches use the DeleteCall method to drop it. You'll need to deal with the modem disappearing and reappearing too - at a guess you'll need to reregister the listener every time a 'new' modem appears.
  Reply
#6
(10-29-2020, 04:11 PM)wibble Wrote:
(10-28-2020, 04:18 PM)natasha Wrote:
(10-24-2020, 10:05 AM)wibble Wrote: I don't know if any of the existing phone apps do it. It's the obvious place to add it so it can be integrated into the UI, but I think you could implement it as a standalone app too, registering for dbus notification on call and rejecting if it's from a blocked number. To be universal you'd nee to cover both ofono and modemmanager dbus interfaces, but the logic should be more or less the same.
Thanks for your answer. I really think this should be included in the phone apps.
Do you know how to officially suggest this to Mobian?

Btw, I also like the idea of writing my own code. I do not have the knowledge to communicate to the dbus interfaces. I don't know what are they. 
If I can my own code I could selectively block unkown phones outside my area, but accept from particular areas. So, I could put my own rules.

So, how do I communicate (I am a python person) with the phone communications?
Mobian is using and contributing back to Purism's apps I think. You could request through https://gitlab.com/mobian1/issues/-/issues or upstream at https://source.puri.sm/Librem5/calls/-/issues

Have a look at https://dbus.freedesktop.org/doc/dbus-python/index.html for some general coverage of dbus in python, and https://www.freedesktop.org/software/Mod...-dbus.html for the ModemManager interfaces. See in particular the Voice interface - you'll probably listen for the CallAdded signal, check the number against your blocklist, and if it matches use the DeleteCall method to drop it. You'll need to deal with the modem disappearing and reappearing too - at a guess you'll need to reregister the listener every time a 'new' modem appears.

Thanks for the links!

I took a look at the python resources.  Even they are not very optimistic about the functionality. Anyway, I don't have the time now to go deep on this. I will ask the developers if they can look at this.
  Reply
#7
This is a bit of a necro, but since this is the only topic that shows up in web search related to this, I'll post the Python script I made for this based on the MM dbus API.

Code:
#!/usr/bin/python3

import gi
import pydbus

blocked_numbers = frozenset((
    '+1123456789',
    '+1987654321',
))

MM_CALL_DIRECTION_INCOMING = 1
MM_CALL_STATE_RINGING_IN = 3

call_added_subscriptions = {}

def try_modem_added(object_path, interfaces):
    if 'org.freedesktop.ModemManager1.Modem.Voice' in interfaces:
        print(f"added modem {object_path}", flush=True)
        modem = bus.get('.ModemManager1', object_path)['org.freedesktop.ModemManager1.Modem.Voice']
        subscription = modem.CallAdded.connect(call_added)
        call_added_subscriptions[object_path] = subscription

def try_modem_removed(object_path, interfaces):
    if 'org.freedesktop.ModemManager1.Modem.Voice' in interfaces:
        print(f"removed modem {object_path}", flush=True)
        subscription = call_added_subscriptions.pop(object_path, None)
        if subscription is not None:
            subscription.disconnect()

def call_added(object_path):
    call = bus.get('.ModemManager1', object_path)['org.freedesktop.ModemManager1.Call']
    if call.Direction == MM_CALL_DIRECTION_INCOMING and call.State == MM_CALL_STATE_RINGING_IN:
        call_number = call.Number
        print(f"added incoming call from {call_number}", flush=True)
        if call_number in blocked_numbers:
            print(f"{call_number} is in blocked numbers list")
            call.Hangup()
            print(f"hung up on {call_number}")

bus = pydbus.SystemBus()
manager = bus.get('.ModemManager1')['org.freedesktop.DBus.ObjectManager']

manager.InterfacesAdded.connect(try_modem_added)
manager.InterfacesRemoved.connect(try_modem_removed)

for object_path, interfaces in manager.GetManagedObjects().items():
    try_modem_added(object_path, interfaces)

loop = gi.repository.GLib.MainLoop()
loop.run()

It requires installing pydbus, running as root (to be able to call `call.Hangup`), and is of course specific to ModemManager.

Note that one obvious downside of a script like this is that both the script and the actual calls program (eg gnome-calls) receive the incoming call notification at the same time and thus act on it in parallel. This means that it's likely that the calls program will ring, log the incoming call, etc before the script hangs up. Having a way to block the call without ringing, logging, etc would require inserting the logic between MM and the calls program, which requires modifying MM or (more likely) the calls program.

So there is still value in following up with gnome-calls etc to add a call-blocking feature.

---

Edit: This script has a hard-coded list of numbers for blocking. A nicer approach would be to block all numbers that aren't in your contacts list.

If you use gnome-contacts, you can modify the script talk to evolution-data-server via its D-Bus API. Note that this requires running in the D-Bus user session of the logged-in user.

Alternatively, eds stores contacts in a sqlite DB that is easy to query from Python, so you could consider doing that. Just be aware of the dangers of relying on internal details and of racing with eds to read the file as it writes to the file.
  Reply
#8
Here they seem to be spoofing random local numbers (I've gotten angry calls from other people when my number has been spoofed) so if you block the numbers you won't stop the calls and you'll miss calls from people in your area code if they ever try to call you.

My solution is to just never pick up from unkown numbers and let them go to voicemail, this is almost never a problem and eventually they assume your phone is no longer active.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Jami on the Pine phone ? bcnaz 0 66 09-16-2021, 04:26 PM
Last Post: bcnaz
  Pine phone Battery life vs operating system bcnaz 19 8,424 08-27-2021, 09:35 PM
Last Post: bcnaz
  Plasma Mobile goes back to lockscreen when the phone isn't charging plaristote 4 671 06-12-2021, 09:06 AM
Last Post: plaristote
  Brand new phone, screen flickers than locks Marekx3 3 717 06-11-2021, 11:40 AM
Last Post: plaristote
  Incoming calls/sms when the phone sleeps petrus 9 3,298 05-19-2021, 04:21 AM
Last Post: samui
  Pine Phone Desktop Mode or "Standard" Gnome Desktop on PinePhone? 4920441 4 1,405 05-11-2021, 02:42 AM
Last Post: wizmart
  Pine Phone 64 - Indicator Lights specific to distribution? Harry27 1 739 03-04-2021, 01:21 PM
Last Post: wibble
  gnome-clocks waking the phone via a waking daemon (POC) seath 2 898 02-28-2021, 09:50 AM
Last Post: seath
  Alarm app available that wakes the phone pothos 12 3,115 02-16-2021, 07:06 PM
Last Post: C0ffeeFreak
  Phone calls on Pinephone Ubuntu touch? Peter Gamma 16 8,144 09-08-2020, 01:42 AM
Last Post: Peter Gamma

Forum Jump:


Users browsing this thread: 5 Guest(s)