-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
318 changed files
with
312 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
## android_privacy_hook | ||
|
||
基于 Booster 对隐私 api 进行 hook,用户同意之前返回空值。同意之后才调用原有的 api。 | ||
|
||
|
||
|
||
## 使用 | ||
|
||
root build.gradle: | ||
```gradle | ||
buildscript { | ||
ext.booster_version = '4.16.2' | ||
ext.privacyhook_version = '0.0.1' | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
dependencies { | ||
// 依赖 booster | ||
classpath "com.didiglobal.booster:booster-gradle-plugin:$booster_version" | ||
// privacyhook:transform | ||
classpath "com.lwjlol.privacyhook:transform:$privacyhook_version" | ||
} | ||
} | ||
``` | ||
|
||
app 的 build.gradle | ||
```gradle | ||
dependencies { | ||
implementation 'com.lwjlol.privacyhook:core:0.0.1' | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.lwjlol.privacyhook.demo | ||
|
||
import android.content.DialogInterface | ||
import android.os.Bundle | ||
import androidx.appcompat.app.AlertDialog | ||
import androidx.appcompat.app.AppCompatActivity | ||
import com.lwjlol.privacyhook.PrivacyHooker | ||
|
||
/** | ||
* @author luwenjie on 2023/5/29 13:51:41 | ||
*/ | ||
class Main : AppCompatActivity() { | ||
private var agree = false | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
PrivacyHooker.isUserAgreed = { | ||
agree | ||
} | ||
val dialog = AlertDialog.Builder(this) | ||
.setPositiveButton( | ||
"同意", | ||
DialogInterface.OnClickListener { dialog, which -> | ||
agree = true | ||
}, | ||
) | ||
.setNegativeButton( | ||
"不同意", | ||
DialogInterface.OnClickListener { dialog, which -> | ||
agree = false | ||
}, | ||
) | ||
.setMessage("是否同意隐私协议?") | ||
dialog.show() | ||
} | ||
|
||
companion object { | ||
private const val TAG = "Main" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,29 @@ | ||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||
buildscript { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath files("transform.jar") | ||
classpath "com.didiglobal.booster:booster-task-analyser:4.16.2" | ||
} | ||
} | ||
plugins { | ||
id 'com.android.application' version '8.0.2' apply false | ||
id 'com.android.library' version '8.0.2' apply false | ||
id 'com.android.application' version '7.4.2' apply false | ||
id 'com.android.library' version '7.4.2' apply false | ||
id 'org.jetbrains.kotlin.android' version '1.8.20' apply false | ||
} | ||
id 'com.didiglobal.booster' version '4.16.2' apply false | ||
} | ||
|
||
// load local.properties | ||
Properties properties = new Properties() | ||
if (project.file('local.properties').exists()) { | ||
properties.load(project.file('local.properties').newDataInputStream()) | ||
properties.entrySet().each { | ||
project.ext.set(it.key, it.value) | ||
} | ||
} | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,20 @@ kotlin.code.style=official | |
# Enables namespacing of each library's R class so that its R class includes only the | ||
# resources declared in the library itself and none from the library's dependencies, | ||
# thereby reducing the size of the R class for that library | ||
android.nonTransitiveRClass=true | ||
android.nonTransitiveRClass=true | ||
|
||
|
||
|
||
LIB_GROUP=com.lwjlol.privacyhook | ||
LIB_VERSION=0.0.1 | ||
LIB_DES=An Android library based on Kotlin Coroutines and DAG(Directd Acyclic Graph), which schdules dependent tasks. | ||
LIB_URL=https://github.com/lwj1994/privacy_hook | ||
|
||
SCM_URL=[email protected]:lwj1994/privacy_hook.git | ||
|
||
DEVELOPER_NAME=wen | ||
DEVELOPER_EMAIL=[email protected] | ||
|
||
LICENSE_NAME=The Apache Software License, Version 2.0 | ||
LICENSE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt | ||
LICENSE_DIST=repo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#Mon May 29 11:44:52 CST 2023 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'signing' | ||
|
||
// 设置group和版本名称 | ||
group = LIB_GROUP | ||
version = LIB_VERSION | ||
|
||
// 如何配置,参考文档:https://developer.android.com/studio/publish-library | ||
task androidSourcesJar(type: Jar) { | ||
classifier = 'sources' | ||
from android.sourceSets.main.java.source | ||
} | ||
|
||
def LIB_ARTIFACT = project.name | ||
println("LIB_ARTIFACT = $LIB_ARTIFACT") | ||
|
||
publishing { | ||
publications { | ||
// release:自定义发布产物名称 | ||
release(MavenPublication) { | ||
artifactId LIB_ARTIFACT | ||
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar") | ||
artifact androidSourcesJar | ||
|
||
pom { | ||
name = LIB_ARTIFACT | ||
description = LIB_DES | ||
url = LIB_URL | ||
licenses { | ||
license { | ||
name = LICENSE_NAME | ||
url = LICENSE_URL | ||
distribution = LICENSE_DIST | ||
} | ||
} | ||
developers { | ||
developer { | ||
name = DEVELOPER_NAME | ||
email = DEVELOPER_EMAIL | ||
} | ||
} | ||
scm { | ||
url = SCM_URL | ||
connection = 'scm:git:github.com/lwj1994/privacy_hook.git' | ||
developerConnection = 'scm:git:ssh://github.com/lwj1994/privacy_hook.git' | ||
} | ||
withXml { | ||
def dependenciesNode = asNode().appendNode('dependencies') | ||
|
||
project.configurations.implementation.allDependencies.each { | ||
def dependencyNode = dependenciesNode.appendNode('dependency') | ||
dependencyNode.appendNode('groupId', it.group) | ||
dependencyNode.appendNode('artifactId', it.name) | ||
dependencyNode.appendNode('version', it.version) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
repositories { | ||
maven { | ||
// change URLs to point to your repos, e.g. http://my.org/repo | ||
def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/' | ||
def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/' | ||
def mavenUrl = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl | ||
url = mavenUrl | ||
|
||
println("publish to mavenUrl=$mavenUrl") | ||
// 校验不支持本地文件目录 | ||
if (mavenUrl.startsWith("https")) { | ||
credentials { | ||
username = ossrhUsername | ||
password = ossrhPassword | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
sign publishing.publications.release | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'signing' | ||
|
||
// 设置group和版本名称 | ||
group = LIB_GROUP | ||
version = LIB_VERSION | ||
|
||
// 如何配置,参考文档:https://developer.android.com/studio/publish-library | ||
java { | ||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
def LIB_ARTIFACT = project.name | ||
println("LIB_ARTIFACT = $LIB_ARTIFACT") | ||
|
||
publishing { | ||
publications { | ||
// release:自定义发布产物名称 | ||
release(MavenPublication) { | ||
afterEvaluate { | ||
from components.java | ||
} | ||
versionMapping { | ||
usage('java-api') { | ||
fromResolutionOf('runtimeClasspath') | ||
} | ||
usage('java-runtime') { | ||
fromResolutionResult() | ||
} | ||
} | ||
|
||
artifactId = LIB_ARTIFACT | ||
|
||
pom { | ||
name = LIB_ARTIFACT | ||
description = LIB_DES | ||
url = LIB_URL | ||
licenses { | ||
license { | ||
name = LICENSE_NAME | ||
url = LICENSE_URL | ||
distribution = LICENSE_DIST | ||
} | ||
} | ||
developers { | ||
developer { | ||
name = DEVELOPER_NAME | ||
email = DEVELOPER_EMAIL | ||
} | ||
} | ||
scm { | ||
url = SCM_URL | ||
} | ||
} | ||
} | ||
} | ||
repositories { | ||
maven { | ||
// change URLs to point to your repos, e.g. http://my.org/repo | ||
def releasesRepoUrl = 'https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/' | ||
def snapshotsRepoUrl = 'https://s01.oss.sonatype.org/content/repositories/snapshots/' | ||
def mavenUrl = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl | ||
url = mavenUrl | ||
|
||
println("publish to mavenUrl=$mavenUrl") | ||
// 校验不支持本地文件目录 | ||
if (mavenUrl.startsWith("https")) { | ||
credentials { | ||
username = ossrhUsername | ||
password = ossrhPassword | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
sign publishing.publications.release | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.