2
0
mirror of https://gitlab.com/Nanolx/NanoDroid synced 2024-10-31 09:20:23 +00:00
NanoDroid/CommonInstaller

2172 lines
63 KiB
Plaintext
Raw Normal View History

2018-01-23 20:11:52 +00:00
#!/sbin/sh
2021-01-09 09:45:12 +00:00
VERSION=23.1.20210109
2018-07-30 19:14:22 +00:00
NANODROID_UPGRADE=0
INSTALL_SUCCESS=TRUE
NANODROID_LIST=/system/addon.d/NanoDroid_FileList
NANODROID_LIST_OLD=/data/adb/NanoDroid_FileList
2019-05-05 10:17:26 +00:00
STORAGE=/data/media/0
curdate=$(date +%Y%m%d_%H.%M.%S)
nanodroid_logfile="${STORAGE}/nanodroid_logs/${MODID}_${VERSION}_log_${curdate}.log"
2018-01-23 20:11:52 +00:00
config_locations="${STORAGE} /external_sd /sdcard /sdcard1 /data /system/addon.d /tmp"
nanodroid_all_init='"10_sqlite 20_fstrim 30_logcat 40_external_sd 50_logscleaner"'
##########################################################################################
# NanoDroid Installer Setup Function
##########################################################################################
2018-07-08 15:21:02 +00:00
setup_installer () {
detect_bootmode
detect_outfd
#check_space
show_progress 1.0 0
2018-03-13 19:30:55 +00:00
show_banner
set_progress 0.1
unpack_zip
setup_busybox
mount_partitions
detect_arch
set_progress 0.2
if ${BOOTMODE}; then
media_rw=$(grep "^/dev/block.*/mnt/media_rw" /proc/mounts \
| cut -d " " -f 2 \
| cut -d "/" -f 4)
ext_storage="/storage/${media_rw}"
[ -r "${ext_storage}" ] && config_locations="${ext_storage} ${config_locations}"
fi
[ -n "${1}" ] && get_cfg_setup
[ -n "${2}" ] && get_cfg_overlay
[ -n "${3}" ] && get_cfg_apps
detect_mode
set_progress 0.3
2019-02-04 19:00:54 +00:00
}
2018-10-11 16:50:51 +00:00
2018-01-23 20:11:52 +00:00
##########################################################################################
# Misc. Functions
##########################################################################################
##########################################################################################
# Debug Echo: only echo in TWRP, in Magisk Manager print to logfile
##########################################################################################
decho () {
mkdir -p "${STORAGE}/nanodroid_logs"
if ${BOOTMODE}; then
echo "$@" >> "${nanodroid_logfile}"
else
echo "$@"
fi
}
##########################################################################################
# use print_info() instead of ui_print() to avoid spamming Magisk Manager output
##########################################################################################
2018-01-23 20:11:52 +00:00
print_info () {
2018-01-23 20:11:52 +00:00
if ${BOOTMODE}; then
echo "${@}"
decho "${@}"
2020-12-20 09:20:03 +00:00
else
2018-03-28 18:18:25 +00:00
echo -n -e "ui_print ${@}\n" >> /proc/self/fd/${OUTFD}
echo -n -e "ui_print\n" >> /proc/self/fd/${OUTFD}
2018-01-23 20:11:52 +00:00
fi
}
show_progress() {
${BOOTMODE} || echo "progress ${1} ${2}" >> /proc/self/fd/${OUTFD}
}
set_progress() {
${BOOTMODE} || echo "set_progress ${1}" >> /proc/self/fd/${OUTFD}
}
##########################################################################################
# Error out with proper cleanup
##########################################################################################
error () {
print_info " !!"
print_info "${@}"
print_info " !!"
if is_mounted /data; then
[ "${MODE}" = "MAGISK" ] && rm -rf "${MODPATH}"
installer_cleanup_env
INSTALL_SUCCESS=FALSE
nanodroid_storelogs
fi
${BOOTMODE} || umount_partitions
exit 1
}
##########################################################################################
# Taken from Magisk, check where to print to
##########################################################################################
detect_outfd () {
if [ -z $OUTFD ] || readlink /proc/$$/fd/$OUTFD | grep -q /tmp; then
# We will have to manually find out OUTFD
for FD in `ls /proc/$$/fd`; do
if readlink /proc/$$/fd/$FD | grep -q pipe; then
if ps | grep -v grep | grep -q " 3 $FD "; then
OUTFD=$FD
break
fi
fi
done
fi
}
##########################################################################################
# XXX - unused - Check if enough free space in /dev/tmp
##########################################################################################
check_space () {
space_required=524288
space_available=$(df /dev 2>/dev/null | awk '/tmpfs/{print $4}')
decho " required space : ${space_required}"
decho " available space: ${space_available}"
if [ ${space_available} -lt ${space_required} ]; then
error "Less than 512 MB free space availabe from TWRP!"
fi
}
##########################################################################################
# Taken from Magisk, check whether we're in Magisk Manager or TWRP
##########################################################################################
detect_bootmode () {
[ -z ${BOOTMODE} ] && ps | grep zygote | grep -qv grep && BOOTMODE=true
[ -z ${BOOTMODE} ] && ps -A 2>/dev/null | grep zygote | grep -qv grep && BOOTMODE=true
[ -z ${BOOTMODE} ] && BOOTMODE=false
}
##########################################################################################
# Taken from Magisk, grep build_props / /proc/cmdline for value
##########################################################################################
2018-01-23 20:11:52 +00:00
grep_prop() {
2020-10-20 16:45:09 +00:00
sed -n "s/^${1}=//p" /system/build.prop ${2} | head -n 1
2018-01-23 20:11:52 +00:00
}
grep_cmdline() {
local REGEX="s/^${1}=//p"
sed -E 's/ +/\n/g' /proc/cmdline | \
sed -n "${REGEX}" 2>/dev/null
}
##########################################################################################
# Set permissions for installed files
##########################################################################################
2018-01-23 20:11:52 +00:00
set_perm () {
chown ${2}:${3} ${1} || error "failed change owner for ${1}"
chmod ${4} ${1} || error "failed to change mode for ${1}"
2020-10-04 16:22:13 +00:00
if [ -n "${5}" ]; then
2018-01-23 20:11:52 +00:00
chcon ${5} ${1} 2>/dev/null
else chcon 'u:object_r:system_file:s0' ${1} 2>/dev/null
fi
}
set_perm_recursive() {
find ${1} -type d 2>/dev/null | while read dir; do
set_perm ${dir} ${2} ${3} ${4} ${6}
done
find ${1} -type f 2>/dev/null | while read file; do
set_perm ${file} ${2} ${3} ${5} ${6}
done
}
set_perm_data () {
if [ "${1}" = "-r" ]; then
decho " perm: data [recursive] {${2}}"
2018-01-23 20:11:52 +00:00
set_perm_recursive ${2} 0 0 0755 0644
else
decho " perm: data [single] {${1}}"
2018-01-23 20:11:52 +00:00
set_perm ${1} 0 0 0644
fi
}
set_perm_bin () {
if [ "${1}" = "-r" ]; then
decho " perm: exec [recursive] {${2}}"
2018-01-23 20:11:52 +00:00
set_perm_recursive ${2} 0 0 0755 0755
else
decho " perm: exec [single] {${1}}"
2018-01-23 20:11:52 +00:00
set_perm ${1} 0 0 0755
fi
}
##########################################################################################
# Taken from Magisk, mount functions
# Modified for NanoDroid
##########################################################################################
is_mounted () {
2020-10-18 07:39:35 +00:00
grep -q " $(readlink -f ${1}) " /proc/mounts 2>/dev/null
return $?
2019-10-23 18:52:43 +00:00
}
##########################################################################################
2020-08-17 16:54:55 +00:00
# taken from Magisk, with minor modifications for NanoDroid
# mount partitions
##########################################################################################
find_block () {
unset tmp
tmp=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${1}${SLOT} | head -n 1)
2020-10-21 18:15:03 +00:00
[ -z "${tmp}" ] && tmp=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${1}${SLOT} | head -n 1)
if [ -z "${tmp}" ]; then
for uevent in /sys/dev/block/*/uevent; do
partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent})
if [ "${1}${SLOT}" = "${partname}" ]; then
tmp="/dev/block/$(awk -F= '/DEVNAME/{print $2}' ${uevent})"
break
fi
done
fi
2020-10-21 18:15:03 +00:00
readlink -f "${tmp}"
}
2019-10-23 18:52:43 +00:00
mount_partitions () {
2020-10-17 19:39:41 +00:00
if ! ${BOOTMODE}; then
DEVICE_AB=FALSE
VENDOR_COMPAT=FALSE
SYSTEM_AS_ROOT=FALSE
SLOT=$(grep_cmdline androidboot.slot_suffix)
decho " INFO: #1 [SLOT] ${SLOT}"
if [ -z ${SLOT} ]; then
SLOT=$(grep_cmdline androidboot.slot)
echo " INFO: #2 [SLOT] ${SLOT}"
2020-10-28 21:04:34 +00:00
if [ ! -z ${SLOT} ]; then
SLOT=_${SLOT}
echo " INFO: #3 [SLOT] ${SLOT}"
DEVICE_AB=TRUE
fi
2019-10-23 19:33:35 +00:00
fi
2019-10-23 18:52:43 +00:00
is_mounted /data || mount /data || decho "failed to mount /data!"
2020-10-20 16:45:09 +00:00
mount -o bind /dev/urandom /dev/random
SYSTEM_BLOCK=$(find_block system)
decho " INFO: #5 [SYSTEM_BLOCK] ${SYSTEM_BLOCK}"
2019-10-23 18:52:43 +00:00
mkdir -p /system /system_root
mount -o rw ${SYSTEM_BLOCK} /system
if [ -f /system/build.prop ]; then
SYSTEM=/system
elif [ -f /system/system/build.prop -o -f /system/init -o -L /system/init ]; then
SYSTEM_AS_ROOT=true
SYSTEM=/system/system
if ! mount --move /system /system_root; then
umount /system
umount -l /system
moun -o rw ${SYSTEM_BLOCK} /system_root
fi
mount -o bind /system_root/system /system
fi
VENDOR_BLOCK=$(find_block vendor)
decho " INFO: #7 [VENDOR_BLOCK] ${VENDOR_BLOCK}"
! is_mounted /vendor && mount -o ro /vendor
! is_mounted /vendor && mount -o ro ${VENDOR_BLOCK} /vendor
if [[ ! $(is_mounted /vendor) && -d /system/vendor ]]; then
2020-09-29 18:21:51 +00:00
### XXX work-around required for some devices
VENDOR_COMPAT=TRUE
ln -sf /system/vendor /vendor >/dev/null
fi
2019-10-23 18:55:31 +00:00
decho " INFO: #8 [prop]"
2020-10-17 19:39:41 +00:00
ls -l /system/*.prop
2019-10-23 18:52:43 +00:00
[ -d /system/apex ] && mount_apex
fi
2020-10-20 16:45:09 +00:00
[ ! -f /system/build.prop ] && error "failed to mount /system (unsupported A/B device?)"
2020-10-17 19:39:41 +00:00
if [ -d /apex/com.android.art ]; then
export ANDROID_ART_ROOT=/apex/com.android.art
export ANDROID_RUNTIME_ROOT=${ANDROID_ART_ROOT}
elif [ -d /apex/com.android.runtime ]; then
export ANDROID_RUNTIME_ROOT=/apex/com.android.runtime
fi
export ANDROID_TZDATA_ROOT=/apex/com.android.tzdata
2020-10-17 20:01:14 +00:00
export ANDROID_I18N_ROOT=/apex/com.android.i18n
}
##########################################################################################
# taken from Magisk, with minor modifications for NanoDroid
# mount APEX directories or images
##########################################################################################
mount_apex () {
mkdir -p /apex
for apex in /system/apex/*; do
apex_mount="/apex/$(basename ${apex} .apex)"
apex_loop="/dev/loop_apex_$(basename ${apex} .apex)"
[ "${apex_mount}" == /apex/com.android.runtime.release ] && apex_mount=/apex/com.android.runtime
[ "${apex_mount}" == /apex/com.android.runtime.debug ] && apex_mount=/apex/com.android.runtime
[ "${apex_mount}" == /apex/com.android.art.release ] && apex_mount=/apex/com.android.art
[ "${apex_mount}" == /apex/com.android.art.debug ] && apex_mount=/apex/com.android.art
mkdir -p "${apex_mount}"
if [ -f "${apex}" ]; then
unzip -oq "${apex}" apex_payload.img -d /apex
mount_apex_loop "${apex_mount}" || error "APEX loop setup failed!"
elif [ -d "${apex}" ]; then
mount -o bind "${apex}" "${apex_mount}"
fi
done
echo " INFO: #10 [APEX [ALL]] $(ls /system/apex/*)"
}
##########################################################################################
# taken from Magisk, with minor modifications for NanoDroid
# helper function for mounting APEX directories or images
##########################################################################################
mount_apex_loop () {
local number=0
local minorx=1
local loop
[ -e /dev/block/loop1 ] && minorx=$(stat -Lc '%T' /dev/block/loop1)
apex_mount="${1}"
decho " *** mount_apex_loop [apex_mount]: ${apex_mount}"
while [ ${number} -lt 64 ]; do
loop=/dev/block/loop${number}
[ -e ${loop} ] || mknod ${loop} b 7 $((number * minorx))
if losetup "${loop}" /apex/apex_payload.img 2>/dev/null; then
decho " *** mount_apex_loop [loop]: ${loop}"
if mount -text4 -oro,noatime "${loop}" "${apex_mount}"; then
rm -f /apex/apex_payload.img
break
fi
fi
number=$((number + 1))
done
}
##########################################################################################
# unmount partitions
##########################################################################################
umount_partitions () {
umount -l /system_root 2>/dev/null
umount -l /system 2>/dev/null
umount -l /system/vendor 2>/dev/null
umount -l /vendor 2>/dev/null
umount -l /dev/random 2>/dev/null
mount | awk '/ \/apex/{print $1 " " $3}' | while read apex_loop apex_mount; do
umount -l "${apex_mount}" 2>/dev/null
losetup -d "${apex_loop}" 2>/dev/null
done
rm -rf /apex
unset ANDROID_RUNTIME_ROOT
unset ANDROID_TZDATA_ROOT
}
##########################################################################################
# migrate from Nanolx to Official APKs and vice-versa
##########################################################################################
2018-01-28 10:31:15 +00:00
detect_migrate_apk () {
local app_id="${1}"
local app_name="${2}"
USER_PATH=$(find /data/app -type d -name "${app_id}-*" &>/dev/null)
2020-10-04 16:22:13 +00:00
if [ -n ${USER_PATH} ]; then
if ${UNZIP} -l "${MODPATH}/system/priv-app/${app_name}/${app_name}.apk" | grep META-INF/NANOLX.RSA &>/dev/null; then
BUILD_INST=Nanolx
else BUILD_INST=Official
fi
if ${UNZIP} -l "${USER_PATH}/base.apk" | grep META-INF/NANOLX.RSA &>/dev/null; then
BUILD_USER=Nanolx
else BUILD_USER=Official
fi
if [ "${BUILD_INST}" != "${BUILD_USER}" ]; then
decho " + Removing ${BUILD_USER} ${app_name} in favor of ${BUILD_INST} ${app_name}"
rm -rf "${USER_PATH}"
if [ "${app_id}" = "com.google.android.gms" ]; then
decho " + Resetting GCM/FCM connection of all apps to allow re-registration"
find /data/data/*/shared_prefs -name com.google.android.gms.*.xml -delete
2018-01-23 20:11:52 +00:00
fi
fi
fi
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# check if ROM has native fake signature spoofing support
# origingally by @ale5000 - revised by me
##########################################################################################
check_fake_package_signature () {
PERMISSION=android.permission.FAKE_PACKAGE_SIGNATURE
PERMISSION_OD=$(echo -n "${PERMISSION}" | od -A n -t x1 | tr -d '\n' | sed -e 's/^ //g;s/ /00/g')
PATCH_TYPE=""
FRAMEWORKRES_PATCH=false
SERVICESJAR_PATCH=false
mkdir -p ${TMPDIR}/sigcheck
# natively patched ROM: only framework-res.apk patched (old)
# natively patched ROM: both framework-res.apk and services.jar patched (new)
# self patched ROM: only services.jar patched
# check framework-res.apk for the patch
unzip -oq /system/framework/framework-res.apk -d "${TMPDIR}/sigcheck" \
|| error "failed to unpack framework-res.apk"
grep -qF "${PERMISSION}" "${TMPDIR}"/sigcheck/AndroidManifest.xml && FRAMEWORKRES_PATCH=true
od -A n -t x1 "${TMPDIR}"/sigcheck/AndroidManifest.xml | tr -d ' \n' | grep -qF "${PERMISSION_OD}" && FRAMEWORKRES_PATCH=true
# check services.jar for the patch
unzip -oq /system/framework/services.jar -d "${TMPDIR}/sigcheck" \
|| error "failed to unpack services.jar"
grep -qF "${PERMISSION}" "${TMPDIR}"/sigcheck/*.dex && SERVICESJAR_PATCH=true
od -A n -t x1 "${TMPDIR}"/sigcheck/*.dex | tr -d ' \n' | grep -qF "${PERMISSION_OD}" && SERVICESJAR_PATCH=true
# we don't use this anywhere (except in SysTest log),
# but may still come in hand in the future
if ${FRAMEWORKRES_PATCH} && ! ${SERVICESJAR_PATCH}; then
PATCH_TYPE="native_old"
elif ${FRAMEWORKRES_PATCH} && ${SERVICESJAR_PATCH}; then
PATCH_TYPE="native_new"
elif ! ${FRAMEWORKRES_PATCH} && ${SERVICESJAR_PATCH}; then
PATCH_TYPE="self_patched"
fi
[ -n "${PATCH_TYPE}" ] && return 0 || return 1
}
##########################################################################################
# check if Bromite System WebView is supported
##########################################################################################
check_bromite_webview_support () {
WEBVIEW_PKG="com.android.webview"
HAS_WEBVIEW=false
${AAPT} dump xmltree /system/framework/framework-res.apk res/xml/config_webview_packages.xml | \
tr -d '\n' | sed -e 's/webviewprovider/\n/g' | grep com.android.webview | \
grep -q 'E: signature' || HAS_WEBVIEW=true
${HAS_WEBVIEW} && return 0 || return 1
}
##########################################################################################
# privapp permission whitelist generation
##########################################################################################
dump_system_privapp_permissions () {
local sys_list="${TMPDIR}/privapp-permissions.list"
local tmp_list="${TMPDIR}/privapp-permissions.dump"
rm -f "${sys_list}"
2018-03-18 19:15:17 +00:00
"${AAPT}" dump xmltree /system/framework/framework-res.apk AndroidManifest.xml | \
tr -d '\n' | sed -e 's/E:/\n/g' > "${tmp_list}"
2020-10-10 06:01:01 +00:00
for pattern in "(type 0x11)0x[1357]2" "(type 0x11)0xc212" \
"(type 0x11)0x[02]" "(type 0x11)0x[13]02" \
"(type 0x11)0x1[01]2" "(type 0x11)0x1001"; do
grep "${pattern}" "${tmp_list}" | \
2020-09-28 15:53:21 +00:00
awk -F\" '{print $2}' >> "${sys_list}"
done
# XXX pre-patched custom ROM
check_fake_package_signature && \
echo "android.permission.FAKE_PACKAGE_SIGNATURE" >> "${sys_list}"
2018-01-23 20:11:52 +00:00
}
create_privapp_permissions_whitelist () {
local apk="${MODPATH}/system/priv-app/${1}/${1}.apk"
local apk_name="$("${AAPT}" dump badging "${apk}" | awk -F \' '/^package: name/{print $2}')"
local apk_list="${TMPDIR}/${apk_name}.list"
local sys_list="${TMPDIR}/privapp-permissions.list"
local app_whitelist="${TMPDIR}/${apk_name}.xml"
local inst_whitelist="/system/etc/permissions/${apk_name}.xml"
[ ! -f "${sys_list}" ] && dump_system_privapp_permissions
"${AAPT}" dump permissions "${apk}" | \
awk -F \' '/^uses-permission:/{print $2}' > "${apk_list}"
echo '<?xml version="1.0" encoding="utf-8"?>
<permissions>
<privapp-permissions package="'${apk_name}'">' > "${app_whitelist}"
cat "${apk_list}" | while read perm; do
if grep -q "${perm}" "${sys_list}"; then
decho " ++ package ${apk_Name} needs privapp-whitelist ${perm}"
echo ' <permission name="'${perm}'" />' >> "${app_whitelist}"
fi
done
echo ' </privapp-permissions>
</permissions>' >> "${app_whitelist}"
mkdir -p "${MODPATH}/system/etc/permissions/"
cp "${app_whitelist}" "${MODPATH}/${inst_whitelist}"
set_perm_data "${MODPATH}/${inst_whitelist}"
installinfo_add "${inst_whitelist}"
}
##########################################################################################
# Reset System Runtime permissions
##########################################################################################
reset_runtime_permissions () {
# required on Android 10, else all apps bundled with NanoDroid will not
# show a permission prompt for android.permission.WRITE_EXTERNAL_STORAGE
if [ "${SDK_VERSION}" -ge 29 ]; then
if ${BOOTMODE}; then
pm reset-permissions
else
find /data/system/users -type f -name 'runtime-permissions.xml' 2>/dev/null | while read file; do
rm -f "${file}"
decho " ++ resetting permissions: ${file}"
done
fi
fi
}
##########################################################################################
# Unpack NanoDroid zip
##########################################################################################
2018-01-23 20:11:52 +00:00
unpack_zip () {
TMPDIR=/dev/tmp
TMP_LIBDIR=${TMPDIR}/nanodroid-lib
INSTALLER=${TMPDIR}/install
rm -rf ${INSTALLER}
mkdir -p ${INSTALLER} || error "failed to prepare environment!"
2018-01-23 20:11:52 +00:00
print_info " > prepare installation"
2019-04-25 18:49:26 +00:00
unzip -oq "${ZIP}" -d "${INSTALLER}" || \
error "failed to prepare environment!"
2019-02-04 19:00:54 +00:00
rm -rf ${TMPDIR}/framework-res
rm -f ${TMPDIR}/*.xml
rm -f ${TMPDIR}/*.list
2019-10-27 20:01:34 +00:00
2020-08-11 19:25:48 +00:00
chmod 0755 ${INSTALLER}/*.*
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# Print NanoDroid banner
##########################################################################################
show_banner () {
print_info " "
print_info "*****************************"
print_info " NanoDroid "
case ${MODID} in
NanoDroid )
print_info " > Full package "
;;
NanoDroid_microG )
print_info " > microG package "
;;
NanoDroid_FDroid )
print_info " > F-Droid package "
;;
NanoDroid_BromiteWebView )
print_info " > Bromite WebView package "
;;
NanoDroid_OsmAnd )
print_info " > OsmAnd package "
;;
NanoDroid_Google )
print_info " > Google package "
;;
2018-04-22 18:08:38 +00:00
esac
if [ "${ZIP}" == *${VERSION}* ]; then
print_info " ${VERSION} "
else
print_info " ${VERSION} (snapshot) "
fi
print_info "*****************************"
print_info " "
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# Architecture detection
##########################################################################################
detect_arch () {
SDK_VERSION=$(grep_prop ro.build.version.sdk)
ABI=$(grep_prop ro.product.cpu.abi | cut -c-3)
ABI2=$(grep_prop ro.product.cpu.abi2 | cut -c-3)
ABILONG=$(grep_prop ro.product.cpu.abi)
ARCH=arm
[ "$ABI" = "x86" ] && ARCH=x86
[ "$ABI2" = "x86" ] && ARCH=x86
[ "$ABILONG" = "arm64-v8a" ] && ARCH=arm64
[ "$ABILONG" = "x86_64" ] && ARCH=x86_64
2018-01-23 20:11:52 +00:00
case ${ARCH} in
arm ) BIN_ARCH="arm"
LIB_ARCHES="armeabi-v7a armeabi"
SWIPE_LIBDIR=lib ;;
arm64 ) BIN_ARCH="arm"
LIB_ARCHES="arm64-v8a armeabi-v7a armeabi"
SWIPE_LIBDIR=lib64 ;;
x86 ) BIN_ARCH="x86"
LIB_ARCHES="x86 armeabi-v7a armeabi"
SWIPE_LIBDIR=lib ;;
x86_64 ) BIN_ARCH="x86"
LIB_ARCHES="x86_64 x86 armeabi-v7a armeabi"
SWIPE_LIBDIR=lib64 ;;
esac
2019-06-26 18:50:52 +00:00
UNZIP="${INSTALLER}/unzip.${BIN_ARCH}"
2019-05-23 16:56:37 +00:00
AAPT="${INSTALLER}/aapt.${BIN_ARCH}"
ZSTD="${INSTALLER}/zstd.${BIN_ARCH}"
chmod +x "${UNZIP}" "${AAPT}" "${ZSTD}"
2018-01-26 14:32:52 +00:00
2018-01-23 20:11:52 +00:00
case ${SDK_VERSION} in
19 ) GSYNC_VER=K ;;
21 | 22 ) GSYNC_VER=L ;;
23 ) GSYNC_VER=M ;;
24 | 25 ) GSYNC_VER=N ;;
26 | 27 ) GSYNC_VER=O ;;
28 ) GSYNC_VER=P ;;
29 ) GSYNC_VER=Q ;;
2018-01-23 20:11:52 +00:00
* ) GSYNC_UNSUPPORTED=1 ;;
esac
case ${ARCH} in
arm )
case ${SDK_VERSION} in
2020-01-27 17:15:14 +00:00
29 )
LIBJNI_IME=libjni_latinimegoogle.so_28
;;
19 | 21 | 22 | 23 | 27 | 28 )
LIBJNI_IME=libjni_latinimegoogle.so_${SDK_VERSION}
;;
24 | 25 | 26 )
LIBJNI_IME=libjni_latinimegoogle.so_23
;;
* )
SWIPE_UNSUPPORTED=1
;;
esac
;;
arm64 )
case ${SDK_VERSION} in
2020-01-27 17:15:14 +00:00
29 )
LIBJNI_IME=libjni_latinimegoogle.so_28
;;
21 | 22 | 23 | 27 | 28 )
LIBJNI_IME=libjni_latinimegoogle.so_${SDK_VERSION}
;;
24 | 25 | 26 )
LIBJNI_IME=libjni_latinimegoogle.so_23
;;
* )
SWIPE_UNSUPPORTED=1
;;
esac
;;
x86 | x86_64 )
case ${SDK_VERSION} in
19 | 21 | 22 )
SWIPE_UNSUPPORTED=1
;;
2020-01-27 17:15:14 +00:00
23 | 24 | 25 | 26 | 27 | 28 | 29 )
LIBJNI_IME=libjni_latinimegoogle.so
;;
* )
SWIPE_UNSUPPORTED=1
;;
esac
;;
esac
2018-01-23 20:11:52 +00:00
if [[ "${SDK_VERSION}" -lt 21 ]]; then
UNFOLD_APP_DIR=1
else UNFOLD_APP_DIR=0
fi
if [[ "${SDK_VERSION}" -lt 19 ]]; then
print_info " "
print_info " ++ Installing on pre-KitKat ROM, full"
print_info " ++ compatibility is not guaranteed!"
print_info " "
2018-01-23 20:11:52 +00:00
fi
[ ! -d /data/adb ] && mkdir /data/adb
}
##########################################################################################
# Detect and setup installation mode
##########################################################################################
detect_mode () {
[ -f "${NANODROID_LIST_OLD}" ] && mv "${NANODROID_LIST_OLD}" "${NANODROID_LIST}"
case "${nanodroid_forcesystem}" in
1 )
if ${BOOTMODE}; then
print_info "nanodroid_forcesystem set to true"
error "can't install to /system from Magisk Manager"
fi
MODE_DETECT=forced
MODE=SYSTEM
;;
0 | *)
MODE_DETECT=detected
MODE=SYSTEM
MAGISK_VER_CODE=0
if [ ! -f "${NANODROID_LIST}" ]; then
if [ -f /data/adb/magisk/util_functions.sh ]; then
. /data/adb/magisk/util_functions.sh
elif [ -f /data/magisk/util_functions.sh ]; then
. /data/magisk/util_functions.sh
fi
if [ ${MAGISK_VER_CODE} -ge 19000 ]; then
MODE=MAGISK
else
MODE=SYSTEM
fi
fi
;;
esac
print_info " > Mode | ${MODE} | ${MODE_DETECT}"
print_info " "
case ${MODE} in
SYSTEM )
installer_setup_env
unset MODPATH
mkdir -p /system/addon.d
[ -f "${NANODROID_LIST}" ] && NANODROID_UPGRADE=1
;;
MAGISK )
magisk_install_setup
case ${MODID} in
NanoDroid | NanoDroid_microG )
magisk_install_preinst
;;
esac
;;
esac
NANODROID_BINDIR="${MODPATH}/system/bin"
}
##########################################################################################
# Finalize NanoDroid Installation
##########################################################################################
nanodroid_finalize () {
case ${MODID} in
NanoDroid | NanoDroid_microG )
if [ "${nanodroid_overlay}" -eq 1 ]; then
print_info " << with /system applications overlays"
${NANODROID_BINDIR}/nanodroid-overlay --create
else
print_info " << without /system applications overlays"
fi
;;
esac
if [ "${MODE}" = "MAGISK" ]; then
magisk_install_finish
else
install_addond
sync
nanodroid_storelogs
sort ${NANODROID_LIST} | uniq > /tmp/nanodroid-list
mv /tmp/nanodroid-list ${NANODROID_LIST}
installer_cleanup_env
fi
2018-04-09 18:22:48 +00:00
[ "${NANODROID_UPGRADE}" -eq 0 ] && reset_runtime_permissions
print_info " "
print_info " Thanks for using NanoDroid "
print_info " "
${BOOTMODE} || umount_partitions
rm -rf ${INSTALLER}
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# Setup Environment
##########################################################################################
##########################################################################################
# Setup Busybox
##########################################################################################
setup_busybox () {
if [[ "$(uname -m)" == a* ]]; then
local bb_arch=arm
else local bb_arch=x86
fi
mkdir -p ${INSTALLER}/busybox
ln -s ${INSTALLER}/busybox.${bb_arch} ${INSTALLER}/busybox/busybox
chmod 0755 ${INSTALLER}/busybox.${bb_arch}
${INSTALLER}/busybox.${bb_arch} --install -s ${INSTALLER}/busybox/
2020-12-29 09:25:51 +00:00
OLD_PATH=${PATH}
2020-12-29 19:14:11 +00:00
export PATH=${INSTALLER}/busybox:/system/bin:/vendor/bin
}
##########################################################################################
# Move envvars out of the way
##########################################################################################
installer_setup_env () {
if ! ${BOOTMODE}; then
OLD_PATH=${PATH}
OLD_LD_LIB=${LD_LIBRARY_PATH}
OLD_LD_PRE=${LD_PRELOAD}
OLD_LD_CFG=${LD_CONFIG_FILE}
unset LD_LIBRARY_PATH
unset LD_PRELOAD
unset LD_CONFIG_FILE
fi
}
##########################################################################################
# Restore envvars
##########################################################################################
installer_cleanup_env () {
if ${BOOTMODE}; then
[ -n ${OLD_PATH} ] && PATH=${OLD_PATH}
else
[ -n ${OLD_PATH} ] && PATH=${OLD_PATH}
[ -n ${OLD_LD_LIB} ] && LD_LIBRARY_PATH=${OLD_LD_LIB}
[ -n ${OLD_LD_PRE} ] && LD_PRELOAD=${OLD_LD_PRE}
[ -n ${OLD_LD_CFG} ] && LD_CONFIG_FILE=${OLD_LD_CFG}
fi
}
2018-01-23 20:11:52 +00:00
##########################################################################################
# Magisk Mode Installation
##########################################################################################
##########################################################################################
# Setup Magisk Mode Installation
##########################################################################################
2018-01-23 20:11:52 +00:00
magisk_install_setup () {
print_info " "
print_info "******************************"
print_info "Powered by Magisk (@topjohnwu)"
print_info "******************************"
print_info " "
print_info " > setup Magisk environment"
2018-01-23 20:11:52 +00:00
MAGISKBASE=/data/adb
installer_setup_env
2018-01-23 20:11:52 +00:00
case ${MODID} in
NanoDroid )
# check for sub-modules which are not
# supposed to be installed alongside
for dir in NanoDroid_microG NanoDroid_FDroid; do
if [ -d ${MAGISKBASE}/modules/${dir} ]; then
print_info " !! ${dir} module detected - uninstalling!"
rm -rf ${MAGISKBASE}/modules/${dir}
NANODROID_UPGRADE=1
fi
if [ -d ${MAGISKBASE}/modules_update/${dir} ]; then
print_info " !! ${dir} module detected - uninstalling!"
rm -rf ${MAGISKBASE}/modules_update/${dir}
2018-01-23 20:11:52 +00:00
fi
done
;;
2018-09-08 17:05:01 +00:00
NanoDroid_microG | NanoDroid_FDroid )
2018-01-23 20:11:52 +00:00
# check for Full package and abort if found
[ -d ${MAGISKBASE}/modules/NanoDroid -o -d ${MAGISKBASE}/modules_update/NanoDroid ] && \
error "${MODID} can't be installed along side the Full package"
;;
NanoDroid_OsmAnd | NanoDroid_Google | NanoDroid_BromiteWebView )
true
;;
* )
error "unknown module intended to be installed!?"
2018-01-23 20:11:52 +00:00
;;
esac
2018-09-08 17:05:01 +00:00
[ -d ${MODPATH} ] && NANODROID_UPGRADE=1
if [ "${NANODROID_UPGRADE}" -eq 1 ]; then
MODPATH=${MAGISKBASE}/modules_update/${MODID}
rm -rf ${MODPATH}
else
MODPATH=${MAGISKBASE}/modules/${MODID}
fi
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# Magisk Mode Installation: Pre-Installation Tasks
##########################################################################################
2018-01-23 20:11:52 +00:00
magisk_install_preinst () {
if [ -f ${MODPATH}/system.prop ]; then
print_info " << backing up module's system.prop"
cp ${MODPATH}/system.prop ${TMPDIR}/system.prop
2018-01-23 20:11:52 +00:00
fi
if [ -d ${MODPATH}/logs ]; then
print_info " << backing up init.d script logs"
cp -r ${MODPATH}/logs ${TMPDIR}/logs
fi
if [ -d ${MODPATH}/logcats ]; then
print_info " << backing up logcats"
cp -r ${MODPATH}/logcats ${TMPDIR}/logcats
fi
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# Magisk Mode Installation: Post-Installation Tasks
##########################################################################################
2018-01-23 20:11:52 +00:00
magisk_install_postinst () {
if [ -f ${TMPDIR}/system.prop ]; then
print_info " << restoring system.prop"
cp ${TMPDIR}/system.prop ${MODPATH}/system.prop
2018-01-23 20:11:52 +00:00
fi
if [ "${nanodroid_microg}" -ne 0 -o "${MODID}" = "NanoDroid_microG" ]; then
2020-10-04 16:22:13 +00:00
if [ -n $(grep_prop ro.setupwizard.mode) ]; then
echo "ro.setupwizard.mode=DISABLED" >> ${MODPATH}/system.prop
fi
fi
if [ -d ${TMPDIR}/logs ]; then
print_info " << restoring init.d script logs"
cp -r ${TMPDIR}/logs ${MODPATH}/logs
fi
if [ -d ${TMPDIR}/logcats ]; then
print_info " << restoring logcats"
cp -r ${TMPDIR}/logcats ${MODPATH}/logcats
fi
}
##########################################################################################
# Finalize Magisk Mode Installation
##########################################################################################
magisk_install_finish () {
# Magisk Module files
cp -af ${INSTALLER}/module.prop ${MODPATH}/module.prop
if [ -f ${INSTALLER}/service.sh ]; then
cp -af ${INSTALLER}/service.sh ${MODPATH}/service.sh
chmod +x ${MODPATH}/service.sh
fi
case ${MODID} in
NanoDroid | NanoDroid_microG )
magisk_install_postinst
;;
esac
if ${BOOTMODE}; then
touch "${MAGISKBASE}/modules/${MODID}/update" 2>/dev/null
cp -af "${INSTALLER}/module.prop" "${MAGISKBASE}/modules/${MODID}/module.prop" 2>/dev/null
fi
sync
nanodroid_storelogs
installer_cleanup_env
}
##########################################################################################
# Generic Installation
##########################################################################################
##########################################################################################
# Install microG
##########################################################################################
install_microg () {
# install microG if requested
# respectively force if it's the microG package
if [ "${nanodroid_microg}" -ne 0 -o "${MODID}" = "NanoDroid_microG" ]; then
gapps_solve_conflicts
gapps_destroy_artifacts
2018-07-08 15:21:02 +00:00
print_info " << with microg"
print_info " ++ microG GmsCore"
nanodroid_install_apk GmsCore
detect_migrate_apk com.google.android.gms GmsCore
if [ "${nanodroid_microg}" -ne 2 ]; then
for app in GsfProxy DroidGuard; do
nanodroid_install_apk ${app}
done
detect_migrate_apk org.microg.gms.droidguard DroidGuard
${NANODROID_BINDIR}/nanodroid-overlay --add GmsDroidGuard
fi
NLPBACKEND="nlpBackendNominatim"
print_info " ++ Nominatim geocoder backend"
${NANODROID_BINDIR}/nanodroid-overlay --add NominatimGeocoderBackend
${NANODROID_BINDIR}/nanodroid-overlay --add NominatimNlpBackend
if [ "${nanodroid_nlpbackend:0:1}" -eq 1 ]; then
NLPBACKEND="${NLPBACKEND} nlpBackendDejavu"
print_info " ++ Déjà Vu location backend"
${NANODROID_BINDIR}/nanodroid-overlay --add DejaVuNlpBackend
${NANODROID_BINDIR}/nanodroid-overlay --add DejaVuBackend
fi
if [ "${nanodroid_nlpbackend:1:1}" -eq 1 ]; then
NLPBACKEND="${NLPBACKEND} nlpBackendIchnaea"
print_info " ++ Ichnaea location backend"
${NANODROID_BINDIR}/nanodroid-overlay --add IchnaeaNlpBackend
${NANODROID_BINDIR}/nanodroid-overlay --add MozillaNlpBackend
fi
if [ "${nanodroid_nlpbackend:2:1}" -eq 1 ]; then
NLPBACKEND="${NLPBACKEND} nlpBackendApple"
print_info " ++ Apple location backend"
fi
2018-01-23 20:11:52 +00:00
2019-01-05 23:27:14 +00:00
if [ "${nanodroid_nlpbackend:3:1}" -eq 1 ]; then
NLPBACKEND="${NLPBACKEND} nlpBackendRadiocell"
print_info " ++ Radiocell location backend"
fi
2018-11-28 20:35:30 +00:00
for app in ${NLPBACKEND}; do
nanodroid_install_apk ${app}
done
2018-03-02 18:31:30 +00:00
nanodroid_install_file etc/sysconfig/microg-a5k.xml
nanodroid_install_file etc/default-permissions/microg-permissions.xml
else print_info " << without microG"
2018-01-23 20:11:52 +00:00
fi
}
##########################################################################################
# Install Maps API v1 support
##########################################################################################
2018-01-23 20:11:52 +00:00
install_mapsv1 () {
# install mapsv1 if requested
if [ "${nanodroid_mapsv1}" -eq 1 ]; then
print_info " << with Maps API version 1"
2018-03-02 18:31:30 +00:00
nanodroid_install_file etc/permissions/com.google.android.maps.xml
2018-11-06 20:55:39 +00:00
nanodroid_install_file framework/com.google.android.maps.jar
else print_info " << without Maps API version 1"
2018-01-23 20:11:52 +00:00
fi
}
##########################################################################################
# Install F-Droid
##########################################################################################
2018-01-23 20:11:52 +00:00
install_fdroid () {
# install F-Droid if requested
# respectively force if it's the F-Droid package
2018-01-23 20:11:52 +00:00
if [ "${nanodroid_fdroid}" -eq 3 ]; then
install_fdroid_fdroid
install_fdroid_aurora
elif [ "${nanodroid_fdroid}" -eq 2 ]; then
install_fdroid_aurora
elif [ "${nanodroid_fdroid}" -eq 1 -o "${MODID}" = "NanoDroid_FDroid" ]; then
install_fdroid_fdroid
else print_info " << without F-Droid"
2018-01-23 20:11:52 +00:00
fi
}
install_fdroid_aurora () {
print_info " << with Aurora Droid"
nanodroid_install_apk AuroraDroid
nanodroid_install_apk AuroraServices
}
install_fdroid_fdroid () {
print_info " << with F-Droid"
nanodroid_install_apk FDroid
nanodroid_install_apk FDroidPrivileged
${NANODROID_BINDIR}/nanodroid-overlay --add FDroidPriv
nanodroid_install_file etc/org.fdroid.fdroid/additional_repos.xml
}
##########################################################################################
# Install Applications
##########################################################################################
2018-01-23 20:11:52 +00:00
install_apps () {
# install apps if requested
if [ "${nanodroid_apps}" -eq 1 ]; then
print_info " << with applications"
2018-01-23 20:11:52 +00:00
APP_STRING=" <<>"
2020-09-08 20:25:12 +00:00
grep -E -v '^(#|[[:space:]]*$)' "${cfg_apps}" | while read app; do
if [ -d "${INSTALLER}/system/app/${app}" ]; then
print_info " ++ ${app}"
2018-01-23 20:11:52 +00:00
nanodroid_install_apk ${app}
else print_info " ++ app: ${app} missing"
2018-01-23 20:11:52 +00:00
fi
done
else print_info " << without applications"
2018-01-23 20:11:52 +00:00
fi
}
##########################################################################################
# Install App Store
##########################################################################################
2018-01-23 20:11:52 +00:00
install_store () {
STORE_CHOICE=${nanodroid_play:0:1}
FAKE_STORE=${nanodroid_play:1:1}
[ "${FAKE_STORE}" -eq 1 ] && STORE_CONFLICT="Phonesky" || STORE_CONFLICT=""
# install Aurora and/or Play Store whichever requested
case "${STORE_CHOICE}" in
1 )
install_store_play
;;
2 )
install_store_aurora
;;
3 )
install_store_play
install_store_aurora
;;
2018-08-18 16:36:44 +00:00
2019-01-14 19:24:18 +00:00
* )
print_info " << without App Store"
2019-01-14 19:24:18 +00:00
;;
esac
2018-08-18 16:36:44 +00:00
2019-01-14 19:24:18 +00:00
# Only install Fake Store if requested and Play Store is not installed
if [ "${FAKE_STORE}" -eq 1 ]; then
print_info " << with Fake Store"
nanodroid_install_apk FakeStore
else print_info " << without Fake Store"
fi
[ -n "${STORE_CONFLICT}" ] && ${NANODROID_BINDIR}/nanodroid-overlay --add ${STORE_CONFLICT}
if [ "${NANODROID_UPGRADE}" -eq 0 ]; then
rm -rf /data/data/com.android.vending
rm -rf /data/user/*/com.android.vending
rm -rf /data/user_de/*/com.android.vending
rm -rf /data/app/com.android.vending-*
fi
2018-01-23 20:11:52 +00:00
}
install_store_play () {
# force unselect Fake Store when user has choosen Play Store
STORE_CONFLICT="FakeStore"
FAKE_STORE=0
print_info " << with Play Store"
${NANODROID_BINDIR}/nanodroid-overlay --remove Phonesky
nanodroid_install_apk Phonesky
nanodroid_install_file etc/default-permissions/phonesky-permissions.xml
}
install_store_aurora () {
print_info " << with Aurora Store"
nanodroid_install_apk AuroraStore
nanodroid_install_apk AuroraServices
}
##########################################################################################
# Install GNU Bash
##########################################################################################
2018-01-23 20:11:52 +00:00
install_bash () {
2018-03-12 17:40:40 +00:00
if [ "${nanodroid_bash}" -eq 1 ]; then
print_info " << with GNU Bash Shell and Less Pager"
for file in etc/bash_logout etc/bashrc; do
nanodroid_install_file ${file}
done
for file in bin/bash bin/bash.bin.${BIN_ARCH} \
bin/bashbug.${BIN_ARCH} bin/less bin/less.bin.${BIN_ARCH} \
bin/lessecho.${BIN_ARCH} bin/lesskey.${BIN_ARCH}; do
nanodroid_install_file ${file} bin
done
else print_info " << without GNU Bash Shell"
2018-03-12 17:40:40 +00:00
fi
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# Install NanoDroid Scripts
##########################################################################################
2018-03-15 19:55:02 +00:00
install_nanodroidscripts () {
print_info " << with NanoDroid Scripts"
2018-03-15 19:54:06 +00:00
for script in npem nutl novl \
nanodroid-perm nanodroid-util \
nanodroid-overlay; do
nanodroid_install_file bin/${script} bin
2018-03-15 19:54:06 +00:00
done
2018-01-23 20:11:52 +00:00
nanodroid_substitute bin/nanodroid-overlay
2018-03-17 16:24:02 +00:00
if [ "${MODE}" = "MAGISK" ]; then
for script in nprp nanodroid-prop; do
nanodroid_install_file bin/${script} bin
done
nanodroid_substitute bin/nanodroid-prop
fi
2018-03-17 13:28:47 +00:00
}
##########################################################################################
# Install init scripts
##########################################################################################
2018-01-23 20:11:52 +00:00
install_initd () {
if [ -n "${nanodroid_init}" ]; then
print_info " << with init scripts"
2018-01-23 20:11:52 +00:00
if [ "${MODE}" = "SYSTEM" ]; then
INIT_BASE="${MODPATH}/system/etc/init.d"
else INIT_BASE="${MODPATH}/init.d"
fi
mkdir -p "${INIT_BASE}"
for script in ${nanodroid_init}; do
if [ -f "${INSTALLER}/system/etc/init.d/${script}" ]; then
cp "${INSTALLER}/system/etc/init.d/${script}" "${INIT_BASE}/"
set_perm_bin "${INIT_BASE}/${script}"
installinfo_add "/system/etc/init.d/${script}"
else
ui_print " -- ${script} is not a known init script"
fi
done
else print_info " << without init scripts"
2018-01-23 20:11:52 +00:00
fi
}
##########################################################################################
# Install Bromite System WebView
##########################################################################################
2018-11-08 17:27:34 +00:00
install_bromite_webview () {
if [ "${MODID}" = "NanoDroid_BromiteWebView" ]; then
if ! check_bromite_webview_support; then
error "ROM does not support Bromite WebView installation!"
else
print_info " << with Bromite WebView"
case ${ARCH} in
arm | arm64 | x86 ) BROMITE_ARCH=${ARCH} ;;
x86_64 ) BROMITE_ARCH=x86 ;;
esac
WEBVIEW_REPLACE=BromiteWebView
WEBVIEW_DIR=""
2018-11-08 17:27:34 +00:00
for app in webview webviewstub WebViewStub Webview; do
if [ -d /system/app/${app} ]; then
WEBVIEW_REPLACE=${app}
break
elif [ -d /system/product/app/${app} ]; then
WEBVIEW_REPLACE=${app}
WEBVIEW_DIR="product/app"
break
fi
done
2019-01-06 17:57:15 +00:00
if [ "${NANODROID_UPGRADE}" -eq 0 ]; then
for app in com.android.webview; do
rm -rf /data/data/${app}
rm -rf /data/user/*/${app}
rm -rf /data/user_de/*/${app}
rm -rf /data/app/${app}-*
rm -rf /mnt/asec/${app}-*
rm -rf ${STORAGE}/Android/data/${app}
done
fi
2018-11-08 17:27:34 +00:00
nanodroid_install_apk BromiteWebView_${BROMITE_ARCH} multilib ${WEBVIEW_REPLACE} ${WEBVIEW_DIR}
fi
2018-11-08 17:27:34 +00:00
fi
}
##########################################################################################
# Install OpenStreetMap Android
##########################################################################################
2018-11-23 20:04:36 +00:00
install_osmand () {
2018-11-23 20:18:01 +00:00
if [ "${MODID}" = "NanoDroid_OsmAnd" ]; then
print_info " << with OsmAnd"
2018-11-23 20:04:36 +00:00
nanodroid_install_apk OsmAnd
2018-11-23 20:18:01 +00:00
nanodroid_install_apk OsmAnd_ContourLines
2018-11-23 20:04:36 +00:00
fi
}
##########################################################################################
# Install Google Sync Adapters
##########################################################################################
install_gsync () {
# install GSync if requested
if [ "${nanodroid_gsync}" -eq 1 ]; then
if [ "${GSYNC_UNSUPPORTED}" -eq 1 ]; then
print_info " << Google Sync Adapters are unsupported on SDK ${SDK_VERSION}"
else
print_info " << with Google Sync Adapters (${GSYNC_VER})"
for app in GoogleCalendarSync GoogleContactsSync GoogleBackupTransport; do
nanodroid_install_apk ${app}
done
nanodroid_install_file etc/default-permissions/google-sync-permissions.xml
fi
else print_info " << without Google Sync Adapters"
fi
}
##########################################################################################
# Install swipe libraries
##########################################################################################
2018-01-23 20:11:52 +00:00
install_swipe () {
if [ "${nanodroid_swipe}" -eq 1 ]; then
if [ "${SWIPE_UNSUPPORTED}" -eq 1 ]; then
print_info " << Swipe Libraries are unsupported on SDK ${SDK_VERSION}"
else
print_info " << with swipe libraries"
2018-01-23 20:11:52 +00:00
SWIPE_SRC="${INSTALLER}/swipe/${ARCH}"
SWIPE_DEST="/system/${SWIPE_LIBDIR}"
2018-01-23 20:11:52 +00:00
APPL_IME="/system/app/LatinIME/${SWIPE_LIBDIR}/${ARCH}"
PRODL_IME="/system/product/app/LatinIME/${SWIPE_LIBDIR}/${ARCH}"
mkdir -p "${MODPATH}${SWIPE_DEST}"
2018-01-23 20:11:52 +00:00
cp "${SWIPE_SRC}/libjni_keyboarddecoder.so" "${MODPATH}${SWIPE_DEST}" || \
error "failed to install libjni_keyboarddecoder.so"
set_perm_data "${MODPATH}${SWIPE_DEST}/libjni_keyboarddecoder.so"
2018-01-23 20:11:52 +00:00
cp "${SWIPE_SRC}/${LIBJNI_IME}" "${MODPATH}${SWIPE_DEST}/libjni_latinimegoogle.so" || \
error "failed to install libjni_latinimegoogle.so"
set_perm_data "${MODPATH}${SWIPE_DEST}/libjni_latinimegoogle.so"
installinfo_add "${SWIPE_DEST}/libjni_keyboarddecoder.so"
installinfo_add "${SWIPE_DEST}/libjni_latinimegoogle.so"
link_swipe_libs "${APPL_IME}"
link_swipe_libs "${PRODL_IME}"
fi
else print_info " << without swipe libraries"
fi
}
link_swipe_libs () {
DEST_IME=${1}
if [ -f "${DEST_IME}/libjni_latinime.so" ]; then
decho " swipe: symlinking libjni_latinimegoogle as libjni_latinime in ${DEST_IME}"
mkdir -p "${MODPATH}${DEST_IME}"
ln -sfn "${MODPATH}${SWIPE_DEST}/libjni_latinimegoogle.so" "${MODPATH}${DEST_IME}/libjni_latinime.so"
ln -sfn "${MODPATH}${SWIPE_DEST}/libjni_keyboarddecoder.so" "${MODPATH}${DEST_IME}/libjni_keyboarddecoder.so"
installinfo_add "${MODPATH}${DEST_IME}/libjni_latinime.so"
installinfo_add "${MODPATH}${DEST_IME}/libjni_keyboarddecoder.so"
elif [ -f "${DEST_IME}/libjni_latinimegoogle.so" ]; then
decho " swipe: symlinking libjni_latinimegoogle as libjni_latinimegoogle in ${DEST_IME}"
mkdir -p "${MODPATH}${DEST_IME}"
ln -sfn "${MODPATH}${SWIPE_DEST}/libjni_latinimegoogle.so" "${MODPATH}${DEST_IME}/libjni_latinimegoogle.so"
ln -sfn "${MODPATH}${SWIPE_DEST}/libjni_keyboarddecoder.so" "${MODPATH}${DEST_IME}/libjni_keyboarddecoder.so"
installinfo_add "${MODPATH}${DEST_IME}/libjni_latinimegoogle.so"
installinfo_add "${MODPATH}${DEST_IME}/libjni_keyboarddecoder.so"
2018-01-23 20:11:52 +00:00
fi
}
##########################################################################################
# SYSTEM MODE addon.d
##########################################################################################
install_addond () {
print_info " << System Mode OTA survival"
cp "${INSTALLER}/CommonAddon" "/system/addon.d/91-nanodroid.sh" || \
error "failed to install System Mode OTA survival"
chmod 0755 "/system/addon.d/91-nanodroid.sh"
}
2018-01-23 20:11:52 +00:00
##########################################################################################
# Advanced Installation Functions
##########################################################################################
##########################################################################################
# Create Uninstaller / addon.d filelist for SYSTEM MODE
##########################################################################################
installinfo_add () {
if [ "${MODE}" = "SYSTEM" ]; then
for file in ${@}; do
echo ${file} >> ${NANODROID_LIST}
done
fi
}
##########################################################################################
# NanoDroid installation function for files
##########################################################################################
nanodroid_install_file () {
dir="$(dirname "${1}")"
file="$(basename "${1}")"
unset source
for sdir in system gsync; do
if [ -f "${INSTALLER}/${sdir}/${dir}/${file}" ]; then
source="${INSTALLER}/${sdir}/${dir}/${file}"
break
fi
done
[ -z "${source}" ] && error "file: ${file} not found"
# strip off .${BIN_ARCH} from final filename (if any)
xfile=$(basename ${file} .${BIN_ARCH})
decho " installing file: ${xfile}"
mkdir -p "${MODPATH}/system/${dir}/"
cp "${source}" "${MODPATH}/system/${dir}/${xfile}" || \
error "failed to install ${xfile}"
case ${2} in
bin ) set_perm_bin "${MODPATH}/system/${dir}/${xfile}" ;;
* ) set_perm_data "${MODPATH}/system/${dir}/${xfile}" ;;
esac
installinfo_add "/system/${dir}/${xfile}"
}
##########################################################################################
# NanoDroid installation function for directories
2018-01-23 20:11:52 +00:00
##########################################################################################
nanodroid_install_dir () {
dir="${1}"
[ -n "${2}" ] && dest="${2}" || dest="/system/${dir}"
2018-01-23 20:11:52 +00:00
[ ! -d "${INSTALLER}/system/${dir}" ] && \
error "dir: ${dir} not found"
2018-01-23 20:11:52 +00:00
echo " installing dir: ${dir}"
mkdir -p "${MODPATH}${dest}"
cp -r "${INSTALLER}/system/${dir}"/* "${MODPATH}${dest}/" || \
error "failed to install ${dir}"
2018-01-23 20:11:52 +00:00
case ${2} in
bin ) set_perm_bin -r "${MODPATH}${dest}" ;;
* ) set_perm_data -r "${MODPATH}${dest}" ;;
esac
2018-08-23 19:27:15 +00:00
find "${INSTALLER}/system/${dir}" -type f | \
sed -e "s,^${INSTALLER},,g" | \
installinfo_add
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# NanoDroid installation function for APKs
##########################################################################################
2018-01-23 20:11:52 +00:00
nanodroid_install_apk () {
app=${1}
multilib=${2}
alias=${3}
2018-01-23 20:11:52 +00:00
unset prefix
unset source
2018-01-23 20:11:52 +00:00
for sdir in system/app system/priv-app \
2019-08-06 18:12:56 +00:00
gsync/${GSYNC_VER}/app gsync/${GSYNC_VER}/priv-app; do
if [ -f "${INSTALLER}/${sdir}/${app}/${app}.apk.zst" ]; then
source="${INSTALLER}/${sdir}/${app}/${app}.apk"
dir=system/$(basename ${sdir})
break
fi
done
2018-01-23 20:11:52 +00:00
[ -n "${4}" ] && dir="system/${4}"
[ -z "${source}" ] && error "app ${app} not found"
2018-01-23 20:11:52 +00:00
if [ "${UNFOLD_APP_DIR}" -eq 1 ]; then
dest="${MODPATH}/${dir}"
2018-01-23 20:11:52 +00:00
else
if [ -z "${alias}" ]; then
dest="${MODPATH}/${dir}/${app}"
else dest="${MODPATH}/${dir}/${alias}"
fi
2018-01-23 20:11:52 +00:00
fi
2020-10-04 16:22:13 +00:00
if [ -n "${alias}" ]; then
dest_apk=${alias}.apk
2019-07-08 19:03:25 +00:00
else dest_apk=${app}.apk
fi
mkdir -p "${dest}"
decho " installing app: ${app}"
decho " from: ${source}"
decho " into: ${dest} [${dest_apk}]"
cp "${source}.zst" "${dest}/${dest_apk}.zst" || \
error "failed to install ${source} to ${dest}"
2018-01-23 20:11:52 +00:00
2020-10-17 20:47:04 +00:00
${ZSTD} -fd --rm "${dest}/${dest_apk}.zst" || \
error "failed to decompress ${dest}/${dest_apk}.zst"
installinfo_add "${dest}/${dest_apk}"
2018-01-23 20:11:52 +00:00
nanodroid_install_lib "${dest}/${dest_apk}" "${2}"
2018-01-23 20:11:52 +00:00
2020-10-10 06:01:01 +00:00
[ "${dir}" == "system/priv-app" ] && create_privapp_permissions_whitelist ${app}
set_perm_data -r "${dest}"
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# NanoDroid installation function for libraries
##########################################################################################
2018-01-23 20:11:52 +00:00
nanodroid_install_lib () {
apk="${1}"
dest="$(dirname ${1})"
multilib="${2}"
unset libd
2018-01-23 20:11:52 +00:00
if [ "${UNFOLD_APP_DIR}" -eq 1 ]; then
case ${ARCH} in
arm | x86 ) libd=${MODPATH}/system/lib ;;
arm64 | x86_64 ) libd=${MODPATH}/system/lib64 ;;
esac
else
libd=${dest}/lib
2018-01-23 20:11:52 +00:00
fi
rm -rf ${TMP_LIBDIR}
mkdir -p ${TMP_LIBDIR}
unset srcdir
"${UNZIP}" -oq "${apk}" "lib/*" -d "${TMP_LIBDIR}" \
2018-01-23 20:11:52 +00:00
2>/dev/null
unzip_return=$?
case ${unzip_return} in
0 ) decho " ${app} does have libs" ;;
11 ) decho " ${app} does not have any libs" ;;
50 ) error " not enough space available!" ;;
2019-04-26 20:35:51 +00:00
* ) error " unpacking libs for ${app} failed [${unzip_return}]" ;;
2018-01-23 20:11:52 +00:00
esac
if [ -d ${TMP_LIBDIR}/lib ]; then
for ARCHLIB in ${LIB_ARCHES}; do
if [ -d ${TMP_LIBDIR}/lib/${ARCHLIB} ]; then
srcdir=${TMP_LIBDIR}/lib/${ARCHLIB}
case ${srcdir} in
*arm64* ) decho " ${app}: installing arm64 libs"
lib_arch=arm64 ;;
*arm* ) decho " ${app}: installing arm libs"
lib_arch=arm ;;
*x86_64* ) decho " ${app}: installing x86_64 libs"
lib_arch=x86_64 ;;
*x86* ) decho " ${app}: installing x86 libs"
lib_arch=x86 ;;
esac
decho " from: ${srcdir}"
decho " into: ${libd}/${lib_arch}"
mkdir -p "${libd}/${lib_arch}"
for lib in ${srcdir}/*; do
decho " library: $(basename ${lib})"
cp ${lib} "${libd}/${lib_arch}/" || \
2019-04-26 20:35:51 +00:00
error " installing libs for ${app} failed"
installinfo_add "${libd}/${lib_arch}/$(basename ${lib})"
done
[ -z "${multilib}" ] && break
fi
done
2018-01-23 20:11:52 +00:00
fi
}
##########################################################################################
# substitute values in installed files
##########################################################################################
2018-01-23 20:11:52 +00:00
nanodroid_substitute () {
dir="$(dirname "${1}")"
file="$(basename "${1}")"
target="${MODPATH}/system/${dir}/${file}"
[ ! -f "${target}" ] && error "file: ${file} not found"
2018-01-23 20:11:52 +00:00
if grep -q @MODPATH@ ${target}; then
sed -e "s|@MODPATH@|${MODPATH}|g" -i ${target}
decho " substitute: adjust @MODPATH@ in ${target}"
2018-01-23 20:11:52 +00:00
fi
if grep -q @MODID@ ${target}; then
sed -e "s|@MODID@|${MODID}|g" -i ${target}
decho " substitute: adjust @MODID@ in ${target}"
fi
if grep -q @MODE@ ${target}; then
sed -e "s|@MODE@|${MODE}|g" -i ${target}
decho " substitute: adjust @MODE@ in ${target}"
fi
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# create installation logs
##########################################################################################
2018-01-23 20:11:52 +00:00
nanodroid_storelogs () {
mkdir -p "${STORAGE}/nanodroid_logs"
2018-01-23 20:11:52 +00:00
echo "\
Installation successful: ${INSTALL_SUCCESS}
2018-01-23 20:11:52 +00:00
### VALUES ###
ZIP=${ZIP}
TMPDIR=${TMPDIR}
TMP_LIBDIR=${TMP_LIBDIR}
INSTALLER=${INSTALLER}
MODID=${MODID}
SDK_VERSION=${SDK_VERSION}
ARCH=${ARCH}
LIB_ARCHES=${LIB_ARCHES}
MODPATH=${MODPATH}
SWIPE_LIBDIR=${SWIPE_LIBDIR}
MODE=${MODE}
MAGISK_VER_CODE=${MAGISK_VER_CODE}
2018-07-08 18:13:12 +00:00
NANODROID_UPGRADE=${NANODROID_UPGRADE}
2018-08-19 16:46:55 +00:00
NANODROID_BINDIR=${NANODROID_BINDIR}
2019-05-11 19:37:50 +00:00
HAS_FAKESIGN=${HAS_FAKESIGN}
HAS_WEBVIEW=${HAS_WEBVIEW}
2018-01-23 20:11:52 +00:00
2019-01-12 09:04:51 +00:00
### MOUNTED PARTITIONS ###
" >> ${nanodroid_logfile}
mount | awk '{print $1 " on " $3 " params: " $6}' \
>> ${nanodroid_logfile}
2019-04-27 21:23:14 +00:00
echo "
2019-07-27 18:40:16 +00:00
### PARTITION INFORMATION ###
2019-07-27 18:25:31 +00:00
2019-07-27 18:40:16 +00:00
DEVICE_AB=${DEVICE_AB}
VENDOR_COMPAT=${VENDOR_COMPAT}
2019-07-27 18:25:31 +00:00
SYSTEM_AS_ROOT=${SYSTEM_AS_ROOT}
2020-10-20 19:29:25 +00:00
SYSTEM_BLOCK=${SYSTEM_BLOCK}
VENDOR_BLOCK=${VENDOR_BLOCK}
2019-07-27 18:25:31 +00:00
2019-04-27 21:23:14 +00:00
### DISK USAGE ###
" >> ${nanodroid_logfile}
df 2>/dev/null | sed '/^\//d' >> ${nanodroid_logfile}
2019-04-27 21:23:14 +00:00
2020-10-04 16:22:13 +00:00
if [ -n "${cfg_setup}" ]; then
2019-07-27 18:27:46 +00:00
2019-01-12 09:04:51 +00:00
echo "
2018-01-23 20:11:52 +00:00
### SETUP ###
configuration: ${cfg_setup}
2019-04-25 18:57:07 +00:00
" >> ${nanodroid_logfile}
2018-01-23 20:11:52 +00:00
cat "${cfg_setup}" >> ${nanodroid_logfile}
2018-01-23 20:11:52 +00:00
2019-07-27 18:27:46 +00:00
fi
2020-10-04 16:22:13 +00:00
if [ -n "${cfg_apps}" ]; then
2018-04-10 19:14:52 +00:00
2018-01-23 20:11:52 +00:00
echo "
### APPS ###
configuration: ${cfg_apps}
" >> ${nanodroid_logfile}
2018-01-23 20:11:52 +00:00
cat "${cfg_apps}" >> ${nanodroid_logfile}
2018-01-23 20:11:52 +00:00
2018-04-10 19:14:52 +00:00
fi
2020-10-04 16:22:13 +00:00
if [ -n "${cfg_overlay}" ]; then
2018-04-10 19:14:52 +00:00
2018-01-23 20:11:52 +00:00
echo "
### OVERLAY ###
configuration: ${cfg_overlay}
" >> ${nanodroid_logfile}
2018-01-23 20:11:52 +00:00
cat "${cfg_overlay}" >> ${nanodroid_logfile}
2018-01-23 20:11:52 +00:00
2018-04-10 19:14:52 +00:00
fi
chown root:sdcard_rw ${nanodroid_logfile}
chmod 0644 ${nanodroid_logfile}
print_info " | storing installation logs in ${STORAGE}/nanodroid_logs/"
print_info " | NanoDroid log:"
print_info " || ""$(basename ${nanodroid_logfile})"
if [ -d /twres ]; then
nanodroid_twrplog="${STORAGE}/nanodroid_logs/${MODID}_${VERSION}_twrp_${curdate}.log"
cat /tmp/recovery.log > ${nanodroid_twrplog}
chown root:sdcard_rw ${nanodroid_twrplog}
chmod 0644 ${nanodroid_twrplog}
print_info " | TWRP log:"
print_info " || $(basename ${nanodroid_twrplog})"
print_info " "
fi
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# NanoDroid Configuration File Handling
##########################################################################################
get_config () {
config=""
config_exists=0
for path in ${config_locations}; do
if test -r "${path}/.nanodroid-${1}"; then
config="${path}/.nanodroid-${1}"
config_exists=1
return
fi
done
}
set_prop () {
2018-09-15 17:21:42 +00:00
echo "${1}=${2}" >> "${cfg_setup}"
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# Load and verify .nanodroid-setup configuration file
##########################################################################################
get_cfg_setup () {
get_config setup
if [ "$config_exists" -eq 1 ]; then
cfg_setup="${config}"
check_cfg_setup
print_info " > Config | nanodroid-setup | $(dirname ${cfg_setup})"
else
cfg_setup="${INSTALLER}/.nanodroid-setup"
source "${cfg_setup}"
print_info " > Config | nanodroid-setup | fallback"
fi
}
2018-01-23 20:11:52 +00:00
# check whether '.nanodroid-setup' has all required entries
check_cfg_setup () {
# see https://gitlab.com/Nanolx/NanoDroid/-/issues/147
dos2unix "${cfg_setup}" &>/dev/null
2018-09-15 17:21:42 +00:00
source "${cfg_setup}"
2018-01-23 20:11:52 +00:00
2018-09-15 17:21:42 +00:00
[ -z "${nanodroid_fdroid}" ] && set_prop nanodroid_fdroid 1
[ -z "${nanodroid_microg}" ] && set_prop nanodroid_microg 1
[ -z "${nanodroid_apps}" ] && set_prop nanodroid_apps 1
[ -z "${nanodroid_play}" ] && set_prop nanodroid_play 10
2018-12-08 13:43:50 +00:00
# in NanoDroid 20.3 nanodroid_play has changed
if [ "${#nanodroid_play}" -lt 2 ]; then
case "${nanodroid_play}" in
0 ) tmp_prop="00" ;;
1 ) tmp_prop="10" ;;
2 ) tmp_prop="20" ;;
3 ) tmp_prop="01" ;;
4 ) tmp_prop="21" ;;
* ) tmp_prop="10" ;;
esac
2018-11-27 18:55:04 +00:00
sed -e '/^nanodroid_play/d' -i "${cfg_setup}"
set_prop nanodroid_play "${tmp_prop}"
fi
2018-01-23 20:11:52 +00:00
# in NanoDroid 22.5 nanodroid_play has changed
if [ "${nanodroid_play}" -gt 30 ]; then
sed -e '/^nanodroid_play/d' -i "${cfg_setup}"
set_prop nanodroid_play 20
fi
2018-01-23 20:11:52 +00:00
if [ "${MODID}" = "NanoDroid" ]; then
2018-09-15 17:21:42 +00:00
[ -z "${nanodroid_overlay}" ] && set_prop nanodroid_overlay 1
else [ -z "${nanodroid_overlay}" ] && set_prop nanodroid_overlay 0
2018-01-23 20:11:52 +00:00
fi
2018-09-15 17:21:42 +00:00
[ -z "${nanodroid_mapsv1}" ] && set_prop nanodroid_mapsv1 1
[ -z "${nanodroid_gsync}" ] && set_prop nanodroid_gsync 0
[ -z "${nanodroid_forcesystem}" ] && set_prop nanodroid_forcesystem 0
[ -z "${nanodroid_swipe}" ] && set_prop nanodroid_swipe 0
[ -z "${nanodroid_bash}" ] && set_prop nanodroid_bash 1
[ -z "${nanodroid_nlpbackend}" ] && set_prop nanodroid_nlpbackend 1000
2018-12-08 13:43:50 +00:00
# in NanoDroid 20.3 nanodroid_nlpbackend has changed
if [ "${#nanodroid_nlpbackend}" -eq 1 ]; then
case "${nanodroid_nlpbackend}" in
0 ) tmp_prop="0000" ;;
1 ) tmp_prop="1000" ;;
2 ) tmp_prop="0100" ;;
3 ) tmp_prop="1100" ;;
* ) tmp_prop="1000" ;;
esac
sed -e '/^nanodroid_nlpbackend/d' -i "${cfg_setup}"
set_prop nanodroid_nlpbackend "${tmp_prop}"
2020-03-08 19:55:11 +00:00
fi
# in NanoDroid 20.5 nanodroid_nlpbackend has changed (again)
if [ "${#nanodroid_nlpbackend}" -eq 3 ]; then
tmp_prop="${nanodroid_nlpbackend}0"
sed -e '/^nanodroid_nlpbackend/d' -i "${cfg_setup}"
set_prop nanodroid_nlpbackend "${tmp_prop}"
fi
[ -z "${nanodroid_init+x}" ] && set_prop nanodroid_init "${nanodroid_all_init}"
2020-03-08 19:55:11 +00:00
# in NanoDroid 22.7 nanodroid_init has changed
if [ "${#nanodroid_init}" -eq 1 ]; then
sed -e '/^nanodroid_init/d' -i "${cfg_setup}"
set_prop nanodroid_init "${nanodroid_all_init}"
fi
# in NanoDroid 21.0.90 nanodroid_override was dropped
sed -e '/^nanodroid_override/d' -i "${cfg_setup}"
# in NanoDroid 22.5 nanodroid_fonts was dropped
sed -e '/^nanodroid_fonts/d' -i "${cfg_setup}"
2018-09-15 17:21:42 +00:00
2020-01-17 21:13:12 +00:00
# in NanoDroid 22.6 nanodroid_nano was dropped
sed -e '/^nanodroid_nano/d' -i "${cfg_setup}"
2020-01-17 21:03:40 +00:00
2020-01-17 21:13:12 +00:00
# in NanoDroid 22.6 nanodroid_zelda was dropped
sed -e '/^nanodroid_zelda/d' -i "${cfg_setup}"
2020-01-17 21:09:36 +00:00
2020-10-03 19:10:40 +00:00
# in NanoDroid 23.0 nanodroid_utils was dropped
sed -e '/^nanodroid_uitls/d' -i "${cfg_setup}"
2018-09-15 17:21:42 +00:00
source "${cfg_setup}"
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# Load and verify .nanodroid-overlay configuration file
##########################################################################################
get_cfg_overlay () {
get_config overlay
if [ "$config_exists" -eq 1 ]; then
cfg_overlay="${config}"
check_cfg_overlay
print_info " > Config | nanodroid-overlay | $(dirname ${cfg_overlay})"
else
cfg_overlay="${INSTALLER}/.nanodroid-overlay"
print_info " > Config | nanodroid-overlay | fallback"
fi
}
# check whether '.nanodroid-overlay' is up to date
check_cfg_overlay () {
# see https://gitlab.com/Nanolx/NanoDroid/-/issues/147
dos2unix "${cfg_overlay}" &>/dev/null
# 22.0 flagged the following for overlay creation which caused issues
grep -q "^GmsCore$" "${cfg_overlay}" && sed '/^GmsCore$/d' -i "${cfg_overlay}"
grep -q "^GsfProxy$" "${cfg_overlay}" && sed '/^GsfProxy$/d' -i "${cfg_overlay}"
grep -q "^DroidGuard$" "${cfg_overlay}" && sed '/^DroidGuard$/d' -i "${cfg_overlay}"
}
##########################################################################################
# Load and verify .nanodroid-apps configuration file
##########################################################################################
get_cfg_apps () {
get_config apps
if [ "$config_exists" -eq 1 ]; then
cfg_apps="${config}"
check_cfg_apps
print_info " > Config | nanodroid-apps | $(dirname ${cfg_apps})"
else
cfg_apps="${INSTALLER}/.nanodroid-apps"
print_info " > Config | nanodroid-apps | fallback"
fi
}
2018-09-15 17:21:42 +00:00
# check whether '.nanodroid-apps' is up to date
2018-01-23 20:11:52 +00:00
check_cfg_apps () {
# see https://gitlab.com/Nanolx/NanoDroid/-/issues/147
dos2unix "${cfg_apps}" &>/dev/null
# <= 16.3 has KeePass DX instead of KeePassDroid, migrate
2019-06-09 18:31:15 +00:00
grep -q KeePassDroid "${cfg_apps}" && sed -e 's/KeePassDroid/KeePassDX/g' -i "${cfg_apps}"
2019-07-26 14:29:24 +00:00
# <= 17.7 has Substratum instead of Bucket (LibreSubtratum), migrate
2019-06-09 18:31:15 +00:00
grep -q Bucket "${cfg_apps}" && sed -e 's/Bucket/Substratum/g' -i "${cfg_apps}"
2018-09-15 17:21:42 +00:00
# <= 18.1 has Orfox instead of TorBrowser, migrate
2019-06-09 18:31:15 +00:00
grep -q Orfox "${cfg_apps}" && sed -e 's/Orfox/TorBrowser/g' -i "${cfg_apps}"
2018-09-29 20:05:51 +00:00
# <= 18.4 has Adaway instead of Blockada, migrate
2019-06-09 18:31:15 +00:00
grep -q Adaway "${cfg_apps}" && sed -e 's/Adaway/Blokada/g' -i "${cfg_apps}"
2019-04-24 18:55:29 +00:00
# >= 20.7.92 no longer ships YahooWeatherProvider, remove
2019-06-09 18:31:15 +00:00
grep -q YahooWeatherProvider "${cfg_apps}" && sed -e '/YahooWeatherProvider/d' -i "${cfg_apps}"
2019-05-11 18:41:36 +00:00
# >= 20.8.90 no longer ships OmniJAWS, remove
2019-06-09 18:31:15 +00:00
grep -q OmniJAWS "${cfg_apps}" && sed -e '/OmniJAWS/d' -i "${cfg_apps}"
# >= 21.0.90 has Alarmio instead of OmniClock, migrate
2019-06-09 18:31:15 +00:00
grep -q OmniClock "${cfg_apps}" && sed -e 's/OmniClock/Alarmio/g' -i "${cfg_apps}"
# >= 21.0.90 no longer ships OpenWeatherMapProvider, remove
2019-06-09 18:31:15 +00:00
grep -q OpenWeatherMapProvider "${cfg_apps}" && sed -e '/OpenWeatherMapProvider/d' -i "${cfg_apps}"
2019-06-09 18:29:16 +00:00
# >= 21.0.90 has Lightning instead of Privacy Browser, migrate
grep -q Lightning "${cfg_apps}" && sed -e 's/Lightning/PrivacyBrowser/g' -i "${cfg_apps}"
# >= 21.0.90 has Hacker's Keyboard instead of BeHeKeyboard, migrate
grep -q BeHeKeyboard "${cfg_apps}" && sed -e 's/BeHeKeyboard/HackersKeyboard/g' -i "${cfg_apps}"
# >= 22.1 has SmartPack-Kernel-Manager instead of Kernel Adiutor, migrate
grep -q KernelAdiutor "${cfg_apps}" && sed -e 's/KernelAdiutor/SmartPackKernelManager/g' -i "${cfg_apps}"
2020-01-17 20:56:26 +00:00
2020-01-17 21:13:12 +00:00
# >= 22.6 has Frost instead of FaceSlim, migrate
2020-01-17 20:56:26 +00:00
grep -q FaceSlim "${cfg_apps}" && sed -e 's/FaceSlim/Frost/g' -i "${cfg_apps}"
2020-01-17 20:58:10 +00:00
2020-01-17 21:13:12 +00:00
# >= 22.6 no longer ships Substratum, remove
2020-01-17 20:58:10 +00:00
grep -q Substratum "${cfg_apps}" && sed -e '/Substratum/d' -i "${cfg_apps}"
2020-01-17 20:59:59 +00:00
2020-12-20 09:20:03 +00:00
# >= 22.6 no longer ships Orbot, remove
2020-01-17 20:59:59 +00:00
grep -q Orbot "${cfg_apps}" && sed -e '/Orbot/d' -i "${cfg_apps}"
2020-07-27 18:07:06 +00:00
# >= 22.7 has OAndBackupX instead of Oandbackup
grep -q Oandbackup "${cfg_apps}" && sed -e 's/Oandbackup/OAndBackupX/g' -i "${cfg_apps}"
2020-12-20 09:20:03 +00:00
# >= 23.1 no longer ships XDA Labs, remove
grep -q XDALabs "${cfg_apps}" && sed -e '/XDALabs/d' -i "${cfg_apps}"
2018-01-23 20:11:52 +00:00
}
##########################################################################################
# Destroy all GApps!
##########################################################################################
gapps_solve_conflicts () {
# first get rid of conflicting packages
print_google_apps | while read app; do
decho " ++ removing app: ${app} [google_apps]"
${NANODROID_BINDIR}/nanodroid-overlay --add ${app}
rm -rf /data/dalvik-cache/*/system"@priv-app@${app}"[@\.]*@classes.*
rm -rf /data/dalvik-cache/*/system"@app@${app}"[@\.]*@classes.*
done
print_google_data | while read app; do
decho " ++ removing data for: ${app} [google_data]"
rm -rf /data/data/${app}
rm -rf /data/user/*/${app}
rm -rf /data/user_de/*/${app}
rm -rf /data/app/${app}-*
rm -rf /mnt/asec/${app}-*
rm -rf ${STORAGE}/Android/data/${app}
done
2018-01-23 20:11:52 +00:00
}
gapps_destroy_artifacts () {
# this removes original Play Services
# only if this is a fresh NanoDroid installation
if [ "${NANODROID_UPGRADE}" -eq 0 ]; then
rm -rf /data/dalvik-cache/*/system"@priv-app@GmsCore"[@\.]*@classes.*
print_google_data_dirty | while read app; do
decho " ++ removing data for: ${app} [google_data_dirty]"
rm -rf /data/data/${app}
rm -rf /data/user/*/${app}
rm -rf /data/user_de/*/${app}
rm -rf /data/app/${app}-*
rm -rf /mnt/asec/${app}-*
rm -rf ${STORAGE}/Android/data/${app}
done
find /data/system* -type f -name 'accounts*db' 2>/dev/null | while read database; do
decho " ++ deleting Google Accounts from ${database} (if any)"
${INSTALLER}/sqlite3.${BIN_ARCH} ${database} \
"DELETE FROM accounts WHERE type='com.google';"
done
find /data/system/users -type f -name 'runtime-permissions.xml' 2>/dev/null | while read file; do
if grep -q "com.google.android" "${file}"; then
decho " ++ resetting permissions: ${file}"
rm -f "${file}"
fi
done
if [ -f /data/system/packages.list ]; then
print_google_data_dirty | while read app; do
decho " ++ de-registering app: ${app} (if installed)"
sed -e "/${app}/d" -i /data/system/packages.list
done
fi
2018-01-23 20:11:52 +00:00
fi
}
##########################################################################################
# GApps debloat list
# mostly by @ale5000
# extended for NanoDroid
##########################################################################################
print_google_apps()
{
cat <<EOF
AMAPNetworkLocation
BaiduNetworkLocation
BlankStore
ConfigUpdater
GCS
GmsCoreSetupPrebuilt
GmsCore_update
GoogleFeedback
GoogleLoginService
GoogleOneTimeInitializer
GoogleServicesFramework
GoogleConnectivityServices
GoogleTTS
LegacyNetworkLocation
MarketUpdater
MarkupGoogle
NetworkLocation
Phonesky
PlayGames
PlayStore
PrebuiltGmsCore
PrebuiltGmsCorePi
PrebuiltGmsCorePix
UnifiedNlp
Velvet
Vending
WhisperPush
EOF
2018-01-23 20:11:52 +00:00
}
print_google_data ()
{
cat <<EOF
com.amap.android.location
com.baidu.location
com.google.android.location
org.microg.nlp
org.microg.unifiednlp
EOF
}
print_google_data_dirty ()
{
cat <<EOF
com.android.vending
com.google.android.gms
com.google.android.gsf
com.google.android.gsf.login
com.google.android.feedback
com.mgoogle.android.gms
EOF
2018-01-23 20:11:52 +00:00
}