Fix background call hangup and end calls on screen lock or lid close
This commit is contained in:
1 parent
c7cdde6734
commit
0c352f0a10
55 files changed
+391
-120
No files matched your search
+3
-3
@@ -26,9 +26,9 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
|
||||
- Configured BlueZ (`/etc/bluetooth/main.conf`, `/etc/bluetooth/input.conf`), WirePlumber (`50-bluetooth.conf` across `/etc/wireplumber`, `/usr/share/wireplumber`, and `~/.config/wireplumber` with `bluetooth.autoswitch-to-headset-profile = false`, `bluetooth.use-persistent-storage = false`, `bluez5.enable-msbc = false`, and disabled `hardware.video-capture` / `monitor.bluez-midi` / `support.logind` / `support.reserve-device` / `support.portal-permissionstore` probing, plus `pipewire-0` socket readiness gating in `sxmo_hook_start.sh` and automatic `Restart=always` in `wireplumber.service` / `pipewire-pulse.service` / `pipewire.service`), and the `6.12.1-msm8916` QDSP6/ASoC/SMD kernel stack (`0005-msm8909-qdsp6-bt-sco-support.patch` adding `INTERNAL_BT_SCO_RX` `0x3000` / `INTERNAL_BT_SCO_TX` `0x3001` `dai@136`/`dai@137` AFE ports, `AFE_PARAM_ID_INTERNAL_BT_FM_CONFIG`, dynamic mid-call `q6voice` CVP port switching with idempotent `q6voice_path_stop` / `q6voice_path_start` null-session guards, codec-less DPCM backend links in `snd-soc-qcom-common.ko.zst` / `snd-soc-apq8016-sbc.ko.zst`, and `HCI_SCODATA_PKT` handling in `btqcomsmd.ko.zst`) with full **A2DP** (`a2dp_sink`, `a2dp_source` with `sbc_xq`, `aac`, `ldac`, `aptx`, `aptx_hd`), **HSP/HFP** (`hsp_hs`, `hsp_ag`, `hfp_hf`, `hfp_ag` 8 kHz CVSD over hardware LPASS `INT_BT_SCO_RX`/`INT_BT_SCO_TX` with automatic PipeWire SCO socket keepalive), and **HID / BLE HOGP** (`uhid`, `hidp`, `uinput`, `rfcomm`, `bnep`, `xpad`) profile support, and added `Bluetooth` as a selectable and hotplug-monitored audio output/input route in `sxmo_audio.sh`, `sxmo_soundmonitor.sh`, `sxmo_modemaudio.sh`, `sxmo_hook_ring.sh`, `xcallscreen` (`[3] Audio Out`), `xdrawer`, `xmusic`, `xringtones`, `xfiles`, `webarchy`, `gambatte`, `remedy`, and `dmenu` Audio menu (with automatic `pactl move-sink-input` stream migration, non-blocking post-ACL AVDTP sink readiness polling, lock-coalesced `apply_vol_out` volume stepping and pure-shell `sxmo_hook_statusbar.sh` volume updates, and `SPK DAC Switch` muting when routing to Bluetooth or Headphones).
|
||||
- Added **Discoverable** (`ON (Visible)` / `OFF (Hidden)`, persisted in `~/.config/sxmo/bt_discoverable`) and **Bluetooth Device Name** (`Name: <Alias> [Edit]` with a multi-tap modal editor persisted in `~/.config/sxmo/bt_name` and applied via `bluetoothctl system-alias` independently of the system hostname) rows to the `3:Bluetooth` tab of `xnetworks`, alongside active connection count headers (`Bluetooth: ON (N Active)`), pinned active device cards with live profile and battery badges (`[ACTIVE: A2DP]`, `[ACTIVE: HSP/HFP]`, `[ACTIVE: HID Gamepad]`, `[ACTIVE: HID Keyboard]`, `[ACTIVE: HID Mouse]`), and a **Switch Audio (A2DP / HSP-HFP)** action.
|
||||
- Added a persistent BlueZ `NoInputNoOutput` default pairing/authorization agent (`/org/bananarchy/bt_agent`) and D-Bus `connect`/`pair` handler inside `/usr/bin/bananarchy-bt-obex` (skipping redundant pre-connect inquiry scans for known BlueZ devices and automatically recovering from stale `[LinkKey]` `br-connection-key-missing` errors) for seamless BLE HOGP (`00001812`), Classic HID (`00001124`), and A2DP/HFP bonding and reconnection, an automatic `/dev/uinput` gamepad-to-keypad bridge (`Bananarchy BT Gamepad Bridge`, excluding QWERTY keyboards) so Bluetooth/USB gamepads (`D-Pad` / `Left Stick` -> `Up`/`Down`/`Left`/`Right`, `South/A` -> `Enter`, `East/B` -> `8`, `West/X` -> `5`, `North/Y` -> `6`, `Start` -> `2`, `Select` -> `3`, `L1`/`R1` -> `Left`/`Right softkey`, `L2`/`R2` -> `*`/`0`, `Mode` -> `Escape`) control all NeoUI apps and games (`snake`, `tetris`, `scoundrel`, `gambatte`, `remedy`) out of the box, automatic `[KBD]` external keyboard detection (`isExternalKeyboardActive()`) in `fcitx5-t9`, `libneoui.so`, and DWM plugins so connecting a Bluetooth/USB QWERTY keyboard automatically bypasses T9 multi-tap and preedit popups for all keys (`0-9`, `*`, `#`, `Shift+0-9`, and letters), and automatic `XFixes` cursor display in `dwm` (`dwm_has_external_mouse()`) whenever a Bluetooth/USB mouse is connected.
|
||||
- **Universal Power button (`dmenu power`) access, lockscreen X11 grab preemption, ReMEdy `Call (green)` pause menu, JSR expansion, and 64 MB mark-and-sweep GC**:
|
||||
- Updated `dwm`, `dmenu`, `xdrawer`, `libneoui.so`, `sxmo_multikey.sh`, all standalone Xlib DWM plugins, and standalone games (`scoundrel`, `gambatte`, `remedy`) so pressing **End / Power (red)** (`XF86PowerOff`, keycode `124`) from any active window or menu immediately opens (or toggles) the system **Power menu (`dmenu power`)** while mapped **Call (green)** (`XF86Phone` / `XF86PickupPhone`) and `500 ms` **Right softkey** hold in `remedy` open the **ReMEdy Pause Menu**.
|
||||
- Updated `locker.so` (`xlocker`) and `dwm` to preempt active X11 keyboard grabs and window stacking over any running fullscreen application or game (`webarchy`, `remedy`, `gambatte`, `scoundrel`, `snake`, `tetris`, and all NeoUI plugins) when the screen locks, cleanly restoring the previously focused application upon unlock, and eliminated duplicate `xlocker` startup activations across `bananarchy-x11-session.sh`, `sxmo_hook_start.sh`, `sxmo_hook_lock.sh`, and `locker.so` so the lockscreen activates once at session start without resetting in-progress passcode entry or re-locking if unlocked while background services finish starting.
|
||||
- **Universal Power button (`dmenu power`) access, background call termination, lockscreen X11 grab preemption, ReMEdy `Call (green)` pause menu, JSR expansion, and 64 MB mark-and-sweep GC**:
|
||||
- Updated `dwm`, `dmenu`, `xdrawer`, `libneoui.so`, `sxmo_multikey.sh`, all standalone Xlib DWM plugins, and standalone games (`scoundrel`, `gambatte`, `remedy`) so pressing **End / Power (red)** (`XF86PowerOff`, keycode `124`) from any active window or menu immediately ends any incoming, outgoing, or active call (even when `xcallscreen` has been switched away from in the background) or opens the system **Power menu (`dmenu power`)** when no call is active, while mapped **Call (green)** (`XF86Phone` / `XF86PickupPhone`) and `500 ms` **Right softkey** hold in `remedy` open the **ReMEdy Pause Menu**.
|
||||
- Updated `callscreen.so` (`xcallscreen`), `locker.so` (`xlocker`), `dwm` (`lock_phone_screenoff` on `SW_LID = 1`), `sxmo_hook_lock.sh`, `sxmo_modemcall.sh`, `sxmo_modemdial.sh`, and `msm-modem-uim-selection` so locking the screen or sliding the lid closed immediately hangs up any incoming, outgoing, or active cellular/VoIP call and closes `xcallscreen`, fixed DSDS QMI `call-dial` / `call-hangup all` / `dsds-daemon` state tracking so secondary-SIM calls are never orphaned when switching apps, and eliminated duplicate `xlocker` startup activations across `bananarchy-x11-session.sh`, `sxmo_hook_start.sh`, `sxmo_hook_lock.sh`, and `locker.so`.
|
||||
- Upgraded **ReMEdy (`remedy` / `j2me`)** with a `64 MB` heap budget and mark-and-sweep garbage collector (`System.gc()` / `Runtime.gc()`, `freeSlots_` object reuse, and full heap/JAR release on MIDlet exit), synchronous `Canvas.serviceRepaints()`, `Thread.yield()` / `Thread.sleep()` background thread stepping, synthetic native static field storage (`System.out`, `System.err`, `List.SELECT_COMMAND`, `AlertType.*`, `Boolean.TRUE/FALSE`), exact `String` reference preservation in `List.getString()` and `ChoiceGroup.getString()` (for `MeBoy` / `GTA 2` GBC-to-J2ME cartridges), `java.io.InputStreamReader` / `OutputStreamWriter`, `java.lang.Float` / `Double` / `Character`, **JSR-75** (`FileSystemRegistry` / `FileConnection`), **JSR-82** (`javax.bluetooth.*`), **JSR-120** (`javax.wireless.messaging.*`), **JSR-135** (`MIDIControl`), full **Nokia `DirectGraphics`** (`drawPixels`, `getPixels`, `fillPolygon`, `drawPolygon`, `fillTriangle`, `drawTriangle`, `setARGBColor`), and automatic/configurable sub-QVGA (`128x128`, `128x160`, `176x208`, `176x220`) canvas scaling (`Asphalt 6: Adrenaline`).
|
||||
- **Kernel-to-userspace battery, charging, fuel-gauge, and idle power optimizations**:
|
||||
- Fixed PM8909/PM8916 linear battery charger (`pm8916_lbc.ko.zst`) hardware state-machine engagement by writing `MISC_BOOT_DONE` (`0x1642 = 0x80`), overriding the internal charger comparator (`0x10d0 = 0xa5`, `0x10ee = 0x02`), stopping the USB enumeration watchdog timer (`0x134e = 0x00`, `0x104e = 0x00`), clearing `USB_SUSP` (`0x1347 = 0x00`) and `CHG_FAILED` (`0x104a = 0x80`), enabling `BAT_IF` thermistor pull-ups (`0x1248`, `0x124a`), re-arming `CHG_CTRL = 0x81` on every `usb_vbus` plug event, and setting `qcom,fast-charge-safe-current = 540 mA` (`4.375 V`) across all 5 device trees (`nokia-argon`, `nokia-beatles`, `nokia-tough`, `nokia-sparkler`, `nokia-leo`) so USB charging engages `FAST_CHG_ON` (`0x1010 = 0x20`) instead of idling at `90 mA`.
|
||||
|
||||
Binary file not shown.
@@ -2,6 +2,10 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright 2022 Sxmo Contributors
|
||||
|
||||
export HOME="${HOME:-/home/user}"
|
||||
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/10000}"
|
||||
export PATH="${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/hooks:/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:$PATH"
|
||||
|
||||
# include common definitions
|
||||
# shellcheck source=configs/default_hooks/sxmo_hook_icons.sh
|
||||
. sxmo_hook_icons.sh
|
||||
@@ -127,13 +131,23 @@ pickup() {
|
||||
}
|
||||
|
||||
hangup() {
|
||||
CALLID="$1"
|
||||
CALLID="${1:-all}"
|
||||
|
||||
case "$CALLID" in
|
||||
""|"-"|"all")
|
||||
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/"* /tmp/sxmo_call_ringing /tmp/sxmo_active_call 2>/dev/null || true
|
||||
mmcli -m any --voice-hangup-all >/dev/null 2>&1 || true
|
||||
doas -n /usr/libexec/msm-modem-uim-selection call-hangup all >/dev/null 2>&1 || \
|
||||
/usr/libexec/msm-modem-uim-selection call-hangup all >/dev/null 2>&1 || true
|
||||
doas -n dbus-send --system --type=signal / org.ofono.VoiceCallManager.CallRemoved >/dev/null 2>&1 || true
|
||||
sxmo_hook_hangup.sh || true
|
||||
return 0
|
||||
;;
|
||||
sub1_*|sub0_*)
|
||||
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}."* 2>/dev/null || true
|
||||
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}."* "$XDG_RUNTIME_DIR/sxmo_calls/sub1_dialing."* /tmp/sxmo_call_ringing /tmp/sxmo_active_call 2>/dev/null || true
|
||||
doas -n /usr/libexec/msm-modem-uim-selection call-hangup "$CALLID" >/dev/null 2>&1 || \
|
||||
/usr/libexec/msm-modem-uim-selection call-hangup "$CALLID" >/dev/null 2>&1 || true
|
||||
/usr/libexec/msm-modem-uim-selection call-hangup "$CALLID" >/dev/null 2>&1 || \
|
||||
doas -n /usr/libexec/msm-modem-uim-selection call-hangup all >/dev/null 2>&1 || true
|
||||
doas -n dbus-send --system --type=signal / org.ofono.VoiceCallManager.CallRemoved >/dev/null 2>&1 || true
|
||||
sxmo_hook_hangup.sh || true
|
||||
return 0
|
||||
@@ -155,10 +169,13 @@ hangup() {
|
||||
# this call was never picked up and hung up immediately, so it is a discarded call
|
||||
touch "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.discardedcall" || true
|
||||
fi
|
||||
rm -f /tmp/sxmo_call_ringing /tmp/sxmo_active_call 2>/dev/null || true
|
||||
|
||||
HANGUP_FAILED=0
|
||||
if ! mmcli -m any -o "$CALLID" --hangup 2>/dev/null && \
|
||||
! doas -n /usr/libexec/msm-modem-uim-selection call-hangup "$CALLID" >/dev/null 2>&1; then
|
||||
! mmcli -m any --voice-hangup-all 2>/dev/null && \
|
||||
! doas -n /usr/libexec/msm-modem-uim-selection call-hangup "$CALLID" >/dev/null 2>&1 && \
|
||||
! doas -n /usr/libexec/msm-modem-uim-selection call-hangup all >/dev/null 2>&1; then
|
||||
# we ignore already closed calls
|
||||
if list_active_calls | grep -q "/$CALLID "; then
|
||||
HANGUP_FAILED=1
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
# Copyright 2022 Sxmo Contributors
|
||||
|
||||
export HOME="${HOME:-/home/user}"
|
||||
export XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR:-/run/user/10000}"
|
||||
export PATH="${XDG_CONFIG_HOME:-$HOME/.config}/sxmo/hooks:/usr/share/sxmo/default_hooks:/usr/local/bin:/usr/bin:/bin:/sbin:/usr/sbin:$PATH"
|
||||
|
||||
# include common definitions
|
||||
# shellcheck source=scripts/core/sxmo_common.sh
|
||||
. sxmo_common.sh
|
||||
@@ -57,8 +61,7 @@ dial_number() {
|
||||
sxmo_log "Attempting to dial on Secondary GW (SIM $TARGET_SIM): $NUMBER"
|
||||
if [ -p "/tmp/dwm_plugin_callscreen.fifo" ]; then
|
||||
printf "OUTGOING - %s SIM%s\n" "$NUMBER" "$TARGET_SIM" > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
|
||||
fi
|
||||
if command -v xcallscreen >/dev/null 2>&1; then
|
||||
elif command -v xcallscreen >/dev/null 2>&1; then
|
||||
xcallscreen outgoing "-" "$NUMBER" >/dev/null 2>&1 || true
|
||||
fi
|
||||
if ! CALLID="$(doas -n /usr/libexec/msm-modem-uim-selection call-dial "$TARGET_SIM" "$NUMBER" 2>/dev/null || /usr/libexec/msm-modem-uim-selection call-dial "$TARGET_SIM" "$NUMBER" 2>/dev/null)"; then
|
||||
@@ -68,13 +71,19 @@ dial_number() {
|
||||
sxmo_notify_user.sh --urgency=critical "We failed to initiate call on SIM $TARGET_SIM"
|
||||
return 1
|
||||
fi
|
||||
rm "$XDG_RUNTIME_DIR/sxmo_calls/$CALLID."* 2>/dev/null || true
|
||||
rm -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.terminated" \
|
||||
"$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.hangedupcall" \
|
||||
"$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.discardedcall" 2>/dev/null || true
|
||||
touch "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.initiatedcall"
|
||||
doas -n dbus-send --system --type=signal / org.ofono.VoiceCallManager.CallAdded >/dev/null 2>&1 || true
|
||||
sxmo_hook_dial.sh || true
|
||||
sxmo_modemaudio.sh setup_audio || true
|
||||
if [ -p "/tmp/dwm_plugin_callscreen.fifo" ]; then
|
||||
printf "OUTGOING %s %s SIM%s\n" "$CALLID" "$NUMBER" "$TARGET_SIM" > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
|
||||
if [ -f "$XDG_RUNTIME_DIR/sxmo_calls/${CALLID}.active" ]; then
|
||||
printf "ACTIVE %s %s SIM%s\n" "$CALLID" "$NUMBER" "$TARGET_SIM" > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
|
||||
else
|
||||
printf "OUTGOING %s %s SIM%s\n" "$CALLID" "$NUMBER" "$TARGET_SIM" > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
|
||||
fi
|
||||
elif command -v xcallscreen >/dev/null 2>&1; then
|
||||
xcallscreen outgoing "$CALLID" "$NUMBER" >/dev/null 2>&1 || true
|
||||
fi
|
||||
@@ -93,8 +102,7 @@ dial_number() {
|
||||
sxmo_log "Attempting to dial (SIM $TARGET_SIM): $NUMBER"
|
||||
if [ -p "/tmp/dwm_plugin_callscreen.fifo" ]; then
|
||||
printf "OUTGOING - %s SIM%s\n" "$NUMBER" "$TARGET_SIM" > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
|
||||
fi
|
||||
if command -v xcallscreen >/dev/null 2>&1; then
|
||||
elif command -v xcallscreen >/dev/null 2>&1; then
|
||||
xcallscreen outgoing "-" "$NUMBER" >/dev/null 2>&1 || true
|
||||
fi
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2046,6 +2046,14 @@ if sub_cmd == "call-dial":
|
||||
num = "".join(c for c in arg2 if c in "+0123456789*#").encode("ascii")
|
||||
if not num:
|
||||
sys.exit(1)
|
||||
calls_dir = "/run/user/10000/sxmo_calls"
|
||||
dial_marker = os.path.join(calls_dir, f"sub{sub}_dialing.initiatedcall")
|
||||
try:
|
||||
os.makedirs(calls_dir, exist_ok=True)
|
||||
open(dial_marker, "w").close()
|
||||
os.chown(dial_marker, 10000, 10000)
|
||||
except Exception:
|
||||
pass
|
||||
s = socket.socket(AF_QIPCRTR, socket.SOCK_DGRAM)
|
||||
qmi_req(s, 1, 0x0044, struct.pack("<BHB", 0x01, 1, sub))
|
||||
tlvs = qmi_req(s, 2, 0x0020, struct.pack("<BH", 0x01, len(num)) + num, timeout=5.0)
|
||||
@@ -2056,28 +2064,70 @@ if sub_cmd == "call-dial":
|
||||
subprocess.run(["dbus-send", "--system", "--type=signal", "/", "org.ofono.VoiceCallManager.CallAdded"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
cid = tlvs.get(0x10, b"\x01")[0]
|
||||
prefix = f"sub{sub}_"
|
||||
try:
|
||||
cid_marker = os.path.join(calls_dir, f"{prefix}{cid}.initiatedcall")
|
||||
open(cid_marker, "w").close()
|
||||
os.chown(cid_marker, 10000, 10000)
|
||||
if os.path.exists(dial_marker):
|
||||
os.remove(dial_marker)
|
||||
except Exception:
|
||||
pass
|
||||
print(f"{prefix}{cid}")
|
||||
sys.exit(0)
|
||||
try:
|
||||
if os.path.exists(dial_marker):
|
||||
os.remove(dial_marker)
|
||||
except Exception:
|
||||
pass
|
||||
sys.exit(1)
|
||||
|
||||
elif sub_cmd in ("call-accept", "call-hangup", "call-dtmf"):
|
||||
import subprocess
|
||||
if sub_cmd == "call-hangup" and arg1 in ("", "-", "all"):
|
||||
any_ended = False
|
||||
txn = 1
|
||||
for sub in (1, 0):
|
||||
s = socket.socket(AF_QIPCRTR, socket.SOCK_DGRAM)
|
||||
qmi_req(s, txn, 0x0044, struct.pack("<BHB", 0x01, 1, sub))
|
||||
txn += 1
|
||||
calls = parse_call_info(qmi_req(s, txn, 0x002F))
|
||||
txn += 1
|
||||
for cid, c in calls.items():
|
||||
if c["state"] not in (8, 9):
|
||||
tlvs = qmi_req(s, txn, 0x0021, struct.pack("<BHB", 0x01, 1, cid))
|
||||
txn += 1
|
||||
res_tlv = tlvs.get(0x02, b"")
|
||||
if len(res_tlv) >= 4 and struct.unpack("<HH", res_tlv[:4]) == (0, 0):
|
||||
any_ended = True
|
||||
s.close()
|
||||
if any_ended:
|
||||
subprocess.run(["dbus-send", "--system", "--type=signal", "/", "org.ofono.VoiceCallManager.CallRemoved"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
sys.exit(0)
|
||||
sys.exit(1)
|
||||
|
||||
# Target sub=1 by default or parse sub1_<id>
|
||||
target_sub = 1
|
||||
target_cid = 0
|
||||
if arg1.startswith("sub0_"):
|
||||
target_sub = 0
|
||||
target_cid = int(arg1.split("_", 1)[1])
|
||||
try:
|
||||
target_cid = int(arg1.split("_", 1)[1])
|
||||
except Exception:
|
||||
target_cid = 0
|
||||
elif arg1.startswith("sub1_"):
|
||||
target_sub = 1
|
||||
target_cid = int(arg1.split("_", 1)[1])
|
||||
try:
|
||||
target_cid = int(arg1.split("_", 1)[1])
|
||||
except Exception:
|
||||
target_cid = 0
|
||||
elif arg1.isdigit() and sub_cmd != "call-dtmf":
|
||||
target_cid = int(arg1)
|
||||
|
||||
s = socket.socket(AF_QIPCRTR, socket.SOCK_DGRAM)
|
||||
qmi_req(s, 1, 0x0044, struct.pack("<BHB", 0x01, 1, target_sub))
|
||||
if target_cid == 0:
|
||||
calls = parse_call_info(qmi_req(s, 2, 0x002F))
|
||||
calls = parse_call_info(qmi_req(s, 2, 0x002F))
|
||||
if target_cid == 0 or (sub_cmd == "call-hangup" and target_cid not in calls):
|
||||
target_cid = 0
|
||||
for cid, c in calls.items():
|
||||
if sub_cmd == "call-accept" and c["state"] in (2, 7):
|
||||
target_cid = cid
|
||||
@@ -2094,6 +2144,11 @@ elif sub_cmd in ("call-accept", "call-hangup", "call-dtmf"):
|
||||
tlvs = qmi_req(s, 3, 0x0022, struct.pack("<BHB", 0x01, 1, target_cid))
|
||||
elif sub_cmd == "call-hangup":
|
||||
tlvs = qmi_req(s, 3, 0x0021, struct.pack("<BHB", 0x01, 1, target_cid))
|
||||
txn = 4
|
||||
for cid, c in calls.items():
|
||||
if cid != target_cid and c["state"] not in (8, 9):
|
||||
qmi_req(s, txn, 0x0021, struct.pack("<BHB", 0x01, 1, cid))
|
||||
txn += 1
|
||||
subprocess.run(["dbus-send", "--system", "--type=signal", "/", "org.ofono.VoiceCallManager.CallRemoved"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
else:
|
||||
ch = (arg1[-1] if arg1 else "0").encode("ascii")[:1]
|
||||
@@ -2764,7 +2819,7 @@ def sync_sub1_calls(calls, sim_slot):
|
||||
|
||||
# Update /run/user/10000/sxmo_calls/sub1_<id>.<state>
|
||||
for fn in os.listdir(CALLS_DIR):
|
||||
if fn.startswith(f"{call_key}.") and not fn.endswith(".initiatedcall") and not fn.endswith(".pickedupcall") and not fn.endswith(".mutedring"):
|
||||
if fn == "sub1_dialing.initiatedcall" or (fn.startswith(f"{call_key}.") and not fn.endswith(".initiatedcall") and not fn.endswith(".pickedupcall") and not fn.endswith(".mutedring")):
|
||||
try:
|
||||
os.remove(os.path.join(CALLS_DIR, fn))
|
||||
except Exception:
|
||||
@@ -2942,7 +2997,8 @@ while True:
|
||||
if not got_voice_ind and (active_calls or has_sub1_call_files()):
|
||||
full_tlvs = qmi_req(vs, voice_addr, v_txn, 0x002F)
|
||||
v_txn = (v_txn % 60000) + 1
|
||||
sync_sub1_calls(parse_call_info(full_tlvs), sec_slot)
|
||||
if full_tlvs:
|
||||
sync_sub1_calls(parse_call_info(full_tlvs), sec_slot)
|
||||
|
||||
if not os.path.exists("/tmp/bananarchy_screen_locked") and time.time() - last_poll >= 600.0:
|
||||
w_txn = poll_stored_sms(ws, wms_addr, w_txn, sec_slot)
|
||||
|
||||
@@ -17,6 +17,16 @@ cur_state=""
|
||||
printf '1\n' > /tmp/bananarchy_screen_locked
|
||||
pkill -STOP -x conky 2>/dev/null || true
|
||||
|
||||
if ! sxmo_jobs.sh running proximity_lock -q; then
|
||||
if [ -f /tmp/sxmo_call_ringing ] || [ -f /tmp/sxmo_active_call ] || [ -n "$(ls -A "$XDG_RUNTIME_DIR/sxmo_calls" 2>/dev/null)" ]; then
|
||||
rm -f /tmp/sxmo_call_ringing /tmp/sxmo_active_call 2>/dev/null || true
|
||||
if [ -p /tmp/dwm_plugin_callscreen.fifo ]; then
|
||||
printf 'HANGUP_CLOSE\n' > /tmp/dwm_plugin_callscreen.fifo 2>/dev/null || true
|
||||
fi
|
||||
sxmo_modemcall.sh hangup all >/dev/null 2>&1 &
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$SXMO_DISABLE_LEDS" ]; then
|
||||
sxmo_led.sh blink blue &
|
||||
fi
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -452,6 +452,22 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
int selectedRow = 0;
|
||||
|
||||
auto hasBtAudioCard = []() -> bool {
|
||||
bool hciConnected = false;
|
||||
DIR* bd = ::opendir("/sys/class/bluetooth");
|
||||
if (bd) {
|
||||
struct dirent* ent;
|
||||
while ((ent = ::readdir(bd)) != nullptr) {
|
||||
if (std::strncmp(ent->d_name, "hci", 3) == 0 &&
|
||||
std::strchr(ent->d_name, ':') != nullptr) {
|
||||
hciConnected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
::closedir(bd);
|
||||
}
|
||||
if (!hciConnected) {
|
||||
return false;
|
||||
}
|
||||
FILE* fp = ::popen("pactl list short cards 2>/dev/null", "r");
|
||||
if (!fp) return false;
|
||||
char line[256];
|
||||
@@ -1421,7 +1437,35 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
render();
|
||||
};
|
||||
|
||||
auto hangupCall = [&]() {
|
||||
int missingModemPolls = 0;
|
||||
|
||||
auto resetToIdleAndClose = [&]() {
|
||||
stopRecording();
|
||||
if (micMuted) {
|
||||
setMicMuted(false);
|
||||
}
|
||||
stopRingingJobs();
|
||||
btAudioOn = false;
|
||||
dtmfMode = false;
|
||||
ringMuted = false;
|
||||
sipZrtpSas.clear();
|
||||
callState = CallState::Idle;
|
||||
callId.clear();
|
||||
callNumber.clear();
|
||||
contactName.clear();
|
||||
endedAtMs = 0;
|
||||
missingModemPolls = 0;
|
||||
writeActiveStateFiles();
|
||||
hideWindow(false);
|
||||
runAsyncCmd("sxmo_jobs.sh stop ringing >/dev/null 2>&1; "
|
||||
"pkill -TERM -f sxmo_hook_ring.sh >/dev/null 2>&1; "
|
||||
"pkill -TERM -f 'pw-play.*ring' >/dev/null 2>&1; "
|
||||
"pkill -TERM -f 'mpv.*ring' >/dev/null 2>&1; "
|
||||
"pkill -TERM -x sxmo_vibrate >/dev/null 2>&1; "
|
||||
"sxmo_modemaudio.sh disable_call_audio_mode >/dev/null 2>&1");
|
||||
};
|
||||
|
||||
auto hangupCall = [&](bool closeImmediately = false) {
|
||||
std::string cid = resolveActiveModemCallId();
|
||||
bool wasIncoming = (callState == CallState::Incoming);
|
||||
stopRingingJobs();
|
||||
@@ -1432,9 +1476,16 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
} else if (!cid.empty() && cid != "-" && cid != "sim" && cid != "test") {
|
||||
runAsyncArgv("sxmo_modemcall.sh", "hangup", cid.c_str());
|
||||
} else {
|
||||
runAsyncCmd("mmcli -m any --voice-hangup-all >/dev/null 2>&1");
|
||||
runAsyncArgv("sxmo_modemcall.sh", "hangup", "all");
|
||||
sendPluginCommand("sip", "CALL_HANGUP");
|
||||
sendPluginCommand("tox", "CALL_HANGUP");
|
||||
}
|
||||
if (closeImmediately || !visible || callState == CallState::Idle ||
|
||||
callState == CallState::SelectSim || callState == CallState::Ended) {
|
||||
resetToIdleAndClose();
|
||||
} else {
|
||||
transitionToEnded(wasIncoming ? "CALL REJECTED" : "CALL ENDED");
|
||||
}
|
||||
transitionToEnded(wasIncoming ? "CALL REJECTED" : "CALL ENDED");
|
||||
};
|
||||
|
||||
auto sendDtmfTone = [&](char ch) {
|
||||
@@ -1527,6 +1578,7 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
SockAddrQrtr vSq { kAfQipcrtr, vNode, vPort };
|
||||
bool gotValidReply = false;
|
||||
for (int sub : {1, 0}) {
|
||||
int sfd = ::socket(kAfQipcrtr, SOCK_DGRAM | SOCK_CLOEXEC, 0);
|
||||
if (sfd < 0) continue;
|
||||
@@ -1537,21 +1589,35 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
::sendto(sfd, bindReq, sizeof(bindReq), 0,
|
||||
reinterpret_cast<const struct sockaddr*>(&vSq), sizeof(vSq));
|
||||
struct pollfd pfd { sfd, POLLIN, 0 };
|
||||
if (::poll(&pfd, 1, 40) > 0) {
|
||||
uint8_t tmp[256];
|
||||
::recv(sfd, tmp, sizeof(tmp), 0);
|
||||
int64_t bindDeadline = nowMs() + 150;
|
||||
while (nowMs() < bindDeadline) {
|
||||
int waitMs = static_cast<int>(std::max<int64_t>(5, bindDeadline - nowMs()));
|
||||
if (::poll(&pfd, 1, waitMs) <= 0) break;
|
||||
uint8_t tmp[512];
|
||||
ssize_t rlen = ::recv(sfd, tmp, sizeof(tmp), 0);
|
||||
if (rlen >= 7 && tmp[0] == 0x02 && tmp[1] == 0x01 && tmp[2] == 0x00 &&
|
||||
tmp[3] == 0x44 && tmp[4] == 0x00) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
uint8_t infoReq[7] = { 0x00, 0x02, 0x00, 0x2F, 0x00, 0x00, 0x00 };
|
||||
::sendto(sfd, infoReq, sizeof(infoReq), 0,
|
||||
reinterpret_cast<const struct sockaddr*>(&vSq), sizeof(vSq));
|
||||
if (::poll(&pfd, 1, 50) > 0) {
|
||||
int64_t infoDeadline = nowMs() + 200;
|
||||
while (nowMs() < infoDeadline) {
|
||||
int waitMs = static_cast<int>(std::max<int64_t>(5, infoDeadline - nowMs()));
|
||||
if (::poll(&pfd, 1, waitMs) <= 0) break;
|
||||
uint8_t buf[1024];
|
||||
ssize_t rlen = ::recv(sfd, buf, sizeof(buf), 0);
|
||||
if (rlen >= 7 && buf[0] == 0x02 && buf[3] == 0x2F) {
|
||||
const uint8_t* rawCi = nullptr;
|
||||
uint16_t lenCi = 0;
|
||||
const uint8_t* rawNum = nullptr;
|
||||
uint16_t lenNum = 0;
|
||||
if (rlen >= 7 && buf[0] == 0x02 && buf[1] == 0x02 && buf[2] == 0x00 &&
|
||||
buf[3] == 0x2F && buf[4] == 0x00) {
|
||||
gotValidReply = true;
|
||||
const uint8_t* rawCi01 = nullptr;
|
||||
uint16_t lenCi01 = 0;
|
||||
const uint8_t* rawCi10 = nullptr;
|
||||
uint16_t lenCi10 = 0;
|
||||
const uint8_t* rawNum11 = nullptr;
|
||||
uint16_t lenNum11 = 0;
|
||||
size_t pos = 7;
|
||||
while (pos + 3 <= static_cast<size_t>(rlen)) {
|
||||
uint8_t tt = buf[pos];
|
||||
@@ -1559,15 +1625,22 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
(static_cast<uint16_t>(buf[pos + 2]) << 8);
|
||||
pos += 3;
|
||||
if (pos + tl > static_cast<size_t>(rlen)) break;
|
||||
if (tt == 0x10) {
|
||||
rawCi = buf + pos;
|
||||
lenCi = tl;
|
||||
if (tt == 0x01) {
|
||||
rawCi01 = buf + pos;
|
||||
lenCi01 = tl;
|
||||
} else if (tt == 0x10) {
|
||||
rawCi10 = buf + pos;
|
||||
lenCi10 = tl;
|
||||
} else if (tt == 0x11) {
|
||||
rawNum = buf + pos;
|
||||
lenNum = tl;
|
||||
rawNum11 = buf + pos;
|
||||
lenNum11 = tl;
|
||||
}
|
||||
pos += tl;
|
||||
}
|
||||
const uint8_t* rawCi = rawCi01 ? rawCi01 : rawCi10;
|
||||
uint16_t lenCi = rawCi01 ? lenCi01 : lenCi10;
|
||||
const uint8_t* rawNum = rawCi01 ? rawCi10 : rawNum11;
|
||||
uint16_t lenNum = rawCi01 ? lenCi10 : lenNum11;
|
||||
if (rawCi && lenCi >= 1) {
|
||||
uint8_t cnt = rawCi[0];
|
||||
size_t off = 1;
|
||||
@@ -1608,11 +1681,12 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
::close(sfd);
|
||||
}
|
||||
return true;
|
||||
return gotValidReply;
|
||||
};
|
||||
|
||||
auto syncModemCalls = [&]() {
|
||||
@@ -1625,55 +1699,59 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
std::string foundNum;
|
||||
bool sawTerminated = false;
|
||||
|
||||
FILE* fp = ::popen("mmcli -m any --voice-list-calls -a 2>/dev/null", "r");
|
||||
if (fp) {
|
||||
char line[512];
|
||||
while (std::fgets(line, sizeof(line), fp)) {
|
||||
std::string s(line);
|
||||
if (s.find("No calls") != std::string::npos) {
|
||||
continue;
|
||||
if (callId.rfind("sub", 0) != 0) {
|
||||
FILE* fp = ::popen("mmcli -m any --voice-list-calls -a 2>/dev/null", "r");
|
||||
if (fp) {
|
||||
char line[512];
|
||||
while (std::fgets(line, sizeof(line), fp)) {
|
||||
std::string s(line);
|
||||
if (s.find("No calls") != std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
if (s.find("terminated") != std::string::npos) {
|
||||
sawTerminated = true;
|
||||
continue;
|
||||
}
|
||||
size_t callPos = s.find("/Call/");
|
||||
if (callPos == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
size_t idStart = callPos + 6;
|
||||
size_t idEnd = idStart;
|
||||
while (idEnd < s.size() && std::isdigit(static_cast<unsigned char>(s[idEnd]))) {
|
||||
++idEnd;
|
||||
}
|
||||
if (idEnd == idStart) {
|
||||
continue;
|
||||
}
|
||||
foundId = s.substr(idStart, idEnd - idStart);
|
||||
if (s.find("incoming") != std::string::npos) {
|
||||
foundDir = "incoming";
|
||||
} else if (s.find("outgoing") != std::string::npos) {
|
||||
foundDir = "outgoing";
|
||||
}
|
||||
size_t lp = s.find('(');
|
||||
size_t rp = s.find(')', lp == std::string::npos ? 0 : lp);
|
||||
if (lp != std::string::npos && rp != std::string::npos && rp > lp + 1) {
|
||||
foundState = s.substr(lp + 1, rp - lp - 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (s.find("terminated") != std::string::npos) {
|
||||
sawTerminated = true;
|
||||
continue;
|
||||
}
|
||||
size_t callPos = s.find("/Call/");
|
||||
if (callPos == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
size_t idStart = callPos + 6;
|
||||
size_t idEnd = idStart;
|
||||
while (idEnd < s.size() && std::isdigit(static_cast<unsigned char>(s[idEnd]))) {
|
||||
++idEnd;
|
||||
}
|
||||
if (idEnd == idStart) {
|
||||
continue;
|
||||
}
|
||||
foundId = s.substr(idStart, idEnd - idStart);
|
||||
if (s.find("incoming") != std::string::npos) {
|
||||
foundDir = "incoming";
|
||||
} else if (s.find("outgoing") != std::string::npos) {
|
||||
foundDir = "outgoing";
|
||||
}
|
||||
size_t lp = s.find('(');
|
||||
size_t rp = s.find(')', lp == std::string::npos ? 0 : lp);
|
||||
if (lp != std::string::npos && rp != std::string::npos && rp > lp + 1) {
|
||||
foundState = s.substr(lp + 1, rp - lp - 1);
|
||||
}
|
||||
break;
|
||||
::pclose(fp);
|
||||
}
|
||||
::pclose(fp);
|
||||
}
|
||||
|
||||
if (sawTerminated) {
|
||||
runAsyncCmd("sxmo_modem.sh checkforfinishedcalls >/dev/null 2>&1");
|
||||
}
|
||||
|
||||
bool qmiOk = true;
|
||||
if (foundId.empty()) {
|
||||
queryQmiVoiceCalls(foundId, foundDir, foundState, foundNum, sawTerminated);
|
||||
qmiOk = queryQmiVoiceCalls(foundId, foundDir, foundState, foundNum, sawTerminated);
|
||||
}
|
||||
|
||||
if (!foundId.empty()) {
|
||||
missingModemPolls = 0;
|
||||
if (callId.empty() || callId == "-") {
|
||||
callId = foundId;
|
||||
}
|
||||
@@ -1725,6 +1803,10 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
sawTerminated ||
|
||||
(callState == CallState::Outgoing &&
|
||||
((!callId.empty() && callId != "-") || nowMs() - callStartMs > 3500))) {
|
||||
if (!sawTerminated && (!qmiOk || ++missingModemPolls < 2)) {
|
||||
return;
|
||||
}
|
||||
missingModemPolls = 0;
|
||||
std::string callsDir = getRuntimeFile("sxmo_calls");
|
||||
DIR* d = ::opendir(callsDir.c_str());
|
||||
if (d) {
|
||||
@@ -1754,6 +1836,14 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
return;
|
||||
}
|
||||
if (line == "CLOSE") {
|
||||
if (callState == CallState::SelectSim || callState == CallState::Ended) {
|
||||
callState = CallState::Idle;
|
||||
callId.clear();
|
||||
callNumber.clear();
|
||||
contactName.clear();
|
||||
endedAtMs = 0;
|
||||
writeActiveStateFiles();
|
||||
}
|
||||
hideWindow(false);
|
||||
return;
|
||||
}
|
||||
@@ -1770,13 +1860,12 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (line == "HANGUP_CLOSE" || line.rfind("HANGUP_CLOSE ", 0) == 0) {
|
||||
hangupCall(true);
|
||||
return;
|
||||
}
|
||||
if (line == "HANGUP" || line.rfind("HANGUP ", 0) == 0) {
|
||||
if (callState == CallState::Incoming || callState == CallState::Outgoing ||
|
||||
callState == CallState::Active) {
|
||||
hangupCall();
|
||||
} else {
|
||||
hideWindow(false);
|
||||
}
|
||||
hangupCall(!visible);
|
||||
return;
|
||||
}
|
||||
if (line == "MUTE_RING") {
|
||||
@@ -1816,6 +1905,11 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
iss >> verb >> arg1 >> arg2 >> arg3;
|
||||
|
||||
if (verb == "PROMPT_SIM") {
|
||||
if (callState == CallState::Incoming || callState == CallState::Outgoing ||
|
||||
callState == CallState::Active) {
|
||||
showWindow();
|
||||
return;
|
||||
}
|
||||
simInfo = queryDualSimInfo(true);
|
||||
callId = "-";
|
||||
callNumber.clear();
|
||||
@@ -1857,7 +1951,9 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
activeSimSlot = 4;
|
||||
return;
|
||||
}
|
||||
simInfo = queryDualSimInfo();
|
||||
if (!simInfo.slot1Present && !simInfo.slot2Present) {
|
||||
simInfo = queryDualSimInfo();
|
||||
}
|
||||
if (tagStr == "SIM1") {
|
||||
activeSimSlot = 1;
|
||||
} else if (tagStr == "SIM2") {
|
||||
@@ -1883,6 +1979,8 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
parseSimTag(arg1, arg3);
|
||||
callState = CallState::Incoming;
|
||||
callStartMs = nowMs();
|
||||
lastModemPollMs = callStartMs;
|
||||
missingModemPolls = 0;
|
||||
ringMuted = false;
|
||||
speakerOn = false;
|
||||
dtmfMode = false;
|
||||
@@ -1902,6 +2000,8 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
parseSimTag(arg1, arg3);
|
||||
callState = CallState::Outgoing;
|
||||
callStartMs = nowMs();
|
||||
lastModemPollMs = callStartMs;
|
||||
missingModemPolls = 0;
|
||||
ringMuted = false;
|
||||
speakerOn = false;
|
||||
btAudioOn = hasBtAudioCard();
|
||||
@@ -1921,8 +2021,10 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
parseSimTag(arg1, arg3);
|
||||
}
|
||||
callState = CallState::Active;
|
||||
lastModemPollMs = nowMs();
|
||||
missingModemPolls = 0;
|
||||
if (!wasActive) {
|
||||
callStartMs = nowMs();
|
||||
callStartMs = lastModemPollMs;
|
||||
if (!wasOutgoing) {
|
||||
speakerOn = false;
|
||||
btAudioOn = hasBtAudioCard();
|
||||
@@ -2009,6 +2111,14 @@ int callscreen_run_main(int argc, char** argv) {
|
||||
} else if (ev.type == VisibilityNotify &&
|
||||
ev.xvisibility.state != VisibilityUnobscured) {
|
||||
if (isAnotherPluginActive("callscreen")) {
|
||||
if (callState == CallState::SelectSim || callState == CallState::Ended) {
|
||||
callState = CallState::Idle;
|
||||
callId.clear();
|
||||
callNumber.clear();
|
||||
contactName.clear();
|
||||
endedAtMs = 0;
|
||||
writeActiveStateFiles();
|
||||
}
|
||||
hideWindow(false);
|
||||
} else {
|
||||
XRaiseWindow(dpy, win);
|
||||
|
||||
@@ -937,6 +937,12 @@ int dialer_run_main(int argc, char** argv) {
|
||||
case XF86XK_Phone:
|
||||
case XF86XK_PickupPhone:
|
||||
case XF86XK_Send: {
|
||||
if (isCallActiveOrRingingFast()) {
|
||||
writeSoftkeySuppress(nowMs() + 350);
|
||||
hideWindow(false);
|
||||
placePhoneCall("");
|
||||
break;
|
||||
}
|
||||
std::string target = selectActiveNumber();
|
||||
if (!target.empty()) {
|
||||
if (target == "*#06#") {
|
||||
@@ -954,8 +960,8 @@ int dialer_run_main(int argc, char** argv) {
|
||||
executeUssd(target, false);
|
||||
} else {
|
||||
writeSoftkeySuppress(nowMs() + 350);
|
||||
placePhoneCall(target);
|
||||
hideWindow(false);
|
||||
placePhoneCall(target);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -446,8 +446,12 @@ int locker_run_main(int argc, char** argv) {
|
||||
int64_t lastActivityMs = 0;
|
||||
int lastRenderedMin = -1;
|
||||
|
||||
auto isCallScreenVisible = [&]() -> bool {
|
||||
return isPidFileAlive(getRuntimeFile("xcallscreen.pid"));
|
||||
};
|
||||
|
||||
auto grabLockerInput = [&]() {
|
||||
if (!visible || isCallActiveOrRingingFast()) {
|
||||
if (!visible || isCallScreenVisible()) {
|
||||
return;
|
||||
}
|
||||
XRaiseWindow(dpy, win);
|
||||
@@ -477,6 +481,7 @@ int locker_run_main(int argc, char** argv) {
|
||||
};
|
||||
|
||||
auto closeOtherOverlays = [&]() {
|
||||
closeOtherPlugins("locker");
|
||||
sendPluginCommand("dmenu", "CLOSE");
|
||||
sendPluginCommand("xdrawer", "CLOSE");
|
||||
::unlink("/tmp/dwm_plugin_dmenu.active");
|
||||
@@ -637,7 +642,7 @@ int locker_run_main(int argc, char** argv) {
|
||||
passcode.empty() ? "Sleep" : "Clear",
|
||||
&theme.colYellow);
|
||||
|
||||
if (!grabHeld && !isCallActiveOrRingingFast()) {
|
||||
if (!grabHeld && !isCallScreenVisible()) {
|
||||
grabLockerInput();
|
||||
}
|
||||
neo.present();
|
||||
@@ -675,8 +680,15 @@ int locker_run_main(int argc, char** argv) {
|
||||
|
||||
auto lockPhone = [&](bool blankDisplay) {
|
||||
bool alreadyVisible = visible;
|
||||
bool hadActiveCall = isCallActiveOrRingingFast() || isCallScreenVisible();
|
||||
writeSmallFileStr(kLockFlagPath, "1\n");
|
||||
writeIntFile(activePidPath, static_cast<int>(::getpid()));
|
||||
sendPluginCommand("callscreen", "HANGUP_CLOSE");
|
||||
if (hadActiveCall) {
|
||||
::unlink("/tmp/sxmo_call_ringing");
|
||||
::unlink("/tmp/sxmo_active_call");
|
||||
runAsyncArgv("sxmo_modemcall.sh", "hangup", "all");
|
||||
}
|
||||
closeOtherOverlays();
|
||||
verifier.refreshIfNeeded();
|
||||
int64_t now = nowMs();
|
||||
@@ -834,7 +846,7 @@ int locker_run_main(int argc, char** argv) {
|
||||
updateClockFont();
|
||||
render();
|
||||
}
|
||||
bool callNow = isCallActiveOrRingingFast();
|
||||
bool callNow = isCallScreenVisible();
|
||||
if (callNow && !callWasActive) {
|
||||
releaseLockerGrab();
|
||||
} else if (!callNow && callWasActive) {
|
||||
@@ -856,7 +868,7 @@ int locker_run_main(int argc, char** argv) {
|
||||
} else if (ev.type == VisibilityNotify || ev.type == FocusOut ||
|
||||
ev.type == UnmapNotify) {
|
||||
if (visible && ::access(kLockFlagPath, F_OK) == 0 &&
|
||||
!isCallActiveOrRingingFast()) {
|
||||
!isCallScreenVisible()) {
|
||||
if (ev.type == UnmapNotify) {
|
||||
XMapRaised(dpy, win);
|
||||
}
|
||||
@@ -889,6 +901,12 @@ int locker_run_main(int argc, char** argv) {
|
||||
sym == XF86XK_HangupPhone || sym == XK_Cancel ||
|
||||
sym == _EVDEVK(0x74) || sym == _EVDEVK(0x8e) ||
|
||||
sym == XK_Escape) {
|
||||
if (isCallActiveOrRingingFast() || isCallScreenVisible()) {
|
||||
sendPluginCommand("callscreen", "HANGUP_CLOSE");
|
||||
::unlink("/tmp/sxmo_call_ringing");
|
||||
::unlink("/tmp/sxmo_active_call");
|
||||
runAsyncArgv("sxmo_modemcall.sh", "hangup", "all");
|
||||
}
|
||||
passcode.clear();
|
||||
statusMsg.clear();
|
||||
statusIsError = false;
|
||||
@@ -966,7 +984,7 @@ int locker_run_main(int argc, char** argv) {
|
||||
setSxmoStateFile("screenoff");
|
||||
blankScreenBacklight();
|
||||
} else {
|
||||
if (!isCallActiveOrRingingFast() && !grabHeld) {
|
||||
if (!isCallScreenVisible() && !grabHeld) {
|
||||
grabLockerInput();
|
||||
}
|
||||
std::time_t t = std::time(nullptr);
|
||||
@@ -981,7 +999,7 @@ int locker_run_main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
int timeoutMs = -1;
|
||||
if (visible && !isScreenBlanked() && !isCallActiveOrRingingFast() &&
|
||||
if (visible && !isScreenBlanked() && !isCallScreenVisible() &&
|
||||
!grabHeld) {
|
||||
timeoutMs = 35;
|
||||
} else if (visible && !isScreenBlanked()) {
|
||||
|
||||
@@ -1880,6 +1880,12 @@ inline DualSimInfo queryDualSimInfo(bool forceRefresh = false) {
|
||||
}
|
||||
|
||||
inline void placePhoneCall(const std::string& rawNumber, int simSlot = 0) {
|
||||
if (isCallActiveOrRingingFast()) {
|
||||
if (!sendPluginCommand("callscreen", "OPEN")) {
|
||||
runAsyncArgv("xcallscreen");
|
||||
}
|
||||
return;
|
||||
}
|
||||
std::string num = normalizePhone(rawNumber);
|
||||
if (num.empty()) {
|
||||
return;
|
||||
@@ -1948,7 +1954,10 @@ inline void closeOtherPlugins(const char* selfPluginName) {
|
||||
}
|
||||
|
||||
inline bool isAnotherPluginActive(const char* selfPluginName) {
|
||||
bool isCallScreenSelf =
|
||||
(selfPluginName && std::strcmp(selfPluginName, "callscreen") == 0);
|
||||
if ((!selfPluginName || std::strcmp(selfPluginName, "locker") != 0) &&
|
||||
!(isCallScreenSelf && isCallActiveOrRingingFast()) &&
|
||||
::access("/tmp/bananarchy_screen_locked", F_OK) == 0) {
|
||||
return true;
|
||||
}
|
||||
@@ -1987,6 +1996,10 @@ inline bool isAnotherPluginActive(const char* selfPluginName) {
|
||||
if (selfPluginName && std::strcmp(p.name, selfPluginName) == 0) {
|
||||
continue;
|
||||
}
|
||||
if (isCallScreenSelf && std::strcmp(p.name, "locker") == 0 &&
|
||||
isCallActiveOrRingingFast()) {
|
||||
continue;
|
||||
}
|
||||
if (isPidFileAlive(getRuntimeFile(p.pidFile))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -208,7 +208,7 @@ bool isRuntimePidAliveNeoui(const char* pidFile) {
|
||||
|
||||
bool isExternalOverlayOrLockActive(const std::string& appName) {
|
||||
if (appName != "callscreen" && appName != "xcallscreen") {
|
||||
if (isCallActiveOrRingingInNeoui() ||
|
||||
if (::access("/tmp/sxmo_call_ringing", F_OK) == 0 ||
|
||||
isRuntimePidAliveNeoui("xcallscreen.pid")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+21
-29
@@ -1637,6 +1637,8 @@ handle_t9_keypress(int key_id)
|
||||
drawmenu();
|
||||
}
|
||||
|
||||
static int has_tracked_calls(void);
|
||||
|
||||
static void
|
||||
keypress(XKeyEvent *ev)
|
||||
{
|
||||
@@ -1780,6 +1782,16 @@ insert:
|
||||
cancel_session();
|
||||
return;
|
||||
case XF86XK_PowerOff:
|
||||
if (has_tracked_calls()) {
|
||||
int cfd = open("/tmp/dwm_plugin_callscreen.fifo",
|
||||
O_WRONLY | O_NONBLOCK | O_CLOEXEC);
|
||||
if (cfd >= 0) {
|
||||
(void)write(cfd, "HANGUP\n", 7);
|
||||
close(cfd);
|
||||
}
|
||||
cancel_session();
|
||||
return;
|
||||
}
|
||||
if (daemon_mode &&
|
||||
(menu_mode != MODE_BUILTIN || strcmp(current_builtin_menu, "power") != 0)) {
|
||||
if (active_client_fd >= 0)
|
||||
@@ -2154,6 +2166,9 @@ count_notifications(void)
|
||||
static int
|
||||
has_tracked_calls(void)
|
||||
{
|
||||
if (access("/tmp/sxmo_call_ringing", F_OK) == 0 ||
|
||||
access("/tmp/sxmo_active_call", F_OK) == 0)
|
||||
return 1;
|
||||
const char *rdir = getenv("XDG_RUNTIME_DIR");
|
||||
char cdir[256];
|
||||
snprintf(cdir, sizeof(cdir), "%s/sxmo_calls", (rdir && rdir[0]) ? rdir : "/run/user/10000");
|
||||
@@ -2266,35 +2281,12 @@ append_active_call_entries(void)
|
||||
{
|
||||
if (!has_tracked_calls())
|
||||
return;
|
||||
FILE *fp = popen("sxmo_modemcall.sh list_active_calls 2>/dev/null", "r");
|
||||
if (!fp)
|
||||
return;
|
||||
char line[512];
|
||||
int shown_incall = 0;
|
||||
while (fgets(line, sizeof(line), fp)) {
|
||||
char *nl = strpbrk(line, "\r\n");
|
||||
if (nl)
|
||||
*nl = '\0';
|
||||
if (!line[0])
|
||||
continue;
|
||||
if (strstr(line, "(ringing-in)")) {
|
||||
char callid[64] = "";
|
||||
char *sp = strchr(line, ' ');
|
||||
if (sp)
|
||||
*sp = '\0';
|
||||
char *slash = strrchr(line, '/');
|
||||
snprintf(callid, sizeof(callid), "%s", slash ? (slash + 1) : line);
|
||||
char label[256];
|
||||
snprintf(label, sizeof(label), "%s Incoming call %s", ICON_PHN, callid);
|
||||
add_menu_item(label, "@plugin:callscreen", 0);
|
||||
} else if (!shown_incall) {
|
||||
shown_incall = 1;
|
||||
char label[128];
|
||||
snprintf(label, sizeof(label), "%s Call Screen", ICON_PHN);
|
||||
add_menu_item(label, "@plugin:callscreen", 0);
|
||||
}
|
||||
}
|
||||
pclose(fp);
|
||||
char label[128];
|
||||
if (access("/tmp/sxmo_call_ringing", F_OK) == 0)
|
||||
snprintf(label, sizeof(label), "%s Incoming Call", ICON_PHN);
|
||||
else
|
||||
snprintf(label, sizeof(label), "%s Call Screen", ICON_PHN);
|
||||
add_menu_item(label, "@plugin:callscreen", 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
+14
-1
@@ -2305,7 +2305,7 @@ static void
|
||||
lock_phone_screenoff(void)
|
||||
{
|
||||
const Arg offcmd = SHCMD("sxmo_dmenu.sh close; sxmo_state.sh set screenoff");
|
||||
int lfd;
|
||||
int lfd, cfd;
|
||||
softkey_pending = 0;
|
||||
softkey_first_ms = 0;
|
||||
softkey_deadline_ms = 0;
|
||||
@@ -2316,6 +2316,13 @@ lock_phone_screenoff(void)
|
||||
star_down = 0;
|
||||
pound_down = 0;
|
||||
write_softkey_state(0, 0);
|
||||
cfd = open("/tmp/dwm_plugin_callscreen.fifo", O_WRONLY | O_NONBLOCK | O_CLOEXEC);
|
||||
if (cfd >= 0) {
|
||||
(void)write(cfd, "HANGUP_CLOSE\n", 13);
|
||||
close(cfd);
|
||||
}
|
||||
unlink("/tmp/sxmo_call_ringing");
|
||||
unlink("/tmp/sxmo_active_call");
|
||||
lfd = open("/tmp/bananarchy_screen_locked", O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);
|
||||
if (lfd >= 0) {
|
||||
(void)write(lfd, "1\n", 2);
|
||||
@@ -2377,6 +2384,12 @@ keypress(XEvent *e)
|
||||
return;
|
||||
}
|
||||
if (is_passcode_locked()) {
|
||||
if (CLEANMASK(ev->state) == 0 &&
|
||||
(keysym == XF86XK_PowerOff || ev->keycode == 124 ||
|
||||
keysym == XF86XK_Phone || keysym == XF86XK_PickupPhone || ev->keycode == 177)) {
|
||||
if (dispatch_plugin_global_key(keysym, ev->keycode, CLEANMASK(ev->state), 1))
|
||||
return;
|
||||
}
|
||||
host_spawn_plugin("locker", "wake");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <fstream>
|
||||
#include <poll.h>
|
||||
@@ -1244,6 +1245,33 @@ static int xdrawer_run_main(int argc, char** argv) {
|
||||
|
||||
if (sym == XF86XK_PowerOff || ev.xkey.keycode == 124) {
|
||||
hideWindow(false);
|
||||
bool callActive = (::access("/tmp/sxmo_call_ringing", F_OK) == 0 ||
|
||||
::access("/tmp/sxmo_active_call", F_OK) == 0);
|
||||
if (!callActive) {
|
||||
std::string cdir = getRuntimeFile("sxmo_calls");
|
||||
DIR* d = ::opendir(cdir.c_str());
|
||||
if (d) {
|
||||
struct dirent* ent;
|
||||
while ((ent = ::readdir(d)) != nullptr) {
|
||||
if (ent->d_name[0] != '.' && ent->d_name[0] != '\0') {
|
||||
callActive = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
::closedir(d);
|
||||
}
|
||||
}
|
||||
if (callActive) {
|
||||
int cfd = ::open("/tmp/dwm_plugin_callscreen.fifo",
|
||||
O_WRONLY | O_NONBLOCK | O_CLOEXEC);
|
||||
if (cfd >= 0) {
|
||||
(void)::write(cfd, "HANGUP\n", 7);
|
||||
::close(cfd);
|
||||
} else {
|
||||
runAsyncCmd("xcallscreen hangup >/dev/null 2>&1");
|
||||
}
|
||||
break;
|
||||
}
|
||||
int ffd = ::open("/tmp/dwm_plugin_dmenu.fifo",
|
||||
O_WRONLY | O_NONBLOCK | O_CLOEXEC);
|
||||
if (ffd >= 0) {
|
||||
|
||||
Reference in new issue
Block a user