echo "1、GP包（无权限）"
echo "2、渠道包（有权限）"
echo "3、马甲包 GP"
echo "4、马甲包 渠道"
echo -n "选择打包方式："
read action

. ../../gradle.properties

if((${action}=='1')) || ((${action}=='3'))
then
#同盾插拔
    ./sdk_manager.py ${td_mode} "TD"
    #api混淆
    if ((${rename_api}=='true'))
    then
        cd code
        chmod a+x rename_api.py
        ./rename_api.py
        cd ..
    fi
fi

cd garble
#四大组件混淆
./rename_project.sh
#代码结构混淆
./insert.py

cd ../../../
rm -rf resGuardApks
gradlew clean

if((${action}=='1'))
then
    gradlew resguardAppProductGoogleplayRelease

elif((${action}=='2'))
then
    gradlew resguardAppProductWebsiteRelease

elif((${action}=='3'))
then
    mv app/src/main/res/drawable-xxhdpi/logo_majia.png  app/src/main/res/drawable-xxhdpi/logo.png
    sed -i "" "s#^app_name=.*#app_name=${majia_name}#g"  gradle.properties
    gradlew resguardAppProductGoogleplayRelease

elif((${action}=='4'))
then
    mv app/src/main/res/drawable-xxhdpi/logo_majia.png  app/src/main/res/drawable-xxhdpi/logo.png
    sed -i "" "s#^app_name=.*#app_name=${majia_name}#g"  gradle.properties
    gradlew resguardAppProductWebsiteRelease

else
    echo "未知的打包方式"
fi

cd lib_base/script/garble/
./reset_name.sh
