2018-01-23 20:11:52 +00:00
|
|
|
#!/sbin/sh
|
|
|
|
|
2018-10-29 19:47:47 +00:00
|
|
|
VERSION=19.1.99999999
|
2018-07-30 19:14:22 +00:00
|
|
|
NANODROID_UPGRADE=0
|
2018-08-21 19:59:15 +00:00
|
|
|
NANODROID_LIST=/data/adb/NanoDroid_FileList
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-08-24 22:28:06 +00:00
|
|
|
GOOGLE_APPS="AMAPNetworkLocation
|
|
|
|
BaiduNetworkLocation
|
|
|
|
BlankStore
|
|
|
|
com.qualcomm.location
|
|
|
|
DejaVuBackend
|
|
|
|
DejaVuNlpBackend
|
|
|
|
FDroidPriv
|
|
|
|
GmsCoreSetupPrebuilt
|
|
|
|
GmsCore_update
|
|
|
|
GmsDroidGuard
|
|
|
|
GoogleFeedback
|
2018-03-13 19:30:55 +00:00
|
|
|
GoogleLoginService
|
|
|
|
GoogleOneTimeInitializer
|
2018-08-24 19:25:01 +00:00
|
|
|
GoogleServicesFramework
|
|
|
|
GoogleTTS
|
2018-03-13 19:30:55 +00:00
|
|
|
IchnaeaNlpBackend
|
2018-08-24 22:28:06 +00:00
|
|
|
LegacyNetworkLocation
|
|
|
|
MarketUpdater
|
|
|
|
MarkupGoogle
|
2018-03-13 19:30:55 +00:00
|
|
|
MozillaNlpBackend
|
2018-08-24 22:28:06 +00:00
|
|
|
NetworkLocation
|
2018-03-13 19:30:55 +00:00
|
|
|
NominatimGeocoderBackend
|
2018-08-24 19:25:01 +00:00
|
|
|
NominatimNlpBackend
|
2018-08-24 22:28:06 +00:00
|
|
|
PlayGames
|
|
|
|
PlayStore
|
|
|
|
PrebuiltGmsCore
|
|
|
|
UnifiedNlp
|
|
|
|
Velvet
|
|
|
|
Vending
|
|
|
|
WhisperPush
|
|
|
|
YouTube"
|
2018-07-08 15:21:02 +00:00
|
|
|
|
2018-08-24 22:28:06 +00:00
|
|
|
GOOGLE_DATA="com.amap.android.location
|
|
|
|
com.baidu.location
|
2018-03-13 19:30:55 +00:00
|
|
|
com.google.android.feedback
|
|
|
|
com.google.android.gsf.login
|
2018-08-24 22:28:06 +00:00
|
|
|
com.google.android.location
|
2018-03-13 19:30:55 +00:00
|
|
|
com.google.android.youtube
|
2018-08-24 22:28:06 +00:00
|
|
|
com.mgoogle.android.gms
|
2018-03-13 19:30:55 +00:00
|
|
|
com.qualcomm.location
|
|
|
|
org.microg.nlp
|
2018-09-07 19:23:14 +00:00
|
|
|
org.microg.unifiednlp"
|
2018-03-13 19:30:55 +00:00
|
|
|
|
2018-10-11 16:50:51 +00:00
|
|
|
GOOGLE_DATA_DIRTY="com.google.android.gms
|
|
|
|
com.google.android.gsf
|
|
|
|
com.android.vending"
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
##########################################################################################
|
|
|
|
# Misc. Functions
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
detect_bootmode () {
|
2018-09-01 17:14:09 +00:00
|
|
|
ps | grep zygote | grep -qv grep && BOOTMODE=true || BOOTMODE=false
|
|
|
|
${BOOTMODE} || ps -A | grep zygote | grep -qv grep && BOOTMODE=true
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ui_print() {
|
|
|
|
if ${BOOTMODE}; then
|
|
|
|
echo "${@}"
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2018-03-28 18:06:53 +00:00
|
|
|
show_progress() {
|
2018-08-19 16:55:38 +00:00
|
|
|
${BOOTMODE} || echo "progress ${1} ${2}" >> /proc/self/fd/${OUTFD}
|
2018-03-28 18:06:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
set_progress() {
|
2018-08-19 16:55:38 +00:00
|
|
|
${BOOTMODE} || echo "set_progress ${1}" >> /proc/self/fd/${OUTFD}
|
2018-03-28 18:06:53 +00:00
|
|
|
}
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
grep_prop() {
|
|
|
|
REGEX="${1}"
|
|
|
|
shift
|
2018-01-26 14:32:52 +00:00
|
|
|
FILES="${@}"
|
2018-08-04 18:50:17 +00:00
|
|
|
[ -z "${@}" ] && FILES='/system/build.prop'
|
2018-01-26 14:32:52 +00:00
|
|
|
sed -n "s/^${REGEX}=//p" ${FILES} | \
|
2018-01-23 20:11:52 +00:00
|
|
|
head -n 1
|
|
|
|
}
|
|
|
|
|
2018-07-08 15:33:43 +00:00
|
|
|
grep_cmdline() {
|
|
|
|
local REGEX="s/^${1}=//p"
|
|
|
|
sed -E 's/ +/\n/g' /proc/cmdline | \
|
|
|
|
sed -n "${REGEX}" 2>/dev/null
|
|
|
|
}
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
is_mounted() {
|
2018-03-20 17:54:01 +00:00
|
|
|
if [ ! -z "${2}" ]; then
|
2018-01-23 20:11:52 +00:00
|
|
|
cat /proc/mounts | grep ${1} | grep ${2}, >/dev/null
|
|
|
|
else cat /proc/mounts | grep ${1} >/dev/null
|
|
|
|
fi
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
set_perm() {
|
2018-09-07 16:21:48 +00:00
|
|
|
chown ${2}:${3} ${1} || error "failed change owner for ${1}"
|
|
|
|
chmod ${4} ${1} || error "failed to change mode for ${1}"
|
2018-01-23 20:11:52 +00:00
|
|
|
if [ ! -z "${5}" ]; then
|
|
|
|
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
|
|
|
|
echo " perm: data [recursive] {${2}}"
|
|
|
|
set_perm_recursive ${2} 0 0 0755 0644
|
|
|
|
else
|
|
|
|
echo " perm: data [single] {${1}}"
|
|
|
|
set_perm ${1} 0 0 0644
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
set_perm_bin () {
|
|
|
|
if [ "${1}" = "-r" ]; then
|
|
|
|
echo " perm: exec [recursive] {${2}}"
|
|
|
|
set_perm_recursive ${2} 0 0 0755 0755
|
|
|
|
else
|
|
|
|
echo " perm: exec [single] {${1}}"
|
|
|
|
set_perm ${1} 0 0 0755
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-08-23 19:27:15 +00:00
|
|
|
installinfo_add () {
|
2018-08-21 19:59:15 +00:00
|
|
|
if [ "${MODE}" = "SYSTEM" ]; then
|
|
|
|
for file in ${@}; do
|
|
|
|
echo ${file} >> ${NANODROID_LIST}
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
detect_outfd () {
|
2018-09-08 18:02:46 +00:00
|
|
|
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
|
2018-01-23 20:11:52 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
show_banner () {
|
|
|
|
ui_print " "
|
|
|
|
ui_print "*****************************"
|
|
|
|
ui_print " NanoDroid ${VERSION} "
|
|
|
|
ui_print " created by Nanolx "
|
|
|
|
case ${MODID} in
|
2018-08-19 16:58:48 +00:00
|
|
|
NanoDroid )
|
|
|
|
ui_print " Full package "
|
|
|
|
;;
|
2018-01-23 20:11:52 +00:00
|
|
|
NanoDroid_microG )
|
|
|
|
ui_print " microG package "
|
|
|
|
;;
|
|
|
|
NanoDroid_FDroid )
|
|
|
|
ui_print " F-Droid package "
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
ui_print "*****************************"
|
|
|
|
ui_print " "
|
|
|
|
}
|
|
|
|
|
|
|
|
error () {
|
|
|
|
ui_print " !!"
|
|
|
|
ui_print "${@}"
|
|
|
|
ui_print " !!"
|
|
|
|
|
|
|
|
if [ "${MODE}" = "MAGISK" ]; then
|
|
|
|
rm -rf "${MODPATH}"
|
2018-03-28 18:07:24 +00:00
|
|
|
unmount_magisk_img
|
2018-01-23 20:11:52 +00:00
|
|
|
fi
|
|
|
|
|
2018-08-19 16:58:48 +00:00
|
|
|
${BOOTMODE} || recovery_cleanup
|
2018-01-23 20:11:52 +00:00
|
|
|
nanodroid_storelogs
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2018-02-15 16:50:33 +00:00
|
|
|
# taken from Magisk, with minor modifications for NanoDroid
|
2018-02-25 13:26:55 +00:00
|
|
|
mount_partitions () {
|
2018-07-08 15:33:43 +00:00
|
|
|
SLOT=$(grep_cmdline androidboot.slot_suffix)
|
2018-02-15 16:50:33 +00:00
|
|
|
if [ -z ${SLOT} ]; then
|
2018-08-04 18:05:14 +00:00
|
|
|
SLOT=_$(grep_cmdline androidboot.slot)
|
2018-02-25 18:50:51 +00:00
|
|
|
[ "${SLOT}" = "_" ] && SLOT=
|
2018-02-15 16:50:33 +00:00
|
|
|
fi
|
|
|
|
|
2018-09-04 18:07:06 +00:00
|
|
|
is_mounted /data || mount /data || error "failed to mount /data!"
|
2018-02-15 16:50:33 +00:00
|
|
|
|
|
|
|
${BOOTMODE} || mount -o bind /dev/urandom /dev/random
|
|
|
|
|
2018-08-04 18:07:14 +00:00
|
|
|
! is_mounted /system && mount -o rw /system
|
2018-02-15 16:50:33 +00:00
|
|
|
|
2018-02-25 13:26:55 +00:00
|
|
|
if [ ! -f /system/build.prop ]; then
|
2018-02-15 16:50:33 +00:00
|
|
|
SYSTEMBLOCK=$(find /dev/block -iname system${SLOT} | head -n 1)
|
2018-08-04 18:05:14 +00:00
|
|
|
mount -t ext4 -o rw ${SYSTEMBLOCK} /system
|
2018-02-15 16:50:33 +00:00
|
|
|
fi
|
|
|
|
|
2018-08-04 18:07:14 +00:00
|
|
|
[ -f /system/build.prop ] || is_mounted /system || error "failed to mount /system (unsupported A/B device?)"
|
2018-08-04 06:44:54 +00:00
|
|
|
|
2018-07-08 15:33:43 +00:00
|
|
|
if [ -f /system/init ]; then
|
2018-03-07 19:20:21 +00:00
|
|
|
mkdir /system_root 2>/dev/null
|
|
|
|
mount --move /system /system_root
|
|
|
|
mount -o bind /system_root/system /system
|
|
|
|
fi
|
2018-08-04 18:50:54 +00:00
|
|
|
|
|
|
|
[ ! -f /system/build.prop ] && error "failed to mount /system (unsupported A/B device?)"
|
2018-08-27 16:12:17 +00:00
|
|
|
|
2018-08-29 15:00:56 +00:00
|
|
|
if [ -L /system/vendor ]; then
|
|
|
|
! is_mounted /vendor && mount /vendor
|
|
|
|
if ! is_mounted /vendor; then
|
|
|
|
VENDORBLOCK=$(find /dev/block -iname vendor${SLOT} | head -n 1)
|
|
|
|
mount -t ext4 -o ro ${VENDORBLOCK} /vendor
|
|
|
|
fi
|
2018-09-15 21:00:55 +00:00
|
|
|
elif [ -d /system/vendor ]; then
|
2018-08-29 15:00:56 +00:00
|
|
|
### XXX work-around required for some ROMs
|
|
|
|
echo " xxx compat /vendor link created!"
|
2018-09-15 21:00:55 +00:00
|
|
|
ln -sf /system/vendor /vendor >/dev/null
|
2018-08-27 16:12:17 +00:00
|
|
|
fi
|
2018-08-29 15:00:56 +00:00
|
|
|
|
|
|
|
mount | awk '{print $1 " on " $3}'
|
2018-02-15 16:50:33 +00:00
|
|
|
}
|
|
|
|
|
2018-09-04 18:24:10 +00:00
|
|
|
migrate_magisk_custom () {
|
|
|
|
if [ ! -d /data/adb/ ]; then
|
|
|
|
mkdir -p /data/adb/
|
|
|
|
chown root:root /data/adb
|
|
|
|
chmod 0644 /data/adb
|
|
|
|
fi
|
2018-09-15 20:05:45 +00:00
|
|
|
|
2018-09-04 18:24:10 +00:00
|
|
|
cp -r ${1} /data/adb/magisk
|
|
|
|
}
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
detect_mode () {
|
2018-09-08 08:51:27 +00:00
|
|
|
[ -f /data/adb/.nanodroid-list ] && mv /data/adb/.nanodroid-list "${NANODROID_LIST}"
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
case "${nanodroid_forcesystem}" in
|
2018-01-28 10:31:15 +00:00
|
|
|
1 )
|
2018-09-04 18:30:23 +00:00
|
|
|
MODE_DETECT=forced
|
2018-09-07 16:27:53 +00:00
|
|
|
MODE=SYSTEM
|
2018-09-04 18:30:23 +00:00
|
|
|
|
2018-09-07 16:27:53 +00:00
|
|
|
${BOOTMODE} && error "Forced System Mode installation requested, but device in BOOTMODE"
|
2018-01-28 10:31:15 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
0 | *)
|
2018-09-04 18:30:23 +00:00
|
|
|
MODE_DETECT=detected
|
|
|
|
|
2018-09-17 17:05:06 +00:00
|
|
|
if [ -f /data/adb/magisk/magisk ]; then
|
2018-01-23 20:11:52 +00:00
|
|
|
MODE=MAGISK
|
2018-08-02 18:03:45 +00:00
|
|
|
elif [ -f /data/.magisk/magisk ]; then
|
2018-09-04 18:24:10 +00:00
|
|
|
migrate_magisk_custom /data/.magisk/
|
2018-08-02 18:03:45 +00:00
|
|
|
MODE=MAGISK
|
2018-09-04 18:15:04 +00:00
|
|
|
elif [ -f /data/magisk/magisk ]; then
|
2018-09-04 18:24:10 +00:00
|
|
|
migrate_magisk_custom /data/magisk/
|
2018-09-04 18:15:04 +00:00
|
|
|
MODE=MAGISK
|
2018-01-28 09:51:51 +00:00
|
|
|
elif ! ${BOOTMODE}; then
|
2018-01-23 20:11:52 +00:00
|
|
|
MODE=SYSTEM
|
2018-01-28 09:51:51 +00:00
|
|
|
else
|
2018-09-07 16:21:48 +00:00
|
|
|
error "Magisk 15.0+ not found and device in BOOTMODE"
|
2018-01-23 20:11:52 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2018-09-04 18:30:23 +00:00
|
|
|
ui_print " > Mode | ${MODE} | ${MODE_DETECT}"
|
|
|
|
ui_print " "
|
2018-09-04 18:22:11 +00:00
|
|
|
|
2018-09-04 18:30:23 +00:00
|
|
|
if [ "${MODE}" = "SYSTEM" ]; then
|
2018-09-17 17:05:06 +00:00
|
|
|
if [ -f "${NANODROID_LIST}" ]; then
|
2018-07-08 15:21:02 +00:00
|
|
|
NANODROID_UPGRADE=1
|
2018-08-21 19:59:15 +00:00
|
|
|
else NANODROID_UPGRADE=0
|
2018-07-08 15:21:02 +00:00
|
|
|
fi
|
2018-08-18 19:12:46 +00:00
|
|
|
|
|
|
|
recovery_actions
|
2018-07-08 15:21:02 +00:00
|
|
|
fi
|
|
|
|
|
2018-09-08 17:05:01 +00:00
|
|
|
[ "${MODE}" = "MAGISK" ] && magisk_install_setup
|
2018-03-18 19:44:56 +00:00
|
|
|
|
2018-03-18 20:33:11 +00:00
|
|
|
if [ "${nanodroid_fonts}" -eq 1 ]; then
|
2018-04-02 18:45:01 +00:00
|
|
|
if test -h ${RESTORE_PATH}/system/fonts/Roboto-Regular.ttf; then
|
|
|
|
CUSTOM_FONT="$(basename $(readlink ${RESTORE_PATH}/system/fonts/Roboto-Regular.ttf) .ttf)"
|
2018-03-18 20:33:11 +00:00
|
|
|
ui_print " << Detected NanoDroid-Font (${CUSTOM_FONT})"
|
|
|
|
fi
|
2018-03-18 19:15:17 +00:00
|
|
|
fi
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
if [ "${MODE}" = "MAGISK" ]; then
|
|
|
|
case ${MODID} in
|
|
|
|
NanoDroid | NanoDroid_microG )
|
|
|
|
magisk_install_preinst
|
|
|
|
;;
|
|
|
|
esac
|
2018-03-18 20:33:11 +00:00
|
|
|
else unset MODPATH
|
2018-01-23 20:11:52 +00:00
|
|
|
fi
|
2018-08-19 16:46:55 +00:00
|
|
|
|
|
|
|
if [ "${ROM_NO_XBIN}" -eq 0 ]; then
|
2018-08-20 19:34:50 +00:00
|
|
|
NANODROID_BINDIR="${MODPATH}/system/xbin"
|
|
|
|
else NANODROID_BINDIR="${MODPATH}/system/bin"
|
2018-08-19 16:46:55 +00:00
|
|
|
fi
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unpack_zip () {
|
|
|
|
TMPDIR=/dev/tmp
|
|
|
|
TMP_LIBDIR=${TMPDIR}/nanodroid-lib
|
|
|
|
INSTALLER=${TMPDIR}/install
|
|
|
|
|
|
|
|
rm -rf ${INSTALLER}
|
2018-09-07 16:21:48 +00:00
|
|
|
mkdir -p ${INSTALLER} || error "failed to prepare environment!"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
ui_print " > prepare installation"
|
|
|
|
unzip -o "${ZIP}" -d "${INSTALLER}" || \
|
2018-09-07 16:21:48 +00:00
|
|
|
error "failed to prepare environment!"
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nanodroid_finalize () {
|
2018-04-20 18:05:48 +00:00
|
|
|
case ${MODID} in
|
|
|
|
NanoDroid | NanoDroid_microG )
|
|
|
|
if [ "${nanodroid_overlay}" -eq 1 ]; then
|
|
|
|
ui_print " << with /system applications override"
|
2018-08-19 16:46:55 +00:00
|
|
|
${NANODROID_BINDIR}/nanodroid-overlay --create
|
2018-04-20 18:05:48 +00:00
|
|
|
else
|
|
|
|
ui_print " << without /system applications override"
|
|
|
|
fi
|
2018-04-22 18:47:14 +00:00
|
|
|
;;
|
2018-04-22 18:08:38 +00:00
|
|
|
esac
|
2018-04-20 18:05:48 +00:00
|
|
|
|
2018-04-10 18:31:28 +00:00
|
|
|
if [ "${MODE}" = "MAGISK" ]; then
|
|
|
|
magisk_install_finish
|
|
|
|
else
|
|
|
|
install_addond
|
2018-08-18 19:12:46 +00:00
|
|
|
recovery_cleanup
|
2018-04-10 18:31:28 +00:00
|
|
|
|
2018-08-21 19:59:15 +00:00
|
|
|
sort ${NANODROID_LIST} | uniq > /tmp/nanodroid-list
|
|
|
|
mv /tmp/nanodroid-list ${NANODROID_LIST}
|
2018-04-10 18:31:28 +00:00
|
|
|
fi
|
2018-04-10 17:58:45 +00:00
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
rm -rf ${INSTALLER}
|
2018-02-15 16:50:33 +00:00
|
|
|
|
2018-02-20 17:59:32 +00:00
|
|
|
ui_print " "
|
|
|
|
ui_print " Thanks for using NanoDroid "
|
|
|
|
ui_print " "
|
|
|
|
|
|
|
|
sync
|
|
|
|
nanodroid_storelogs
|
|
|
|
|
2018-02-15 16:50:33 +00:00
|
|
|
if ! ${BOOTMODE} ; then
|
|
|
|
umount -l /system_root 2>/dev/null
|
|
|
|
umount -l /system 2>/dev/null
|
|
|
|
umount -l /vendor 2>/dev/null
|
|
|
|
umount -l /dev/random 2>/dev/null
|
|
|
|
fi
|
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
|
2018-10-16 18:18:29 +00:00
|
|
|
[ "$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
|
|
|
|
|
2018-03-28 18:14:04 +00:00
|
|
|
chmod +x "${INSTALLER}/system/xbin/unzip.${BIN_ARCH}"
|
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 ;;
|
2018-08-31 18:03:52 +00:00
|
|
|
28 ) GSYNC_VER=P ;;
|
2018-01-23 20:11:52 +00:00
|
|
|
* ) GSYNC_UNSUPPORTED=1 ;;
|
|
|
|
esac
|
|
|
|
|
2018-10-31 19:35:39 +00:00
|
|
|
|
|
|
|
case ${ARCH} in
|
|
|
|
arm )
|
|
|
|
case ${SDK_VERSION} in
|
|
|
|
19 | 21 | 22 | 23 | 27 | 28 )
|
|
|
|
LIBJNI_IME=lib_latinimegoogle.so_${SDK_VERSION}
|
|
|
|
;;
|
|
|
|
24 | 25 | 26 )
|
|
|
|
LIBJNI_IME=lib_latinimegoogle.so_23
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
SWIPE_UNSUPPORTED=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
|
|
|
arm64 )
|
|
|
|
case ${SDK_VERSION} in
|
|
|
|
21 | 22 | 23 | 27 | 28 )
|
|
|
|
LIBJNI_IME=lib_latinimegoogle.so_${SDK_VERSION}
|
|
|
|
;;
|
|
|
|
24 | 25 | 26 )
|
|
|
|
LIBJNI_IME=lib_latinimegoogle.so_23
|
|
|
|
;;
|
|
|
|
* )
|
|
|
|
SWIPE_UNSUPPORTED=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
|
|
|
|
x86 | x86_64 )
|
|
|
|
case ${SDK_VERSION} in
|
|
|
|
19 | 21 | 22 )
|
|
|
|
SWIPE_UNSUPPORTED=1
|
|
|
|
;;
|
|
|
|
23 | 24 | 25 | 26 | 27 | 28 )
|
|
|
|
LIBJNI_IME=lib_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
|
|
|
|
ui_print " "
|
|
|
|
ui_print " ++ Installing on pre-KitKat ROM, full"
|
|
|
|
ui_print " ++ compatibility is not garantueed!"
|
|
|
|
ui_print " "
|
|
|
|
fi
|
2018-03-28 18:14:04 +00:00
|
|
|
|
|
|
|
if [ ! -d /system/xbin ]; then
|
|
|
|
ROM_NO_XBIN=1
|
|
|
|
echo " ++ ROM has no /system/xbin, using /system/bin instead"
|
|
|
|
else ROM_NO_XBIN=0
|
|
|
|
fi
|
2018-04-09 18:22:48 +00:00
|
|
|
|
|
|
|
[ ! -d /data/adb ] && mkdir /data/adb
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
2018-08-20 18:46:41 +00:00
|
|
|
setup_busybox () {
|
|
|
|
OLD_PATH=${PATH}
|
|
|
|
|
|
|
|
mkdir -p ${INSTALLER}/busybox
|
|
|
|
ln -s ${INSTALLER}/busybox.${BIN_ARCH} ${INSTALLER}/busybox/busybox
|
|
|
|
|
2018-09-01 09:23:15 +00:00
|
|
|
chmod 0755 ${INSTALLER}/busybox.${BIN_ARCH}
|
2018-08-20 18:46:41 +00:00
|
|
|
${INSTALLER}/busybox.${BIN_ARCH} --install -s ${INSTALLER}/busybox/
|
|
|
|
|
|
|
|
export PATH="${INSTALLER}/busybox:${PATH}"
|
|
|
|
}
|
|
|
|
|
2018-08-18 19:12:46 +00:00
|
|
|
# Taken from Magisk, used for System Mode installation
|
|
|
|
recovery_actions () {
|
|
|
|
mv /sbin /sbin_tmp
|
|
|
|
OLD_LD_LIB=$LD_LIBRARY_PATH
|
|
|
|
OLD_LD_PRE=$LD_PRELOAD
|
|
|
|
unset LD_LIBRARY_PATH
|
|
|
|
unset LD_PRELOAD
|
|
|
|
}
|
|
|
|
|
|
|
|
# Taken from Magisk, used for System Mode installation
|
|
|
|
recovery_cleanup () {
|
|
|
|
mv /sbin_tmp /sbin 2>/dev/null
|
|
|
|
[ -z $OLD_PATH ] || export PATH=$OLD_PATH
|
|
|
|
[ -z $OLD_LD_LIB ] || export LD_LIBRARY_PATH=$OLD_LD_LIB
|
|
|
|
[ -z $OLD_LD_PRE ] || export LD_PRELOAD=$OLD_LD_PRE
|
|
|
|
}
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
##########################################################################################
|
|
|
|
# Magisk Mode Installation
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
magisk_install_setup () {
|
|
|
|
ui_print "******************************"
|
|
|
|
ui_print "Powered by Magisk (@topjohnwu)"
|
|
|
|
ui_print "******************************"
|
|
|
|
ui_print " "
|
|
|
|
ui_print " > setup Magisk environment"
|
|
|
|
|
2018-07-11 20:11:34 +00:00
|
|
|
MOUNTPATH=${TMPDIR}/magisk_img
|
2018-09-08 17:05:01 +00:00
|
|
|
MAGISKBIN=/data/adb/magisk
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-08-02 18:03:45 +00:00
|
|
|
[ -f ${MAGISKBIN}/util_functions.sh ] || \
|
2018-09-07 16:21:48 +00:00
|
|
|
error "Magisk version 15.0 or newer is required"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
. ${MAGISKBIN}/util_functions.sh
|
|
|
|
|
2018-03-20 17:54:01 +00:00
|
|
|
MIN_VER=$(grep_prop minMagisk ${INSTALLER}/module.prop)
|
2018-01-23 20:11:52 +00:00
|
|
|
[ ! -z ${MAGISK_VER_CODE} -a ${MAGISK_VER_CODE} -ge ${MIN_VER} ] || \
|
2018-09-07 16:21:48 +00:00
|
|
|
error "Magisk 15.0 or newer is required"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
${BOOTMODE} && IMG=/data/adb/magisk_merge.img || IMG=/data/adb/magisk.img
|
|
|
|
|
|
|
|
MODPATH=${MOUNTPATH}/${MODID}
|
2018-09-09 12:21:13 +00:00
|
|
|
MAGISKPATH=/sbin/.core/img
|
|
|
|
REALPATH=${MAGISKPATH}/${MODID}
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
${BOOTMODE} && boot_actions || recovery_actions
|
2018-04-02 18:45:01 +00:00
|
|
|
${BOOTMODE} && RESTORE_PATH=${REALPATH} || RESTORE_PATH=${MODPATH}
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
request_size_check "${INSTALLER}"
|
|
|
|
mount_magisk_img
|
|
|
|
|
|
|
|
case ${MODID} in
|
|
|
|
NanoDroid )
|
2018-08-22 18:01:37 +00:00
|
|
|
# check for sub-modules which are not
|
|
|
|
# supposed to be installed alongside
|
|
|
|
for dir in NanoDroid_microG NanoDroid_FDroid; do
|
2018-09-09 12:21:13 +00:00
|
|
|
if [ -d ${MOUNTPATH}/${dir} -o -d ${MAGISKPATH}/${dir} ]; then
|
2018-08-04 18:23:59 +00:00
|
|
|
ui_print " !! ${dir} module detected - uninstalling!"
|
2018-09-09 12:21:13 +00:00
|
|
|
rm -rf ${MOUNTPATH}/${dir} ${MAGISKPATH}/${dir}
|
2018-08-04 18:23:59 +00:00
|
|
|
NANODROID_UPGRADE=1
|
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
|
2018-09-09 12:21:13 +00:00
|
|
|
[ -d ${MOUNTPATH}/NanoDroid -o -d ${MAGISKPATH}/NanoDroid ] && \
|
2018-09-07 16:21:48 +00:00
|
|
|
error "${MODID} can't be installed along side the Full package"
|
2018-08-04 18:23:59 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
* )
|
|
|
|
error "unknown module intended to be installed!?"
|
2018-01-23 20:11:52 +00:00
|
|
|
;;
|
|
|
|
esac
|
2018-09-08 17:05:01 +00:00
|
|
|
|
2018-09-09 12:21:13 +00:00
|
|
|
[ -d ${MOUNTPATH}/${MODID} -o -d ${MAGISKPATH}/${MODID} ] && NANODROID_UPGRADE=1
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
magisk_install_preinst () {
|
2018-04-02 18:45:01 +00:00
|
|
|
if [ -f ${RESTORE_PATH}/system.prop ]; then
|
2018-01-23 20:11:52 +00:00
|
|
|
ui_print " << backing up module's system.prop"
|
2018-04-02 18:45:01 +00:00
|
|
|
cp ${RESTORE_PATH}/system.prop ${TMPDIR}/system.prop
|
2018-01-23 20:11:52 +00:00
|
|
|
fi
|
|
|
|
|
2018-04-02 18:45:01 +00:00
|
|
|
if [ -f ${RESTORE_PATH}/system/framework/services.jar ]; then
|
2018-09-16 08:52:38 +00:00
|
|
|
ui_print " << backing up patched services.jar"
|
2018-09-08 08:41:48 +00:00
|
|
|
cp ${RESTORE_PATH}/system/framework/services.jar ${TMPDIR}/services.jar
|
2018-01-23 20:11:52 +00:00
|
|
|
fi
|
|
|
|
|
2018-07-11 20:25:01 +00:00
|
|
|
${BOOTMODE} || rm -rf "${MODPATH}"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-03-12 17:25:19 +00:00
|
|
|
for dir in app etc priv-app bin; do
|
2018-01-23 20:11:52 +00:00
|
|
|
mkdir -p "${MODPATH}/system/${dir}"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
magisk_install_postinst () {
|
|
|
|
if [ -f ${TMPDIR}/system.prop ]; then
|
|
|
|
ui_print " << restoring system.prop"
|
2018-08-21 20:33:53 +00:00
|
|
|
cp ${TMPDIR}/system.prop ${MODPATH}/system.prop
|
2018-01-23 20:11:52 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f ${TMPDIR}/services.jar ]; then
|
|
|
|
ui_print " << restoring patched services.jar"
|
|
|
|
mkdir -p ${MODPATH}/system/framework
|
2018-08-21 20:33:53 +00:00
|
|
|
cp ${TMPDIR}/services.jar ${MODPATH}/system/framework/services.jar
|
2018-01-23 20:11:52 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
magisk_install_finish () {
|
|
|
|
# Magisk Module files
|
|
|
|
mktouch ${MODPATH}/auto_mount
|
|
|
|
cp -af ${INSTALLER}/module.prop ${MODPATH}/module.prop
|
2018-02-09 16:09:36 +00:00
|
|
|
|
|
|
|
if [[ -f ${INSTALLER}/common/service.sh ]]; then
|
|
|
|
cp -af ${INSTALLER}/common/service.sh ${MODPATH}/service.sh
|
|
|
|
chmod +x ${MODPATH}/service.sh
|
|
|
|
fi
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
if ${BOOTMODE}; then
|
|
|
|
# Update info for Magisk Manager
|
|
|
|
mktouch /sbin/.core/img/${MODID}/update
|
|
|
|
cp -af ${INSTALLER}/module.prop /sbin/.core/img/${MODID}/module.prop
|
|
|
|
fi
|
|
|
|
|
|
|
|
case ${MODID} in
|
|
|
|
NanoDroid | NanoDroid_microG )
|
|
|
|
magisk_install_postinst
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2018-03-28 18:36:36 +00:00
|
|
|
if [ "${nanodroid_fonts}" -eq 1 -a ! -z ${CUSTOM_FONT} ]; then
|
2018-03-18 19:44:56 +00:00
|
|
|
ui_print " << Restore NanoDroid-Font (${CUSTOM_FONT})"
|
2018-08-19 16:46:55 +00:00
|
|
|
${NANODROID_BINDIR}/nanodroid-font -s "${CUSTOM_FONT}"
|
2018-03-18 19:01:49 +00:00
|
|
|
fi
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
unmount_magisk_img
|
|
|
|
${BOOTMODE} || recovery_cleanup
|
|
|
|
}
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# Generic Installation
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
install_microg () {
|
|
|
|
# install microG if requested
|
|
|
|
# respectively force if it's the microG package
|
|
|
|
if [ "${nanodroid_microg}" -eq 1 -o "${MODID}" = "NanoDroid_microG" ]; then
|
2018-04-02 16:59:07 +00:00
|
|
|
|
|
|
|
# first get rid of conflicting packages
|
2018-04-22 18:47:14 +00:00
|
|
|
for app in ${GOOGLE_APPS}; do
|
2018-08-19 16:46:55 +00:00
|
|
|
${NANODROID_BINDIR}/nanodroid-overlay --add ${app}
|
2018-07-08 15:21:02 +00:00
|
|
|
|
|
|
|
rm -rf /data/dalvik-cache/*/system"@priv-app@${app}"[@\.]*@classes.*
|
|
|
|
rm -rf /data/dalvik-cache/*/system"@app@${app}"[@\.]*@classes.*
|
|
|
|
done
|
|
|
|
|
|
|
|
for app in ${GOOGLE_DATA}; do
|
|
|
|
rm -rf /data/data/${app}
|
|
|
|
rm -rf /data/user/*/${app}
|
|
|
|
rm -rf /data/user_de/*/${app}
|
|
|
|
rm -rf /data/app/${app}-*
|
2018-10-11 16:50:51 +00:00
|
|
|
rm -rf /mnt/asec/${app}-*
|
2018-10-11 16:53:19 +00:00
|
|
|
rm -rf /data/media/Android/data/${app}
|
2018-04-22 18:47:14 +00:00
|
|
|
done
|
2018-04-02 16:59:07 +00:00
|
|
|
|
2018-07-08 15:21:02 +00:00
|
|
|
if [ "${NANODROID_UPGRADE}" -eq 0 ]; then
|
|
|
|
# this removes original Play Services
|
|
|
|
# only if this is a fresh NanoDroid installation
|
|
|
|
rm -rf /data/dalvik-cache/*/system"@priv-app@GmsCore"[@\.]*@classes.*
|
|
|
|
|
2018-10-11 16:50:51 +00:00
|
|
|
for app in ${GOOGLE_DATA_DIRTY}; do
|
2018-08-10 17:22:25 +00:00
|
|
|
rm -rf /data/data/${app}
|
|
|
|
rm -rf /data/user/*/${app}
|
|
|
|
rm -rf /data/user_de/*/${app}
|
|
|
|
rm -rf /data/app/${app}-*
|
2018-10-11 16:50:51 +00:00
|
|
|
rm -rf /mnt/asec/${app}-*
|
2018-10-11 16:53:19 +00:00
|
|
|
rm -rf /data/media/Android/data/${app}
|
2018-08-10 17:22:25 +00:00
|
|
|
done
|
2018-07-08 15:21:02 +00:00
|
|
|
|
2018-07-30 18:32:54 +00:00
|
|
|
for file in /data/system/users/*/runtime-permissions.xml; do
|
2018-10-11 16:50:51 +00:00
|
|
|
if grep -q "com.google.android" "${file}"; then
|
2018-07-30 18:32:54 +00:00
|
|
|
rm -f "${file}"
|
2018-07-31 17:09:56 +00:00
|
|
|
echo " upgrade: removing ${file}"
|
2018-07-30 18:32:54 +00:00
|
|
|
fi
|
|
|
|
done
|
2018-10-20 12:32:03 +00:00
|
|
|
|
|
|
|
if [ -f /data/system/packages.xml ]; then
|
|
|
|
cp /data/system/packages.xml /tmp/packages.xml
|
|
|
|
|
|
|
|
for app in ${GOOGLE_DATA_DIRTY}; do
|
|
|
|
awk -v RS='</package>' "!/${app}/"'{print $0 RS}' \
|
|
|
|
/tmp/packages.xml > /tmp/_packages.xml
|
2018-10-20 12:36:41 +00:00
|
|
|
|
2018-10-20 12:32:03 +00:00
|
|
|
mv /tmp/_packages.xml /tmp/packages.xml
|
2018-10-20 12:36:41 +00:00
|
|
|
sed -e '$ d' -i /tmp/packages.xml
|
2018-10-20 12:32:03 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
cp /tmp/packages.xml /data/system/packages.xml
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f /data/system/packages.list ]; then
|
|
|
|
for app in ${GOOGLE_DATA_DIRTY}; do
|
|
|
|
sed -e "/${app}/d" -i /data/system/packages.list
|
|
|
|
done
|
|
|
|
fi
|
2018-07-08 17:31:23 +00:00
|
|
|
fi
|
2018-07-08 15:21:02 +00:00
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
case ${nanodroid_nlpbackend} in
|
|
|
|
0 ) NLPBACKEND=""
|
|
|
|
ui_print " << with microG [Nominatim]" ;;
|
|
|
|
1 ) NLPBACKEND="nlpBackendDejavu"
|
|
|
|
ui_print " << with microG [Déjà Vu, Nominatim]" ;;
|
|
|
|
2 ) NLPBACKEND="nlpBackendIchnaea"
|
|
|
|
ui_print " << with microG [Ichnaea, Nominatim]" ;;
|
|
|
|
3 ) NLPBACKEND="nlpBackendDejavu nlpBackendIchnaea"
|
|
|
|
ui_print " << with microG [Déjà Vu, Ichnaea, Nominatim]" ;;
|
|
|
|
esac
|
|
|
|
|
2018-03-02 19:38:06 +00:00
|
|
|
for app in ${NLPBACKEND} nlpBackendNominatim GmsCore GsfProxy DroidGuard; do
|
2018-01-23 20:11:52 +00:00
|
|
|
nanodroid_install_apk ${app}
|
|
|
|
done
|
|
|
|
|
2018-09-16 08:18:23 +00:00
|
|
|
if [ -z "$(find /data/app -type d -name 'org.microg.gms.droidguard*')" ]; then
|
2018-09-15 20:05:45 +00:00
|
|
|
cp -r "${INSTALLER}/system/priv-app/DroidGuard/" \
|
|
|
|
/data/app/org.microg.gms.droidguard-1
|
|
|
|
|
2018-10-29 16:41:47 +00:00
|
|
|
set_perm_recursive /data/app/org.microg.gms.droidguard-1 1000 1000 0755 0644
|
2018-09-15 20:05:45 +00:00
|
|
|
fi
|
|
|
|
|
2018-03-02 18:31:30 +00:00
|
|
|
nanodroid_install_file etc/permissions/features.xml
|
2018-10-31 19:54:23 +00:00
|
|
|
nanodroid_install_file etc/permissions/privapp-permissions-microg.xml
|
2018-03-02 18:31:30 +00:00
|
|
|
nanodroid_install_file etc/default-permissions/microg-permissions.xml
|
|
|
|
nanodroid_install_file etc/sysconfig/microg-a5k.xml
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
else ui_print " << without microG"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install_mapsv1 () {
|
|
|
|
# install mapsv1 if requested
|
|
|
|
if [ "${nanodroid_mapsv1}" -eq 1 ]; then
|
|
|
|
ui_print " << with Maps API version 1"
|
2018-03-02 18:31:30 +00:00
|
|
|
nanodroid_install_file etc/permissions/com.google.android.maps.xml
|
2018-01-23 20:11:52 +00:00
|
|
|
nanodroid_install_dir framework
|
|
|
|
else ui_print " << without Maps API version 1"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install_gsync () {
|
|
|
|
# install GSync if requested
|
|
|
|
if [ "${nanodroid_gsync}" -eq 1 ]; then
|
|
|
|
if [ "${GSYNC_UNSUPPORTED}" -eq 1 ]; then
|
|
|
|
ui_print " << Google Sync Adapters are unsupported on pre-KitKat ROMs"
|
|
|
|
else
|
|
|
|
GSYNC_BASE="${INSTALLER}/gsync/${GSYNC_VER}"
|
|
|
|
ui_print " << with Google Sync Adapters (${GSYNC_VER})"
|
|
|
|
|
|
|
|
for app in CalendarSync ContactsSync; do
|
|
|
|
echo " installing app: Google${app}"
|
|
|
|
mkdir -p "${MODPATH}/system/app/Google${app}"
|
|
|
|
|
|
|
|
cp "${GSYNC_BASE}/app/Google${app}/Google${app}.apk" \
|
|
|
|
"${MODPATH}/system/app/Google${app}/" || \
|
2018-09-07 16:21:48 +00:00
|
|
|
error "failed to install Google${app}"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
set_perm_data -r "${MODPATH}/system/app/Google${app}"
|
|
|
|
|
2018-08-23 19:27:15 +00:00
|
|
|
installinfo_add "/system/app/Google${app}/Google${app}.apk"
|
2018-01-23 20:11:52 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
echo " installing app: GoogleBackupTransport"
|
|
|
|
mkdir -p "${MODPATH}/system/priv-app/GoogleBackupTransport"
|
|
|
|
|
|
|
|
cp "${GSYNC_BASE}/priv-app/GoogleBackupTransport/GoogleBackupTransport.apk" \
|
|
|
|
"${MODPATH}/system/priv-app/GoogleBackupTransport/" || \
|
2018-09-07 16:21:48 +00:00
|
|
|
error "failed to install GoogleBackupTransport"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
set_perm_data -r "${MODPATH}/system/priv-app/GoogleBackupTransport"
|
|
|
|
|
2018-08-23 19:27:15 +00:00
|
|
|
installinfo_add "/system/priv-app/GoogleBackupTransport/GoogleBackupTransport.apk"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-10-05 18:15:48 +00:00
|
|
|
cp -r "${INSTALLER}/gsync/etc/default-permissions/" "${MODPATH}/system/etc/"
|
|
|
|
set_perm_data -r "${MODPATH}/system/etc/default-permissions/"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-10-31 19:54:23 +00:00
|
|
|
cp -r "${INSTALLER}/gsync/etc/permissions/" "${MODPATH}/system/etc/"
|
|
|
|
set_perm_data -r "${MODPATH}/system/etc/permissions/"
|
|
|
|
|
2018-10-05 18:15:48 +00:00
|
|
|
find "${INSTALLER}/gsync/etc/default-permissions/" -type f | \
|
2018-08-23 19:27:15 +00:00
|
|
|
sed -e "s,${INSTALLER}/gsync/etc,/system/etc,g" | \
|
2018-08-24 19:25:01 +00:00
|
|
|
installinfo_add
|
2018-01-23 20:11:52 +00:00
|
|
|
fi
|
|
|
|
else ui_print " << without Google Sync Adapters"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install_fdroid () {
|
|
|
|
# install F-Droid if requested
|
|
|
|
# respectively force if it's the F-Droid package
|
|
|
|
if [ "${nanodroid_fdroid}" -eq 1 -o "${MODID}" = "NanoDroid_FDroid" ]; then
|
|
|
|
ui_print " << with F-Droid"
|
|
|
|
nanodroid_install_apk FDroid
|
|
|
|
nanodroid_install_apk FDroidPrivileged
|
2018-03-27 08:47:16 +00:00
|
|
|
nanodroid_install_file etc/permissions/org.fdroid.fdroid.privileged.xml
|
2018-10-20 11:40:27 +00:00
|
|
|
nanodroid_install_file etc/org.fdroid.fdroid/additional_repos.xml
|
2018-01-23 20:11:52 +00:00
|
|
|
else ui_print " << without F-Droid"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install_apps () {
|
|
|
|
# install apps if requested
|
|
|
|
if [ "${nanodroid_apps}" -eq 1 ]; then
|
|
|
|
ui_print " << with applications"
|
|
|
|
APP_STRING=" <<>"
|
|
|
|
|
|
|
|
INSTALL_APPS=$(cat "${cfg_apps}")
|
|
|
|
for app in ${INSTALL_APPS}; do
|
|
|
|
[[ -d "${INSTALLER}/system/app/${app}" ]] && \
|
|
|
|
APP_STRING="${APP_STRING} ${app}, "
|
|
|
|
done
|
|
|
|
|
|
|
|
ui_print "${APP_STRING}"
|
|
|
|
|
|
|
|
for app in ${INSTALL_APPS}; do
|
2018-09-29 20:05:51 +00:00
|
|
|
if [[ ${app} = OmniClock && -d /system/app/OmniClockOSS ]]; then
|
2018-08-18 16:50:37 +00:00
|
|
|
if [ "${nanodroid_override}" -eq 0 ]; then
|
|
|
|
ui_print " <<> app: OmniClock already provided by ROM (as OmniClockOSS)"
|
|
|
|
else
|
|
|
|
nanodroid_install_apk OmniClock
|
|
|
|
echo " + removing conflicting OmniClockOSS"
|
2018-08-31 18:11:54 +00:00
|
|
|
${NANODROID_BINDIR}/nanodroid-overlay --add OmniClockOSS
|
2018-08-18 16:50:37 +00:00
|
|
|
fi
|
2018-04-02 18:45:01 +00:00
|
|
|
elif [[ -d /system/app/${app} && ! -d ${RESTORE_PATH}/system/app/${app} ]]; then
|
2018-08-18 16:50:37 +00:00
|
|
|
if [ "${nanodroid_override}" -eq 0 ]; then
|
|
|
|
ui_print " <<> app: ${app} already provided by ROM"
|
|
|
|
else nanodroid_install_apk ${app}
|
|
|
|
fi
|
2018-01-23 20:11:52 +00:00
|
|
|
elif [[ -d "${INSTALLER}/system/app/${app}" ]]; then
|
|
|
|
nanodroid_install_apk ${app}
|
|
|
|
else ui_print " <<>> app: ${app} missing"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else ui_print " << without applications"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install_store () {
|
2018-08-18 19:36:34 +00:00
|
|
|
NANODROID_APP_STORE=""
|
|
|
|
NANODROID_REM_STORE=""
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
# install Yalp Store or Play Store whichever requested
|
2018-04-02 17:44:48 +00:00
|
|
|
case "${nanodroid_play}" in
|
|
|
|
0 )
|
|
|
|
ui_print " << without App Store"
|
|
|
|
;;
|
|
|
|
|
|
|
|
1 )
|
|
|
|
ui_print " << with Play Store"
|
2018-08-18 19:36:34 +00:00
|
|
|
NANODROID_APP_STORE="Phonesky"
|
|
|
|
NANODROID_REM_STORE="FakeStore"
|
2018-10-31 19:54:23 +00:00
|
|
|
|
|
|
|
nanodroid_install_file etc/permissions/privapp-permissions-phonesky.xml
|
|
|
|
nanodroid_install_file etc/default-permissions/phonesky-permissions.xml
|
2018-04-02 17:44:48 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
2 )
|
2018-08-18 16:36:44 +00:00
|
|
|
ui_print " << with Yalp Store"
|
2018-08-18 19:36:34 +00:00
|
|
|
NANODROID_APP_STORE="YalpStore"
|
|
|
|
NANODROID_REM_STORE=""
|
2018-04-02 17:44:48 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
3 )
|
|
|
|
ui_print " << with Fake Store"
|
2018-08-18 19:36:34 +00:00
|
|
|
NANODROID_APP_STORE="FakeStore"
|
|
|
|
NANODROID_REM_STORE="Phonesky"
|
2018-08-18 16:36:44 +00:00
|
|
|
;;
|
|
|
|
|
|
|
|
4 )
|
|
|
|
ui_print " << with Yalp Store and Fake Store"
|
2018-08-18 19:36:34 +00:00
|
|
|
NANODROID_APP_STORE="YalpStore FakeStore"
|
|
|
|
NANODROID_REM_STORE="Phonesky"
|
|
|
|
;;
|
|
|
|
esac
|
2018-08-18 16:36:44 +00:00
|
|
|
|
2018-08-18 19:36:34 +00:00
|
|
|
if [ ! -z "${NANODROID_APP_STORE}" ]; then
|
|
|
|
for app in ${NANODROID_APP_STORE}; do
|
|
|
|
nanodroid_install_apk ${app}
|
|
|
|
done
|
|
|
|
fi
|
2018-08-18 16:36:44 +00:00
|
|
|
|
2018-08-18 19:36:34 +00:00
|
|
|
if [ ! -z "${NANODROID_REM_STORE}" ]; then
|
|
|
|
for app in ${NANODROID_REM_STORE}; do
|
2018-08-19 16:46:55 +00:00
|
|
|
${NANODROID_BINDIR}/nanodroid-overlay --add ${app}
|
2018-08-18 19:36:34 +00:00
|
|
|
done
|
2018-08-20 18:57:22 +00:00
|
|
|
|
|
|
|
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-08-18 19:36:34 +00:00
|
|
|
fi
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install_zelda () {
|
|
|
|
# install Zelda Ringtones when requested
|
|
|
|
if [ "${nanodroid_zelda}" -eq 1 ]; then
|
|
|
|
ui_print " << with Zelda sounds"
|
|
|
|
nanodroid_install_dir media
|
|
|
|
else ui_print " << without Zelda sounds"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install_bash () {
|
2018-03-12 17:40:40 +00:00
|
|
|
if [ "${nanodroid_bash}" -eq 1 ]; then
|
2018-04-02 17:44:48 +00:00
|
|
|
ui_print " << with GNU Bash Shell"
|
2018-03-12 17:40:40 +00:00
|
|
|
nanodroid_install_file etc/bash_logout
|
|
|
|
nanodroid_install_file etc/bashrc
|
|
|
|
|
2018-03-28 17:51:51 +00:00
|
|
|
nanodroid_install_file xbin/bash bin
|
|
|
|
nanodroid_install_file xbin/bash.bin.${BIN_ARCH} bin
|
|
|
|
nanodroid_install_file xbin/bashbug.${BIN_ARCH} bin
|
|
|
|
nanodroid_install_file xbin/less bin
|
|
|
|
nanodroid_install_file xbin/less.bin.${BIN_ARCH} bin
|
2018-03-12 17:40:40 +00:00
|
|
|
else ui_print " << without GNU Bash Shell"
|
|
|
|
fi
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
2018-03-15 19:55:02 +00:00
|
|
|
install_nanodroidscripts () {
|
2018-04-02 17:44:48 +00:00
|
|
|
ui_print " << with NanoDroid Scripts"
|
2018-03-15 19:54:06 +00:00
|
|
|
|
2018-10-02 07:35:03 +00:00
|
|
|
for script in npem nutl novl \
|
|
|
|
nanodroid-perm nanodroid-util \
|
|
|
|
nanodroid-overlay; do
|
2018-03-28 17:51:51 +00:00
|
|
|
nanodroid_install_file xbin/${script} bin
|
2018-03-15 19:54:06 +00:00
|
|
|
done
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-04-20 18:12:35 +00:00
|
|
|
nanodroid_substitute xbin/nanodroid-overlay
|
|
|
|
|
2018-03-17 16:24:02 +00:00
|
|
|
if [ "${MODE}" = "MAGISK" ]; then
|
2018-04-20 18:12:35 +00:00
|
|
|
for script in nprp nanodroid-prop; do
|
2018-03-28 17:51:51 +00:00
|
|
|
nanodroid_install_file xbin/${script} bin
|
2018-03-17 16:17:25 +00:00
|
|
|
done
|
|
|
|
|
2018-03-28 18:29:25 +00:00
|
|
|
nanodroid_substitute xbin/nanodroid-prop
|
2018-03-17 16:17:25 +00:00
|
|
|
fi
|
2018-03-17 13:28:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install_fonts () {
|
2018-03-18 19:01:49 +00:00
|
|
|
if [ "${nanodroid_fonts}" -eq 1 ]; then
|
2018-04-02 17:44:48 +00:00
|
|
|
ui_print " << with Nintendo Fonts"
|
2018-03-28 17:51:51 +00:00
|
|
|
nanodroid_install_file xbin/nanodroid-font bin
|
2018-03-28 18:29:25 +00:00
|
|
|
nanodroid_substitute xbin/nanodroid-font
|
2018-03-28 17:51:51 +00:00
|
|
|
nanodroid_install_file xbin/nfnt bin
|
2018-03-17 13:28:47 +00:00
|
|
|
|
|
|
|
nanodroid_install_dir fonts
|
2018-03-17 13:16:31 +00:00
|
|
|
fi
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install_nano () {
|
2018-03-12 17:40:40 +00:00
|
|
|
if [ "${nanodroid_nano}" -eq 1 ]; then
|
2018-04-02 17:44:48 +00:00
|
|
|
ui_print " << with GNU Nano Terminal Editor"
|
2018-03-12 17:40:40 +00:00
|
|
|
nanodroid_install_dir etc/terminfo
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-03-28 17:51:51 +00:00
|
|
|
nanodroid_install_file xbin/nano bin
|
|
|
|
nanodroid_install_file xbin/nano.bin bin
|
2018-03-12 17:40:40 +00:00
|
|
|
else ui_print " << without GNU Nano Terminal Editor"
|
|
|
|
fi
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install_shell_utils () {
|
2018-03-12 17:40:40 +00:00
|
|
|
if [ "${nanodroid_utils}" -eq 1 ]; then
|
2018-04-02 17:44:48 +00:00
|
|
|
ui_print " << with Shell Utilities"
|
2018-03-12 17:40:40 +00:00
|
|
|
|
|
|
|
# architecture dependend stuff
|
2018-04-22 18:08:38 +00:00
|
|
|
for binary in col colcrt colrm column findfs findmnt \
|
2018-04-20 18:12:35 +00:00
|
|
|
hexdump lessecho lesskey look lsblk lscpu lsipc \
|
2018-03-12 17:40:40 +00:00
|
|
|
lslocks lsns ncal setterm unzip whereis; do
|
2018-03-28 17:51:51 +00:00
|
|
|
nanodroid_install_file xbin/${binary}.${BIN_ARCH} bin
|
2018-03-12 17:40:40 +00:00
|
|
|
done
|
|
|
|
else ui_print " << without Shell Utilities"
|
|
|
|
fi
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
install_initd () {
|
|
|
|
if [ "${nanodroid_init}" -eq 1 ]; then
|
|
|
|
ui_print " << with init scripts"
|
|
|
|
|
|
|
|
if [ "${MODE}" = "SYSTEM" ]; then
|
|
|
|
INIT_BASE="${MODPATH}/system/etc/init.d"
|
|
|
|
else INIT_BASE="${MODPATH}/init.d"
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p "${INIT_BASE}"
|
|
|
|
cp "${INSTALLER}/system/etc/init.d"/* "${INIT_BASE}/"
|
|
|
|
set_perm_bin "${INIT_BASE}"
|
|
|
|
|
2018-08-21 19:59:15 +00:00
|
|
|
for init in fstrim logcat logscleaner sqlite external_sd; do
|
2018-08-23 19:27:15 +00:00
|
|
|
installinfo_add "/system/etc/init.d/${init}"
|
2018-08-21 19:59:15 +00:00
|
|
|
done
|
2018-01-23 20:11:52 +00:00
|
|
|
else ui_print " << without init scripts"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
install_swipe () {
|
2018-10-31 19:35:39 +00:00
|
|
|
if [ "${nanodroid_swipe}" ]; then
|
|
|
|
if [ "${SWIPE_UNSUPPORTED}" -eq 1 ]; then
|
|
|
|
ui_print " << Swipe Libraries are unsupported on pre-KitKat ROMs"
|
|
|
|
else
|
|
|
|
ui_print " << with swipe libraries"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-10-31 19:35:39 +00:00
|
|
|
SWIPE_SRC="${INSTALLER}/swipe/${ARCH}"
|
|
|
|
SWIPE_DEST="/system/${SWIPE_LIBDIR}"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-10-31 19:35:39 +00:00
|
|
|
mkdir -p "${MODPATH}${SWIPE_DEST}"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-10-31 19:35:39 +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
|
|
|
|
2018-10-31 19:35:39 +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"
|
|
|
|
fi
|
2018-01-23 20:11:52 +00:00
|
|
|
else ui_print " << without swipe libraries"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-04-10 17:58:45 +00:00
|
|
|
install_addond () {
|
|
|
|
if [ -d /system/addon.d ]; then
|
|
|
|
ui_print " << System Mode OTA survival"
|
|
|
|
|
|
|
|
cp "${INSTALLER}/CommonAddon" "/system/addon.d/91-nanodroid.sh" || \
|
2018-09-07 16:21:48 +00:00
|
|
|
error "failed to install System Mode OTA survival"
|
2018-04-10 17:58:45 +00:00
|
|
|
|
|
|
|
chmod 0755 "/system/addon.d/91-nanodroid.sh"
|
|
|
|
sed -e "s|@MODID@|${MODID}|g" -i "/system/addon.d/91-nanodroid.sh"
|
|
|
|
else
|
|
|
|
ui_print " << ROM does not have addon.d support"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
##########################################################################################
|
|
|
|
# Advanced Installation Functions
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
nanodroid_install_dir () {
|
|
|
|
dir="${1}"
|
|
|
|
dest="/system/${dir}"
|
|
|
|
|
|
|
|
[ ! -d "${INSTALLER}/system/${dir}" ] && \
|
2018-09-07 16:21:48 +00:00
|
|
|
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}/" || \
|
2018-09-07 16:21:48 +00:00
|
|
|
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" | \
|
2018-08-24 19:25:01 +00:00
|
|
|
installinfo_add
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nanodroid_install_apk () {
|
|
|
|
app=${1}
|
|
|
|
unset prefix
|
|
|
|
|
|
|
|
if [ -f "${INSTALLER}/system/app/${app}/${app}.apk" ]; then
|
|
|
|
dir=system/app
|
|
|
|
elif [ -f "${INSTALLER}/system/priv-app/${app}/${app}.apk" ]; then
|
|
|
|
dir=system/priv-app
|
|
|
|
else
|
2018-09-07 16:21:48 +00:00
|
|
|
error "app ${app} not found"
|
2018-01-23 20:11:52 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
source="${INSTALLER}/${dir}/${app}/${app}.apk"
|
|
|
|
|
|
|
|
if [ "${UNFOLD_APP_DIR}" -eq 1 ]; then
|
|
|
|
dest="${dir}"
|
|
|
|
mkdir -p "${MODPATH}/${dir}"
|
|
|
|
else
|
|
|
|
dest="${dir}/${app}"
|
|
|
|
mkdir -p "${MODPATH}/${dir}/${app}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo " installing app: ${app}"
|
|
|
|
cp "${source}" "${MODPATH}/${dest}" || \
|
2018-09-07 16:21:48 +00:00
|
|
|
error "failed to install ${source} to ${dest}"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
set_perm_data -r "${MODPATH}/${dest}"
|
|
|
|
|
2018-08-23 19:27:15 +00:00
|
|
|
installinfo_add "/${dest}/${app}.apk"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
nanodroid_install_lib
|
|
|
|
}
|
|
|
|
|
|
|
|
nanodroid_install_file () {
|
|
|
|
dir="$(dirname "${1}")"
|
|
|
|
file="$(basename "${1}")"
|
|
|
|
|
|
|
|
[ ! -f "${INSTALLER}/system/${dir}/${file}" ] && \
|
2018-09-07 16:21:48 +00:00
|
|
|
error "file: ${file} not found"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-03-28 17:51:51 +00:00
|
|
|
# if /system/xbin does not exist, use /system/bin
|
2018-05-07 17:39:06 +00:00
|
|
|
[ "${dir}" = "xbin" -a "${ROM_NO_XBIN}" -eq 1 ] && xdir="bin" || xdir="${dir}"
|
2018-03-28 17:51:51 +00:00
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
# strip off .${BIN_ARCH} from final filename (if any)
|
|
|
|
xfile=$(basename ${file} .${BIN_ARCH})
|
|
|
|
|
|
|
|
echo " installing file: ${xfile}"
|
|
|
|
|
2018-05-07 17:39:06 +00:00
|
|
|
mkdir -p "${MODPATH}/system/${xdir}/"
|
2018-01-23 20:11:52 +00:00
|
|
|
cp "${INSTALLER}/system/${dir}/${file}" \
|
2018-05-07 17:39:06 +00:00
|
|
|
"${MODPATH}/system/${xdir}/${xfile}" || \
|
2018-09-07 16:21:48 +00:00
|
|
|
error "failed to install ${xfile}"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
case ${2} in
|
2018-05-07 17:39:06 +00:00
|
|
|
bin ) set_perm_bin "${MODPATH}/system/${xdir}/${xfile}" ;;
|
|
|
|
* ) set_perm_data "${MODPATH}/system/${xdir}/${xfile}" ;;
|
2018-01-23 20:11:52 +00:00
|
|
|
esac
|
|
|
|
|
2018-08-23 19:27:15 +00:00
|
|
|
installinfo_add "/system/${xdir}/${xfile}"
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nanodroid_install_lib () {
|
|
|
|
apk="${MODPATH}/${dest}/${app}.apk"
|
|
|
|
|
|
|
|
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=${MODPATH}/${dir}/${app}/lib
|
|
|
|
fi
|
|
|
|
|
|
|
|
rm -rf ${TMP_LIBDIR}
|
|
|
|
mkdir -p ${TMP_LIBDIR}
|
|
|
|
|
|
|
|
unset srcdir
|
|
|
|
|
2018-03-28 18:14:04 +00:00
|
|
|
"${INSTALLER}/system/xbin/unzip.${BIN_ARCH}" \
|
2018-01-23 20:11:52 +00:00
|
|
|
-oq ${apk} "lib/*" -d "${TMP_LIBDIR}" \
|
|
|
|
2>/dev/null
|
|
|
|
unzip_return=$?
|
|
|
|
|
|
|
|
case ${unzip_return} in
|
|
|
|
0 ) echo " ${app} does have libs" ;;
|
|
|
|
11 ) echo " ${app} does not have any libs" ;;
|
|
|
|
* ) error " !! installing libs for ${app} failed" ;;
|
|
|
|
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}
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -d "${srcdir}" ]; then
|
|
|
|
case ${srcdir} in
|
|
|
|
*arm64* ) echo " ${app}: installing arm64 libs"
|
|
|
|
lib_arch=arm64 ;;
|
|
|
|
*arm* ) echo " ${app}: installing arm libs"
|
|
|
|
lib_arch=arm ;;
|
|
|
|
*x86_64* ) echo " ${app}: installing x86_64 libs"
|
|
|
|
lib_arch=x86_64 ;;
|
|
|
|
*x86* ) echo " ${app}: installing x86 libs"
|
|
|
|
lib_arch=x86 ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
echo " from: ${srcdir}"
|
|
|
|
echo " into: ${libd}/${lib_arch}"
|
|
|
|
mkdir -p ${libd}/${lib_arch}
|
|
|
|
|
|
|
|
for lib in ${srcdir}/*; do
|
|
|
|
echo " library: $(basename ${lib})"
|
|
|
|
cp ${lib} ${libd}/${lib_arch}/ || \
|
2018-09-07 16:21:48 +00:00
|
|
|
error "installing libraries failed"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
set_perm_data ${libd}/${lib_arch}/$(basename ${lib})
|
|
|
|
|
2018-08-23 19:27:15 +00:00
|
|
|
installinfo_add /${dir}/${app}/lib/${lib_arch}/$(basename ${lib})
|
2018-01-23 20:11:52 +00:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
nanodroid_substitute () {
|
2018-03-28 18:31:11 +00:00
|
|
|
dir="$(dirname "${1}")"
|
|
|
|
file="$(basename "${1}")"
|
|
|
|
|
|
|
|
# if /system/xbin does not exist, use /system/bin
|
|
|
|
[ "${dir}" = "xbin" -a "${ROM_NO_XBIN}" -eq 1 ] && dir="bin"
|
|
|
|
|
|
|
|
target="${MODPATH}/system/${dir}/${file}"
|
|
|
|
|
2018-09-07 16:21:48 +00:00
|
|
|
[ ! -f "${target}" ] && error "file: ${file} not found"
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
if grep -q @ZIPDIR@ "${target}"; then
|
|
|
|
if [[ "${ZIPDIR}" == "/external_sd" ]]; then
|
|
|
|
# /external_sd is already known by `nanodroid-overlay`
|
|
|
|
# no need to add it a second time
|
|
|
|
sed -e 's|@ZIPDIR@||' -i ${target}
|
|
|
|
echo " substitute: remove @ZIPDIR@ in ${target}"
|
|
|
|
else
|
|
|
|
sed -e "s|@ZIPDIR@|${ZIPDIR}|g" -i ${target}
|
|
|
|
echo " substitute: adjust @ZIPDIR@ in ${target}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if grep -q @MODPATH@ ${target}; then
|
|
|
|
sed -e "s|@MODPATH@|${REALPATH}|g" -i ${target}
|
|
|
|
echo " substitute: adjust @MODPATH@ in ${target}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
nanodroid_storelogs () {
|
|
|
|
|
2018-07-09 18:38:56 +00:00
|
|
|
curdate=$(date +%Y%m%d_%H.%M.%S)
|
|
|
|
nanodroid_logfile="/data/adb/${MODID}_log_${curdate}"
|
|
|
|
nanodroid_twrplog="/data/adb/${MODID}_twrp_${curdate}"
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
echo "\
|
|
|
|
### VALUES ###
|
|
|
|
ZIP=${ZIP}
|
|
|
|
ZIPDIR=${ZIPDIR}
|
|
|
|
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}
|
|
|
|
REALPATH=${REALPATH}
|
|
|
|
MODE=${MODE}
|
|
|
|
MAGISK_VER_CODE=${MAGISK_VER_CODE}
|
2018-03-20 17:55:07 +00:00
|
|
|
CUSTOM_FONT=${CUSTOM_FONT}
|
2018-03-28 18:14:04 +00:00
|
|
|
ROM_NO_XBIN=${ROM_NO_XBIN}
|
2018-04-02 18:45:01 +00:00
|
|
|
RESTORE_PATH=${RESTORE_PATH}
|
2018-07-08 18:13:12 +00:00
|
|
|
NANODROID_UPGRADE=${NANODROID_UPGRADE}
|
2018-08-19 16:46:55 +00:00
|
|
|
NANODROID_BINDIR=${NANODROID_BINDIR}
|
2018-01-23 20:11:52 +00:00
|
|
|
|
|
|
|
### SETUP ###
|
2018-07-09 18:38:56 +00:00
|
|
|
" > ${nanodroid_logfile}
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-07-09 18:38:56 +00:00
|
|
|
cat "${cfg_setup}" >> ${nanodroid_logfile}
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-04-10 19:14:52 +00:00
|
|
|
if [ ! -z "${cfg_apps}" ]; then
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
echo "
|
|
|
|
### APPS ###
|
2018-07-09 18:38:56 +00:00
|
|
|
" >> ${nanodroid_logfile}
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-07-09 18:38:56 +00:00
|
|
|
cat "${cfg_apps}" >> ${nanodroid_logfile}
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-04-10 19:14:52 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -z "${cfg_overlay}" ]; then
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
echo "
|
|
|
|
### OVERLAY ###
|
2018-07-09 18:38:56 +00:00
|
|
|
" >> ${nanodroid_logfile}
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-07-09 18:38:56 +00:00
|
|
|
cat "${cfg_overlay}" >> ${nanodroid_logfile}
|
2018-01-23 20:11:52 +00:00
|
|
|
|
2018-04-10 19:14:52 +00:00
|
|
|
fi
|
|
|
|
|
2018-07-09 18:38:56 +00:00
|
|
|
${BOOTMODE} || cat /tmp/recovery.log > ${nanodroid_twrplog}
|
|
|
|
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
##########################################################################################
|
|
|
|
# NanoDroid Configuration File Handling
|
|
|
|
##########################################################################################
|
|
|
|
|
|
|
|
# check for configuration files
|
|
|
|
config_locations="/sdcard /external_sd ${ZIPDIR} /data"
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
# check whether '.nanodroid-setup' has all required entries
|
|
|
|
check_cfg_setup () {
|
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 1
|
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_zelda}" ] && set_prop nanodroid_zelda 1
|
|
|
|
[ -z "${nanodroid_mapsv1}" ] && set_prop nanodroid_mapsv1 1
|
|
|
|
[ -z "${nanodroid_init}" ] && set_prop nanodroid_init 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_nlpbackend}" ] && set_prop nanodroid_nlpbackend 1
|
|
|
|
[ -z "${nanodroid_bash}" ] && set_prop nanodroid_bash 1
|
|
|
|
[ -z "${nanodroid_nano}" ] && set_prop nanodroid_nano 1
|
|
|
|
[ -z "${nanodroid_utils}" ] && set_prop nanodroid_utils 1
|
|
|
|
[ -z "${nanodroid_fonts}" ] && set_prop nanodroid_fonts 1
|
|
|
|
[ -z "${nanodroid_override}" ] && set_prop nanodroid_override 0
|
|
|
|
|
|
|
|
source "${cfg_setup}"
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
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 () {
|
2018-04-22 17:36:59 +00:00
|
|
|
# <= 16.3 has KeePass DX instead of KeePassDroid, migrate
|
2018-03-17 16:08:36 +00:00
|
|
|
if grep -q KeePassDroid "${cfg_apps}"; then
|
|
|
|
sed -e 's/KeePassDroid/KeePassDX/g' -i "${cfg_apps}"
|
|
|
|
fi
|
2018-04-22 17:36:59 +00:00
|
|
|
|
2018-06-15 19:37:24 +00:00
|
|
|
# <= 17.0~beta1 && <= 17.2~beta1 has Bucket (LibreSubtratum) instead of Substratum, migrate
|
|
|
|
if grep -q Bucket "${cfg_apps}"; then
|
|
|
|
sed -e 's/Bucket/Substratum/g' -i "${cfg_apps}"
|
2018-04-22 17:36:59 +00:00
|
|
|
fi
|
2018-09-15 17:21:42 +00:00
|
|
|
|
|
|
|
# <= 18.1 has Orfox instead of TorBrowser, migrate
|
|
|
|
if grep -q Orfox "${cfg_apps}"; then
|
|
|
|
sed -e 's/Orfox/TorBrowser/g' -i "${cfg_apps}"
|
2018-09-29 20:05:51 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# <= 18.4 has Adaway instead of Blockada, migrate
|
|
|
|
if grep -q Adaway "${Blockada}"; then
|
|
|
|
sed -e 's/Adaway/Blockada/g' -i "${cfg_apps}"
|
2018-09-15 17:21:42 +00:00
|
|
|
fi
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
2018-09-15 17:21:42 +00:00
|
|
|
# check whether '.nanodroid-overlay' is up to date
|
2018-01-23 20:11:52 +00:00
|
|
|
check_cfg_overlay () {
|
2018-08-22 18:01:37 +00:00
|
|
|
return 0
|
2018-01-23 20:11:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
get_cfg_setup () {
|
|
|
|
get_config setup
|
|
|
|
if [ "$config_exists" -eq 1 ]; then
|
|
|
|
cfg_setup="${config}"
|
|
|
|
check_cfg_setup
|
|
|
|
ui_print " > Config | nanodroid-setup | $(dirname ${cfg_setup})"
|
|
|
|
else
|
|
|
|
cfg_setup="${INSTALLER}/.nanodroid-setup"
|
|
|
|
source "${cfg_setup}"
|
|
|
|
ui_print " > Config | nanodroid-setup | fallback"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
get_cfg_overlay () {
|
|
|
|
get_config overlay
|
|
|
|
if [ "$config_exists" -eq 1 ]; then
|
|
|
|
cfg_overlay="${config}"
|
|
|
|
check_cfg_overlay
|
|
|
|
ui_print " > Config | nanodroid-overlay | $(dirname ${cfg_overlay})"
|
|
|
|
else
|
|
|
|
cfg_overlay="${INSTALLER}/.nanodroid-overlay"
|
|
|
|
ui_print " > Config | nanodroid-overlay | fallback"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
get_cfg_apps () {
|
|
|
|
get_config apps
|
|
|
|
if [ "$config_exists" -eq 1 ]; then
|
|
|
|
cfg_apps="${config}"
|
|
|
|
check_cfg_apps
|
|
|
|
ui_print " > Config | nanodroid-apps | $(dirname ${cfg_apps})"
|
|
|
|
else
|
|
|
|
cfg_apps="${INSTALLER}/.nanodroid-apps"
|
|
|
|
ui_print " > Config | nanodroid-apps | fallback"
|
|
|
|
fi
|
|
|
|
}
|