Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/omamobile-modem/profiles/modem.conf
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,30 @@ modem_gnss_nodes() {
}
modem_gnss() { [[ $MODEM_GNSS == 1 ]] && modem_gnss_nodes; }

# gnssd's libcustomgnss (gps.cfg GlueLayer_IsUseCustomGnssLib=1) dlopen()s
# /vendor/lib64/libsitril-gps.so and takes GpsOpen, GpsClose,
# RegisterCallback and RequestAGPS from it. The real library reaches the
# RIL's GPS channel through libsitril-client over binder, and this profile
# has no binder: with a chroot from CP3A.261005.005, libbinder ends gnssd at
# its first call ("Binder driver '/dev/binder' could not be opened.
# Terminating.", SIGABRT), so the 9a has no GNSS. omamobile-gnss's stub
# (the same four calls, succeeding as no-ops, as for the 7 Pro's gpsd) goes
# over it, read-only, inside this namespace only; the image is unchanged.
SITRIL_GPS=/vendor/lib64/libsitril-gps.so
SITRIL_GPS_STUB=libomamobile-sitril-gps.so
modem_gnss_sitril() {
local dst=$ROOT$SITRIL_GPS
[[ -f $dst ]] || return 0
if [[ ! -f $STUBS/$SITRIL_GPS_STUB ]]; then
say "no $STUBS/$SITRIL_GPS_STUB (omamobile-gnss): gnssd keeps the RIL's library, which needs binder"
return 0
fi
# not bind(): it truncates a file target first, and this one is the
# image's own file (read-only here, but never the place to write)
mount --bind "$STUBS/$SITRIL_GPS_STUB" "$dst"
mount -o remount,bind,ro "$dst"
}

profile_setup() {
local p l mnt=$ROOT/mnt/vendor
mkdir -p "$NV"
Expand Down Expand Up @@ -209,6 +233,7 @@ profile_setup() {
for p in "${MODEM_NODES[@]}"; do bind "/dev/$p" "$ROOT/dev/$p"; done
if modem_gnss_nodes; then
for p in "${GNSS_NODES[@]}"; do bind "/dev/$p" "$ROOT/dev/$p"; done
modem_gnss_sitril
mkdir -p "$STATE/data/vendor/gps/logs" "$STATE/data/vendor/gps/overlay"
fi
# cbd logs to the kernel log, next to CPIF's lines
Expand Down
28 changes: 28 additions & 0 deletions packages/omamobile-modem/test/all
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,34 @@ out=$(bash -c '
[[ $out == alive ]] || fail "a daemon exiting 3 leaves spawn_optional's job alive (got: $out)"
pass "spawn_optional survives a failing daemon"

# gnssd's RIL library: the stub goes over it read-only when both exist, and
# nothing is mounted (or written) otherwise.
sitril=$(sed -n '/^SITRIL_GPS=/p; /^SITRIL_GPS_STUB=/p; /^modem_gnss_sitril() {$/,/^}$/p' profiles/modem.conf)
[[ $sitril == *modem_gnss_sitril* ]] || fail "modem_gnss_sitril found in modem.conf"
st=$(mktemp -d)
mkdir -p "$st/root/vendor/lib64" "$st/stubs"
run_sitril() {
bash -c '
set -euo pipefail
ROOT=$1/root STUBS=$1/stubs
say() { echo "say: $*"; }
mount() { echo "mount $*"; }
'"$sitril"'
modem_gnss_sitril
' _ "$st"
}
[[ -z $(run_sitril) ]] || fail "no libsitril-gps.so in the image: nothing mounted"
echo real > "$st/root/vendor/lib64/libsitril-gps.so"
[[ $(run_sitril) == "say: no "*"(omamobile-gnss)"* ]] || fail "no stub: a note and no mount"
echo stub > "$st/stubs/libomamobile-sitril-gps.so"
out=$(run_sitril)
[[ $out == "mount --bind $st/stubs/libomamobile-sitril-gps.so $st/root/vendor/lib64/libsitril-gps.so"$'\n'"mount -o remount,bind,ro $st/root/vendor/lib64/libsitril-gps.so" ]] ||
fail "the stub is bound read-only over libsitril-gps.so (got: $out)"
[[ $(cat "$st/root/vendor/lib64/libsitril-gps.so") == real ]] || fail "the image's library is left as it was"
rm -rf "$st"
grep -q '^ modem_gnss_sitril$' profiles/modem.conf || fail "profile_setup binds the stub with the GNSS devices"
pass "gnssd gets the SIT RIL GPS stub instead of the binder library"

# rfsd's job: an exit is a crash (the supervisor stops the profile) unless
# this invocation's stop intent is in place; then it stays open for systemd.
python3 test/rfsd-lifecycle.py || fail "rfsd's job through an orderly stop"
Expand Down
2 changes: 1 addition & 1 deletion packages/omamobile-modem/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.26
0.1.27