device-pine64-pinephone: automatically recover modem when it dies (MR 4937)

eg25-manager is supposed to watch for the modem going away and recover it
automatically, but it doesn't seem to actually do anything.
Manually restarting eg25-manager in this situation does recover the modem.
This upstream issue https://gitlab.com/mobian1/eg25-manager/-/issues/47
is probably the same, and as that issue says, manually restarting eg25-manager
in this situation does recover the modem.

So this change adds a udev rule to automatically restart eg25-manager when
the modem dies. Common triggers for the modem dying are:

1. When the phone wakes up from suspend.

2. When an incoming call is disconnected, especially if the disconnect happens
   very quickly after the call started, such as what happens when
   phosh-antispam identified the call as spam.

3. When plugging or unplugging the phone from USB power, and when plugging
   or unplugging other USB devices like keyboard from a connected dock.

udev shouldn't be used for spawning long-lasting processes,
but `rc-service start` will parent the process to the service manager and exit,
so that's fine. It does take a few seconds during which udev is blocked and
can't process other events, which udev also recommends against,
but in this case it's not a big deal IMO.

Fixes #2641
[ci:skip-build]: already built successfully in CI
This commit is contained in:
Arnav Singh 2024-03-16 13:27:26 -07:00 committed by Stefan Hansson
parent 540caff8ae
commit d67aa6b44d
No known key found for this signature in database
GPG key ID: 8A700086A9FE41FD
2 changed files with 13 additions and 2 deletions

View file

@ -0,0 +1 @@
SUBSYSTEM=="usb", ACTION=="remove", ENV{DEVTYPE}=="usb_device", ENV{PRODUCT}="2c7c/125/318", RUN+="/sbin/rc-service eg25-manager restart"

View file

@ -2,8 +2,8 @@
# Maintainer: Arnav Singh <me@arnavion.dev>
# Co-Maintainer: Jan Jasper de Kroon <jajadekroon@gmail.com>
pkgname=device-pine64-pinephone
pkgver=0.47
pkgrel=3
pkgver=1
pkgrel=0
pkgdesc="PINE64 PinePhone"
url="https://postmarketos.org"
license="MIT"
@ -14,6 +14,7 @@ subpackages="
$pkgname-gnome
$pkgname-kirigami:kirigami
$pkgname-nonfree-firmware:nonfree_firmware
$pkgname-openrc
$pkgname-plasma-mobile:plasma_mobile
$pkgname-sensorfw
$pkgname-shelli
@ -47,6 +48,7 @@ source="
60-flashlight.rules
70-wifi-pm.rules
90-modem-eg25.rules
90-modem-eg25-openrc.rules
UPower.conf
deviceinfo
modules-initfs
@ -172,6 +174,13 @@ nonfree_firmware() {
mkdir "$subpkgdir"
}
openrc() {
install_if="$pkgname=$pkgver-r$pkgrel eg25-manager-openrc"
depends="eg25-manager-openrc"
install -Dm644 "$srcdir"/90-modem-eg25-openrc.rules -t \
"$subpkgdir"/usr/lib/udev/rules.d/
}
camera() {
install_if="$pkgname=$pkgver-r$pkgrel postmarketos-default-camera"
depends="megapixels"
@ -246,6 +255,7 @@ bac664c504d9a3adc6e3d25f24ac63cf7c449a82374544a5b56c259dc25af580897b9dc992865ac8
9170da7ac869254644f2fc8d914102f2c16e917dbeb53e33b96c76936711d0540f55fa5c2526d73d5fe244500bc2728bc9d629e2524cf52c573d11e833aee666 60-flashlight.rules
8b6fa7b12c15f439c561901f3ffe24a1ef2a0c343401c0a79281060854ab29e08a1fb5e7adae8684b12aa9f535ed99e2dad993dce9724822cb0fbf2497dd86e5 70-wifi-pm.rules
7dc2b7c20b4a2b15f597a6417bd01797643dad84a3683b0dee648e030fb6326e9d020307643fdcdf1bb43fc44af9975697e417003bd359610bae2d8ce614fc00 90-modem-eg25.rules
c6d9b65100072687df11ed2231edf3a007a6a54941e321fc5416131e881291eaf5853a4f6f7819510c460adcc487fce59bfd4eeb001363ddc87cae7ef85e3e98 90-modem-eg25-openrc.rules
ed0e03f7e1c0348c06be9a7922414469245604ce813bbf0c8910ef211cb993bbb0d0d4615c9c961d50712415f85d6b73e0cf02780ac784666aac56e4889341e4 UPower.conf
87751806329118272bc887691a0d5b588fa7a601fb048594785032a661b7e48a86c9d97f8bfa99edf247051a81799f2e628e5bf7c129cf2919c2abf0c146e031 deviceinfo
218d1361622418a0f79bd661a601baf586aec3995cf32304399b47664caf92bac006466ae1e59afa90f6ab4b9ed6acd16147a696fffd0dcab2492e2428ecc0b0 modules-initfs