update install script with key-selector
This commit is contained in:
parent
faadfde638
commit
ab91d30272
|
|
@ -100,6 +100,8 @@ LANG_UTIL_ERR_ANDROID_UNSUPPORT_1="Unsupported Android version"
|
|||
LANG_UTIL_ERR_ANDROID_UNSUPPORT_2="(below Oreo)"
|
||||
LANG_UTIL_ERR_ANDROID_UNSUPPORT_3="Learn more from our GitHub Wiki"
|
||||
LANG_UTIL_ERR_PLATFORM_UNSUPPORT="Unsupported platform"
|
||||
LANG_UTIL_ERR_VARIANT_SELECTION="Error occurred when selecting variant"
|
||||
LANG_UTIL_ERR_VARIANT_UNSUPPORT="Unsupported variant"
|
||||
LANG_UTIL_ERR_DUPINST_1="Duplicate installation is now allowed"
|
||||
LANG_UTIL_ERR_DUPINST_2="Remove"
|
||||
LANG_UTIL_ERR_DUPINST_3="and reboot to install again"
|
||||
|
|
@ -136,6 +138,29 @@ check_magisk_version
|
|||
check_riru_version
|
||||
edxp_check_architecture
|
||||
|
||||
# determinate variant
|
||||
if [ "${ARCH}" == "arm" ]; then
|
||||
BIN_PATH="system/bin"
|
||||
elif [ "${ARCH}" == "arm64" ]; then
|
||||
BIN_PATH="system/bin64"
|
||||
elif [ "${ARCH}" == "x86" ]; then
|
||||
BIN_PATH="system_x86/bin"
|
||||
elif [ "${ARCH}" == "x64" ]; then
|
||||
BIN_PATH="system_x86/bin64"
|
||||
else
|
||||
# unreachable
|
||||
abortC "${LANG_UTIL_ERR_PLATFORM_UNSUPPORT}"
|
||||
fi
|
||||
|
||||
extract "${ZIPFILE}" "${BIN_PATH}/key_selector" "${TMPDIR}"
|
||||
SELECTOR_PATH="${TMPDIR}/${BIN_PATH}/key_selector"
|
||||
chmod 755 "${SELECTOR_PATH}"
|
||||
"${SELECTOR_PATH}"
|
||||
VARIANT=$?
|
||||
if [ VARIANT -lt 16 ]; then
|
||||
abortC "${LANG_UTIL_ERR_VARIANT_SELECTION}"
|
||||
fi
|
||||
|
||||
ui_print "- ${LANG_CUST_INST_EXT_FILES}"
|
||||
|
||||
# extract module files
|
||||
|
|
@ -210,8 +235,14 @@ mkdir -p /data/misc/$MISC_PATH/0/conf/ || abortC "! ${LANG_CUST_ERR_CONF_CREATE}
|
|||
set_perm /data/misc/$MISC_PATH root root 0771 "u:object_r:magisk_file:s0" || abortC "! ${LANG_CUST_ERR_PERM}"
|
||||
echo "[[ -f /data/adb/edxp/keep_data ]] || rm -rf /data/misc/$MISC_PATH" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
|
||||
echo "[[ -f /data/adb/edxp/new_install ]] || rm -rf /data/adb/edxp" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
|
||||
# TODO: let user select variant
|
||||
|
||||
if [ $VARIANT == 17 ]; then
|
||||
echo "1" > /data/misc/$MISC_PATH/variant
|
||||
elif [ $VARIANT == 18 ]; then
|
||||
echo "2" > /data/misc/$MISC_PATH/variant
|
||||
else
|
||||
abortC "${LANG_UTIL_ERR_VARIANT_UNSUPPORT} ${VARIANT}"
|
||||
fi
|
||||
|
||||
ui_print "- ${LANG_CUST_INST_COPY_LIB}"
|
||||
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@ LANG_UTIL_ERR_ANDROID_UNSUPPORT_1="不支持的 Android 版本"
|
|||
LANG_UTIL_ERR_ANDROID_UNSUPPORT_2="(Oreo 以下版本)"
|
||||
LANG_UTIL_ERR_ANDROID_UNSUPPORT_3="从我们的 GitHub Wiki 中了解更多"
|
||||
LANG_UTIL_ERR_PLATFORM_UNSUPPORT="不支持的设备平台"
|
||||
LANG_UTIL_ERR_VARIANT_SELECTION="选择变种时出现错误"
|
||||
LANG_UTIL_ERR_VARIANT_UNSUPPORT="不支持的变种"
|
||||
LANG_UTIL_ERR_DUPINST_1="不允许重复安装"
|
||||
LANG_UTIL_ERR_DUPINST_2="删除"
|
||||
LANG_UTIL_ERR_DUPINST_3="并重启以继续安装"
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ afterEvaluate {
|
|||
def variantNameLowered = variant.name.toLowerCase()
|
||||
|
||||
task("copyKeySelector${variantNameCapped}LibraryToMagiskTemplate") {
|
||||
dependsOn tasks.getByName("assemble${variantNameCapped}")
|
||||
def libPathRelease = "${buildDir}/intermediates/cmake/${variantNameLowered}/obj"
|
||||
doLast {
|
||||
copy {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
//
|
||||
// Created by 双草酸酯 on 1/26/21.
|
||||
//
|
||||
|
||||
#ifndef EDXPOSED_LANGUAGES_H
|
||||
#define EDXPOSED_LANGUAGES_H
|
||||
#include <string>
|
||||
|
||||
class Languages {
|
||||
public:
|
||||
virtual const std::string desc_line_1() {
|
||||
return "Select variant. Use Volume Down to move and Volume Up to confirm.";
|
||||
}
|
||||
virtual const std::string desc_line_2(int seconds) {
|
||||
const char base[] = "The program will select YAHFA for you in %d seconds if you don't \nhave a physical volume button. ";
|
||||
std::string out;
|
||||
out.resize(sizeof(base) + 20);
|
||||
sprintf(out.data(), base, seconds);
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
class LanguageChinese: public Languages {
|
||||
public:
|
||||
const std::string desc_line_1() override {
|
||||
return "请选择变种。使用音量减切换,音量加确定。";
|
||||
}
|
||||
const std::string desc_line_2(int seconds) override {
|
||||
const char base[] = "如果您的设备没有音量键,本程序将会在 %d 秒后自动选择 YAHFA 。";
|
||||
std::string out;
|
||||
out.resize(sizeof(base) + 20);
|
||||
sprintf(out.data(), base, seconds);
|
||||
return out;
|
||||
}
|
||||
};
|
||||
|
||||
#endif //EDXPOSED_LANGUAGES_H
|
||||
|
|
@ -28,7 +28,9 @@
|
|||
#include <cerrno>
|
||||
#include <unistd.h>
|
||||
#include <stdexcept>
|
||||
#include <sys/system_properties.h>
|
||||
|
||||
#include "Languages.h"
|
||||
#include "key_selector.h"
|
||||
|
||||
// Global variables
|
||||
|
|
@ -260,16 +262,26 @@ int main() {
|
|||
const int cursor_max = SandHook;
|
||||
|
||||
auto print_status = [&cursor](){
|
||||
std::cout << "\33[2K\r"; // clear this line
|
||||
//std::cout << "\33[2K\r"; // clear this line
|
||||
std::cout << "[";
|
||||
std::cout << (cursor == YAHFA ? "x" : " ");
|
||||
std::cout << "] YAHFA [";
|
||||
std::cout << (cursor == SandHook ? "x" : " ");
|
||||
std::cout << "] SandHook" << std::flush;
|
||||
std::cout << "] SandHook" << std::endl;
|
||||
};
|
||||
|
||||
std::cout << "Select variant. Use Volume Down to move and Volume Up to confirm." << std::endl;
|
||||
std::cout << "The program will select YAHFA for you in " << timeout << " seconds if you don't have a physical volume button. " << std::endl;
|
||||
// languages
|
||||
Languages* l;
|
||||
char locale[256];
|
||||
__system_property_get("persist.sys.locale", locale);
|
||||
if (locale[0] == 'z' && locale[1] == 'h') {
|
||||
l = new LanguageChinese();
|
||||
} else {
|
||||
l = new Languages();
|
||||
}
|
||||
|
||||
std::cout << l->desc_line_1() << std::endl;
|
||||
std::cout << l->desc_line_2(timeout) << std::endl;
|
||||
print_status();
|
||||
while (int event = get_event()) {
|
||||
bool leave = false;
|
||||
|
|
@ -287,12 +299,13 @@ int main() {
|
|||
default:
|
||||
std::cout << "ERROR\n";
|
||||
}
|
||||
print_status();
|
||||
if (leave) {
|
||||
break;
|
||||
}
|
||||
print_status();
|
||||
}
|
||||
|
||||
// std::cout << std::endl << cursor << std::endl;
|
||||
delete l;
|
||||
return cursor;
|
||||
}
|
||||
Loading…
Reference in New Issue