Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- TMP=tmp.$(date +%s)$(uuidgen | sed s/-//g)
- apktool d -o $TMP "$@"
- VERSION=$(cat $TMP/apktool.yml | grep versionName: | awk '{print $2}')
- cd $TMP
- find . -name '*.smali' -exec grep "Landroid/os/Build;->MANUFACTURER:Ljava/lang/String;" {} + | awk '{print $3}' | while read sed; do
- findstr "Landroid/os/Build;->MANUFACTURER:Ljava/lang/String;" | while read file; do
- sed -i -e "s@sget-object $sed Landroid/os/Build;->MANUFACTURER:Ljava/lang/String;@const-string $sed \"samsung\"@g" $file
- done
- done
- find . -name '*.smali' -exec grep "Landroid/os/Build;->DEVICE:Ljava/lang/String;" {} + | awk '{print $3}' | while read sed; do
- findstr "Landroid/os/Build;->DEVICE:Ljava/lang/String;" | while read file; do
- sed -i -e "s@sget-object $sed Landroid/os/Build;->DEVICE:Ljava/lang/String;@const-string $sed \"zeroflte\"@g" $file
- done
- done
- find . -name '*.smali' -exec grep "Landroid/os/Build;->MODEL:Ljava/lang/String;" {} + | awk '{print $3}' | while read sed; do
- findstr "Landroid/os/Build;->MODEL:Ljava/lang/String;" | while read file; do
- sed -i -e "s@sget-object $sed Landroid/os/Build;->MODEL:Ljava/lang/String;@const-string $sed \"SM-G920F\"@g" $file
- done
- done
- find . -name '*.smali' -exec grep "Landroid/os/Build;->HARDWARE:Ljava/lang/String;" {} + | awk '{print $3}' | while read sed; do
- findstr "Landroid/os/Build;->HARDWARE:Ljava/lang/String;" | while read file; do
- sed -i -e "s@sget-object $sed Landroid/os/Build;->HARDWARE:Ljava/lang/String;@const-string $sed \"samsungexynos7420\"@g" $file
- done
- done
- AD_CREATOR=$(grep -l ".field final A" \
- $(grep -l ".field public static final CREATOR" \
- $(find smali* -type f -exec \
- grep -l ".method public constructor <init>(Ljava/util/List;" {} +)))
- if echo $AD_CREATOR | grep -q " "; then
- # Multiple classes detected, bail out
- echo "Multiple AD_CREATOR classes detected!"
- echo $AD_CREATOR
- exit 1
- fi
- echo -n "AD_CREATOR detected : "
- echo $AD_CREATOR
- AD_CREATOR_LINE=$(grep -n ".method public constructor <init>(Ljava/util/List;" $AD_CREATOR | cut -f1 -d:)
- sed -i "$((${AD_CREATOR_LINE} + 2))i\ .param p1" $AD_CREATOR
- if ! sed -n "${AD_CREATOR_LINE},$((${AD_CREATOR_LINE} + 10))p" $AD_CREATOR | grep -q "invoke-direct {p0}, Ljava/lang/Object;-><init>()V"; then
- # "invoke-direct {p0}, Ljava/lang/Object;-><init>()V" not found
- echo "invoke-direct {p0}, Ljava/lang/Object;-><init>()V not found!"
- exit 1
- fi
- sed -i "${AD_CREATOR_LINE},$((${AD_CREATOR_LINE} + 10))s/invoke-direct {p0}, Ljava\/lang\/Object;-><init>()V/invoke-direct {p0}, Ljava\/lang\/Object;-><init>()V\n invoke-static {}, Ljava\/util\/Collections;->emptyList()Ljava\/util\/List;\n move-result-object p1/" $AD_CREATOR
- echo "$AD_CREATOR patched!"
- AD_EXT=$(find smali* -type f -exec \
- grep -l "/VAST/Ad/Wrapper/Extensions/Extension" {} +)
- if echo $AD_EXT | grep -q " "; then
- # Multiple classes detected, bail out
- echo "Multiple AD_EXT classes detected!"
- echo $AD_EXT
- exit 1
- fi
- echo -n "AD_EXT detected : "
- echo $AD_EXT
- AD_EXT_TEXT=$(cat $AD_EXT | grep ".method public static")
- AD_EXT_LINE=$(grep -n ".method public static" $AD_EXT | cut -f1 -d:)
- sed -i '/.method public static/,/.end method/ d' $AD_EXT
- sed -i "${AD_EXT_LINE}i\\${AD_EXT_TEXT}\n .locals 3\n .prologue\n return-void\n.end method" $AD_EXT
- echo "$AD_EXT patched!"
- echo "Patching XMLs"
- echo "watch_metadata_cards
- inline_ad_overlay
- default_ad_overlay
- embedded_ad_overlay
- mdx_ad_overlay
- promoted_video_item
- q_promoted_video_item
- compact_promoted_video_item
- generic_promo_banner
- promoted_app_install
- compact_promoted_item
- interstitial_promo_view
- promoted_tall_descriptive_banner
- promoted_short_descriptive_banner
- grid_promoted_banner
- music_key_promo_banner
- music_key_promo_feature_item
- music_key_promo_small_feature_item
- promoted_app_install_right_align_layout
- sign_in_promo
- promoted_text_banner_layout_one
- promoted_text_banner_layout_two
- promoted_text_banner_layout_three
- music_key_promo_feature_item_text
- generic_promo_card
- background_promo
- promoted_app_install_new_line_layout
- invideo_programming_overlay
- info_cards_teaser_overlay" | while read to_find; do find res -name ${to_find}*.xml; done | while read file; do
- echo "android:layout_height=
- android:layout_margin=
- android:layout_marginBottom=
- android:layout_marginEnd=
- android:layout_marginLeft=
- android:layout_marginRight=
- android:layout_marginStart=
- android:layout_marginTop=
- android:layout_width=" | while read text; do cat $file | tr ' ' '\n' | sed -e 's/</ /g' -e 's/>/ /g' -e 's/ //g' | grep $text | while read grepped; do
- sed -i -e "s#$grepped#${text}\"0.0dip\"#g" $file; done; done; done
- cp -rp res tmp
- cd tmp
- # set to false
- echo "show_startup_promo
- enable_channel_layer_banner
- generic_promo_banner_view" | while read bool; do find . -name bools.xml -exec grep -l $bool {} + | while read file; do sed -i -e "s#$(cat ../res/$file | grep $bool)#$(cat ../res/$file | grep $bool | sed -e s/true/false/g)#g" $file; done; done
- # set to true
- echo "supports_rtl" | while read bool; do find . -name bools.xml -exec grep -l $bool {} + | while read file; do sed -i -e "s#$(cat ../res/$file | grep $bool)#$(cat ../res/$file | grep $bool | sed -e s/false/true/g)#g" $file; done; done
- cd ..
- rm -rf res
- mv tmp res
- echo "XMLs patched!"
- apktool b -c -a /home/arter97/arter97/bin/aapt
- mv dist/* ../$TMP.zip
- cd ..
- zipalign -v 4 $TMP.zip YouTube-${VERSION}_SM-G920F.apk
- rm -rf $TMP $TMP.zip
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement