How to Integrate Sentinel Licensing API in Your Application

This section is relevant if you want to use the integrated protection method for your application.

Integrate the Sentinel Licensing API

To integrate the Sentinel Licensing API in your application:

1.Build the JNI layer as follows:

a.Ensure that Android NDK is installed on your machine (for example: C:\android-ndk-r27d).

b.Modify the Java/jni/Android.mk file to link against your vendor-specific library (libhasp_android_arm64_<vendorId>.a).

c.Switch to the Java directory and run the following sample command from a command prompt:

C:\android-ndk-r27d\ndk-build

d.The build process generates the JNI library in Java/libs/arm64-v8a/libHASPJava.so. If you requested the 32-bit version from Thales customer representative, the build process also generates the library in Java/libs/armeabi-v7a/libHASPJava.so.

2.Add the following files to your project:

Java/src/com/Aladdin/Hasp.java

Java/src/com/Aladdin/HaspApiVersion.java

Java/src/com/Aladdin/HaspStatus.java

Java/src/com/Aladdin/HaspTime.java

Java/src/com/Aladdin/HaspUsbHandler.java

Java/libs/arm64-v8a/libHASPJava.so (64-bit)

Java/libs/arm64-v8a/libhasp_android_<vendorId>.so (64-bit) (refer step 1)

Java/libs/armeabi-v7a/libHASPJava.so (Optional, for 32-bit)

Java/libs/armeabi-v7a/libhasp_android_<vendorId>.so (Optional, for 32-bit) (refer step 1)

3.Refer to Java/src/com/HaspDemo/HaspDemo.java for an example of how to call the Licensing API.

4.Add the following line to load the LDK JNI library:

System.loadLibrary("HASPJava");

5.If you are using Sentinel HL keys to protect and license your application, call the getPermission method of class HaspUsbHandler to get the permission to access the Sentinel HL key from your application.

6.Add the following line to your project's AndroidManifest.xml file:

<uses-sdk android:minSdkVersion="23" />

7.If you are using Sentinel HL keys to protect and license your application, add the following line to your project's AndroidManifest.xml file:

<uses-feature android:name="android.hardware.usb.host" />

Configure 16 KB Page Size Alignment

Starting with Sentinel LDK 10.3.100, Sentinel LDK libraries are compiled with Android NDK r27d. To compile 16 KB-aligned shared libraries with Android NDK r27 or earlier, add the following linker flags to your build system:

>-Wl,-z,max-page-size=16384

>-Wl,-z,common-page-size=16384

For example, if you use the ndk-build system, add the following line to your Android.mk file:

LOCAL_LDFLAGS += -Wl,-z,max-page-size=16384 -Wl,-z,common-page-size=16384

For more information, refer to the official Google Developer Documentation.