Expand Minimize Picture-in-picture Power Device Status Voice Recognition Skip Back Skip Forward Minus Plus Play Search
Documentation
Sidebar

Class RouterServiceValidator

Hierarchy

java.lang.Object

Package
com.smartdevicelink.transport

Overview

This class will tell us if the currently running router service is valid or not. To use this class simply create a new instance of RouterServiceValidator with a supplied context. After that, you have the option to set if you want to test in a production setting. If not, it will default to a debug setting. Once you are ready to check if the router service is trusted you simply call routerServiceValidator.validate();

This validator should be passed into the multiplexing transport construction as well.

Quick Jump

Fields
Constructors
Methods

Fields

ROUTER_SERVICE_PACKAGE

public static final java.lang.String ROUTER_SERVICE_PACKAGE
Constant Value
"com.sdl.router"

FLAG_DEBUG_NONE

public static final int FLAG_DEBUG_NONE

FLAG_DEBUG_PACKAGE_CHECK

public static final int FLAG_DEBUG_PACKAGE_CHECK
Constant Value
1

FLAG_DEBUG_VERSION_CHECK

public static final int FLAG_DEBUG_VERSION_CHECK
Constant Value
3

FLAG_DEBUG_INSTALLED_FROM_CHECK

public static final int FLAG_DEBUG_INSTALLED_FROM_CHECK
Constant Value
4

FLAG_DEBUG_USE_TIMESTAMP_CHECK

public static final int FLAG_DEBUG_USE_TIMESTAMP_CHECK
Constant Value
5

FLAG_DEBUG_PERFORM_ALL_CHECKS

public static final int FLAG_DEBUG_PERFORM_ALL_CHECKS
Constant Value
255

Constructors

RouterServiceValidator( Context context )

public RouterServiceValidator(Context context)

Parameters

context

RouterServiceValidator( Context context, ComponentName service )

public RouterServiceValidator(Context context,ComponentName service)

Parameters

context
service

RouterServiceValidator( MultiplexTransportConfig config )

public RouterServiceValidator(MultiplexTransportConfig config)

Parameters

config

Methods

validate()

Main function to call to ensure we are connecting to a validated router service

public boolean validate()

getService()

public android.content.ComponentName getService()

setFlags( int flags )

Use this method if you would like to test your app in a production setting rather than defaulting to a debug mode where you connect to whatever router service is running.

These flags are only used in debugging mode. During production they will be ignored.

public void setFlags(int flags)

Parameters

flags

setSecurityLevel( int securityLevel )

public void setSecurityLevel(int securityLevel)

Parameters

securityLevel

getRefreshRate()

protected static long getRefreshRate()

componentNameForServiceRunning( PackageManager pm )

This method will find which router service is running. Use that info to find out more about that app and service. It will store the found service for later use and return the package name if found.

public android.content.ComponentName componentNameForServiceRunning(PackageManager pm)

Parameters

pm

wasInstalledByAppStore( String packageName )

Check to see if the app was installed from a trusted app store.

public boolean wasInstalledByAppStore(String packageName)

Parameters

packageName
the package name of the app to be tested

inDebugMode()

This method will check to see if this app is a debug build. If it is, we will attempt to connect to any router service. If false, it will only connect to approved apps with router services.

public boolean inDebugMode()

verifyVersion( int version, JSONArray versions )

protected boolean verifyVersion(int version,JSONArray versions)

Parameters

version
versions

createTrustedListRequest( Context context, boolean forceRefresh )

Performs a look up against installed SDL apps that support the router service. When it receives a list back from the server it will store it for later use.

public static boolean createTrustedListRequest(Context context,boolean forceRefresh)

Parameters

context
forceRefresh

createTrustedListRequest( Context context, boolean forceRefresh, RouterServiceValidator.TrustedListCallback listCallback )

public static boolean createTrustedListRequest(Context context,boolean forceRefresh,RouterServiceValidator.TrustedListCallback listCallback)

Parameters

context
forceRefresh
listCallback

createTrustedListRequest( Context context, boolean forceRefresh, HttpRequestTask.HttpRequestTaskCallback cb )

Deprecated

protected static boolean createTrustedListRequest(Context context,boolean forceRefresh,HttpRequestTask.HttpRequestTaskCallback cb)

Parameters

context
forceRefresh
cb

createTrustedListRequest( Context context, boolean forceRefresh, HttpRequestTask.HttpRequestTaskCallback cb, RouterServiceValidator.TrustedListCallback listCallback )

protected static boolean createTrustedListRequest(Context context,boolean forceRefresh,HttpRequestTask.HttpRequestTaskCallback cb,RouterServiceValidator.TrustedListCallback listCallback)

Parameters

context
forceRefresh
cb
listCallback

isServiceRunning( Context context, ComponentName service )

This method will determine if our supplied component name is really running.

protected boolean isServiceRunning(Context context,ComponentName service)

Parameters

context
service

stringToJson( String json )

Parses a string into a JSON array

protected org.json.JSONObject stringToJson(String json)

Parameters

json

invalidateList( Context context )

public static boolean invalidateList(Context context)

Parameters

context

setTrustedList( Context context, String jsonString )

Saves the list of available applications into user's shared prefs.

protected static boolean setTrustedList(Context context,String jsonString)

Parameters

context
The application's environment
jsonString
The JSON string to save.

getTrustedList( Context context )

Retrieves the list of available applications from user's shared prefs.

protected static java.lang.String getTrustedList(Context context)

Parameters

context
The application's environment.

getTrustedAppListTimeStamp( Context context )

Retrieves the time stamp from the user's shared prefs.

protected static java.lang.Long getTrustedAppListTimeStamp(Context context)

Parameters

context
The application's environment.

setLastRequest( Context context, String request )

protected static boolean setLastRequest(Context context,String request)

Parameters

context
request

getLastRequest( Context context )

Gets the last request JSON object we sent to the RSVP server. It basically contains a list of sdl enabled apps

protected static java.lang.String getLastRequest(Context context)

Parameters

context

cacheSecurityLevel( Context context, int securityLevel )

protected static boolean cacheSecurityLevel(Context context,int securityLevel)

Parameters

context
securityLevel

getSecurityLevel( Context context )

protected static int getSecurityLevel(Context context)

Parameters

context

Inherited Methods

From Class Methods
java.lang.Object getClass, hashCode, equals, clone, toString, notify, notifyAll, wait, wait, wait, finalize
View on GitHub.com
Previous Section Next Section