apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'privacy-sentry-plugin'

android {
    compileSdkVersion 34
    buildToolsVersion "34.0.0"
    namespace "com.yl.lib.privacysentry"
    defaultConfig {
        applicationId "com.yl.lib.privacysentry"
        minSdkVersion 19
        targetSdkVersion 34
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    signingConfigs {
        release {
            storeFile file("../privacy")
            storePassword "123456"
            keyAlias "privacy"
            keyPassword "123456"
            v2SigningEnabled true
        }
    }

    buildTypes {
        debug {
            debuggable true
            signingConfig signingConfigs.release //使用release签名
        }
        release {
            debuggable true
            jniDebuggable false
            shrinkResources false
            minifyEnabled true
            signingConfig signingConfigs.release //使用release签
            zipAlignEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    lintOptions {
        abortOnError false
    }

}

dependencies {
    api fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.core:core-ktx:1.9.0'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'com.google.android.material:material:1.9.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
    implementation "androidx.multidex:multidex:2.0.1"
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

    if (rootProject.ext.build.local_debug) {
        implementation project(":hook-sentry")
        implementation project(":privacy-proxy")
        implementation project(":privacy-replace")
        implementation project(":privacy-annotation")
    } else {
        def privacyVersion = rootProject.ext.publish_config['version']
        implementation "com.github.allenymt.PrivacySentry:hook-sentry:$privacyVersion"
        implementation "com.github.allenymt.PrivacySentry:privacy-annotation:$privacyVersion"
        //  测试自定义拦截就注释掉
        implementation "com.github.allenymt.PrivacySentry:privacy-proxy:$privacyVersion"
        // 新增类替换，主要是为了hook构造函数的参数
        implementation "com.github.allenymt.PrivacySentry:privacy-replace:$privacyVersion"
    }
    implementation(project(path: ':privacy-test')) {
        exclude module: 'privacy-annotation'
    }
    implementation "androidx.exifinterface:exifinterface:1.3.6"
    implementation "androidx.work:work-runtime-ktx:2.8.1"
    implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
    implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.2"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'
    // 测试SHA-256 digest error问题
//    api "org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5"
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

}


privacy {
    // 设置免hook的名单
    blackList = []
    // 开关PrivacySentry插件功能，核心功能开关，默认为true
    enablePrivacy = true

    // 开启hook反射的方法,默认为false,按需打开
    hookReflex = false
    // 配置反射拦截 反射获取小米系统的oaid、aaid、vaid,例如极光、个推、穿山甲等SDK都有获取
    reflexMap = ["com.android.id.impl.IdProviderImpl":["getOAID","getAAID","getVAID"]]


    ///// *************后续不再维护，只保留hook方法的核心功能****************
    // 默认为false,按需打开
    hookConstructor = false
    // 默认为false,按需打开
    hookField = false


    //*************以下是分割线，主要是对Service的自启动优化处理,默认为false,按需打开****************
    // 处理Manifest文件，主要是处理Service的Priority ， 关闭Service的Export
    enableProcessManifest = false
    // hook Service的部分代码，修复在MIUI上的自启动问题
    // 部分Service把自己的Priority设置为1000，这里开启代理功能，可以代理成0
    enableReplacePriority = false
    replacePriority = 1

    // 支持关闭Service的Export功能，默认为false，注意部分厂商通道之类的push(xiaomi、vivo、huawei等厂商的pushService)，不能关闭
    enableCloseServiceExport = false
    // Export白名单Service
    serviceExportPkgWhiteList = ["white"]
    enableHookServiceStartCommand = false
}

project.afterEvaluate {
    project.gradle.taskGraph.whenReady {
        println("=======> print allTasks")
        println(project.gradle.taskGraph.allTasks)
    }
}
