Skip to content

Commit

Permalink
Support Mi 9 for xiaomi.eu fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
linusyang committed Apr 16, 2019
1 parent 27b00ca commit db8ea39
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 26 deletions.
33 changes: 17 additions & 16 deletions cleaner-fix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ case $key in
shift
;;
--clock)
regular_apps="DeskClock $regular_apps"
EXTRA_PRIV="app/DeskClock $EXTRA_PRIV"
echo "--> Modify Clock to support work day alarms"
shift
;;
Expand Down Expand Up @@ -45,6 +45,8 @@ sign="java -Xmx${heapsize}m -jar $tool_dir/apksigner.jar sign \
aria2c_opts="--check-certificate=false --file-allocation=trunc -s10 -x10 -j10 -c"
aria2c="aria2c $aria2c_opts"
sed="sed"
imgroot=""
imgexroot="system/"

exists() {
command -v "$1" >/dev/null 2>&1
Expand Down Expand Up @@ -243,7 +245,6 @@ extract() {
file=$3
apps=$4
priv_apps=$5
regular_apps=$6
dir=miuieu-$model-$ver
img=$dir-system.img

Expand Down Expand Up @@ -277,40 +278,40 @@ extract() {
rm -Rf deodex
mkdir -p deodex/system

detect="$($sevenzip l "$img" system/build.prop)"
if [[ "$detect" == *"build.prop"* ]]; then
echo "--> detected new image structure"
imgroot="system/"
imgexroot=""
fi

echo "--> copying apps"
$sevenzip x -odeodex/system/ "$img" build.prop >/dev/null || clean "$work_dir"
file_list="$($sevenzip l "$img" priv-app/Weather)"
$sevenzip x -odeodex/${imgexroot} "$img" ${imgroot}build.prop >/dev/null || clean "$work_dir"
file_list="$($sevenzip l "$img" ${imgroot}priv-app/Weather)"
if [[ "$file_list" == *Weather* ]]; then
apps="$apps Weather"
fi
for f in $apps; do
echo "----> copying $f..."
$sevenzip x -odeodex/system/ "$img" priv-app/$f >/dev/null || clean "$work_dir"
done
for f in $regular_apps; do
echo "----> copying $f..."
$sevenzip x -odeodex/system/ "$img" app/$f >/dev/null || clean "$work_dir"
$sevenzip x -odeodex/${imgexroot} "$img" ${imgroot}priv-app/$f >/dev/null || clean "$work_dir"
done
for f in $priv_apps; do
echo "----> copying $f..."
$sevenzip x -odeodex/system/ "$img" $f >/dev/null || clean "$work_dir"
$sevenzip x -odeodex/${imgexroot} "$img" ${imgroot}$f >/dev/null || clean "$work_dir"
done
arch="arm64"
for f in $apps; do
deodex "$work_dir" "$f" "$arch" priv-app || clean "$work_dir"
done
for f in $regular_apps; do
deodex "$work_dir" "$f" "$arch" app || clean "$work_dir"
done
for f in $priv_apps; do
deodex "$work_dir" "$(basename $f)" "$arch" "$(dirname $f)" || clean "$work_dir"
done

file_list="$($sevenzip l "$img" data-app/Weather)"
file_list="$($sevenzip l "$img" ${imgroot}data-app/Weather)"
if [[ "$file_list" == *Weather* ]]; then
echo "--> patching weather"
rm -f ../weather-*.apk
$sevenzip x -odeodex/system/ "$img" data-app/Weather >/dev/null || clean "$work_dir"
$sevenzip x -odeodex/${imgexroot} "$img" ${imgroot}data-app/Weather >/dev/null || clean "$work_dir"
cp deodex/system/data-app/Weather/Weather.apk ../weather-$model-$ver-orig.apk
deodex "$work_dir" Weather "$arch" data-app || clean "$work_dir"
mv deodex/system/data-app/Weather/Weather.apk ../weather-$model-$ver-mod.apk
Expand Down Expand Up @@ -361,7 +362,7 @@ for f in *.zip; do
fi
model=${arr[2]}
ver=${arr[3]}
extract $model $ver $f "$mipay_apps" "$private_apps" "$regular_apps"
extract $model $ver $f "$mipay_apps" "$private_apps"
hasfile=true
done

Expand Down
16 changes: 14 additions & 2 deletions tools/update-binary
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
ver=
tmp=/tmp/mipay-apps
default_prop=/system/build.prop
imgroot=

if [ "$3" ]; then
zip=$3
Expand Down Expand Up @@ -50,6 +51,12 @@ setperm() {
}

setprop() {
if ! [ -f "$default_prop" ]; then
default_prop="${imgroot}${default_prop}"
fi
if ! [ -f "$default_prop" ]; then
abort "build.prop not found."
fi
if grep -q "^[[:space:]]*$1[[:space:]]*=" "$default_prop"; then
sed -i "s/^[[:space:]]*$1[[:space:]]*=.*$/$1=$2/g" "$default_prop"
else
Expand Down Expand Up @@ -89,16 +96,21 @@ fi
}
cd "$tmp"

if [ -d "/system/system/app" ]; then
print 'New image structure detected.'
imgroot=/system
fi

app_list=""
for f in ./system/app/*; do
app_list="${app_list} /system/app/$(basename $f)"
app_list="${app_list} ${imgroot}/system/app/$(basename $f)"
done

print "Clean files..."
rm -rf $app_list

print "Adding files..."
cp -R ./system/app/* /system/app/ || abort "Failed copy apps"
cp -R ./system/app/* ${imgroot}/system/app/ || abort "Failed copy apps"
#mkdir_symlink

print "Setting correct permissions..."
Expand Down
29 changes: 21 additions & 8 deletions tools/update-binary-cleaner
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

ver=
tmp=/tmp/cleaner-fix-apps
imgroot=

if [ "$3" ]; then
zip=$3
Expand Down Expand Up @@ -63,8 +64,15 @@ rmcache() {
}

rmprop() {
if grep -q "^[[:space:]]*$1[[:space:]]*=" "$2"; then
sed -i "s/^[[:space:]]*$1[[:space:]]*=/#$1=/" "$2" && \
f="$2"
if ! [ -f "$f" ]; then
f="${imgroot}${f}"
fi
if ! [ -f "$f" ]; then
abort "$(basename "$f") not found."
fi
if grep -q "^[[:space:]]*$1[[:space:]]*=" "$f"; then
sed -i "s/^[[:space:]]*$1[[:space:]]*=/#$1=/" "$f" && \
print "Comment out property: $1" || \
print "Failed to modify property: $1"
fi
Expand All @@ -88,31 +96,36 @@ fi
}
cd "$tmp"

if [ -d "/system/system/app" ]; then
print 'New image structure detected.'
imgroot=/system
fi

app_list=""
for f in ./system/priv-app/*; do
app_list="${app_list} /system/priv-app/$(basename $f)"
app_list="${app_list} ${imgroot}/system/priv-app/$(basename $f)"
done
if [ -d ./system/app ]; then
for f in ./system/app/*; do
app_list="${app_list} /system/app/$(basename $f)"
app_list="${app_list} ${imgroot}/system/app/$(basename $f)"
done
fi
if [ -d ./system/framework ]; then
for f in ./system/framework/*; do
app_list="${app_list} /system/framework/$(basename $f)"
app_list="${app_list} ${imgroot}/system/framework/$(basename $f)"
done
fi

print "Clean files..."
rm -rf $app_list

print "Adding files..."
cp -R ./system/priv-app/* /system/priv-app/ || abort "Failed to copy priv-apps"
cp -R ./system/priv-app/* ${imgroot}/system/priv-app/ || abort "Failed to copy priv-apps"
if [ -d ./system/app ]; then
cp -R ./system/app/* /system/app/ || abort "Failed to copy apps"
cp -R ./system/app/* ${imgroot}/system/app/ || abort "Failed to copy apps"
fi
if [ -d ./system/framework ]; then
cp -R ./system/framework/* /system/framework/ || abort "Failed to copy frameworks"
cp -R ./system/framework/* ${imgroot}/system/framework/ || abort "Failed to copy frameworks"
fi

print "Setting correct permissions..."
Expand Down
3 changes: 3 additions & 0 deletions tools/update-binary-fbe
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ try_del() {

force_encrypt_oreo() {
fstab=/system/vendor/etc/fstab.qcom
if ! [ -f "$fstab" ]; then
fstab="/system${fstab}"
fi
if ! [ -f "$fstab" ]; then
print "No fstab.qcom in vendor, skipping..."
else
Expand Down

0 comments on commit db8ea39

Please sign in to comment.