Android

Requirement

Compliance

1.1 According to the user's information protection regulations, before your users start the App for the first time and start collecting information, your company should fully inform the user of the purpose, method, and scope of collecting, using, and sharing the user's personal information with a third party through an interactive interface or design (such as a pop-up window of the privacy policy), and obtain the express consent of the end user.

1.2 To provide business security and risk control services to your company, the TrustDecision SDK will collect, process, and use the identification information(IMEI/IDFA), AndroidID, IMSI, MEID, MAC address, SIM card serial number, device type, device model, system type, geographical location, login IP address, application list, running process, sensor information(light sensor, gravity sensor, magnetic field sensor, acceleration sensor, gyroscope sensor) and other device information of the user's device. To ensure compliance with your use of related services, the aforementioned privacy policy should cover the authorization of TrustDecision SDK to provide services and collect, process, and use relevant information. The following terms are for your reference. The specific expression can be determined by your company according to the overall framework and content of your privacy agreement:

TrustDecision SDK: For business security and risk control, our company uses the TrustDecision SDK. The SDK needs to obtain the information of your devices, such as (IMEI/IDFA), AndroidID, IMSI, MAC address, SIM card serial number, device type, device model, system type, geographic location, login IP address, application list, running process, sensor information(light sensor, gravity sensor, magnetic field sensor, acceleration sensor, gyroscope sensor) and other related device information, for fraud risk identification.

Privacy Policy: https://www.trustdecision.com/legal/privacy-policy

Environment

说明
Supported System VersionsAndroid 5.0 and above
Supported Architecturesarmeabi, armeabi-v7a, arm64-v8a, x86

Integrate

integrate sample: https://github.com/trustdecision/mobrisk-android-sample

Install

If installing offline, please refer to Offline Install

Add Warehouse

Add the maven library configuration to build.gradle in the project root directory

allprojects {
    repositories {
        ...
        mavenCentral()
    }
}

If your gradle version is 7 or higher, add this configuration to your settings.gradle

repositories {
    ...
    mavenCentral()
}

Add Dependencies

Add dependencies to build.gradle of the main module

dependencies {
    implementation 'com.trustdecision.android:mobrisk:4.3.2.8'
 }

If you encounter compliance issues, you can exclude the collection of relevant modules

dependencies {
  
    implementation('com.trustdecision.android:mobrisk:4.3.2.8'){
    		// after removal, sdk does not get the list of installation packages
        exclude group: 'com.trustdecision.android', module: 'packagelist'
        // after removal, sdk will not collect READ_PHONE_STATE related information
        exclude group: 'com.trustdecision.android', module: 'readphone'
       // after removal, sdk will not collect location information
        exclude group: 'com.trustdecision.android', module: 'location'
       // after removal, sdk will not collect sensor information
        exclude group: 'com.trustdecision.android', module: 'sensor'
       // after removal, sdk will not collect wifi information
        exclude group: 'com.trustdecision.android', module: 'wifiinfo'
    }
 }

Abi Configuration

The SDK currently supports four ABI types: armeabi, armeabi-v7a, arm64-v8a, and x86. It is recommended to specify the required architecture type in the app/build.gradle file using the abiFilters configuration.

defaultConfig {
    ...
    ndk {
       abiFilters 'armeabi-v7a', 'arm64-v8a'
    }
}

AndroidManifest.xml

Declare the following permissions in the AndroidManifest.xml file under the application module

<manifest>
   <!-- required -->
   <uses-permission android:name="android.permission.INTERNET"/>
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
   <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
  <!-- Outside the Chinese Mainland -->
  <uses-permission android:name="com.google.android.gms.permission.AD_ID"/>

   <!--optional, If not declared, some device information will be abandoned -->
   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
   <uses-permission android:name="android.permission.READ_PHONE_STATE" />
   <!-- required for Android 11 and above to obtain the installed packages -->
   <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
        tools:ignore="QueryAllPackagesPermission" />
</manifest>

Permissions

NameDescription
INTERNET(required)Allows the app to access the network connection and send requests to communicate with the server.
ACCESS_NETWORK_STATE(required)Collect network connection status information.
ACCESS_WIFI_STATE(required)Collect the current WiFi access status and WLAN hotspot information.
AD_ID(required)Collect the Google advertising ID, required outside the Chinese Mainland.
ACCESS_COARSE_LOCATIONGet location information, with an accuracy of approximately 30 to 1500 meters.
ACCESS_FINE_LOCATIONGet location information, with positioning accuracy within 10 meters.
READ_PHONE_STATECollect information on SIM card
QUERY_ALL_PACKAGESCollect installed packages

Initialization

Cautions

  • Ensure that it is initialized after the user agrees to the privacy agreement.
  • Ensure that it is initialized in the main process.

Definition

public static void initWithOptions(Context ctx, TDRisk.Builder builder)

