Skip to content

Commit 4c19548

Browse files
committed
Add a mocked ADB script
It's probably brittle and definitely incomplete, but it allows purr to boot correctly in an environment without adb or a device present.
1 parent feb63f8 commit 4c19548

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

makefile

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
OUTDIR?=$(CURDIR)/out
22
SRCDIR?=$(CURDIR)/src
33
RESDIR?=$(CURDIR)/res
4+
TESTDIR?=$(CURDIR)/tests
45

56
PURRFILE ?=$(OUTDIR)/purr
67
PURRFILE_TEMP ?=$(OUTDIR)/purr_temp
78

8-
all: purr
9+
ADBMOCKFILE ?=$(OUTDIR)/adb_mock
10+
11+
all: purr adb_mock
912

1013
.PHONY: purr
1114

@@ -69,7 +72,17 @@ purr:
6972
mv -f $(PURRFILE_TEMP) $(PURRFILE)
7073

7174
# Grant execution permission.
72-
chmod 777 $(PURRFILE)
75+
chmod +rwx $(PURRFILE)
76+
77+
.PHONY: adb_mock
78+
79+
adb_mock:
80+
mkdir -p $(OUTDIR)
81+
echo "" > $(ADBMOCKFILE)
82+
83+
cat $(TESTDIR)/mocks/adb_mock.sh >> "$(ADBMOCKFILE)"
84+
85+
chmod +rwx $(ADBMOCKFILE)
7386

7487
.PHONY: clean
7588

tests/mocks/adb_mock.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env zsh
2+
3+
if grep -q "devices" <<< $@; then
4+
echo "List of devices attached"
5+
echo "emulator-5554 device"
6+
elif grep -q "wait-for-device" <<< $@; then
7+
sleep 0.01;
8+
elif grep -q "logcat" <<< $@; then
9+
cat <<-END
10+
--------- beginning of system
11+
11-30 11:51:17.111 520 565 V DisplayPowerController2[0]: Brightness [0.39763778] reason changing to: 'manual', previous reason: 'manual [ dim ]'.
12+
11-30 11:51:17.111 520 565 I DisplayPowerController2[0]: BrightnessEvent: disp=0, physDisp=local:4619827259835644672, brt=0.39763778, initBrt=0.05, rcmdBrt=NaN, preBrt=NaN, lux=0.0, preLux=0.0, hbmMax=1.0, hbmMode=off, rbcStrength=0, thrmMax=1.0, powerFactor=1.0, wasShortTermModelActive=false, flags=, reason=manual, autoBrightness=false, strategy=InvalidBrightnessStrategy
13+
--------- beginning of main
14+
11-30 11:51:17.159 397 397 I android.hardware.lights-service.example: Lights setting state for id=1 to color ff101010
15+
11-30 11:51:17.186 397 397 I android.hardware.lights-service.example: Lights setting state for id=1 to color ff111111
16+
11-30 11:51:17.197 397 397 I android.hardware.lights-service.example: Lights setting state for id=1 to color ff121212
17+
11-30 11:51:17.214 397 397 I android.hardware.lights-service.example: Lights setting state for id=1 to color ff131313
18+
11-30 11:51:17.231 397 397 I android.hardware.lights-service.example: Lights setting state for id=1 to color ff141414
19+
11-30 11:51:17.247 397 397 I android.hardware.lights-service.example: Lights setting state for id=1 to color ff151515
20+
11-30 11:51:17.264 397 397 I android.hardware.lights-service.example: Lights setting state for id=1 to color ff161616
21+
11-30 11:51:17.281 397 397 I android.hardware.lights-service.example: Lights setting state for id=1 to color ff171717
22+
END
23+
sleep infinity
24+
fi

0 commit comments

Comments
 (0)