forked from openstf/minicap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·60 lines (49 loc) · 1.56 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
# Fail on error, verbose output
set -exo pipefail
# Build project
#ndk-build NDK_DEBUG=1 1>&2
# Figure out which ABI and SDK the device has
abi=$(adb shell getprop ro.product.cpu.abi | tr -d '\r')
sdk=$(adb shell getprop ro.build.version.sdk | tr -d '\r')
rel=$(adb shell getprop ro.build.version.release | tr -d '\r')
# PIE is only supported since SDK 16
if (($sdk >= 16)); then
bin=minicap
else
bin=minicap-nopie
fi
args=
if [ "$1" = "autosize" ]; then
set +o pipefail
size=$(adb shell dumpsys window | grep -Eo 'init=\d+x\d+' | head -1 | cut -d= -f 2)
if [ "$size" = "" ]; then
w=$(adb shell dumpsys window | grep -Eo 'DisplayWidth=\d+' | head -1 | cut -d= -f 2)
h=$(adb shell dumpsys window | grep -Eo 'DisplayHeight=\d+' | head -1 | cut -d= -f 2)
size="${w}x${h}"
fi
args="-P $size@$size/0"
set -o pipefail
shift
fi
# Create a directory for our resources
dir=/data/local/tmp/minicap-devel
# begin - JRH - 2016-09-14
# The following command caused the script to fail:
#adb shell "mkdir $dir 2>/dev/null"
# But now it works, with one small change:
adb shell "mkdir -p $dir 2>/dev/null"
# end - JRH - 2016-09-14
# Upload the binary
adb push libs/$abi/$bin $dir
# Upload the shared library
if [ -e jni/minicap-shared/aosp/libs/android-$rel/$abi/minicap.so ]; then
adb push jni/minicap-shared/aosp/libs/android-$rel/$abi/minicap.so $dir
else
adb push jni/minicap-shared/aosp/libs/android-$sdk/$abi/minicap.so $dir
fi
# Run!
adb shell LD_LIBRARY_PATH=$dir $dir/$bin $args "$@"
# Clean up
adb shell rm -r $dir
echo 'VIDEO-STARTED'