apply plugin: 'walle'
apply plugin: 'stringfog'

android {
    defaultConfig {
        buildConfigField 'Boolean', 'IS_COLLECT_MODE', 'false'
        buildConfigField 'Boolean', 'IS_DIVERSION_MODE', 'false'
        buildConfigField 'Boolean', 'IS_KSP', 'false'
        //同盾采集SDK
        buildConfigField 'String', 'TONGDUN_PARENT_CODE', '\"\"'
        buildConfigField 'String', 'TONGDUN_PARENT_KEY', '\"\"'
        buildConfigField 'String', 'TONGDUN_APP_NAME', '\"\"'


        buildConfigField 'String', 'FACEBOOK_APP_ID', "\"${facebook_app_id}\""
        buildConfigField 'String', 'ACCOUNT_KIT_CLIENT_TOKEN', "\"${account_kit_client_token}\""


        resValue('string', 'octopus_open_whatsapp', " Open Whatsapp")

        try {
            buildConfigField 'Boolean', 'NEED_CONTACT', "${contact}"
        } catch (Exception e) {
            buildConfigField 'Boolean', 'NEED_CONTACT', "true"
        }

        try {
            buildConfigField 'Boolean', 'OPEN_LIVENESS', "${open_liveness}"
        } catch (Exception e) {
            buildConfigField 'Boolean', 'OPEN_LIVENESS', "true"
        }


        //同盾指纹SDK
        buildConfigField 'String', 'TONGDUN_DEVICE_PARENT_CODE', '\"\"'
    }

    buildTypes {
        release {
            proguardFiles getDefaultProguardFile('proguard-android.txt'), '../lib_base/proguard-rules.pro'
        }
    }

    lintOptions {
        disable 'GoogleAppIndexingWarning'
    }
    productFlavors {
        website {
            ndk {
                abiFilters 'armeabi-v7a'//,'arm64-v8a'//,'armeabi'//,  'arm64-v8a', 'x86'
            }
            buildConfigField('String', 'BUGLY_APPID', "\"\"")
            dimension "channel"
        }

        googleplay {
            ndk {
                if ("${tongdun_parent_key}".size() > 5) {
                    abiFilters 'armeabi-v7a'
                } else {
                    abiFilters 'armeabi-v7a', 'arm64-v8a'//,'armeabi'//,  'arm64-v8a', 'x86'
                }
            }
            buildConfigField('String', 'BUGLY_APPID', "\"\"")
            dimension "channel"
        }
    }
}

dependencies {
    exec {
        workingDir = "../lib_base/script"
        if ("${tongdun_parent_key}".size() > 5) {
            implementation(name: 'android_spirit-20190220-2.0.0.1', ext: 'aar')
            implementation 'com.alibaba:fastjson:1.1.58.android'
            executable 'sh' args "-c", "./sdk_manager.py open TD"
        } else {
            executable 'sh' args "-c", "./sdk_manager.py close TD"
        }
    }
    exec {
        //活体选择
        workingDir = "../lib_base/script/code"
        try {
            executable 'sh' args "-c", "./choose_liveness.sh ${liveness}"
        } catch (Exception e) {
            executable 'sh' args "-c", "./choose_liveness.sh yitu"
        }
    }


//    def startParams = getGradle().getStartParameter().getTaskRequests()[0]
//    if(startParams!=null && startParams.getArgs().toString().contains("Website")){
//    }

    websiteImplementation 'com.tencent.bugly:crashreport:3.0.0'

}

walle {
    // 指定渠道包的输出路径
    apkOutputFolder = new File("${project.buildDir}/outputs/channels")
    // 定制渠道包的APK的文件名称
    apkFileNameFormat = '${packageName}_${channel}.apk'
    // 渠道配置文件
    channelFile = new File("${project.getProjectDir()}/channel")
}


stringfog {
    // 这是加解密key，可以自由定义。
    key "${string_key}"
    // 开关
    enable true
    // 加解密库的实现类路径，需和上面配置的加解密算法库一致。
    implementation 'com.github.megatronking.stringfog.xor.StringFogImpl'
    // 指定需加密的代码包路径，可配置多个，未指定将默认全部加密。
//    fogPackages = ['com.xxx.xxx']
}

