Sternum Android SDK
com.sternum.cloud.SternumSDK Class Reference

Detailed Description

a Singleton communication relay for Sternum ADS. Please use the static method getInstance to get an SternumSDK instance.

Classes

enum  DeploymentPhase
 
enum  DeviceType
 

Public Member Functions

boolean relayDeviceData (DeviceType deviceType, byte[] data)
 
boolean trace (TraceEventTypeInterface traceEventType, Argument... arguments)
 
native boolean flush ()
 
boolean isInitialized ()
 
synchronized void initialize (@NonNull Context context, @NonNull String sternumURL, @NonNull String firmwareVersion, boolean relayOverrideDeviceID, BigInteger sdkDeviceDefinitionID, DeploymentPhase deploymentPhase, long maxCacheSize, boolean loadNative)
 
void close ()
 

Static Public Member Functions

static synchronized SternumSDK getInstance ()
 

Static Protected Member Functions

static byte[] getSDKDeviceID (@NonNull Context context)
 
static String getCachePath (@NonNull Context context)
 

Member Function Documentation

◆ close()

void com.sternum.cloud.SternumSDK.close ( )

Closes the Sternum SDK. Call initialize to reinitialize.

Note
Call flush before close to prevent data loss.
This function blocks until the all resources are released.

◆ flush()

native boolean com.sternum.cloud.SternumSDK.flush ( )

Flush transmission queue.

Note
This function will block until all pending data is processed and saved to cache.
This function will not ensure a transmission of data to the cloud.
Returns
true on success.

◆ initialize()

synchronized void com.sternum.cloud.SternumSDK.initialize ( @NonNull Context  context,
@NonNull String  sternumURL,
@NonNull String  firmwareVersion,
boolean  relayOverrideDeviceID,
BigInteger  sdkDeviceDefinitionID,
DeploymentPhase  deploymentPhase,
long  maxCacheSize,
boolean  loadNative 
)

Initializes the Singleton. Call this function when first created or if close was called.

Parameters
contextapplication context
sternumURLyour Sternum dedicated transmission URL.
firmwareVersionfirmware version string for target application.
relayOverrideDeviceIDif a remote device that originated the relayed traces cannot have a random a device ID, set to true and the application's device ID will be used.
sdkDeviceDefinitionIDa device definition id for traces transmitted from the importing application.
deploymentPhaseindicates if the application is in production/development phase.
maxCacheSizedefines the maximum amount of bytes to store on disk when caching traces. Cache is automatically emptied when internet connection is available.
loadNativespecify false if you wish to load on your own the native implementation of the SDK.
Note
An ADS device ID is automatically generated for the importing application and saved in SharedPreferences as a private record. The record is removed upon application deletion. For more info please visit https://developer.android.com/training/data-storage -> App preferences.
The cache file is saved inside the application private storage and is not accessible to other entities. The file is removed upon application deletion. For more info please visit https://developer.android.com/training/data-storage/app-specific
The recommended minimum cache size is 65KB to ensure that the biggest protocol payloads can be processed.

◆ isInitialized()

boolean com.sternum.cloud.SternumSDK.isInitialized ( )

Checks if the singleton is initialized.

Returns
true when the Singleton is initialized.

◆ relayDeviceData()

boolean com.sternum.cloud.SternumSDK.relayDeviceData ( DeviceType  deviceType,
byte[]  data 
)

Transmit relayed data that was received from a remote device.

Parameters
deviceTypeeach device type as its own channel for relaying sternum traces. If you are relaying multiple devices in parallel, please make sure to assign each a different device type.
datadata to relay.
Note
This function does not block.

◆ trace()

boolean com.sternum.cloud.SternumSDK.trace ( TraceEventTypeInterface  traceEventType,
Argument...  arguments 
)

Using this API, you will able to create traces.

Each trace call is constructed with a trace event type, defining the purpose of the trace. For example, TRACE_TASK_STARTED. Every trace event type has the "TRACE_" prefix.

A trace can posses multiple arguments. Each argument is constructed from an argument role type that defines the purpose of the argument. For example, ARG_ROLE_NAME. Every argument role type has the "ARG_ROLE_" prefix.

Traces and arguments roles are defined in the TraceEventType.java and ArgumentRoleType.java files. You can download them at any time from ADS.

The Argument class supports an integer/float/string/blob type arguments.

Please see example below: sternumSDK.trace(TraceEventType.TRACE_OS_INFORMATION, new Argument(ArgumentRoleType.ARG_ROLE_NAME, "Android"), new Argument(ArgumentRoleType.ARG_ROLE_VERSION, Build.VERSION.SDK_INT));

Parameters
traceEventTypethe trace event type
argumentsthe trace's arguments.
Note
Each argument role type(ARG_ROLE_*) must be used once under the same trace.
Traces with malformed arguments will be sent if possible with all of the valid arguments up to the malformed one.
The maximum trace size is 64KB.
This function does not block.
Returns
true on success