The s method starts the analysis process, which detects whether a device is rooted or jailbroken. As of version 4.4 of the Root Detection SDK, this method also checks the version of the signature file. The signature file version must be higher than or equal to the version defined in the Root Detection SDK (indicated by the constant t). The aim is to prevent anyone from using signature files that may contain deprecated verification rules.
For Android platforms, another signature for this method exists: public static S s(String c), which does not use the Android context. However, the Android context is necessary to improve the root detection process. As a result, the deprecated method must only be used for backward-compatibility to manage earlier client integrations (Root Detection SDK 4.3 or earlier versions).
Syntax
Android
public static S s(String c, Context a)
iOS
+(s) s: (NSData*) c
Parameters
Start the analysis parameters lists the available signatures for this function:
Parameter name | Data type | Use | Description |
---|---|---|---|
c | String/NSData* | I (mandatory) | Signature file content. |
a | Context | I (mandatory) | Android context (Android only). |
Return values
This method returns the S response object, which contains the following:
Android:
- A return code that indicates the result of the analysis.
- An exception if an unknown error occurs.
Exceptions
Start the analysis exceptions lists the possible error codes for this function.
Examples
This section illustrates how to integrate and use the s method to start the analysis. For more information, refer to the Root Detection SDK sample project in the OneSpan Mobile Security Suite package.
Android
- // Retrieve the signature file
- InputStream ins = assetManager.open(path);
- // Start analysis process
- S response = P.s(convertInsToString(ins),
- this.getApplicationContext());
- int returnCode = response.r();
- // Check the result from the analysis process
- if (returnCode == O.n)
- {
- System.out.println("Device is not rooted.");
- }
- else if (returnCode == O.r)
- {
- System.out.println("Device is rooted.");
- }
- else
- {
- System.out.println(getMsgFromReturnCode(returnCode));
- System.out.println("Error code: " + returnCode);
- }
iOS
- // Get file signature path
- NSString * filePath = [[NSBundlemainBundle] pathForResource:@"signature" ofType:nil];
- // Load signature file
- NSData * d = [NSData dataWithContentsOfFile:filePath];
- // Call s method: check if phone is rooted
- s response = [P s:d];
- NSString * resultText = @"";
- // Parse result
- switch(response.r){
- case P_r:
- resultText = @"** Device is rooted **";
- break;
- case P_n:
- resultText = @"** Device is not rooted **";
- break;
- ...
- ...