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
-
- validateAsync(RouterServiceValidator.ValidationStatusCallback callback)
- getService()
- setFlags(int flags)
- setSecurityLevel(int securityLevel)
- getRefreshRate()
- componentNameForServiceRunning(PackageManager pm)
- wasInstalledByAppStore(String packageName)
- inDebugMode()
- verifyVersion(int version,JSONArray versions)
- createTrustedListRequest(Context context,boolean forceRefresh)
- createTrustedListRequest(Context context,boolean forceRefresh,RouterServiceValidator.TrustedListCallback listCallback)
- createTrustedListRequest(Context context,boolean forceRefresh,HttpRequestTask.HttpRequestTaskCallback cb,RouterServiceValidator.TrustedListCallback listCallback)
- isServiceRunning(Context context,ComponentName service)
- stringToJson(String json)
- invalidateList(Context context)
- setTrustedList(Context context,String jsonString)
- getTrustedList(Context context)
- getTrustedAppListTimeStamp(Context context)
- setLastRequest(Context context,String request)
- getLastRequest(Context context)
- cacheSecurityLevel(Context context,int securityLevel)
- getSecurityLevel(Context context)
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
public static final int FLAG_DEBUG_PERFORM_ALL_CHECKS
- Constant Value
- 255
Constructors
RouterServiceValidator(
Context context
)
public RouterServiceValidator(Context context)
Constructor Parameters
- context
RouterServiceValidator(
Context context,
ComponentName service
)
public RouterServiceValidator(Context context,ComponentName service)
Constructor Parameters
- context
- service
RouterServiceValidator(
MultiplexTransportConfig config
)
public RouterServiceValidator(MultiplexTransportConfig config)
Constructor Parameters
- config
Methods
validateAsync(
RouterServiceValidator.ValidationStatusCallback callback
)
Asynchronously validate the target RouterService, which includes finding the right RouterService.
public void validateAsync(RouterServiceValidator.ValidationStatusCallback callback)
Method Parameters
- callback
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)
Method Parameters
- flags
setSecurityLevel(
int securityLevel
)
public void setSecurityLevel(int securityLevel)
Method 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)
Method Parameters
- pm
- An instance of a package manager. This is no longer used so null can be sent.
wasInstalledByAppStore(
String packageName
)
Check to see if the app was installed from a trusted app store.
public boolean wasInstalledByAppStore(String packageName)
Method 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)
Method 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)
Method Parameters
- context
- forceRefresh
createTrustedListRequest(
Context context,
boolean forceRefresh,
RouterServiceValidator.TrustedListCallback listCallback
)
public static boolean createTrustedListRequest(Context context,boolean forceRefresh,RouterServiceValidator.TrustedListCallback listCallback)
Method Parameters
- context
- forceRefresh
- listCallback
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)
Method 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)
Method Parameters
- context
- service
stringToJson(
String json
)
Parses a string into a JSON array
protected org.json.JSONObject stringToJson(String json)
Method Parameters
- json
invalidateList(
Context context
)
public static boolean invalidateList(Context context)
Method 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)
Method 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)
Method 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)
Method Parameters
- context
- The application's environment.
setLastRequest(
Context context,
String request
)
protected static boolean setLastRequest(Context context,String request)
Method 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)
Method Parameters
- context
cacheSecurityLevel(
Context context,
int securityLevel
)
protected static boolean cacheSecurityLevel(Context context,int securityLevel)
Method Parameters
- context
- securityLevel
getSecurityLevel(
Context context
)
protected static int getSecurityLevel(Context context)
Method 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