Skip to content

Commit

Permalink
fixup! modules/android-integration: add am command
Browse files Browse the repository at this point in the history
  • Loading branch information
t184256 committed Jul 6, 2024
1 parent 1f1b5f2 commit 8bde1f9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
11 changes: 6 additions & 5 deletions pkgs/android-integration/termux-am.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ stdenv.mkDerivation rec {
patchPhase = ''
# Header generation doesn't seem to work on android
echo "#define SOCKET_PATH \"${socketPath}\"" > termux-am.h
cat termux-am.h
# Fix the bash link so that nix can patch it
substituteInPlace termux-am.sh.in --replace @TERMUX_PREFIX@ ""
head termux-am.sh.in
# Fix the bash link so that nix can patch it + path to termux-am-socket
substituteInPlace termux-am.sh.in \
--replace @TERMUX_PREFIX@/bin/bash /bin/bash \
--replace \
"termux-am-socket \"\$am_command_string\"" \
"$out/bin/termux-am-socket \"\$am_command_string\""
'';
postInstall = ''
# Scripts use 'am' as an alias.
Expand Down
18 changes: 17 additions & 1 deletion tests/emulator/android_integration.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import time

import bootstrap_channels

from common import screenshot, wait_for
Expand All @@ -17,8 +19,9 @@ def run(d):
d(f'input text \'cp {cfg} .config/nixpkgs/nix-on-droid.nix\'')
d.ui.press('enter')
screenshot(d, 'pre-switch')
d('input text "nix-on-droid switch"')
d('input text "nix-on-droid switch && echo integration tools installed"')
d.ui.press('enter')
wait_for(d, 'integration tools installed')
screenshot(d, 'post-switch')

# Verify am is there
Expand All @@ -35,6 +38,18 @@ def run(d):
wait_for(d, 'https://dontkillmyapp.com')
screenshot(d, 'am-wants-permission')

# ... there might be a notification now, get rid of it
time.sleep(3)
screenshot(d, 'am-wants-permission-3-seconds-later')
if 'text="TermuxAm Socket Server Error"' in d.ui.dump_hierarchy():
d.ui.open_notification()
time.sleep(1)
screenshot(d, 'notification-opened')
d.ui(text='TermuxAm Socket Server Error').swipe('right')
screenshot(d, 'error-notification-swiped-right')
d.ui.press('back')
screenshot(d, 'back')

# Grant nix app 'Draw over other apps' permission
nod.permissions += 'android.permission.SYSTEM_ALERT_WINDOW'

Expand All @@ -44,6 +59,7 @@ def run(d):
screenshot(d, 'settings-opening')
wait_for(d, 'Search settings')
wait_for(d, 'Network')
screenshot(d, 'settings-awaited')
d.ui.press('back')
screenshot(d, 'back-from-settings')

Expand Down

0 comments on commit 8bde1f9

Please sign in to comment.