Get blackBox

Cautions

  • Call getBlackBox after initWithOptions.
  • Don't cache blackBox returned by getBlackBox in the app. Please rely on this function to get blackBox.

Definition

// get by asynchronous callback  
public static String getBlackBox(TDRiskCallback callback);
// get by synchronous call  
public static String getBlackBox();

Best Practices

  1. Call initialization in the onCreate method of the application, and obtain blackBox asynchronously
// onCreate of APPlication
TDRisk.Builder builder = new TDRisk.Builder()
/*************************** required  ***************************/
.partnerCode("demo")        // get from our customer platform
.appKey("appKey")           // get from our customer platform		 
.country(TDRisk.COUNTRY_CN);

if(agrees to the privacy){
  TDRisk.initWithOptions(getApplicationContext(), builder);
  TDRisk.getBlackBox(new TDRiskCallback() {
  	@Override
  	public void onEvent(String blackbox) {
    	// here is in a new thread
    	Log.i("TD", "init & get success");
  }
});
}
  1. Obtain blackBox in actual business scenarios
public void register() {
  ...
  String blackBox = TDRisk.getBlackBox();
  ...
}

Status Check

  1. Log will be printed in logcat while initialization successfully
TD_JAVA: Tongdun sdk load success
TD_JAVA: Tongdun sdk init success
  1. getBlackBox() will return a 26-bit string while initialization successfully: rGPGX1678775227I9NCwcuVJCb
  2. getBlackBox() will return a string of around 5000 bits while initialization Failed, please refer to overview-definition

Other

Get SDK Version

TDRisk.getSDKVersion()

Error Listen

Please call setOnErrorCodeListener before the initWithOptions method to listen for error messages. It is recommended to use it only in debug mode.

TDRisk.setOnErrorCodeListener(new TDErrorCodeCallback() {
       @Override
       public void onResult(int errorCode, String errorMsg) {
           Log.d(TAG, "errorCode:" + errorCode + "," + "errorMsg:" + errorMsg);
       }
   });

Keep Configuration

-keep class cn.tongdun.**{*;}

All Configurations

KeyDescriptionSample
partnerCode(required)Partner code, contact operator to obtain.builder.partnerCode("partner")
appKey(required)Application identification, please refer tohow to get appKeybuilder.appKey("appKey")
country(required)Data-center:
TRisk.COUNTRY_US(USA)

TDRisk.COUNTRY_FRA (Europe)

TDRisk.COUNTRY_SG (Singapore)

TDRisk.COUNTRY_IDNA (Indonesia)

TDRisk.COUNTRY_CN (China)
builder.country(TDRisk.COUNTRY_CN)
appNameApplication name, contact operator to obtainbuilder.appName("appName")
useDemotionDataWhen unable to obtain a normal blackBox, should downgrading be prioritized and disabled by defaultbuild.useDemotionData(true)
setHttpTimeoutNetwork timeout configuration, in milliseconds, default 15000msbuilder.httpTimeout(5000)
collectLevelYou can set M to control the maximum length of blackBox to 2000, default around 5000builder.collectLevel(TDRisk.COLLECT_LEVEL_M)
disableDebuggerAfter configuration, it will terminate running when debugging is detected, default allowedbuilder.disableDebugger()
disableRunningTasksProhibit obtaining running tasks, default allowedbuilder.disableRunningTasks()
disableGPSProhibit collection of GPS location information, default allowedbuilder.disableGPS()
disableSensorProhibit collecting sensor information, default allowedbuilder.disableSensor()
disableReadPhoneProhibit collection of READ PHONE STATE permission-related information, default allowedbuilder.disableReadPhone()
enableWifiMacEnable collection of WIFI MAC addresses, default notbuilder.enableWifiMac()
disableInstallPackageListProhibit collection of application list information, allowed defaultbuilder.disableInstallPackageList()
customMessageCustom messages, SDK supports transparent transmission and storagebuilder.customMessage(customMessage)

Error Code

codehow to handle
100Ensure initWithOptions is called before getBlackBox
101Not affect usage. If you want to obtain a shorter blackBox, you can learn from the best practices mentioned above
102Not affect usage. If you want to obtain a shorter blackBox, try to use getBlackBox() after a successful callback of getBlackBox (TDRiskCallback)
200Required parameter exception, adjust parameters according to the error message
201Please get in touch with our operator to update the validity period of the appKey
301Please first check if the appKey and partnerCode meet the document requirements. Then check if the appKey fits the package name and sign. At last, check if the setHttpTimeout configuration has been set a too short time, If it still cannot be resolved, please provide the blackBox, code, and error message to the technical for assistance
302Please check the network status of the current device and App first.
400Please focus on checking whether the ABI architecture configuration is within the SDK support scope; Is the so file missing
-1Please provide the blackBox, code, and error message to the technical for assistance