Skip to content

Commit

Permalink
Initial rewrite for project NEXT
Browse files Browse the repository at this point in the history
Signed-off-by: androidacy <admin@androidacy.com>
Signed-off-by: androidacybot <45006100+androidacybot@users.noreply.github.com>
  • Loading branch information
androidacy-user committed Jul 15, 2021
1 parent 72f7b93 commit 7bc2d7f
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 119 deletions.
4 changes: 2 additions & 2 deletions common/addon/Volume-Key-Selector/install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# External Tools
#!/bin/bash
chmod -R 0755 $MODPATH/common/addon/Volume-Key-Selector/tools

chooseport_legacy() {
Expand Down Expand Up @@ -31,7 +31,7 @@ chooseport() {
local count=0
while true; do
timeout $delay /system/bin/getevent -lqc 1 2>&1 > $TMPDIR/events &
sleep 0.25; count=$((count + 1))
sleep 0.5; count=$((count + 1))
if (`grep -q 'KEY_VOLUMEUP *DOWN' $TMPDIR/events`); then
return 0
elif (`grep -q 'KEY_VOLUMEDOWN *DOWN' $TMPDIR/events`); then
Expand Down
30 changes: 6 additions & 24 deletions common/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,14 @@ it_failed() {
ui_print " "
ui_print "⚠ ⚠ ⚠ ⚠ ⚠ ⚠ ⚠ ⚠ ⚠ ⚠ ⚠ ⚠ ⚠ ⚠"
ui_print " "
$INTERNET && curl -s -d "$P&i=2" "$U"/ping >/dev/null
exit 1
}
set_tls() {
mkdir "$TMPDIR"/path
unzip "$MODPATH"/common/tools/tools.zip -d "$TMPDIR"/path >/dev/null
}
set_tls
alias aapt='$TMPDIR/path/$ARCH/aapt'
alias sign='$TMPDIR/path/zipsigner'
chmod 755 "$TMPDIR/path/$ARCH/aapt"
chmod 755 "$TMPDIR/path/zipsigner"
dl() {
if ! wget -qc "${U}/${3}?${P}${1}" -O "$2"; then
ui_print "⚠ Download failed! Bailing out!"
it_failed
fi
}
get_v() {
dl "&s=$DIR" '-' version
}
ui_print "- PLEASE NOTE: This module requires interent access and will abort if you don't have any"
. $MODPATH/common/tools/apiClient.sh
initClient 'wvm' '10.0.0-beta'
alias aapt='$MODPATH/common/tools/$ARCH/aapt'
alias sign='$MODPATH/common/tools/zipsigner'
chmod 755 aapt zip
abort() {
ui_print "$1"
rm -fr $MODPATH 2>/dev/null
Expand Down Expand Up @@ -87,11 +74,6 @@ mkdir "$MODPATH"/logs/
mkdir -p "$EXT_DATA"/apks/
mkdir -p "$EXT_DATA"/logs/
chmod 750 -R "$EXT_DATA"
A=$(resetprop ro.system.build.version.release | sed 's#\ #%20#g' || resetprop ro.build.version.release | sed 's#\ #%20#g') && D=$(resetprop ro.product.model | sed 's#\ #%20#g' || resetprop ro.product.device | sed 's#\ #%20#g' | sed 's#\ #%20#g' || resetprop ro.product.vendor.device | sed 's#\ #%20#g' | sed 's#\ #%20#g' || resetprop ro.product.system.model | sed 's#\ #%20#g' | sed 's#\ #%20#g' || resetprop ro.product.vendor.model | sed 's#\ #%20#g' | sed 's#\ #%20#g' || resetprop ro.product.name | sed 's#\ #%20#g') && L=$(resetprop persist.sys.locale | sed 's#\ #%20#g' || resetprop ro.product.locale | sed 's#\ #%20#g') && M="wvm" && P="m=$M&av=$A&a=$ARCH&d=$D&ss=%20&l=$L" && U="https://api.androidacy.com"
test_connection() {
(wget -qc "$U/ping?$P" -O /dev/null -o /dev/null) && return 0 || return 1
}
test_connection && INTERNET=true
mount_apex() {
$BOOTMODE || [ ! -d /system/apex ] && return
local APEX DEST
Expand Down
110 changes: 20 additions & 90 deletions common/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,6 @@ if [ -f $VEN/build.prop ]; then
else
BUILDS="/system/build.prop"
fi
check_config() {
if [[ "$CV" -ne 6 ]]; then
ui_print "⚠ Wrong config version! Using defaults"
cp "$MODPATH"/config.txt "$EXT_DATA"
. "$EXT_DATA"/config.txt
fi
overrid_conf() {
cp "$MODPATH"/config.txt "$EXT_DATA"
vol_sel
}
if [[ $FORCE_CONFIG -ne 0 ]] && [[ $FORCE_CONFIG -ne 1 ]]; then
ui_print "⚠ Invalid config value for FORCE_CONFIG!"
overrid_conf
elif [[ $OFFLINE -ne 0 ]] && [[ $OFFLINE -ne 1 ]]; then
ui_print "⚠ Invalid config value for OFFLINE!"
overrid_conf
elif [[ $INSTALL -ne 0 ]] && [[ $INSTALL -ne 1 ]] && [[ $INSTALL -ne 2 ]]; then
ui_print "⚠ Invalid config value for INSTALL!"
overrid_conf
elif [[ $WEBVIEW -ne 0 ]] && [[ $WEBVIEW -ne 1 ]] && [[ $WEBVIEW -ne 2 ]]; then
ui_print "⚠ Invalid config value for WEBIEW!"
overrid_conf
elif [[ $BROWSER -ne 0 ]] && [[ $BROWSER -ne 1 ]] && [[ $BROWSER -ne 2 ]] && [[ $BROWSER -ne 3 ]]; then
ui_print "⚠ Invalid config value for BROWSER!"
overrid_conf
fi
}
vol_sel() {
ui_print "ⓘ Starting config mode...."
ui_print "ⓘ To use config.txt, set FORCE_CONFIG=1 in config.txt and edit as necessary."
Expand Down Expand Up @@ -136,7 +109,8 @@ vol_sel() {
set_config() {
ui_print "ⓘ Setting configs..."
if [[ ! -f "$EXT_DATA"/config.txt ]]; then
cp "$MODPATH"/config.txt "$EXT_DATA"
ui_print "- WARNING! Old config.txt found. Note this is no longer used."
ui_print "- Using selection mode."
vol_sel
else
FORCE_CONFIG=0
Expand All @@ -152,36 +126,36 @@ set_config() {
do_ungoogled_webview() {
NAME="Ungoogled-Chromium"
DIR='ugc-w'
W_VER=$(get_v)
W_VER=$(updateChecker "$DIR")
}
do_ungoogled_browser() {
NAME="Ungoogled-Chromium"
DIR='ugc-b'
B_VER=$(get_v)
B_VER=$(updateChecker "$DIR")
if [[ $BROWSER -eq 3 ]]; then
DIR='ugc-e'
B_VER=$(get_v)
B_VER=$(updateChecker "$DIR")
fi
}
do_vanilla_webview() {
NAME="Chromium"
DIR=chrm
W_VER=$(get_v)
W_VER=$(updateChecker "$DIR")
}
do_vanilla_browser() {
NAME="Chromium"
DIR=chrm
B_VER=$(get_v)
B_VER=$(updateChecker "$DIR")
}
do_bromite_webview() {
NAME="Bromite"
DIR=brm
W_VER=$(get_v)
W_VER=$(updateChecker "$DIR")
}
do_bromite_browser() {
NAME="Bromite"
DIR=brm
B_VER=$(get_v)
B_VER=$(updateChecker "$DIR")
}
old_version() {
ui_print "ⓘ Checking whether this is a new install...."
Expand All @@ -208,7 +182,7 @@ download_webview() {
fi
if [[ "$VF" -eq 1 ]]; then
ui_print "ⓘ Redownloading ${NAME} webview, attempt number ${TRY_COUNT}, please be patient..."
dl "&s=$DIR&w=webview&ft=apk" "${EXT_DATA}/apks/${NAME}Webview.apk" "download"
downloadFile "$DIR" "webview${ARCH}" "apk" "${EXT_DATA}/apks/${NAME}Webview.apk"
sed -i "/OLD_WEBVIEW/d" "$VERSIONFILE"
echo "OLD_WEBVIEW=$(echo "$W_VER" | sed 's/[^0-9]*//g')" >>"$VERSIONFILE"
else
Expand All @@ -217,7 +191,7 @@ download_webview() {
if [[ -f $EXT_DATA/apks/"$NAME"Webview.apk ]]; then
if [[ $OLD_WEBVIEW -lt "$(echo "$W_VER" | sed 's/[^0-9]*//g' | tr -d '.')" ]]; then
ui_print "ⓘ Downloading update for ${NAME} webview, please be patient..."
dl "&s=$DIR&w=webview&ft=apk" "${EXT_DATA}/apks/${NAME}Webview.apk" "download"
downloadFile "$DIR" "webview${ARCH}" "apk" "${EXT_DATA}/apks/${NAME}Webview.apk"
sed -i "/OLD_WEBVIEW/d" "$VERSIONFILE"
echo "OLD_WEBVIEW=$(echo "$W_VER" | sed 's/[^0-9]*//g')" >>"$VERSIONFILE"
else
Expand All @@ -226,7 +200,7 @@ download_webview() {
else
ui_print "ⓘ No existing apk found for ${NAME} webview!"
ui_print "ⓘ Downloading ${NAME} webview, please be patient..."
dl "&s=$DIR&w=webview&ft=apk" "${EXT_DATA}/apks/${NAME}Webview.apk" "download"
downloadFile "$DIR" "webview${ARCH}" "apk" "${EXT_DATA}/apks/${NAME}Webview.apk"
sed -i "/OLD_WEBVIEW/d" "$VERSIONFILE"
echo "OLD_WEBVIEW=$(echo "$W_VER" | sed 's/[^0-9]*//g')" >>"$VERSIONFILE"
fi
Expand All @@ -243,7 +217,7 @@ download_browser() {
fi
if [[ "$VF" -eq 1 ]]; then
ui_print "ⓘ Redownloading ${NAME} browser, please be patient..."
dl "&s=$DIR&w=browser&ft=apk" "${EXT_DATA}/apks/${NAME}Browser.apk" "download"
downloadFile "$DIR" "browser${ARCH}" "apk" "${EXT_DATA}/apks/${NAME}Browser.apk"
sed -i "/OLD_BROWSER/d" "$VERSIONFILE"
echo "OLD_BROWSER=$(echo "$B_VER" | sed 's/[^0-9]*//g')" >>"$VERSIONFILE"
else
Expand All @@ -252,7 +226,7 @@ download_browser() {
if [[ -f $EXT_DATA/apks/"$NAME"Browser.apk ]]; then
if [[ $OLD_BROWSER -lt "$(echo "$B_VER" | sed 's/[^0-9]*//g' | tr -d '.')" ]]; then
ui_print "ⓘ Downloading update for ${NAME} browser, please be patient..."
dl "&s=$DIR&w=browser&ft=apk" "${EXT_DATA}/apks/${NAME}Browser.apk" "download"
downloadFile "$DIR" "browser${ARCH}" "apk" "${EXT_DATA}/apks/${NAME}Browser.apk"
sed -i "/OLD_BROWSER/d" "$VERSIONFILE"
echo "OLD_BROWSER=$(echo "$B_VER" | sed 's/[^0-9]*//g')" >>"$VERSIONFILE"
else
Expand All @@ -261,7 +235,7 @@ download_browser() {
else
ui_print "ⓘ No existing apk found for ${NAME} browser!"
ui_print "ⓘ Downloading ${NAME} browser, please be patient..."
dl "&s=$DIR&w=browser&ft=apk" "${EXT_DATA}/apks/${NAME}Browser.apk" "download"
downloadFile "$DIR" "browser${ARCH}" "apk" "${EXT_DATA}/apks/${NAME}Browser.apk"
sed -i "/OLD_BROWSER/d" "$VERSIONFILE"
echo "OLD_BROWSER=$(echo "$B_VER" | sed 's/[^0-9]*//g')" >>"$VERSIONFILE"
fi
Expand All @@ -272,7 +246,8 @@ verify_w() {
if $VERIFY; then
cd "$EXT_DATA"/apks || return
O_S=$(md5sum "$NAME"Webview.apk | sed "s/\ $NAME.*//" | tr -d '[:space:]')
T_S=$(dl "&s=$DIR&w=webview&ft=apk" '-' verify | tr -d '[:space:]')
getChecksum "$DIR" "webview${ARCH}" "apk"
T_S=$(echo "$response" | tr -d '[:space:]')
if [ "$T_S" != "$O_S" ]; then
ui_print "⚠ Verification failed, retrying download"
rm -f "$EXT_DATA"/apks/*Webview.apk
Expand Down Expand Up @@ -300,7 +275,8 @@ verify_b() {
if $VERIFY; then
cd "$EXT_DATA"/apks || return
O_S=$(md5sum "$NAME"Browser.apk | sed "s/\ $NAME.*//" | tr -d '[:space:]')
T_S=$(dl "&s=$DIR&w=browser&ft=apk" '-' verify | tr -d '[:space:]')
getChecksum "$DIR" "browser${ARCH}" "apk"
T_S=$(echo "$response" | tr -d '[:space:]')
if [ "$T_S" != "$O_S" ]; then
ui_print "⚠ Verification failed, retrying download"
rm -f "$EXT_DATA"/apks/*Browser.apk
Expand Down Expand Up @@ -433,58 +409,13 @@ online_install() {
download_browser
fi
}
offline_install() {
set_path
for file in "$EXT_DATA"/apks/*browser.apk; do
if [ -e "$file" ]; then
ui_print "ⓘ Browser apk found! Using it"
OFFLN_BRS=true
extract_browser
break
else
ui_print "⚠ No browser apk found!"
break
fi
done
for file in "$EXT_DATA"/apks/*webview.apk; do
if [ -e "$file" ]; then
ui_print "ⓘ Webview apk found! Using it"
OFFLN_WV=true
extract_webview
break
else
ui_print "⚠ No webview apk found!"
break
fi
done
if [[ -z $OFFLN_BRS ]] && [[ -z $OFFLN_WV ]]; then
ui_print "⚠ Required files for offline install not found!"
it_failed
fi
}
do_install() {
set_config
if ! "$BOOTMODE"; then
ui_print "ⓘ Detected recovery install! Aborting!"
it_failed 1
elif [[ $FORCE_CONFIG -eq 1 ]]; then
if [[ $OFFLINE -eq 1 ]]; then
ui_print "⚠ Offline install selected! Proceeding..."
offline_install
fi
else
if ! $INTERNET; then
ui_print "⚠ Uh-oh, we can't contact the API."
ui_print "⚠ Make sure api.androidacy.com isn't blocked, that you have internet. and re-run the installer."
ui_print "⚠ Falling back to offline mode for now."
offline_install
else
if [[ ${TRY_COUNT} -gt 3 ]]; then
it_failed
else
online_install
fi
fi
online_install
fi
do_cleanup
}
Expand Down Expand Up @@ -543,7 +474,6 @@ ui_print " "
sleep 0.15
ui_print " Webview Manager | By Androidacy"
ui_print ' '
$INTERNET && curl -s -d "$P&i=1" "$U"/ping >/dev/null
ui_print "☑ Donate at https://www.androidacy.com/donate/"
sleep 0.15
ui_print "☑ Website, how to get support and blog is at https://www.androidacy.com"
Expand Down
Loading

0 comments on commit 7bc2d7f

Please sign in to comment.