├── .gitattributes ├── .github └── workflows │ ├── android.yml │ └── release.yml ├── .gitignore ├── LICENSE ├── README.md ├── app ├── .gitignore ├── build.gradle ├── demo_release.jks ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── cn │ │ └── tongdun │ │ └── android │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── assets │ │ └── PrivacyPolicy.html │ ├── kotlin │ │ └── cn │ │ │ └── tongdun │ │ │ └── android │ │ │ ├── MyApplication.kt │ │ │ ├── activitys │ │ │ ├── ItemListActivity.kt │ │ │ ├── MainActivity.kt │ │ │ └── SplashActivity.kt │ │ │ ├── adapters │ │ │ ├── AppListRecyclerViewAdapter.kt │ │ │ ├── BaseRecyclerViewAdapter.kt │ │ │ ├── DeviceInfoItemAdapter.kt │ │ │ └── ViewPagerAdapter.kt │ │ │ ├── base │ │ │ ├── BaseActivity.kt │ │ │ └── BaseFragment.kt │ │ │ ├── beans │ │ │ ├── AppItemData.kt │ │ │ ├── DetailsItemBean.kt │ │ │ └── DeviceModuleItemBean.kt │ │ │ └── fragments │ │ │ ├── DeviceIdFragment.kt │ │ │ └── DeviceInfoFragment.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ ├── build_info_background.xml │ │ ├── detail_item_divider.xml │ │ ├── ic_back.xml │ │ ├── ic_battery.xml │ │ ├── ic_down_arrow.xml │ │ ├── ic_installed_app.xml │ │ ├── ic_internal_storage.xml │ │ ├── ic_launcher_background.xml │ │ ├── ic_phone.xml │ │ ├── ic_random_access_memory.xml │ │ ├── ic_sensor_accelerometer.xml │ │ ├── ic_sensor_all.xml │ │ ├── ic_sensor_gravity.xml │ │ ├── ic_sensor_gyroscope.xml │ │ ├── ic_sensor_heartrate.xml │ │ ├── ic_sensor_hinge.xml │ │ ├── ic_sensor_humidity.xml │ │ ├── ic_sensor_light.xml │ │ ├── ic_sensor_magnetic_field.xml │ │ ├── ic_sensor_motion.xml │ │ ├── ic_sensor_next.xml │ │ ├── ic_sensor_orientation.xml │ │ ├── ic_sensor_pressure.xml │ │ ├── ic_sensor_private.xml │ │ ├── ic_sensor_proximity.xml │ │ ├── ic_sensor_step.xml │ │ ├── ic_sensor_temperature.xml │ │ ├── ic_sensor_tilt.xml │ │ ├── ic_setting.xml │ │ ├── ic_up_arrow.xml │ │ └── item_card_background.xml │ │ ├── layout │ │ ├── activity_app_list.xml │ │ ├── activity_main.xml │ │ ├── activity_splash.xml │ │ ├── fragment_device_id.xml │ │ ├── fragment_device_info.xml │ │ ├── include_battery_info.xml │ │ ├── include_build_info.xml │ │ ├── include_installed_app_list.xml │ │ ├── include_memory_info.xml │ │ ├── include_sensor_list.xml │ │ ├── include_setting_info.xml │ │ ├── include_title_layout.xml │ │ ├── item_app_list.xml │ │ └── item_details.xml │ │ ├── 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 │ │ ├── values-night │ │ ├── colors.xml │ │ └── themes.xml │ │ ├── values-zh-rCN │ │ └── strings.xml │ │ ├── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ │ └── xml │ │ ├── backup_rules.xml │ │ └── data_extraction_rules.xml │ └── test │ └── java │ └── cn │ └── tongdun │ └── android │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── jitpack.yml ├── resources ├── demo.gif ├── demo_2.gif ├── logo_dark.png └── logo_light.png ├── settings.gradle └── trustdevice ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src ├── androidTest └── java │ └── cn │ └── tongdun │ └── android │ └── ExampleInstrumentedTest.java ├── main ├── AndroidManifest.xml ├── cpp │ ├── CMakeLists.txt │ ├── common │ │ ├── logger.h │ │ └── macro.h │ ├── trustdevice.cpp │ ├── trustdevice_risk.cpp │ ├── trustdevice_risk.h │ ├── trustdevice_utils.cpp │ └── trustdevice_utils.h ├── java │ └── cn │ │ └── tongdun │ │ └── mobrisk │ │ ├── TDRisk.kt │ │ ├── TDRiskCallback.kt │ │ ├── TDRiskOption.kt │ │ ├── beans │ │ └── DeviceInfo.kt │ │ ├── core │ │ ├── FMCore.kt │ │ ├── collectors │ │ │ ├── AdvertisingIdClient.kt │ │ │ ├── AppListCollector.kt │ │ │ ├── BatteryInfoCollector.kt │ │ │ ├── BuildInfoCollector.kt │ │ │ ├── CpuInfoCollector.kt │ │ │ ├── DebugInfoCollector.kt │ │ │ ├── DeviceBaseInfoCollector.kt │ │ │ ├── DeviceIdCollector.kt │ │ │ ├── DeviceInfoTamperedCollector.kt │ │ │ ├── DevicePersonalizationInfoCollector.kt │ │ │ ├── EmulatorCollector.kt │ │ │ ├── HookCollector.kt │ │ │ ├── MagiskCollector.kt │ │ │ ├── MemoryInfoCollector.kt │ │ │ ├── RootCollector.kt │ │ │ ├── SensorsInfoCollector.kt │ │ │ ├── SettingInfoCollector.kt │ │ │ ├── VpnCollector.kt │ │ │ └── XposedCollector.kt │ │ └── tools │ │ │ ├── Constants.kt │ │ │ ├── DeviceInfoUtils.kt │ │ │ ├── EnvUtils.kt │ │ │ ├── ExceptionSafeExecutor.kt │ │ │ ├── FileUtils.kt │ │ │ ├── JNIHelper.kt │ │ │ ├── Logger.kt │ │ │ ├── NetworkUtils.kt │ │ │ └── StringUtils.kt │ │ └── providers │ │ ├── AppListsRawData.kt │ │ ├── BatteryInfoRawData.kt │ │ ├── BuildInfoRawData.kt │ │ ├── CpuInfoRawData.kt │ │ ├── DeviceIdRawData.kt │ │ ├── DeviceInfoProvider.kt │ │ ├── MemoryInfoRawData.kt │ │ ├── RiskInfoRawData.kt │ │ ├── SensorInfoRawData.kt │ │ └── SettingInfoRawData.kt └── resources │ └── META-INF │ └── com │ └── trustdecision │ └── android │ └── mobrisk │ └── verification.properties └── test └── java └── cn └── tongdun └── android └── ExampleUnitTest.java /.gitattributes: -------------------------------------------------------------------------------- 1 | *.js linguist-detectable=false 2 | *.css linguist-detectable=false 3 | *.html linguist-detectable=false 4 | -------------------------------------------------------------------------------- /.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 -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | tags: 6 | - '*' 7 | 8 | jobs: 9 | 10 | release: 11 | name: Create Release 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - name: Checkout code 16 | uses: actions/checkout@v3 17 | - name: Set up JDK 18 | uses: actions/setup-java@v3 19 | with: 20 | java-version: '17' 21 | distribution: 'temurin' 22 | cache: gradle 23 | - name: Grant execute permission for gradlew 24 | run: chmod +x gradlew 25 | 26 | - name: Lint 27 | run: ./gradlew trustdevice:lint 28 | 29 | - name: Test 30 | run: ./gradlew trustdevice:test 31 | 32 | - name: Build library 33 | run: ./gradlew trustdevice:assembleRelease 34 | 35 | - name: Build App 36 | run: ./gradlew app:assembleRelease 37 | 38 | - name: Display structure of downloaded files 39 | run: ls -R 40 | 41 | - name: Set release name 42 | run: echo RELEASE_NAME=${GITHUB_REF} >> $GITHUB_ENV 43 | 44 | - name: Get version 45 | id: get_version 46 | run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} 47 | 48 | - name: Create Release 49 | id: create_release 50 | uses: actions/create-release@v1 51 | env: 52 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 53 | with: 54 | tag_name: ${{ github.ref }} 55 | release_name: ${{ env.RELEASE_NAME }} 56 | body: 57 | update demo app. 58 | draft: false 59 | prerelease: false 60 | 61 | - name: Upload aar to release 62 | uses: actions/upload-release-asset@v1.0.1 63 | env: 64 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 65 | with: 66 | upload_url: ${{ steps.create_release.outputs.upload_url }} 67 | asset_path: ./trustdevice/build/outputs/aar/trustdevice-release.aar 68 | asset_name: trustdevice-release-${{ steps.get_version.outputs.VERSION }}.aar 69 | # Common MIME types:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types 70 | asset_content_type: application/zip 71 | 72 | - name: Upload apk to release 73 | uses: actions/upload-release-asset@v1.0.1 74 | env: 75 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 76 | with: 77 | upload_url: ${{ steps.create_release.outputs.upload_url }} 78 | asset_path: ./app/build/outputs/apk/release/TrustDevice-release-${{ steps.get_version.outputs.VERSION }}.apk 79 | asset_name: TrustDevice-release-${{ steps.get_version.outputs.VERSION }}.apk 80 | # Common MIME types:https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types 81 | asset_content_type: application/zip -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.gradle/ 2 | /.idea/ 3 | /build/ 4 | local.properties 5 | -------------------------------------------------------------------------------- /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/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'org.jetbrains.kotlin.android' 4 | id 'kotlin-kapt' 5 | } 6 | 7 | android { 8 | namespace 'com.trustdevice.android.demo' 9 | compileSdk 34 10 | 11 | defaultConfig { 12 | applicationId "com.trustdevice.android.demo" 13 | minSdk 21 14 | targetSdk 34 15 | versionCode 12 16 | versionName "1.1.0" 17 | ndk { 18 | abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64' 19 | } 20 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 21 | } 22 | 23 | signingConfigs { 24 | release { 25 | storeFile file("demo_release.jks") 26 | storePassword 'TRUSTDEVICE' 27 | keyAlias 'TRUSTDEVICE_KEY_ALIAS' 28 | keyPassword 'TRUSTDEVICE' 29 | } 30 | } 31 | 32 | buildTypes { 33 | release { 34 | minifyEnabled false 35 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 36 | signingConfig signingConfigs.release 37 | } 38 | } 39 | applicationVariants.all { variant -> 40 | variant.outputs.all { 41 | outputFileName = "TrustDevice-${variant.name}-${variant.versionName}.apk" 42 | } 43 | } 44 | kotlinOptions { 45 | jvmTarget = '1.8' 46 | } 47 | buildFeatures { 48 | viewBinding true 49 | dataBinding true 50 | } 51 | } 52 | 53 | dependencies { 54 | // implementation fileTree(dir: "libs", include: ["*.jar", "*.aar"]) 55 | implementation project(path: ':trustdevice') 56 | implementation 'com.tencent:mmkv:1.2.15' 57 | implementation 'androidx.appcompat:appcompat:1.5.1' 58 | implementation 'androidx.recyclerview:recyclerview:1.2.1' 59 | implementation 'com.google.android.material:material:1.5.0' 60 | implementation 'androidx.constraintlayout:constraintlayout:2.1.3' 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/demo_release.jks: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/trustdecision/trustdevice-android/70c7f5454db1a95cb9e4cfaef766f90d831ce833/app/demo_release.jks -------------------------------------------------------------------------------- /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/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/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/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 | } -------------------------------------------------------------------------------- /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/kotlin/cn/tongdun/android/activitys/SplashActivity.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android.activitys 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Intent 5 | import android.webkit.WebView 6 | import android.webkit.WebViewClient 7 | import android.widget.Toast 8 | import cn.tongdun.android.base.BaseActivity 9 | import cn.tongdun.mobrisk.TDRisk.init 10 | import com.tencent.mmkv.MMKV 11 | import com.trustdevice.android.demo.R 12 | import com.trustdevice.android.demo.databinding.ActivitySplashBinding 13 | 14 | @SuppressLint("CustomSplashScreen") 15 | class SplashActivity() : BaseActivity() { 16 | override fun getViewBinding(): ActivitySplashBinding = 17 | ActivitySplashBinding.inflate(layoutInflater) 18 | 19 | override fun initData() { 20 | goToMainActivity() 21 | } 22 | 23 | @SuppressLint("SetJavaScriptEnabled") 24 | override fun initView() { 25 | val webSettings = binding.wvWebView.settings 26 | webSettings.apply { 27 | javaScriptCanOpenWindowsAutomatically = 28 | true //Setting js can directly open the window, such as window.open(), the default is false 29 | javaScriptEnabled = 30 | true //Whether to allow js execution, the default is false. When set to true, it will remind you that it may cause XSS vulnerabilities 31 | setSupportZoom(true) //Whether it can be zoomed, the default is true 32 | builtInZoomControls = 33 | true //Whether to display the zoom button, the default is false 34 | useWideViewPort = 35 | true //Set this property to scale at any scale. big view mode 36 | loadWithOverviewMode = 37 | true //Solve the web page adaptation problem together with setUseWideViewPort(true) 38 | domStorageEnabled = true //DOM Storage 39 | } 40 | binding.wvWebView.webViewClient = object : WebViewClient() { 41 | override fun shouldOverrideUrlLoading(view: WebView, url: String): Boolean { 42 | Toast.makeText(this@SplashActivity, url, Toast.LENGTH_SHORT).show() 43 | view.loadUrl(url) 44 | return true 45 | } 46 | 47 | override fun onReceivedError( 48 | view: WebView, 49 | errorCode: Int, 50 | description: String, 51 | failingUrl: String 52 | ) { 53 | super.onReceivedError(view, errorCode, description, failingUrl) 54 | Toast.makeText(this@SplashActivity, "error!!!", Toast.LENGTH_SHORT).show() 55 | } 56 | } 57 | binding.wvWebView.loadUrl("file:///android_asset/PrivacyPolicy.html") 58 | 59 | binding.setClickListener { view -> 60 | when (view.id) { 61 | R.id.bt_agree -> { 62 | MMKV.defaultMMKV().encode("isAgreePrivacyAgreement", true) 63 | init(this) 64 | goToMainActivity() 65 | } 66 | 67 | R.id.bt_reject -> finish() 68 | } 69 | } 70 | } 71 | 72 | private fun goToMainActivity() { 73 | val isAgree = MMKV.defaultMMKV().decodeBool("isAgreePrivacyAgreement") 74 | if (isAgree) { 75 | val intent = Intent(this@SplashActivity, MainActivity::class.java) 76 | startActivity(intent) 77 | finish() 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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/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/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/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/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 | } -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/kotlin/cn/tongdun/android/fragments/DeviceIdFragment.kt: -------------------------------------------------------------------------------- 1 | package cn.tongdun.android.fragments 2 | 3 | import android.os.Bundle 4 | import android.text.TextUtils 5 | import android.util.Log 6 | import android.view.LayoutInflater 7 | import android.view.View 8 | import android.view.ViewGroup 9 | import cn.tongdun.android.base.BaseFragment 10 | import cn.tongdun.mobrisk.TDRisk.getBlackbox 11 | import cn.tongdun.mobrisk.providers.DeviceInfoProvider 12 | import com.trustdevice.android.demo.databinding.FragmentDeviceIdBinding 13 | import org.json.JSONException 14 | 15 | 16 | class DeviceIdFragment : BaseFragment() { 17 | private var mDeviceInfoProvider: DeviceInfoProvider? = null 18 | 19 | 20 | override fun getViewBinding( 21 | inflater: LayoutInflater, 22 | container: ViewGroup? 23 | ): FragmentDeviceIdBinding = FragmentDeviceIdBinding.inflate(inflater, container, false) 24 | 25 | override fun onViewCreated(view: View, savedInstanceState: Bundle?) { 26 | super.onViewCreated(view, savedInstanceState) 27 | getDeviceID() 28 | initView() 29 | } 30 | 31 | private fun getDeviceID() { 32 | val deviceInfo = getBlackbox() 33 | try { 34 | Log.d("TrustDevice", "deviceInfo = " + deviceInfo.toString(1)) 35 | } catch (e: JSONException) { 36 | e.printStackTrace() 37 | } 38 | mDeviceInfoProvider = DeviceInfoProvider(deviceInfo) 39 | } 40 | 41 | private fun initView() { 42 | binding.run { 43 | mDeviceInfoProvider?.run { 44 | tvDeviceId.text = getDeviceInfo().deviceId 45 | tvAndroidId.text = getDeviceInfo().androidId 46 | if(getDeviceInfo().gsfId.isNotEmpty()) { 47 | tvGsfId.text = getDeviceInfo().gsfId.toLong().toString(16) 48 | } 49 | tvGadId.text = getDeviceInfo().gadId 50 | tvMediaDrmId.text = getDeviceInfo().mediaDrmId 51 | tvVmdId.text = getDeviceInfo().vbMetaDigest 52 | val riskLabels = getRiskInfo().toString() 53 | if (TextUtils.isEmpty(riskLabels)) { 54 | tvRiskLabelsTitle.visibility = View.GONE 55 | tvRiskLabels.visibility = View.GONE 56 | } else { 57 | tvRiskLabelsTitle.visibility = View.VISIBLE 58 | tvRiskLabels.visibility = View.VISIBLE 59 | tvRiskLabels.text = riskLabels 60 | } 61 | } 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/build_info_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/detail_item_divider.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_back.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_battery.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_down_arrow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_installed_app.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_internal_storage.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_phone.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_random_access_memory.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_accelerometer.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 12 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_all.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_gravity.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_gyroscope.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_heartrate.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_hinge.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_humidity.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_light.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_magnetic_field.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_motion.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_next.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_orientation.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_pressure.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_private.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_proximity.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_step.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_temperature.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_sensor_tilt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_setting.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 12 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_up_arrow.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/item_card_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_app_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 16 | 17 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 22 | 23 | 24 | 36 | 37 | 45 | 46 | 60 | 61 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_splash.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 18 | 19 | 27 | 28 |