-
Notifications
You must be signed in to change notification settings - Fork 48
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
wuzuchang
committed
Dec 15, 2022
1 parent
b7f4ad3
commit c562f40
Showing
104 changed files
with
4,805 additions
and
1 deletion.
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,47 @@ | ||
name: Android CI | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
name: Build Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
cache: gradle | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Lint | ||
run: ./gradlew trustdevice:lint | ||
|
||
- name: Test | ||
run: ./gradlew trustdevice:test | ||
|
||
- name: Build library | ||
run: ./gradlew trustdevice:assembleRelease | ||
|
||
- name: Save library to artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
path: trustdevice/build/outputs/aar/* | ||
|
||
- name: Build App | ||
run: ./gradlew app:assembleRelease | ||
|
||
- name: Save application to artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
path: app/build/outputs/apk/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,90 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
|
||
release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: checkout code | ||
uses: actions/checkout@v3 | ||
- name: set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
cache: gradle | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Lint | ||
run: ./gradlew trustdevice:lint | ||
|
||
- name: Test | ||
run: ./gradlew trustdevice:test | ||
|
||
- name: Build library | ||
run: ./gradlew trustdevice:assembleRelease | ||
|
||
# - name: Save library to artifacts | ||
# uses: actions/upload-artifact@v2 | ||
# with: | ||
# path: trustdevice/build/outputs/aar/* | ||
|
||
- name: Build App | ||
run: ./gradlew app:assembleRelease | ||
|
||
# - name: Save application to artifacts | ||
# uses: actions/upload-artifact@v3 | ||
# with: | ||
# path: app/build/outputs/apk/release/* | ||
|
||
# - name: Download artifact | ||
# uses: actions/download-artifact@v3 | ||
|
||
- name: Display structure of downloaded files | ||
run: ls -R | ||
|
||
- name: Set release name | ||
run: echo RELEASE_NAME=${GITHUB_REF} >> $GITHUB_ENV | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ env.RELEASE_NAME }} | ||
body: | ||
The first version of trustdevice-android library. | ||
draft: false | ||
prerelease: false | ||
|
||
- name: Upload aar to release | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./trustdevice/build/outputs/aar/trustdevice-release.aar | ||
asset_name: trustdevice-release.aar | ||
# Common MIME types:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types | ||
asset_content_type: application/zip | ||
|
||
- name: Upload apk to release | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./app/build/outputs/apk/release/TrustDevice-release-1.0.0.apk | ||
asset_name: TrustDevice-release-1.0.0.apk | ||
# Common MIME types:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types | ||
asset_content_type: application/zip |
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,4 @@ | ||
/.gradle/ | ||
/.idea/ | ||
/build/ | ||
local.properties |
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 +1,203 @@ | ||
# trustdevice-android | ||
<p align="center"> | ||
<picture> | ||
<source media="(prefers-color-scheme: dark)" srcset="resources/logo_light.png" /> | ||
<source media="(prefers-color-scheme: light)" srcset="resources/logo_dark.png" /> | ||
<img src="resources/logo_dark.png" alt="TrustDevice logo" width="729px" height="67px" /> | ||
</picture> | ||
</p> | ||
<p align="center"> | ||
<a href="https://jitpack.io/#trustdecision/trustdevice-android"> | ||
<img src="https://jitpack.io/v/trustdecision/trustdevice-android.svg" alt="Latest release"> | ||
</a> | ||
<a href="https://github.com/trustdecision/trustdevice-android/actions?workflow=android"> | ||
<img src="https://github.com/trustdecision/trustdevice-android/workflows/Android CI/badge.svg" alt="Build status"> | ||
</a> | ||
<a href="https://android-arsenal.com/api?level=21"> | ||
<img src="https://img.shields.io/badge/API-21%2B-brightgreen.svg" alt="Android minAPI status"> | ||
</a> | ||
</p> | ||
<p align="center"> | ||
<img src="resources/demo.gif" width="320px"> | ||
</p> | ||
|
||
|
||
# TrustDevice-Android | ||
A lightweight library for determining device uniqueness and risk identification. | ||
|
||
Create a device identifier based on basic device information. | ||
|
||
Will remain the same after uninstalling and reinstalling or clearing app data. | ||
|
||
## Quick start | ||
|
||
### 1. Add repository | ||
|
||
Add these lines to your `build.gradle`. | ||
```groovy | ||
allprojects { | ||
repositories { | ||
maven { url 'https://jitpack.io' } | ||
} | ||
} | ||
``` | ||
|
||
If your version of Gradle is 7 or newer, add these lines to your `settings.gradle`: | ||
```groovy | ||
repositories { | ||
... | ||
maven { url 'https://jitpack.io' } | ||
} | ||
``` | ||
|
||
### 2. Add dependency | ||
|
||
Add these lines to `build.gradle` of a module. | ||
```groovy | ||
dependencies { | ||
... | ||
implementation 'com.github.trustdecision:trustdevice-android:1.0.0' | ||
} | ||
``` | ||
|
||
### 3. Get deviceInfo | ||
|
||
DeviceInfo contains device id, risk information and device details. | ||
|
||
#### 3.1. Option 1 | ||
|
||
```java | ||
// initialization | ||
TDRisk.init(context); | ||
|
||
// usage | ||
JSONObject deviceInfo = TDRisk.getBlackbox(); | ||
// Obtain deviceid and risk information through deviceInfo | ||
String deviceID = deviceInfo.optString("device_id"); | ||
JSONObject deviceRisk = deviceInfo.optJSONObject("device_risk_label"); | ||
JSONObject deviceDetail = deviceInfo.optJSONObject("device_detail"); | ||
``` | ||
|
||
`getBlackbox` method executes in the calling thread and takes time to execute. | ||
|
||
#### 3.1.2. Option 2 | ||
|
||
```java | ||
TDRisk.Builder builder = new TDRisk.Builder(); | ||
builder.callback(new TDRiskCallback() { | ||
@Override | ||
public void onEvent(JSONObject deviceInfo) { | ||
// Obtain deviceid and risk information through deviceInfo | ||
String deviceID = deviceInfo.optString("device_id"); | ||
JSONObject deviceRisk = deviceInfo.optJSONObject("device_risk_label"); | ||
JSONObject deviceDetail = deviceInfo.optJSONObject("device_detail"); | ||
} | ||
}); | ||
TDRisk.initWithOptions(context, builder); | ||
``` | ||
|
||
`callback` is in a sub-thread, please do not perform UI operations. | ||
|
||
## Data Sample | ||
|
||
```json | ||
{ | ||
"device_id": "E9BE9A73B4AEA5A94B36FABC0BF5AF302DC332E4BCB7D10F5F5F7B507DF2A782", | ||
"device_risk_label": { | ||
"root": "false", | ||
"debug": "true", | ||
"multiple": "false" | ||
}, | ||
"device_detail": { | ||
"abiType": "arm64-v8a,armeabi-v7a,armeabi", | ||
"accessibilityEnabled": "0", | ||
"adbEnabled": "1", | ||
"allowMockLocation": "0", | ||
"androidId": "5fa5f2bdc283000c", | ||
"androidVersion": "13", | ||
"appList": "com.trustdevice.android", | ||
"availableMemory": "2981945344", | ||
"availableStorage": "50888110080", | ||
"batteryHealthStatus": "good", | ||
"batteryLevel": "76", | ||
"batteryStatus": "charging", | ||
"batteryTemp": "230", | ||
"batteryTotalCapacity": "2800.0", | ||
"brand": "google", | ||
"coresCount": "8", | ||
"country": "CN", | ||
"cpuHardware": "Qualcomm Technologies, Inc SM8150", | ||
"cpuProcessor": "AArch64 Processor rev 14 (aarch64)", | ||
"dataRoaming": "0", | ||
"debug": "true", | ||
"defaultInputMethod": "com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME", | ||
"developmentSettingEnabled": "1", | ||
"display": "TP1A.220624.014", | ||
"filesAbsolutePath": "/data/user/0/com.trustdevice.android/files", | ||
"fingerprint": "google/flame/flame:13/TP1A.220624.014/8819323:user/release-keys", | ||
"gsfId": "", | ||
"hardware": "flame", | ||
"host": "abfarm-release-rbe-64-00043", | ||
"httpProxy": "null", | ||
"kernelVersion": "4.14.276-g8ae7b4ca8564-ab8715030", | ||
"language": "zh", | ||
"manufacturer": "Google", | ||
"mediaDrmId": "A069CC34B11C17F1C390575C794166F83CDE53B0887D2F718EDC901ED337FDF4", | ||
"model": "Pixel 4", | ||
"packageName": "com.trustdevice.android", | ||
"product": "flame", | ||
"root": "false", | ||
"screenBrightness": "63", | ||
"screenOffTimeout": "30000", | ||
"screenResolution": "1080x2280", | ||
"sdkVersion": "33", | ||
"sensorsInfo": "LSM6DSR Accelerometer:STMicro,LIS2MDL Magnetometer:STMicro,LSM6DSR Gyroscope:STMicro,TMD3702V Ambient Light Sensor:AMS", | ||
"systemAppList": "com.google.android.networkstack.tethering,com.google.omadm.trigger", | ||
"timezone": "中国标准时间", | ||
"totalMemory": "5730922496", | ||
"totalStorage": "53684973568", | ||
"touchExplorationEnabled": "0", | ||
"vbMetaDigest": "4ab46ec3675c5251b815ce36de607abdab29cd827ed3bd99a24bd828597a712a" | ||
} | ||
} | ||
``` | ||
|
||
## Open Source Features | ||
|
||
- Basic device ID, This identifier is stable, it will remain the same even after uninstalling and reinstalling your app. But it will be different after factory reset of the device. | ||
- Basic equipment information, which can be used for simple data analysis | ||
- Basic risk identification ability | ||
|
||
| RiskLabel | Risk Description | | ||
| --------- | ------------------------------------------------------------ | | ||
| root | Attackers will have higher privileges and can install many cheating software to affect the normal development of application business. | | ||
| debug | Applications can be modified by attackers at will, and the program will return unexpected values. | | ||
| multiple | Attackers can clone multiple app. | | ||
|
||
Full product comparison: | ||
|
||
| | Open Source | Pro | | ||
| ----------------------------- | ----------- | ---------------- | | ||
| 100% open source | yes | no | | ||
| Device ID | Basic | Extremely stable | | ||
| Device Risk Label | Basic | Extremely rich | | ||
| Device Details | Basic | Extremely rich | | ||
| IP Location | - | ✓ | | ||
| Device Risk Score | - | ✓ | | ||
| Environment Risk Evaluation | - | ✓ | | ||
| Fraud Tools Detection | - | ✓ | | ||
| Behavioral Activity Capturing | - | ✓ | | ||
|
||
## Pro Introduction | ||
|
||
.... | ||
|
||
## TrustDevice Android Demo App | ||
|
||
Try the library features in the [TrustDevice Android Demo App](https://github.com/trustdecision/trustdevice-android/releases/download/1.0.0/TrustDevice-release-1.0.0.apk). | ||
|
||
## Android API support | ||
|
||
trustdevice-android supports API versions from 21 (Android 5.0) and higher. | ||
|
||
## License | ||
This library is MIT licensed. Copyright trustdecision, Inc. 2022. |
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 @@ | ||
/build |
Oops, something went wrong.