mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 07:57:39 +00:00
Add LSPosed launch test
This commit is contained in:
parent
49f241b77c
commit
1ff7b9055f
@ -3,22 +3,25 @@
|
|||||||
emu="$ANDROID_SDK_ROOT/emulator/emulator"
|
emu="$ANDROID_SDK_ROOT/emulator/emulator"
|
||||||
avd="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager"
|
avd="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/avdmanager"
|
||||||
sdk="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
|
sdk="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
|
||||||
emu_args='-no-window -gpu swiftshader_indirect -read-only -no-snapshot -no-audio -no-boot-anim -show-kernel'
|
emu_args='-no-window -no-audio -no-boot-anim -gpu swiftshader_indirect -read-only -no-snapshot -show-kernel -memory 8192'
|
||||||
|
lsposed_url='https://github.com/LSPosed/LSPosed/releases/download/v1.9.2/LSPosed-v1.9.2-7024-zygisk-release.zip'
|
||||||
boot_timeout=600
|
boot_timeout=600
|
||||||
emu_pid=
|
emu_pid=
|
||||||
|
|
||||||
# Should be either 'google_apis' or 'default'
|
|
||||||
type='default'
|
|
||||||
|
|
||||||
# We test these API levels for the following reason
|
# We test these API levels for the following reason
|
||||||
|
|
||||||
# API 23: legacy rootfs w/o Treble
|
# API 23: legacy rootfs w/o Treble
|
||||||
# API 26: legacy rootfs with Treble
|
# API 26: legacy rootfs with Treble
|
||||||
# API 28: legacy system-as-root
|
# API 28: legacy system-as-root
|
||||||
# API 29: 2 Stage Init
|
# API 29: 2 Stage Init
|
||||||
|
# API 33: latest Android with ATD image
|
||||||
# API 34: latest Android
|
# API 34: latest Android
|
||||||
|
|
||||||
api_list='23 26 28 29 34'
|
api_list='23 26 28 29 33 34'
|
||||||
|
|
||||||
|
atd_min_api=30
|
||||||
|
atd_max_api=33
|
||||||
|
lsposed_min_api=27
|
||||||
|
|
||||||
print_title() {
|
print_title() {
|
||||||
echo -e "\n\033[44;39m${1}\033[0m\n"
|
echo -e "\n\033[44;39m${1}\033[0m\n"
|
||||||
@ -70,6 +73,11 @@ wait_for_boot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
set_api_env() {
|
set_api_env() {
|
||||||
|
local type='default'
|
||||||
|
if [ $1 -ge $atd_min_api -a $1 -le $atd_max_api ]; then
|
||||||
|
# Use the lightweight ATD images if possible
|
||||||
|
type='aosp_atd'
|
||||||
|
fi
|
||||||
pkg="system-images;android-$1;$type;$arch"
|
pkg="system-images;android-$1;$type;$arch"
|
||||||
local img_dir="$ANDROID_SDK_ROOT/system-images/android-$1/$type/$arch"
|
local img_dir="$ANDROID_SDK_ROOT/system-images/android-$1/$type/$arch"
|
||||||
ramdisk="$img_dir/ramdisk.img"
|
ramdisk="$img_dir/ramdisk.img"
|
||||||
@ -112,6 +120,7 @@ run_content_cmd() {
|
|||||||
|
|
||||||
test_emu() {
|
test_emu() {
|
||||||
local variant=$1
|
local variant=$1
|
||||||
|
local api=$2
|
||||||
|
|
||||||
print_title "* Testing $pkg ($variant)"
|
print_title "* Testing $pkg ($variant)"
|
||||||
|
|
||||||
@ -126,12 +135,27 @@ test_emu() {
|
|||||||
|
|
||||||
# Use the app to run setup and reboot
|
# Use the app to run setup and reboot
|
||||||
run_content_cmd setup
|
run_content_cmd setup
|
||||||
|
|
||||||
|
# Install LSPosed
|
||||||
|
if [ $api -ge $lsposed_min_api -a $api -le $atd_max_api ]; then
|
||||||
|
adb push out/lsposed.zip /data/local/tmp/lsposed.zip
|
||||||
|
adb shell echo 'magisk --install-module /data/local/tmp/lsposed.zip' \| /system/xbin/su
|
||||||
|
fi
|
||||||
|
|
||||||
adb reboot
|
adb reboot
|
||||||
wait_emu wait_for_boot
|
wait_emu wait_for_boot
|
||||||
|
|
||||||
# Run app tests
|
# Run app tests
|
||||||
run_content_cmd test
|
run_content_cmd test
|
||||||
adb shell echo "'su -c id'" \| /system/xbin/su 2000 | tee /dev/fd/2 | grep -q 'uid=0'
|
adb shell echo 'su -c id' \| /system/xbin/su 2000 | tee /dev/fd/2 | grep -q 'uid=0'
|
||||||
|
|
||||||
|
# Try to launch LSPosed
|
||||||
|
if [ $api -ge $lsposed_min_api -a $api -le $atd_max_api ]; then
|
||||||
|
adb shell am start -c org.lsposed.manager.LAUNCH_MANAGER com.android.shell/.BugreportWarningActivity
|
||||||
|
sleep 10
|
||||||
|
adb shell uiautomator dump
|
||||||
|
adb shell grep -q org.lsposed.manager /sdcard/window_dump.xml
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -141,7 +165,7 @@ run_test() {
|
|||||||
set_api_env $api
|
set_api_env $api
|
||||||
|
|
||||||
# Setup emulator
|
# Setup emulator
|
||||||
"$sdk" $pkg
|
"$sdk" --channel=3 $pkg
|
||||||
echo no | "$avd" create avd -f -n test -k $pkg
|
echo no | "$avd" create avd -f -n test -k $pkg
|
||||||
|
|
||||||
# Launch stock emulator
|
# Launch stock emulator
|
||||||
@ -155,13 +179,13 @@ run_test() {
|
|||||||
./build.py avd_patch -s "$ramdisk"
|
./build.py avd_patch -s "$ramdisk"
|
||||||
kill -INT $emu_pid
|
kill -INT $emu_pid
|
||||||
wait $emu_pid
|
wait $emu_pid
|
||||||
test_emu debug
|
test_emu debug $api
|
||||||
|
|
||||||
# Re-patch and test release build
|
# Re-patch and test release build
|
||||||
./build.py -r avd_patch -s "$ramdisk"
|
./build.py -r avd_patch -s "$ramdisk"
|
||||||
kill -INT $emu_pid
|
kill -INT $emu_pid
|
||||||
wait $emu_pid
|
wait $emu_pid
|
||||||
test_emu release
|
test_emu release $api
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
kill -INT $emu_pid
|
kill -INT $emu_pid
|
||||||
@ -185,8 +209,9 @@ case $(uname -m) in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
yes | "$sdk" --licenses
|
yes | "$sdk" --licenses > /dev/null
|
||||||
"$sdk" --channel=3 --update
|
"$sdk" --channel=3 --update
|
||||||
|
curl -L $lsposed_url -o out/lsposed.zip
|
||||||
|
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
run_test $1
|
run_test $1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user