Skip to content
Open
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
11 changes: 11 additions & 0 deletions zygisk/module/action.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
MANAGER_PACKAGE_NAME="@MANAGER_PACKAGE_NAME@"
INJECTED_PACKAGE_NAME="@INJECTED_PACKAGE_NAME@"

# The manager also ships inside this module as manager.apk and may have been
# installed as a regular package. When it has, launching its activity directly
# is more reliable than the injection path below, which needs
# ${INJECTED_PACKAGE_NAME} to start a 2D activity at all and to receive the
# injected manager dex -- neither holds in every environment (some systems
# never let the shell host an activity, and dynamic code loading restrictions
# can block the dex the way GrapheneOS does, see #805).
if pm path "$MANAGER_PACKAGE_NAME" >/dev/null 2>&1; then
am start -n "$MANAGER_PACKAGE_NAME/.ui.MainActivity" >/dev/null 2>&1 && exit 0
fi

am start -c "${MANAGER_PACKAGE_NAME}.LAUNCH_MANAGER" "${INJECTED_PACKAGE_NAME}/.BugreportWarningActivity"
16 changes: 13 additions & 3 deletions zygisk/module/service.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Extract the directory path and change directory
# Extract the directory path and change directory
MODDIR="${0%/*}"
cd "$MODDIR" || exit 1

# Start the daemon directly in the background within a private mount namespace
unshare --propagation slave -m "$MODDIR/daemon" --system-server-max-retry=3 "$@" &
# Start the daemon directly in the background within a private mount namespace.
# Not every environment's unshare understands --propagation: toybox builds that
# implement only a subset of util-linux reject the flag outright, which leaves
# the daemon dead with nothing anywhere to say so. Probe the flag with a
# throwaway command and fall back to progressively simpler invocations.
if unshare --propagation slave -m true >/dev/null 2>&1; then
unshare --propagation slave -m "$MODDIR/daemon" --system-server-max-retry=3 "$@" &
elif unshare -m true >/dev/null 2>&1; then
unshare -m "$MODDIR/daemon" --system-server-max-retry=3 "$@" &
else
"$MODDIR/daemon" --system-server-max-retry=3 "$@" &
fi