Skip to content

Instantly share code, notes, and snippets.

@d4vidi
d4vidi / adbjam-genycloud.py
Created January 10, 2022 16:57
adbjam-genycloud
#!/usr/bin/env python3
import os
import sys
import signal
import datetime
def log(text):
now=datetime.datetime.now().strftime("%H:%M:%S.%f")
print("@"+now+" <"+ANDROID_SERIAL+"> " + text)
@d4vidi
d4vidi / DetoxTest.java
Last active September 2, 2021 09:05
Android CI Blog: assert test butler
@RunWith(AndroidJUnit4.class)
@LargeTest
public class DetoxTest {
@Rule
public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
@Test
public void runDetoxTests() {
// This is optional - in case you've decided to integrate TestButler
// See https://github.com/wix/Detox/blob/master/docs/Introduction.Android.md#8-test-butler-support-optional
@d4vidi
d4vidi / install-test-butler.sh
Last active September 2, 2021 08:35
Android CI Blog: test butler (emu launch)
# Download test butler
curl -f -o ~/test-butler-2.2.1.apk https://repo1.maven.org/maven2/com/linkedin/testbutler/test-butler-app/2.2.1/test-butler-app-2.2.1.apk
# Install test butler
./platform-tools/adb install ~/test-butler-2.2.1.apk
# Launch the test butler background service!!!
./platform-tools/adb shell am startservice com.linkedin.android.testbutler/com.linkedin.android.testbutler.ButlerService
# Check that the service is indeed running... Expected output is:
@d4vidi
d4vidi / emu-launch-2.sh
Last active September 2, 2021 14:36
Android CI Blog: Emulator launch 2/3
# Enable on-screen indicators of taps, swipes and scroll actions.
./platform-tools/adb shell settings put system show_touches 1
./platform-tools/adb shell settings put system pointer_location 1
# (*OPTIONAL for Detox users*) Restart adb in root mode (i.e. allow root access to the emulator).
# Detox may need this in order to be able to install apps on the emulator in a way more
# stable than using "adb install path/to/app.apk".
# If you wish to use Detox and avoid that nevertheless, apply the "--force-adb-install" argument
# to your "detox test" commands.
# See https://github.com/wix/Detox/blob/master/docs/APIRef.DetoxCLI.md#test for more info.
@d4vidi
d4vidi / emu-launch-3.sh
Created September 1, 2021 18:59
Android CI Blog: Emulator launch 3/3
# Gracefully shut the emulator down
killall qemu-system-x86_64
# (or, if running headless)
killall qemu-system-x86_64-headless
### Side-note: If you wish to brutally shut the emulator down without having
### anything saved - for whatever reason, you can kill using the SIGKILL signal:
killall -9 qemu-system-x86_64
@d4vidi
d4vidi / emu-launch-1.sh
Last active October 17, 2021 06:55
Android CI Blog: Emulator launch 1/3
# Launch the emulator!
./emulator/emulator -verbose -no-boot-anim @Pixel_4_API_29 &
# (or, if running on a headless machine)
./emulator/emulator -verbose -no-boot-anim -no-audio -no-window -gpu swiftshader_indirect @Pixel_4_API_29 &
# Wait for the emulator to boot up completely.
# This script is actually a bit naive. There are various suggestions out there
# as to make this more robust. One alternative is to utilize the "adb wait-for-device" command.
booted=0
while [ "$booted" != "1" ]
@d4vidi
d4vidi / avd-config_ini.sh
Last active September 1, 2021 18:43
Android CI Blog: config.ini
# Attributes in .ini file:
# hw.lcd.density=440
# hw.lcd.height=2280
# hw.lcd.width=1080
# OR, it you need an automated script - they can be simply appended to the existing file:
echo "hw.lcd.density=440" > config.ini
echo "hw.lcd.height=2280" > config.ini
echo "hw.lcd.width=1080" > config.ini
@d4vidi
d4vidi / avd-setup.sh
Last active March 6, 2023 19:54
Android CI Blog: avd setup.
# Install the emulator tool
./tools/bin/sdkmanager --install emulator
# Install an AOSP image that would later be used as the AVD's OS
./tools/bin/sdkmanager --install "system-images;android-29;default;x86_64"
# Accept all licenses...
./tools/bin/sdkmanager --licenses
# To do that automatically in a script, try this:
yes | ./tools/bin/sdkmanager --licenses
alias ll='exa -alF'
alias lt='exa --tree'
alias lt2='exa --tree --level=2'
alias lt3='exa --tree --level=3'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
# Git and Github
@d4vidi
d4vidi / device.log
Last active March 3, 2020 09:18
Detox #1708: Sample 2 - failure on Detox CI running on Jenkins
(https://jenkins-oss.wixpress.com/job/detox-android-61-4-pr/236/consoleFull)
Detox log:
14:38:48 FAIL 03.actions.test.js (210.947s)
14:38:48 Actions
14:38:48 ✓ should tap on an element (3662ms)
14:38:48 ✓ should long press on an element (4754ms)
14:38:48 ✓ should long press with duration on an element (4990ms)
14:38:48 ✓ should multi tap on an element (6332ms)