Skip to content

Commit

Permalink
Commonize updating i18n flag, and allow update Clock to support workd…
Browse files Browse the repository at this point in the history
…ay alarms by switch
  • Loading branch information
EraserKing authored and EraserKing committed Mar 2, 2019
1 parent 0ef0d7c commit 11e9bce
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 37 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ For users in China, you can also download the **xiaomi.eu rom** and run `cleaner
* Fix FC of cleaner app.
* Show payment monitor options in setting page of Security app.
* Use Chinese weather sources in Weather app.
* Allow alarm of legal workday repeat mode.

## (Optional) Encryption for xiaomi.eu ROMs

Expand Down
95 changes: 58 additions & 37 deletions cleaner-fix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ case $key in
echo "--> Increase threshold (50M) to prevent high cpu of traffic monitoring"
shift
;;
--clock)
regular_apps="DeskClock $regular_apps"
echo "--> Modify Clock to support work day alarms"
shift
;;
--nofbe)
NO_EXTRA_FBE="yes"
shift
Expand Down Expand Up @@ -97,6 +102,44 @@ popd() {
command popd "$@" > /dev/null
}

update_international_build_flag() {
path=$1
pattern="Lmiui/os/Build;->IS_INTERNATIONAL_BUILD"

if [ -d $path ]; then
found=()
if [[ "$OSTYPE" == "cygwin"* ]]; then
pushd "$path"
cmdret="$(findstr /sm /c:${pattern} '*.*' | tr -d '\015')"
popd
result="${cmdret//\\//}"
while read i; do
found+=("${path}/$i")
done <<< "$result"
else
files="$(find $path -type f -iname "*.smali")"
while read i; do
if grep -q -F "$pattern" $i; then
found+=("$i")
fi
done <<< "$files"
fi
fi
if [ -f $path ]; then
found=($path)
fi

for i in "${found[@]}"; do
$sed -i 's|sget-boolean \([a-z]\)\([0-9]\+\), Lmiui/os/Build;->IS_INTERNATIONAL_BUILD:Z|const/4 \1\2, 0x0|g' "$i" \
|| return 1
if grep -q -F "$pattern" $i; then
echo "----> ! failed to patch: $(basename $i)"
else
echo "----> patched smali: $(basename $i)"
fi
done
}

deodex() {
app=$2
base_dir="$1"
Expand Down Expand Up @@ -128,50 +171,20 @@ deodex() {

if [[ "$app" == "Weather" ]]; then
echo "----> searching smali..."
pattern="Lmiui/os/Build;->IS_INTERNATIONAL_BUILD"
findroot="$apkdir/smali/com/miui/weather2"
found=()
if [[ "$OSTYPE" == "cygwin"* ]]; then
pushd "$findroot"
cmdret="$(findstr /sm /c:${pattern} '*.*' | tr -d '\015')"
popd
result="${cmdret//\\//}"
while read i; do
found+=("${findroot}/$i")
done <<< "$result"
else
files="$(find $findroot -type f -iname "*.smali")"
while read i; do
if grep -q -F "$pattern" $i; then
found+=("$i")
fi
done <<< "$files"
fi
for i in "${found[@]}"; do
$sed -i 's|sget-boolean \([a-z]\)\([0-9]\+\), Lmiui/os/Build;->IS_INTERNATIONAL_BUILD:Z|const/4 \1\2, 0x0|g' "$i" \
|| return 1
if grep -q -F "$pattern" $i; then
echo "----> ! failed to patch: $(basename $i)"
else
echo "----> patched smali: $(basename $i)"
fi
done
update_international_build_flag "$apkdir/smali/com/miui/weather2"
i="$apkdir/smali/com/miui/weather2/tools/ToolUtils.smali"
if [ -f "$i" ]; then
$patchmethod "$i" -canRequestCommercial -canRequestCommercialInfo || return 1
fi
fi

if [[ "$app" == "SecurityCenter" ]]; then
i="$apkdir/smali/com/miui/antivirus/activity/SettingsActivity.smali"
$sed -i 's|sget-boolean \([a-z]\)\([0-9]\+\), Lmiui/os/Build;->IS_INTERNATIONAL_BUILD:Z|const/4 \1\2, 0x0|g' "$i" \
|| return 1
update_international_build_flag "$apkdir/smali/com/miui/antivirus/activity/SettingsActivity.smali"
fi

if grep -q -F 'Lmiui/os/Build;->IS_INTERNATIONAL_BUILD' $i; then
echo "----> ! failed to patch: $(basename $i)"
else
echo "----> patched smali: $(basename $i)"
fi
if [[ "$app" == "DeskClock" ]]; then
echo "----> searching smali..."
update_international_build_flag "$apkdir/smali/"
fi

if [[ "$app" == "services.jar" ]]; then
Expand Down Expand Up @@ -230,6 +243,7 @@ extract() {
file=$3
apps=$4
priv_apps=$5
regular_apps=$6
dir=miuieu-$model-$ver
img=$dir-system.img

Expand Down Expand Up @@ -273,6 +287,10 @@ extract() {
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"
done
for f in $priv_apps; do
echo "----> copying $f..."
$sevenzip x -odeodex/system/ "$img" $f >/dev/null || clean "$work_dir"
Expand All @@ -281,6 +299,9 @@ extract() {
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
Expand Down Expand Up @@ -340,7 +361,7 @@ for f in *.zip; do
fi
model=${arr[2]}
ver=${arr[3]}
extract $model $ver $f "$mipay_apps" "$private_apps"
extract $model $ver $f "$mipay_apps" "$private_apps" "$regular_apps"
hasfile=true
done

Expand Down

0 comments on commit 11e9bce

Please sign in to comment.