├── app ├── .gitignore ├── demo_release.jks ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── drawable │ │ │ │ ├── item_card_background.xml │ │ │ │ ├── detail_item_divider.xml │ │ │ │ ├── build_info_background.xml │ │ │ │ ├── ic_down_arrow.xml │ │ │ │ ├── ic_up_arrow.xml │ │ │ │ ├── ic_sensor_next.xml │ │ │ │ ├── ic_back.xml │ │ │ │ ├── ic_installed_app.xml │ │ │ │ ├── ic_sensor_temperature.xml │ │ │ │ ├── ic_phone.xml │ │ │ │ ├── ic_sensor_step.xml │ │ │ │ ├── ic_sensor_magnetic_field.xml │ │ │ │ ├── ic_sensor_heartrate.xml │ │ │ │ ├── ic_battery.xml │ │ │ │ ├── ic_sensor_private.xml │ │ │ │ ├── ic_sensor_all.xml │ │ │ │ ├── ic_random_access_memory.xml │ │ │ │ ├── ic_sensor_tilt.xml │ │ │ │ ├── ic_sensor_humidity.xml │ │ │ │ ├── ic_internal_storage.xml │ │ │ │ ├── ic_sensor_orientation.xml │ │ │ │ ├── ic_sensor_pressure.xml │ │ │ │ ├── ic_sensor_proximity.xml │ │ │ │ ├── ic_setting.xml │ │ │ │ ├── ic_sensor_gravity.xml │ │ │ │ ├── ic_sensor_light.xml │ │ │ │ ├── ic_sensor_accelerometer.xml │ │ │ │ ├── ic_sensor_motion.xml │ │ │ │ ├── ic_sensor_gyroscope.xml │ │ │ │ ├── ic_sensor_hinge.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── xml │ │ │ │ ├── backup_rules.xml │ │ │ │ └── data_extraction_rules.xml │ │ │ ├── values-night │ │ │ │ ├── colors.xml │ │ │ │ └── themes.xml │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── themes.xml │ │ │ │ └── strings.xml │ │ │ ├── layout │ │ │ │ ├── activity_app_list.xml │ │ │ │ ├── item_details.xml │ │ │ │ ├── item_app_list.xml │ │ │ │ ├── include_installed_app_list.xml │ │ │ │ ├── include_sensor_list.xml │ │ │ │ ├── include_setting_info.xml │ │ │ │ ├── include_title_layout.xml │ │ │ │ ├── activity_splash.xml │ │ │ │ ├── include_build_info.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── fragment_device_info.xml │ │ │ │ └── include_battery_info.xml │ │ │ ├── values-zh-rCN │ │ │ │ └── strings.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── kotlin │ │ │ └── cn │ │ │ │ └── tongdun │ │ │ │ └── android │ │ │ │ ├── beans │ │ │ │ ├── DetailsItemBean.kt │ │ │ │ ├── AppItemData.kt │ │ │ │ └── DeviceModuleItemBean.kt │ │ │ │ ├── MyApplication.kt │ │ │ │ ├── base │ │ │ │ ├── BaseFragment.kt │ │ │ │ └── BaseActivity.kt │ │ │ │ ├── adapters │ │ │ │ ├── DeviceInfoItemAdapter.kt │ │ │ │ ├── ViewPagerAdapter.kt │ │ │ │ ├── AppListRecyclerViewAdapter.kt │ │ │ │ └── BaseRecyclerViewAdapter.kt │ │ │ │ ├── activitys │ │ │ │ ├── MainActivity.kt │ │ │ │ └── SplashActivity.kt │ │ │ │ └── fragments │ │ │ │ └── DeviceIdFragment.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── cn │ │ │ └── tongdun │ │ │ └── android │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── cn │ │ └── tongdun │ │ └── android │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── trustdevice ├── .gitignore ├── consumer-rules.pro ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── com │ │ │ │ └── trustdecision │ │ │ │ └── android │ │ │ │ └── mobrisk │ │ │ │ └── verification.properties │ │ ├── java │ │ │ └── cn │ │ │ │ └── tongdun │ │ │ │ └── mobrisk │ │ │ │ ├── TDRiskOption.kt │ │ │ │ ├── TDRiskCallback.kt │ │ │ │ ├── providers │ │ │ │ ├── AppListsRawData.kt │ │ │ │ ├── MemoryInfoRawData.kt │ │ │ │ ├── BatteryInfoRawData.kt │ │ │ │ ├── DeviceIdRawData.kt │ │ │ │ ├── SettingInfoRawData.kt │ │ │ │ ├── SensorInfoRawData.kt │ │ │ │ ├── CpuInfoRawData.kt │ │ │ │ ├── RiskInfoRawData.kt │ │ │ │ ├── BuildInfoRawData.kt │ │ │ │ └── DeviceInfoProvider.kt │ │ │ │ ├── core │ │ │ │ ├── tools │ │ │ │ │ ├── EnvUtils.kt │ │ │ │ │ ├── ExceptionSafeExecutor.kt │ │ │ │ │ ├── Logger.kt │ │ │ │ │ ├── JNIHelper.kt │ │ │ │ │ ├── FileUtils.kt │ │ │ │ │ ├── NetworkUtils.kt │ │ │ │ │ ├── StringUtils.kt │ │ │ │ │ ├── Constants.kt │ │ │ │ │ └── DeviceInfoUtils.kt │ │ │ │ └── collectors │ │ │ │ │ ├── VpnCollector.kt │ │ │ │ │ ├── DeviceInfoTamperedCollector.kt │ │ │ │ │ ├── HookCollector.kt │ │ │ │ │ ├── RootCollector.kt │ │ │ │ │ ├── DebugInfoCollector.kt │ │ │ │ │ ├── MagiskCollector.kt │ │ │ │ │ ├── DevicePersonalizationInfoCollector.kt │ │ │ │ │ ├── XposedCollector.kt │ │ │ │ │ ├── SensorsInfoCollector.kt │ │ │ │ │ ├── CpuInfoCollector.kt │ │ │ │ │ ├── BuildInfoCollector.kt │ │ │ │ │ ├── MemoryInfoCollector.kt │ │ │ │ │ ├── DeviceBaseInfoCollector.kt │ │ │ │ │ ├── SettingInfoCollector.kt │ │ │ │ │ ├── AppListCollector.kt │ │ │ │ │ ├── BatteryInfoCollector.kt │ │ │ │ │ ├── AdvertisingIdClient.kt │ │ │ │ │ ├── DeviceIdCollector.kt │ │ │ │ │ └── EmulatorCollector.kt │ │ │ │ ├── TDRisk.kt │ │ │ │ └── beans │ │ │ │ └── DeviceInfo.kt │ │ └── cpp │ │ │ ├── common │ │ │ ├── macro.h │ │ │ └── logger.h │ │ │ ├── trustdevice_utils.h │ │ │ ├── trustdevice_risk.h │ │ │ ├── CMakeLists.txt │ │ │ ├── trustdevice.cpp │ │ │ ├── trustdevice_utils.cpp │ │ │ └── trustdevice_risk.cpp │ ├── test │ │ └── java │ │ │ └── cn │ │ │ └── tongdun │ │ │ └── android │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── cn │ │ └── tongdun │ │ └── android │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── .gitignore ├── resources ├── demo.gif ├── demo_2.gif ├── logo_dark.png └── logo_light.png ├── .gitattributes ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── jitpack.yml ├── settings.gradle ├── .github └── workflows │ ├── android.yml │ └── release.yml ├── LICENSE ├── gradle.properties └── gradlew.bat /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /trustdevice/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /.cxx -------------------------------------------------------------------------------- /trustdevice/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -keep class cn.tongdun.**{*;} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.gradle/ 2 | /.idea/ 3 | /build/ 4 | local.properties 5 | -------------------------------------------------------------------------------- /resources/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trustdecision/trustdevice-android/HEAD/resources/demo.gif -------------------------------------------------------------------------------- /app/demo_release.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trustdecision/trustdevice-android/HEAD/app/demo_release.jks -------------------------------------------------------------------------------- /resources/demo_2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trustdecision/trustdevice-android/HEAD/resources/demo_2.gif -------------------------------------------------------------------------------- /resources/logo_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trustdecision/trustdevice-android/HEAD/resources/logo_dark.png -------------------------------------------------------------------------------- /resources/logo_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trustdecision/trustdevice-android/HEAD/resources/logo_light.png -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.js linguist-detectable=false 2 | *.css linguist-detectable=false 3 | *.html linguist-detectable=false 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trustdecision/trustdevice-android/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trustdecision/trustdevice-android/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trustdecision/trustdevice-android/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trustdecision/trustdevice-android/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trustdecision/trustdevice-android/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trustdecision/trustdevice-android/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /trustdevice/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/kotlin/cn/tongdun/android/beans/DetailsItemBean.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android.beans 2 | 3 | 4 | data class DetailsItemBean( 5 | val name: String, val value: String 6 | ) 7 | -------------------------------------------------------------------------------- /trustdevice/src/main/resources/META-INF/com/trustdecision/android/mobrisk/verification.properties: -------------------------------------------------------------------------------- 1 | #This is the verification token for the com.trustdecision.android:mobrisk SDK. 2 | #Thu Aug 15 01:53:45 PDT 2024 3 | token=SFRFGDU5DFHEPA24CLIK7WIVEE 4 | -------------------------------------------------------------------------------- /jitpack.yml: -------------------------------------------------------------------------------- 1 | before_install: 2 | - yes | sdkmanager "cmake;3.22.1" 3 | - sdk install java 17.0.1-open 4 | - sdk use java 17.0.1-open 5 | install: 6 | - ./gradlew clean 7 | - ./gradlew trustdevice:assembleRelease 8 | - ./gradlew trustdevice:publishMavenJavaPublicationToMavenLocal -------------------------------------------------------------------------------- /app/src/main/res/drawable/item_card_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/TDRiskOption.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk 2 | 3 | /** 4 | * @description: Option 5 | * @author: wuzuchang 6 | * @date: 2023/5/12 7 | */ 8 | class TDRiskOption { 9 | 10 | var partnerCode : String? = null 11 | var callback: TDRiskCallback? = null 12 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/cn/tongdun/android/beans/AppItemData.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android.beans 2 | 3 | import android.graphics.drawable.Drawable 4 | 5 | 6 | data class AppItemData( 7 | val icon: Drawable?, 8 | val appName: String, 9 | val packageName: String, 10 | val versionName: String? 11 | ) 12 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/TDRiskCallback.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk 2 | 3 | import org.json.JSONObject 4 | 5 | /** 6 | * @description: TDRisk Callback 7 | * @author: wuzuchang 8 | * @date: 2023/5/12 9 | */ 10 | interface TDRiskCallback { 11 | fun onEvent(deviceInfo: JSONObject) 12 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/detail_item_divider.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/providers/AppListsRawData.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.providers 2 | 3 | 4 | /** 5 | * @description: 6 | * @author: wuzuchang 7 | * @date: 2023/5/15 8 | */ 9 | data class AppListsRawData(val appList: String, 10 | val systemAppList: String) { 11 | 12 | } -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/tools/EnvUtils.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.tools 2 | 3 | import android.text.TextUtils 4 | import java.io.File 5 | 6 | /** 7 | * @description: 8 | * @author: wuzuchang 9 | * @date: 2023/5/12 10 | */ 11 | object EnvUtils { 12 | fun fileInEnv(fileName: String) = JNIHelper.call4(fileName) 13 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/build_info_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_down_arrow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_up_arrow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/providers/MemoryInfoRawData.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.providers 2 | 3 | /** 4 | * @description:MemoryInfoRawData 5 | * @author: wuzuchang 6 | * @date: 2023/5/16 7 | */ 8 | data class MemoryInfoRawData( 9 | val totalMemory: Long, 10 | val availableMemory: Long, 11 | val totalStorage: Long, 12 | val availableStorage: Long, 13 | ) -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/providers/BatteryInfoRawData.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.providers 2 | 3 | /** 4 | * @description:BatteryInfoRawData 5 | * @author: wuzuchang 6 | * @date: 2023/5/15 7 | */ 8 | data class BatteryInfoRawData( 9 | val health: String, 10 | val status: String, 11 | val temp: Int, 12 | val level: Int, 13 | val totalCapacity: String 14 | ) -------------------------------------------------------------------------------- /app/src/main/kotlin/cn/tongdun/android/beans/DeviceModuleItemBean.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android.beans 2 | 3 | 4 | data class DeviceModuleItemBean( 5 | val moduleName: String, 6 | val detailsItemBeans: List 7 | ) { 8 | constructor( 9 | moduleName: String, 10 | describe: String, 11 | detailsItemBeans: List 12 | ) : this(moduleName, detailsItemBeans) 13 | } 14 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/providers/DeviceIdRawData.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.providers 2 | 3 | /** 4 | * @description:DeviceIdRawData 5 | * @author: wuzuchang 6 | * @date: 2023/5/16 7 | */ 8 | data class DeviceIdRawData( 9 | val deviceId: String, 10 | val androidId: String, 11 | val gsfId: String, 12 | val gadId: String, 13 | val mediaDrmId: String, 14 | val vbMetaDigest: String 15 | ) -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/tools/ExceptionSafeExecutor.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.tools 2 | 3 | import java.lang.Exception 4 | 5 | fun executeSafe(code: () -> T) { 6 | try { 7 | code() 8 | } catch (_: Exception) { 9 | } 10 | } 11 | 12 | fun executeSafe(code: () -> T, defaultValue: T): T { 13 | return try { 14 | code() 15 | } catch (exception: Exception) { 16 | defaultValue 17 | } 18 | } -------------------------------------------------------------------------------- /trustdevice/src/main/cpp/common/macro.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by collam on 2023/6/21. 3 | // 4 | 5 | #ifndef TRUSTDEVICE_ANDROID_MACRO_H 6 | #define TRUSTDEVICE_ANDROID_MACRO_H 7 | 8 | #ifdef __LP64__ 9 | typedef unsigned long long operation_type; 10 | static unsigned long trampoline_code = 0xd61f020058000050; 11 | #else 12 | typedef unsigned long operation_type; 13 | static unsigned long trampoline_code = 0x58000050; 14 | #endif 15 | 16 | #endif //TRUSTDEVICE_ANDROID_MACRO_H 17 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/tools/Logger.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.tools 2 | 3 | import android.util.Log 4 | 5 | /** 6 | * @description: 7 | * @author: wuzuchang 8 | * @date: 2023/5/12 9 | */ 10 | object Logger { 11 | private const val LOG_TAG = "TrustDevice" 12 | 13 | fun d(message: String) { 14 | Log.d(LOG_TAG, message) 15 | } 16 | 17 | fun e(message: String) { 18 | Log.e(LOG_TAG, message) 19 | } 20 | } -------------------------------------------------------------------------------- /app/src/test/java/cn/tongdun/android/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/cn/tongdun/android/MyApplication.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android 2 | 3 | import android.app.Application 4 | import cn.tongdun.mobrisk.TDRisk.init 5 | import com.tencent.mmkv.MMKV 6 | 7 | class MyApplication : Application() { 8 | override fun onCreate() { 9 | super.onCreate() 10 | MMKV.initialize(this) 11 | val isAgree = MMKV.defaultMMKV().decodeBool("isAgreePrivacyAgreement") 12 | if (isAgree) { 13 | init(this) 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/VpnCollector.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.collectors 2 | 3 | import android.content.Context 4 | import cn.tongdun.mobrisk.core.tools.NetworkUtils 5 | 6 | 7 | interface VpnInterface { 8 | fun detectVpn(context:Context?): Boolean 9 | } 10 | 11 | class VpnCollector : VpnInterface { 12 | override fun detectVpn(context:Context?): Boolean { 13 | return NetworkUtils.contain(context,NetworkUtils.TYPE_VPN) 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /trustdevice/src/test/java/cn/tongdun/android/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_next.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/DeviceInfoTamperedCollector.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.collectors 2 | 3 | import android.content.Context 4 | import android.os.Build 5 | 6 | interface DeviceInfoTamperedInterface { 7 | fun tampered(context: Context?): Boolean 8 | } 9 | 10 | class DeviceInfoTamperedCollector : DeviceInfoTamperedInterface { 11 | override fun tampered(context: Context?): Boolean { 12 | return !Build.FINGERPRINT.contains(Build.BRAND,true) 13 | } 14 | } -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/HookCollector.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.collectors 2 | 3 | import cn.tongdun.mobrisk.core.tools.JNIHelper 4 | import cn.tongdun.mobrisk.core.tools.executeSafe 5 | 6 | /** 7 | * @description: 8 | * @author: wuzuchang 9 | * @date: 2023/5/15 10 | */ 11 | interface HookInterface { 12 | fun detectHook(): String 13 | } 14 | 15 | class HookCollector : HookInterface { 16 | override fun detectHook(): String = executeSafe({ JNIHelper.call1() }, "") 17 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_back.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | mavenCentral() 6 | maven { url 'https://jitpack.io' } 7 | } 8 | } 9 | dependencyResolutionManagement { 10 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 11 | repositories { 12 | google() 13 | mavenCentral() 14 | maven { url 'https://jitpack.io' } 15 | } 16 | } 17 | rootProject.name = "trustdevice-android" 18 | include ':app' 19 | include ':trustdevice' 20 | -------------------------------------------------------------------------------- /app/src/main/res/xml/backup_rules.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | -------------------------------------------------------------------------------- /trustdevice/src/main/cpp/trustdevice_utils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zuchangwu on 2023/4/7. 3 | // 4 | 5 | #ifndef TRUSTDEVICE_ANDROID_TRUSTDEVICE_UTILS_H 6 | #define TRUSTDEVICE_ANDROID_TRUSTDEVICE_UTILS_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include "common/logger.h" 12 | 13 | jstring get_property(JNIEnv *env, jobject clazz, jstring _key, jstring _default_value); 14 | bool mem_read_access_by_maps(void *read_addr, size_t len); 15 | char *get_current_thread_name(); 16 | 17 | #endif //TRUSTDEVICE_ANDROID_TRUSTDEVICE_UTILS_H 18 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/providers/SettingInfoRawData.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.providers 2 | 3 | /** 4 | * @description: 5 | * @author: wuzuchang 6 | * @date: 2023/5/16 7 | */ 8 | data class SettingInfoRawData( 9 | val adb: String, 10 | val developmentSetting: String, 11 | val httpProxy: String, 12 | val dataRoaming: String, 13 | val allowMockLocation: String, 14 | val accessibility: String, 15 | val defaultInputMethod: String, 16 | val touchExplorationEnabled: String, 17 | val screenOffTimeout: String 18 | ) -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/RootCollector.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.collectors 2 | 3 | import cn.tongdun.mobrisk.core.tools.EnvUtils 4 | import cn.tongdun.mobrisk.core.tools.JNIHelper 5 | 6 | /** 7 | * @description: 8 | * @author: wuzuchang 9 | * @date: 2023/5/15 10 | */ 11 | 12 | interface RootInterface { 13 | fun getRoot(): Boolean 14 | } 15 | 16 | class RootCollector : RootInterface { 17 | override fun getRoot(): Boolean { 18 | return EnvUtils.fileInEnv("su") || checkProp() 19 | } 20 | 21 | private fun checkProp() = JNIHelper.call2("ro.secure","1") == "0" 22 | } -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/tools/JNIHelper.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.tools 2 | 3 | import androidx.annotation.Keep 4 | 5 | /** 6 | * @description: 7 | * @author: wuzuchang 8 | * @date: 2023/5/12 9 | */ 10 | @Keep 11 | object JNIHelper { 12 | //detect debug 13 | external fun call0(): Int 14 | //detect hook 15 | external fun call1(): String 16 | //get property 17 | external fun call2(key: String, defaultValue: String): String 18 | //mount files time compare 19 | external fun call3(): Boolean 20 | //check bin on environment variables 21 | external fun call4(binName: String): Boolean 22 | } -------------------------------------------------------------------------------- /app/src/main/res/xml/data_extraction_rules.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 12 | 13 | 19 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/providers/SensorInfoRawData.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.providers 2 | 3 | import android.text.TextUtils 4 | import cn.tongdun.mobrisk.core.tools.executeSafe 5 | import org.json.JSONArray 6 | 7 | /** 8 | * @description:SensorInfoRawData 9 | * @author: wuzuchang 10 | * @date: 2023/5/16 11 | */ 12 | data class SensorInfoRawData(val sensorInfo: String) { 13 | fun getSensorTotal(): Int { 14 | if (TextUtils.isEmpty(sensorInfo)) { 15 | return 0 16 | } 17 | var sensorArray: JSONArray? = null 18 | executeSafe { sensorArray = JSONArray(sensorInfo) } 19 | return sensorArray?.length() ?: 0 20 | } 21 | } -------------------------------------------------------------------------------- /app/src/main/res/values-night/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | #222222 11 | #1B1B1B 12 | @color/white 13 | @color/white 14 | #232323 15 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/providers/CpuInfoRawData.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.providers 2 | 3 | import android.util.Pair 4 | 5 | /** 6 | * @description:CpuInfoRawData 7 | * @author: wuzuchang 8 | * @date: 2023/5/15 9 | */ 10 | data class CpuInfoRawData( 11 | val cpuHardware: String, 12 | val cpuProcessor: String, 13 | val abiType: String, 14 | val coresCount: String 15 | ) { 16 | fun getRawData(): List> = mutableListOf>().apply { 17 | add(Pair("hardware", cpuHardware)) 18 | add(Pair("processor", cpuProcessor)) 19 | add(Pair("abi type", abiType)) 20 | add(Pair("cores count", coresCount)) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/DebugInfoCollector.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.collectors 2 | 3 | import android.os.Debug 4 | import cn.tongdun.mobrisk.core.tools.JNIHelper 5 | import cn.tongdun.mobrisk.core.tools.executeSafe 6 | 7 | /** 8 | * @description:Debug info 9 | * @author: wuzuchang 10 | * @date: 2023/5/15 11 | */ 12 | interface DebugInfoInterface { 13 | fun getDebug(): Int 14 | } 15 | 16 | class DebugInfoCollector : DebugInfoInterface { 17 | override fun getDebug(): Int { 18 | var result = 0 19 | if (Debug.isDebuggerConnected()) { 20 | result = result or 0x1 21 | } 22 | val ret: Int = executeSafe({ JNIHelper.call0() }, 0) 23 | result = result or ret 24 | return result 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | #52B456 11 | #F5F5F5 12 | @color/white 13 | @color/black 14 | @color/black 15 | #F2F2F2 16 | #FF6C5C 17 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/MagiskCollector.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.collectors 2 | 3 | import cn.tongdun.mobrisk.core.tools.EnvUtils 4 | import cn.tongdun.mobrisk.core.tools.JNIHelper 5 | 6 | /** 7 | * @description: 8 | * @author: wuzuchang 9 | * @date: 2023/5/15 10 | */ 11 | interface MagiskInterface { 12 | fun detectMagisk(): Boolean 13 | } 14 | 15 | class MagiskCollector : MagiskInterface { 16 | 17 | override fun detectMagisk(): Boolean { 18 | return detectMagiskByFile() || detectMagiskByLastModified() 19 | } 20 | 21 | private fun detectMagiskByLastModified(): Boolean { 22 | return JNIHelper.call3() 23 | } 24 | 25 | private fun detectMagiskByFile(): Boolean { 26 | return EnvUtils.fileInEnv("magisk") 27 | } 28 | } -------------------------------------------------------------------------------- /trustdevice/src/main/cpp/trustdevice_risk.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by zuchangwu on 2023/4/10. 3 | // 4 | 5 | #ifndef TRUSTDEVICE_ANDROID_TRUSTDEVICE_RISK_H 6 | #define TRUSTDEVICE_ANDROID_TRUSTDEVICE_RISK_H 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "trustdevice_utils.h" 19 | #include "common/macro.h" 20 | #include "common/logger.h" 21 | 22 | jint detect_debug(JNIEnv *env, jobject clazz); 23 | jstring detect_hook(JNIEnv *env, jobject clazz); 24 | jboolean detectMagiskByMount(JNIEnv *env, jobject __unused); 25 | jboolean checkBinInEnv(JNIEnv *env, jobject __unused,jstring binName); 26 | #endif //TRUSTDEVICE_ANDROID_TRUSTDEVICE_RISK_H 27 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/main/kotlin/cn/tongdun/android/base/BaseFragment.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android.base 2 | 3 | import android.os.Bundle 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import androidx.fragment.app.Fragment 8 | import androidx.viewbinding.ViewBinding 9 | 10 | abstract class BaseFragment : Fragment() { 11 | private lateinit var _binding: T 12 | protected val binding get() = _binding; 13 | override fun onCreateView( 14 | inflater: LayoutInflater, 15 | container: ViewGroup?, 16 | savedInstanceState: Bundle? 17 | ): View? { 18 | _binding = getViewBinding(inflater, container) 19 | return _binding.root 20 | } 21 | 22 | protected abstract fun getViewBinding(inflater: LayoutInflater, container: ViewGroup?): T 23 | } -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/DevicePersonalizationInfoCollector.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.collectors 2 | 3 | import java.util.* 4 | 5 | /** 6 | * @description:Device Personalization Info 7 | * @author: wuzuchang 8 | * @date: 2023/5/15 9 | */ 10 | interface DevicePersonalizationInfoInterface { 11 | fun getLocaleCountry(): String? 12 | fun getDefaultLanguage(): String? 13 | fun getTimezone(): String? 14 | } 15 | 16 | class DevicePersonalizationInfoCollector : DevicePersonalizationInfoInterface { 17 | override fun getLocaleCountry(): String? { 18 | return Locale.getDefault().country 19 | } 20 | 21 | override fun getDefaultLanguage(): String? { 22 | return Locale.getDefault().language 23 | } 24 | 25 | override fun getTimezone(): String? { 26 | return TimeZone.getDefault().displayName 27 | } 28 | } -------------------------------------------------------------------------------- /trustdevice/src/androidTest/java/cn/tongdun/android/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 23 | assertEquals("cn.tongdun.android.test", appContext.getPackageName()); 24 | } 25 | } -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/XposedCollector.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.collectors 2 | 3 | /** 4 | * @description: 5 | * @author: wuzuchang 6 | * @date: 2023/5/15 7 | */ 8 | interface XposedInterface { 9 | fun findXposed(): Boolean 10 | } 11 | 12 | class XposedCollector : XposedInterface { 13 | override fun findXposed(): Boolean { 14 | val xposedClasses = arrayOf( 15 | "de.robv.android.xposed.XposedBridge", 16 | "de.robv.android.xposed.IXposedHookLoadPackage", 17 | "de.robv.android.xposed.DexposedBridge" 18 | ) 19 | for (className in xposedClasses) { 20 | try { 21 | Class.forName(className, true, ClassLoader.getSystemClassLoader()) 22 | return true 23 | } catch (ignore: Exception) { 24 | } 25 | } 26 | return false 27 | } 28 | } -------------------------------------------------------------------------------- /app/src/androidTest/java/cn/tongdun/android/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android; 2 | 3 | import android.content.Context; 4 | 5 | import androidx.test.platform.app.InstrumentationRegistry; 6 | import androidx.test.ext.junit.runners.AndroidJUnit4; 7 | 8 | import org.junit.Test; 9 | import org.junit.runner.RunWith; 10 | 11 | import static org.junit.Assert.*; 12 | 13 | /** 14 | * Instrumented test, which will execute on an Android device. 15 | * 16 | * @see Testing documentation 17 | */ 18 | @RunWith(AndroidJUnit4.class) 19 | public class ExampleInstrumentedTest { 20 | @Test 21 | public void useAppContext() { 22 | // Context of the app under test. 23 | Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); 24 | assertEquals("com.trustdevice.android", appContext.getPackageName()); 25 | } 26 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/cn/tongdun/android/adapters/DeviceInfoItemAdapter.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android.adapters 2 | 3 | import android.text.TextUtils 4 | import android.util.Pair 5 | import android.view.View 6 | import android.widget.TextView 7 | import com.trustdevice.android.demo.R 8 | 9 | 10 | class DeviceInfoItemAdapter(data: List>) : BaseRecyclerViewAdapter>(data) { 11 | override fun getLayoutId(viewType: Int): Int { 12 | return R.layout.item_details 13 | } 14 | 15 | override fun convert(holder: BaseViewHolder, data: Pair, position: Int) { 16 | val name = holder.getView(R.id.tv_name) 17 | name?.text = data.first 18 | val value = holder.getView(R.id.tv_value) 19 | if (TextUtils.isEmpty(data.second)) { 20 | value?.visibility = View.GONE 21 | } else { 22 | value?.text = data.second 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | -------------------------------------------------------------------------------- /app/src/main/kotlin/cn/tongdun/android/adapters/ViewPagerAdapter.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android.adapters 2 | 3 | import androidx.fragment.app.Fragment 4 | import androidx.fragment.app.FragmentManager 5 | import androidx.lifecycle.Lifecycle 6 | import androidx.viewpager2.adapter.FragmentStateAdapter 7 | import cn.tongdun.android.fragments.DeviceIdFragment 8 | import cn.tongdun.android.fragments.DeviceInfoFragment 9 | 10 | 11 | class ViewPagerAdapter( 12 | private val itemCount: Int, 13 | fragmentManager: FragmentManager, 14 | lifecycle: Lifecycle 15 | ) : 16 | FragmentStateAdapter(fragmentManager, lifecycle) { 17 | override fun createFragment(position: Int): Fragment { 18 | if (position == 0) { 19 | return DeviceIdFragment() 20 | } else if (position == 1) { 21 | return DeviceInfoFragment() 22 | } 23 | return DeviceIdFragment() 24 | } 25 | 26 | override fun getItemCount(): Int { 27 | return itemCount 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_installed_app.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18 | -------------------------------------------------------------------------------- /trustdevice/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | -verbose 4 | -dontusemixedcaseclassnames 5 | 6 | #-dontskipnonpubliclibraryclasses 7 | -dontoptimize 8 | -dontnote java.**, javax.**, org.** 9 | -dontwarn android.support.** 10 | #-overloadaggressively 11 | 12 | #-allowaccessmodification 13 | 14 | #-useuniqueclassmembernames 15 | 16 | -keepattributes SourceFile, LineNumberTable, *Annotation*, Exceptions, InnerClasses 17 | 18 | -keep class cn.tongdun.mobrisk.TDRisk { 19 | public static *; 20 | public *; 21 | } 22 | -keep class cn.tongdun.mobrisk.TDRisk$Builder { 23 | public static *; 24 | public *; 25 | } 26 | -keep class cn.tongdun.mobrisk.beans.DeviceInfo { 27 | private *; 28 | } 29 | -keep class cn.tongdun.mobrisk.providers.** { 30 | public *; 31 | } 32 | -keep interface cn.tongdun.mobrisk.TDRiskCallback {*;} 33 | 34 | -keepclasseswithmembernames class * { 35 | native ; 36 | } -------------------------------------------------------------------------------- /.github/workflows/android.yml: -------------------------------------------------------------------------------- 1 | name: Android CI 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build: 11 | 12 | name: Build Release 13 | runs-on: ubuntu-latest 14 | 15 | steps: 16 | - name: Checkout code 17 | uses: actions/checkout@v3 18 | - name: Set up JDK 19 | uses: actions/setup-java@v3 20 | with: 21 | java-version: '17' 22 | distribution: 'temurin' 23 | cache: gradle 24 | 25 | - name: Grant execute permission for gradlew 26 | run: chmod +x gradlew 27 | 28 | - name: Get latest ninja 29 | uses: urkle/action-get-ninja@v1 30 | 31 | - name: Setup CMake 32 | uses: jwlawson/actions-setup-cmake@v1 33 | with: 34 | cmake-version: '3.22.1' 35 | 36 | - name: Lint 37 | run: ./gradlew trustdevice:lint 38 | 39 | - name: Test 40 | run: ./gradlew trustdevice:test 41 | 42 | - name: Build library 43 | run: ./gradlew trustdevice:assembleRelease -------------------------------------------------------------------------------- /trustdevice/src/main/cpp/common/logger.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by collam on 2023/6/21. 3 | // 4 | 5 | #ifndef TRUSTDEVICE_ANDROID_LOGGER_H 6 | #define TRUSTDEVICE_ANDROID_LOGGER_H 7 | 8 | #include 9 | #include "../trustdevice_utils.h" 10 | 11 | #define TAG "TrustDevice_native" 12 | 13 | #ifdef DEBUG 14 | 15 | #define LOG(_level,...) do { \ 16 | char logBuffer[4096]; \ 17 | snprintf(logBuffer, sizeof(logBuffer), __VA_ARGS__); \ 18 | __android_log_print(_level,TAG,"[%s] %s",get_current_thread_name(),logBuffer); \ 19 | } while(false) 20 | 21 | #define LOGI(...) LOG(ANDROID_LOG_INFO,__VA_ARGS__) 22 | #define LOGV(...) LOG(ANDROID_LOG_VERBOSE,__VA_ARGS__) 23 | #define LOGD(...) LOG(ANDROID_LOG_DEBUG, __VA_ARGS__) 24 | #define LOGW(...) LOG(ANDROID_LOG_WARN,__VA_ARGS__) 25 | #else 26 | #define LOGI(...) 27 | #define LOGV(...) 28 | #define LOGD(...) 29 | #define LOGW(...) 30 | #endif 31 | 32 | #endif //TRUSTDEVICE_ANDROID_LOGGER_H 33 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_temperature.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_phone.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_step.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_magnetic_field.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /trustdevice/src/main/cpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.22.1) 2 | 3 | project("trustdevice") 4 | 5 | add_library( 6 | tddevicefingerprint 7 | 8 | SHARED 9 | 10 | trustdevice.cpp 11 | trustdevice_utils.cpp 12 | trustdevice_risk.cpp) 13 | 14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") 15 | 16 | find_library( 17 | log-lib 18 | log) 19 | 20 | message("Current build type: ${CMAKE_BUILD_TYPE}") 21 | if(CMAKE_BUILD_TYPE MATCHES Debug) 22 | # Debug build settings 23 | add_definitions(-DDEBUG) 24 | message("Open log & keep symbols") 25 | else() 26 | # Release build settings 27 | add_definitions(-DNDEBUG) 28 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden") 29 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") 30 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--exclude-libs,ALL -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384") 31 | message("Close log & strip symbols") 32 | endif() 33 | 34 | target_link_libraries( 35 | tddevicefingerprint 36 | ${log-lib}) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 trustdecision 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_heartrate.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/tools/FileUtils.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.tools 2 | 3 | import java.io.* 4 | import java.nio.charset.StandardCharsets 5 | 6 | /** 7 | * @description: 8 | * @author: wuzuchang 9 | * @date: 2023/5/12 10 | */ 11 | object FileUtils { 12 | fun readFileByKey(fileName: String, keys: List, sep: String): Map { 13 | val info: MutableMap = mutableMapOf() 14 | val file = File(fileName) 15 | if (!file.exists()) { 16 | return info 17 | } 18 | file.readLines().forEach { line-> 19 | if (line.isEmpty()) { 20 | return@forEach 21 | } 22 | val params: List = line.splitNonRegex(sep) 23 | var paramName = "" 24 | if (params.isNotEmpty() && params[0].trim().also { 25 | paramName = it 26 | }.isNotEmpty()) { 27 | if (keys.contains(paramName)) { 28 | if (params.size > 1) { 29 | info[paramName] = params[1].trim() 30 | } 31 | } 32 | } 33 | } 34 | return info 35 | } 36 | } -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/SensorsInfoCollector.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.collectors 2 | 3 | import android.hardware.Sensor 4 | import android.hardware.SensorManager 5 | import cn.tongdun.mobrisk.core.tools.executeSafe 6 | import org.json.JSONArray 7 | import org.json.JSONObject 8 | 9 | /** 10 | * @description:Sensors Info 11 | * @author: wuzuchang 12 | * @date: 2023/5/15 13 | */ 14 | interface SensorsInfoInterface { 15 | fun getSensorList(): String 16 | } 17 | 18 | class SensorsInfoCollector(private val sensorManager: SensorManager) : SensorsInfoInterface { 19 | override fun getSensorList(): String { 20 | val sensorArray = JSONArray() 21 | executeSafe { 22 | val sensorList: List = sensorManager.getSensorList(Sensor.TYPE_ALL) 23 | for (i in sensorList.indices) { 24 | val sensor = sensorList[i] 25 | val sensorInfo = JSONObject() 26 | sensorInfo.put("name", sensor.name) 27 | sensorInfo.put("vendor", sensor.vendor) 28 | sensorInfo.put("type", sensor.type) 29 | sensorArray.put(i, sensorInfo) 30 | } 31 | } 32 | return sensorArray.toString() 33 | } 34 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/cn/tongdun/android/adapters/AppListRecyclerViewAdapter.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android.adapters 2 | 3 | import android.annotation.SuppressLint 4 | import android.widget.ImageView 5 | import android.widget.TextView 6 | import cn.tongdun.android.beans.AppItemData 7 | import com.trustdevice.android.demo.R 8 | 9 | /** 10 | * @description: 11 | * @author: wuzuchang 12 | * @date: 2023/5/16 13 | */ 14 | class AppListRecyclerViewAdapter(private var _data: List) : BaseRecyclerViewAdapter(_data) { 15 | 16 | override fun getLayoutId(viewType: Int): Int { 17 | return R.layout.item_app_list 18 | } 19 | 20 | override fun convert(holder: BaseViewHolder, data: AppItemData?, position: Int) { 21 | val iv_icon: ImageView? = holder.getView(R.id.iv_app_icon) 22 | iv_icon?.setImageDrawable(data?.icon) 23 | val tv_app_name: TextView? = holder.getView(R.id.tv_app_name) 24 | tv_app_name?.text = data?.appName?:"" 25 | val tv_application: TextView? = holder.getView(R.id.tv_application) 26 | tv_application?.text = data?.packageName?:"" 27 | } 28 | 29 | 30 | fun updateData(data: List) { 31 | _data = data 32 | notifyDataSetChanged() 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /trustdevice/src/main/cpp/trustdevice.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "trustdevice_risk.h" 3 | #include "trustdevice_utils.h" 4 | 5 | // Define JNI methods to be registered 6 | static JNINativeMethod jniMethods[] = { 7 | {"call0", "()I", (void *) detect_debug}, 8 | {"call1", "()Ljava/lang/String;", (void *) detect_hook}, 9 | {"call2", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;", (void *) get_property}, 10 | {"call3", "()Z", (void *) detectMagiskByMount}, 11 | {"call4", "(Ljava/lang/String;)Z", (void *) checkBinInEnv} 12 | }; 13 | 14 | // Define JNI library registration function 15 | JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *__unused) { 16 | JNIEnv *env = nullptr; 17 | jclass clazz = NULL; 18 | 19 | if (vm->GetEnv((void **) &env, JNI_VERSION_1_6) != JNI_OK) { 20 | goto err_exit; 21 | } 22 | 23 | clazz = env->FindClass("cn/tongdun/mobrisk/core/tools/JNIHelper"); 24 | 25 | if (clazz == nullptr) { 26 | goto err_exit; 27 | } 28 | if (env->RegisterNatives(clazz, jniMethods, sizeof(jniMethods) / sizeof(jniMethods[0])) < 0) { 29 | goto err_exit; 30 | } 31 | LOGD("JNI_OnLoad called!"); 32 | 33 | return JNI_VERSION_1_6; 34 | err_exit: 35 | return JNI_ERR; 36 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Enables namespacing of each library's R class so that its R class includes only the 19 | # resources declared in the library itself and none from the library's dependencies, 20 | # thereby reducing the size of the R class for that library 21 | android.nonTransitiveRClass=true -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_app_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/providers/RiskInfoRawData.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.providers 2 | 3 | import cn.tongdun.mobrisk.core.tools.Constants 4 | 5 | /** 6 | * @description:RiskInfoRawData 7 | * @author: wuzuchang 8 | * @date: 2023/5/16 9 | */ 10 | data class RiskInfoRawData( 11 | val root: Boolean, 12 | val debug: Boolean, 13 | val multiple: Boolean, 14 | val xposed: Boolean, 15 | val magisk: Boolean, 16 | val hook: Boolean, 17 | val emulator: Boolean, 18 | val vpn: Boolean, 19 | val deviceInfoTampered: Boolean 20 | ) { 21 | 22 | override fun toString(): String { 23 | val risks = arrayOf( 24 | root.takeIf { it }?.let { Constants.KEY_ROOT }, 25 | debug.takeIf { it }?.let { Constants.KEY_DEBUG }, 26 | multiple.takeIf { it }?.let { Constants.KEY_MULTIPLE }, 27 | xposed.takeIf { it }?.let { Constants.KEY_XPOSED }, 28 | magisk.takeIf { it }?.let { Constants.KEY_MAGISK }, 29 | hook.takeIf { it }?.let { Constants.KEY_HOOK }, 30 | emulator.takeIf { it }?.let { Constants.KEY_EMULATOR }, 31 | vpn.takeIf { it }?.let { Constants.KEY_VPN }, 32 | deviceInfoTampered.takeIf { it }?.let { Constants.KEY_DEVICE_INFO_TAMPERED } 33 | ) 34 | return risks.filterNotNull().joinToString() 35 | } 36 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/cn/tongdun/android/base/BaseActivity.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android.base 2 | 3 | import android.content.Context 4 | import android.content.res.Configuration 5 | import android.os.Bundle 6 | import android.view.View 7 | import androidx.appcompat.app.AppCompatActivity 8 | import androidx.viewbinding.ViewBinding 9 | 10 | abstract class BaseActivity : AppCompatActivity() { 11 | private lateinit var _binding: T 12 | protected val binding get() = _binding 13 | 14 | protected lateinit var mContext: Context 15 | override fun onCreate(savedInstanceState: Bundle?) { 16 | super.onCreate(savedInstanceState) 17 | mContext = this 18 | _binding = getViewBinding() 19 | setContentView(_binding.root) 20 | 21 | if (resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK == Configuration.UI_MODE_NIGHT_YES) { 22 | window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR 23 | } else { 24 | window.decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR 25 | } 26 | 27 | initData() 28 | initView() 29 | } 30 | 31 | protected abstract fun getViewBinding(): T 32 | 33 | protected abstract fun initData() 34 | protected abstract fun initView() 35 | override fun onDestroy() { 36 | super.onDestroy() 37 | } 38 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_battery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/values-zh-rCN/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TrustDevice Fingerprint 4 | 设备ID 5 | Android ID 6 | 风险标签 7 | 谷歌服务框架ID 8 | 谷歌广告ID 9 | 数字版权管理ID 10 | vbmeta摘要 11 | 设置 12 | 内部存储 13 | 运行内存 14 | 电池 15 | 应用 16 | 传感器 17 | 应用列表 18 | 显示系统应用 19 | 隐藏系统应用 20 | 传感器列表 21 | 设备ID 22 | 设备信息 23 | 实时的运行内存 24 | 剩余 25 | 总容量 26 | 健康状况 27 | 温度 28 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_private.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_all.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_random_access_memory.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_tilt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/providers/BuildInfoRawData.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.providers 2 | 3 | import android.util.Pair 4 | 5 | /** 6 | * @description: 7 | * @author: wuzuchang 8 | * @date: 2023/5/15 9 | */ 10 | data class BuildInfoRawData( 11 | val model: String, 12 | val brand: String, 13 | val manufacturer: String, 14 | val androidVersion: String, 15 | val sdkVersion: String, 16 | val kernelVersion: String, 17 | val fingerprint: String, 18 | val host: String, 19 | val screenResolution: String, 20 | val screenInches: String, 21 | val screenBrightness: String, 22 | val screenOffTimeout: String 23 | ) { 24 | fun getRawData(): List> = mutableListOf>().apply { 25 | add(Pair("model", model)) 26 | add(Pair("brand", brand)) 27 | add(Pair("manufacturer", manufacturer)) 28 | add(Pair("android version", androidVersion)) 29 | add(Pair("sdk version", sdkVersion)) 30 | add(Pair("kernel version", kernelVersion)) 31 | add(Pair("fingerprint", fingerprint)) 32 | add(Pair("host", host)) 33 | add(Pair("screen resolution", screenResolution)) 34 | add(Pair("screen inches", screenInches)) 35 | add(Pair("screen brightness", screenBrightness)) 36 | } 37 | } -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/CpuInfoCollector.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.collectors 2 | 3 | import android.os.Build 4 | import android.text.TextUtils 5 | import cn.tongdun.mobrisk.core.tools.FileUtils 6 | import cn.tongdun.mobrisk.core.tools.executeSafe 7 | 8 | /** 9 | * @description:Cpu Info 10 | * @author: wuzuchang 11 | * @date: 2023/5/15 12 | */ 13 | 14 | interface CpuInfoInterface { 15 | 16 | fun getCpuProcessor(): String 17 | 18 | fun getCpuHardware(): String 19 | 20 | fun getAbiType(): String 21 | 22 | fun availableProcessors(): String 23 | } 24 | 25 | private val keyList = listOf("Processor", "Hardware") 26 | private const val CPU_INFO_PATH = "/proc/cpuinfo" 27 | private const val KEY_VALUE_DELIMITER = ": " 28 | private var mCpuInfo: Map = mutableMapOf() 29 | 30 | class CpuInfoCollector : CpuInfoInterface { 31 | 32 | init { 33 | executeSafe { 34 | mCpuInfo = FileUtils.readFileByKey(CPU_INFO_PATH, keyList, KEY_VALUE_DELIMITER) 35 | } 36 | } 37 | 38 | override fun getCpuProcessor(): String = executeSafe({ mCpuInfo[keyList[0]] ?: "" }, "") 39 | 40 | override fun getCpuHardware(): String = executeSafe({ mCpuInfo[keyList[1]] ?: "" }, "") 41 | 42 | override fun getAbiType(): String = 43 | executeSafe({ TextUtils.join(",", Build.SUPPORTED_ABIS) }, "") 44 | 45 | override fun availableProcessors(): String = 46 | executeSafe({ Runtime.getRuntime().availableProcessors().toString() }, "") 47 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_humidity.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TrustDevice Fingerprint 3 | Your Device ID 4 | Android ID 5 | Risk Labels 6 | GSF ID 7 | GAD ID 8 | Media DRM ID 9 | vbmetaDigest 10 | Settings 11 | Internal Storage 12 | Random Access Memory 13 | Battery 14 | Apps 15 | Sensors 16 | App list 17 | show system apps 18 | hide system apps 19 | Sensor list 20 | Device id 21 | Device info 22 | The state at the time of collection 23 | Free 24 | total capacity 25 | health 26 | temperature 27 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/TDRisk.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk 2 | 3 | import android.content.Context 4 | import androidx.lifecycle.ViewModelProvider.NewInstanceFactory.Companion.instance 5 | import cn.tongdun.mobrisk.core.FMCore 6 | import org.json.JSONObject 7 | 8 | 9 | /** 10 | * @description: fingerprint entry class 11 | * @author: wuzuchang 12 | * @date: 2023/5/12 13 | */ 14 | object TDRisk { 15 | 16 | @JvmStatic 17 | fun init(context: Context) { 18 | val builder = Builder() 19 | initWithOptions(context, builder) 20 | } 21 | 22 | @JvmStatic 23 | fun initWithOptions(context: Context, builder: Builder) { 24 | FMCore.instance.init(context,builder.build()) 25 | } 26 | 27 | @JvmStatic 28 | fun getBlackbox(): JSONObject { 29 | return FMCore.instance.getDeviceInfo() 30 | } 31 | 32 | class Builder { 33 | private var partnerCode: String? = null 34 | private var callback: TDRiskCallback? = null 35 | fun partner(partner: String): Builder { 36 | partnerCode = partner 37 | return this 38 | } 39 | 40 | fun callback(TDRiskCallback: TDRiskCallback): Builder { 41 | callback = TDRiskCallback 42 | return this 43 | } 44 | 45 | fun build(): TDRiskOption { 46 | val options = TDRiskOption() 47 | options.partnerCode = partnerCode 48 | options.callback = callback 49 | return options 50 | } 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/item_details.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 21 | 22 | 33 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_internal_storage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_orientation.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/tools/NetworkUtils.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.tools 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Context 5 | import android.net.ConnectivityManager 6 | 7 | object NetworkUtils { 8 | const val TYPE_UNKNOWN = 0 9 | const val TYPE_MOBILE = 1 10 | const val TYPE_WIFI = 2 11 | const val TYPE_VPN = 3 12 | const val TYPE_ETHERNET = 4 13 | 14 | fun contain(context: Context?,type: Int):Boolean { 15 | return getNetworkTypes(context).contains(type) 16 | } 17 | 18 | @SuppressLint("MissingPermission") 19 | fun getNetworkTypes(context: Context?): List { 20 | 21 | val list = ArrayList() 22 | if (null == context) { 23 | return list 24 | } 25 | val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager 26 | try { 27 | val networks = cm.allNetworks 28 | if (networks.isEmpty()) { 29 | return list 30 | } 31 | 32 | for (network in networks) { 33 | var networkInfo = cm.getNetworkInfo(network) 34 | list.add(when(networkInfo?.type) { 35 | ConnectivityManager.TYPE_MOBILE -> TYPE_MOBILE 36 | ConnectivityManager.TYPE_WIFI -> TYPE_WIFI 37 | ConnectivityManager.TYPE_ETHERNET -> TYPE_ETHERNET 38 | ConnectivityManager.TYPE_VPN -> TYPE_VPN 39 | else -> { 40 | TYPE_UNKNOWN 41 | } 42 | }) 43 | 44 | } 45 | 46 | } catch (ignored: Throwable) { 47 | } 48 | return list 49 | } 50 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/item_app_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | 28 | 29 | 37 | 38 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_pressure.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/BuildInfoCollector.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.collectors 2 | 3 | import android.os.Build 4 | import cn.tongdun.mobrisk.core.tools.executeSafe 5 | 6 | /** 7 | * @description: Build Info 8 | * @author: wuzuchang 9 | * @date: 2023/5/15 10 | */ 11 | interface BuildInfoInterface { 12 | fun getModel(): String 13 | fun getManufacturer(): String 14 | fun getAndroidVersion(): String 15 | fun getSdkVersion(): String 16 | fun getKernelVersion(): String 17 | fun getFingerprint(): String 18 | fun getHardware(): String 19 | fun getBrand(): String 20 | fun getHost(): String 21 | fun getDisplay(): String 22 | fun getProduct(): String 23 | } 24 | 25 | class BuildInfoCollector : BuildInfoInterface { 26 | override fun getModel(): String = executeSafe({ Build.MODEL }, "") 27 | 28 | override fun getManufacturer(): String = executeSafe({ Build.MANUFACTURER }, "") 29 | 30 | override fun getAndroidVersion(): String = executeSafe({ Build.VERSION.RELEASE }, "") 31 | 32 | override fun getSdkVersion(): String = executeSafe({ Build.VERSION.SDK_INT.toString() }, "") 33 | 34 | override fun getKernelVersion(): String = 35 | executeSafe({ System.getProperty("os.version") ?: "" }, "") 36 | 37 | override fun getFingerprint(): String = executeSafe({ Build.FINGERPRINT }, "") 38 | 39 | override fun getHardware(): String = executeSafe({ Build.HARDWARE }, "") 40 | 41 | override fun getBrand(): String = executeSafe({ Build.BRAND }, "") 42 | 43 | override fun getHost(): String = executeSafe({ Build.HOST }, "") 44 | 45 | override fun getDisplay(): String = executeSafe({ Build.DISPLAY }, "") 46 | 47 | override fun getProduct(): String = executeSafe({ Build.PRODUCT }, "") 48 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/include_installed_app_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 19 | 20 | 31 | 32 | 39 | -------------------------------------------------------------------------------- /app/src/main/res/layout/include_sensor_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 19 | 20 | 31 | 32 | 39 | -------------------------------------------------------------------------------- /trustdevice/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | id 'org.jetbrains.kotlin.android' 4 | id 'maven-publish' 5 | id 'signing' 6 | } 7 | 8 | group = 'com.github.trustdecision' 9 | 10 | afterEvaluate { 11 | publishing { 12 | publications { 13 | mavenJava(MavenPublication) { 14 | groupId = 'com.github.trustdecision' 15 | artifactId = "trustdevice-android" 16 | version = '1.0.0' 17 | artifact("$buildDir/outputs/aar/trustdevice-release.aar") 18 | } 19 | } 20 | } 21 | } 22 | 23 | android { 24 | namespace 'cn.tongdun.mobrisk' 25 | compileSdk 36 26 | 27 | ndkVersion "25.2.9519653" 28 | defaultConfig { 29 | minSdk 21 30 | targetSdk 36 31 | 32 | externalNativeBuild{ 33 | cmake { 34 | abiFilters 'arm64-v8a','armeabi-v7a','x86', 'x86_64' 35 | } 36 | } 37 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 38 | consumerProguardFiles "consumer-rules.pro" 39 | } 40 | 41 | externalNativeBuild { 42 | cmake { 43 | path file('src/main/cpp/CMakeLists.txt') 44 | version '3.22.1' 45 | } 46 | } 47 | buildTypes { 48 | release { 49 | minifyEnabled true 50 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 51 | } 52 | 53 | } 54 | kotlinOptions { 55 | jvmTarget = '1.8' 56 | } 57 | } 58 | 59 | dependencies { 60 | implementation 'androidx.appcompat:appcompat:1.5.1' 61 | testImplementation 'junit:junit:4.13.2' 62 | androidTestImplementation 'androidx.test.ext:junit:1.1.4' 63 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' 64 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/tools/StringUtils.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.tools 2 | 3 | import java.nio.charset.StandardCharsets 4 | import java.security.MessageDigest 5 | 6 | /** 7 | * @description: 8 | * @author: wuzuchang 9 | * @date: 2023/5/15 10 | */ 11 | 12 | fun String.hash(algorithm: String): String { 13 | return executeSafe({ 14 | val md = MessageDigest.getInstance(algorithm) 15 | md.update(this.toByteArray(StandardCharsets.UTF_8)) 16 | md.digest().toUppercaseHexString() 17 | }, "") 18 | } 19 | 20 | fun String.splitNonRegex(delimiter: String): List { 21 | val list: MutableList = mutableListOf() 22 | var input = this 23 | if (input.isEmpty()) { 24 | return list 25 | } 26 | if (delimiter.isEmpty()) { 27 | list.add(input) 28 | return list 29 | } 30 | if (input == delimiter) { 31 | return list 32 | } 33 | while (true) { 34 | val index: Int = input.indexOf(delimiter) 35 | if (index == -1) { 36 | if (input.isNotEmpty()) { 37 | list.add(input) 38 | } 39 | return list 40 | } 41 | if (index != 0) { 42 | list.add(input.substring(0, index)) 43 | } 44 | input = input.substring(index + delimiter.length) 45 | } 46 | } 47 | 48 | fun ByteArray.hash(algorithm: String): String { 49 | return executeSafe({ 50 | val md = MessageDigest.getInstance(algorithm) 51 | md.update(this) 52 | md.digest().toUppercaseHexString() 53 | }, "") 54 | } 55 | 56 | fun ByteArray.toUppercaseHexString(): String { 57 | val hex = StringBuilder() 58 | // Iterating through each byte in the array 59 | for (i in this) { 60 | hex.append(String.format("%02X", i)) 61 | } 62 | return hex.toString() 63 | } -------------------------------------------------------------------------------- /app/src/main/kotlin/cn/tongdun/android/activitys/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android.activitys 2 | 3 | 4 | import android.widget.TextView 5 | import androidx.viewpager2.widget.ViewPager2 6 | import cn.tongdun.android.adapters.ViewPagerAdapter 7 | import cn.tongdun.android.base.BaseActivity 8 | import com.google.android.material.tabs.TabLayout 9 | import com.google.android.material.tabs.TabLayoutMediator 10 | import com.trustdevice.android.demo.R 11 | import com.trustdevice.android.demo.databinding.ActivityMainBinding 12 | 13 | 14 | class MainActivity : BaseActivity() { 15 | private val mTabList: MutableList = ArrayList() 16 | private var mTabLayoutMediator: TabLayoutMediator? = null 17 | override fun getViewBinding(): ActivityMainBinding = ActivityMainBinding.inflate(layoutInflater) 18 | 19 | override fun initData() { 20 | mTabList.add(getString(R.string.tab_title_device_id)) 21 | mTabList.add(getString(R.string.tab_title_device_info)) 22 | } 23 | 24 | override fun initView() { 25 | val viewPagerAdapter = 26 | ViewPagerAdapter(mTabList.size, supportFragmentManager, lifecycle) 27 | binding.viewpager.offscreenPageLimit = ViewPager2.OFFSCREEN_PAGE_LIMIT_DEFAULT 28 | binding.viewpager.adapter = viewPagerAdapter 29 | mTabLayoutMediator = TabLayoutMediator( 30 | binding.tabLayout, binding.viewpager 31 | ) { tab: TabLayout.Tab, position: Int -> 32 | val tabView = TextView(this) 33 | tabView.text = mTabList[position] 34 | tabView.setTextColor(getResources().getColor(R.color.normal_text)) 35 | tab.customView = tabView 36 | } 37 | // binding 38 | mTabLayoutMediator!!.attach() 39 | } 40 | 41 | override fun onDestroy() { 42 | mTabLayoutMediator!!.detach() 43 | super.onDestroy() 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/src/main/res/layout/include_setting_info.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 29 | 30 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /trustdevice/src/main/java/cn/tongdun/mobrisk/core/collectors/MemoryInfoCollector.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.mobrisk.core.collectors 2 | 3 | import android.app.ActivityManager 4 | import android.os.Environment 5 | import android.os.StatFs 6 | import cn.tongdun.mobrisk.core.tools.executeSafe 7 | 8 | /** 9 | * @description:MemoryInfo 10 | * @author: wuzuchang 11 | * @date: 2023/5/15 12 | */ 13 | interface MemoryInfoInterface { 14 | fun getTotalMemory(): Long 15 | fun getAvailableMemory(): Long 16 | fun getAvailableStorage(): Long 17 | fun getTotalStorage(): Long 18 | } 19 | 20 | class MemoryInfoCollector(private val activityManager: ActivityManager) : MemoryInfoInterface { 21 | private var mAvailableMemory = 0L 22 | private var mTotalMemory = 0L 23 | private var mAvailableStorage = 0L 24 | private var mTotalStorage = 0L 25 | 26 | init { 27 | executeSafe { 28 | val memoryInfo = ActivityManager.MemoryInfo() 29 | activityManager.getMemoryInfo(memoryInfo) 30 | mAvailableMemory = memoryInfo.availMem 31 | mTotalMemory = memoryInfo.totalMem 32 | 33 | val path = Environment.getDataDirectory() 34 | val stat = StatFs(path.path) 35 | val blockSize = stat.blockSizeLong 36 | val availableBlocks = stat.availableBlocksLong 37 | val totalBlocks = stat.blockCountLong 38 | mTotalStorage = totalBlocks * blockSize 39 | mAvailableStorage = availableBlocks * blockSize 40 | } 41 | } 42 | 43 | override fun getTotalMemory(): Long { 44 | return mTotalMemory 45 | } 46 | 47 | override fun getAvailableMemory(): Long { 48 | return mAvailableMemory 49 | } 50 | 51 | override fun getAvailableStorage(): Long { 52 | return mAvailableStorage 53 | } 54 | 55 | override fun getTotalStorage(): Long { 56 | return mTotalStorage 57 | } 58 | 59 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /app/src/main/res/layout/include_title_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 17 | 18 | 19 | 34 | 35 | 36 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_proximity.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/kotlin/cn/tongdun/android/adapters/BaseRecyclerViewAdapter.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android.adapters 2 | 3 | import android.util.SparseArray 4 | import android.view.LayoutInflater 5 | import android.view.View 6 | import android.view.ViewGroup 7 | import android.widget.TextView 8 | import androidx.recyclerview.widget.RecyclerView 9 | 10 | /** 11 | * @description: 12 | * @author: wuzuchang 13 | * @date: 2023/5/16 14 | */ 15 | abstract class BaseRecyclerViewAdapter(val data: List) : RecyclerView.Adapter() { 16 | 17 | 18 | abstract fun getLayoutId(viewType: Int): Int 19 | 20 | abstract fun convert(holder: BaseViewHolder, data: T, position: Int) 21 | 22 | override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder { 23 | return BaseViewHolder[parent, getLayoutId(viewType)] 24 | } 25 | 26 | override fun onBindViewHolder(holder: BaseViewHolder, position: Int) { 27 | convert(holder, data[position], position) 28 | } 29 | 30 | override fun getItemCount(): Int { 31 | return data.size 32 | } 33 | 34 | class BaseViewHolder private constructor(private val mConvertView: View) : 35 | RecyclerView.ViewHolder( 36 | mConvertView 37 | ) { 38 | private val mViews: SparseArray = SparseArray() 39 | 40 | fun getView(id: Int): T? { 41 | var v = mViews[id] 42 | if (v == null) { 43 | v = mConvertView.findViewById(id) 44 | mViews.put(id, v) 45 | } 46 | return v as T? 47 | } 48 | 49 | fun setText(id: Int, value: String) { 50 | val view = getView(id) 51 | view?.text = value 52 | } 53 | 54 | companion object { 55 | operator fun get(parent: ViewGroup, layoutId: Int): BaseViewHolder { 56 | val convertView = 57 | LayoutInflater.from(parent.context).inflate(layoutId, parent, false) 58 | return BaseViewHolder(convertView) 59 | } 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 18 | 19 | 27 | 28 |