public class RouterServiceValidator extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
RouterServiceValidator.SdlApp
Class that holds all the info we want to send/receive from the validation server
|
static class |
RouterServiceValidator.TrustedAppStore |
static interface |
RouterServiceValidator.TrustedListCallback
This interface is used as a callback to know when we have either obtained a list or at least returned from our attempt.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
FLAG_DEBUG_INSTALLED_FROM_CHECK |
static int |
FLAG_DEBUG_NONE |
static int |
FLAG_DEBUG_PACKAGE_CHECK |
static int |
FLAG_DEBUG_PERFORM_ALL_CHECKS |
static int |
FLAG_DEBUG_USE_TIMESTAMP_CHECK |
static int |
FLAG_DEBUG_VERSION_CHECK
This will flag the validator to check for app version during debugging.
|
static String |
ROUTER_SERVICE_PACKAGE |
| Constructor and Description |
|---|
RouterServiceValidator(Context context) |
RouterServiceValidator(Context context,
ComponentName service) |
RouterServiceValidator(MultiplexTransportConfig config) |
| Modifier and Type | Method and Description |
|---|---|
protected static boolean |
cacheSecurityLevel(Context context,
int securityLevel) |
ComponentName |
componentNameForServiceRunning(PackageManager pm)
This method will find which router service is running.
|
static boolean |
createTrustedListRequest(Context context,
boolean forceRefresh)
Performs a look up against installed SDL apps that support the router service.
|
protected static boolean |
createTrustedListRequest(Context context,
boolean forceRefresh,
HttpRequestTask.HttpRequestTaskCallback cb,
RouterServiceValidator.TrustedListCallback listCallback) |
static boolean |
createTrustedListRequest(Context context,
boolean forceRefresh,
RouterServiceValidator.TrustedListCallback listCallback) |
protected static String |
getLastRequest(Context context)
Gets the last request JSON object we sent to the RSVP server.
|
protected static long |
getRefreshRate() |
protected static int |
getSecurityLevel(Context context) |
ComponentName |
getService() |
protected static Long |
getTrustedAppListTimeStamp(Context context)
Retrieves the time stamp from the user's shared prefs.
|
protected static String |
getTrustedList(Context context)
Retrieves the list of available applications from user's shared prefs.
|
boolean |
inDebugMode()
This method will check to see if this app is a debug build.
|
static boolean |
invalidateList(Context context) |
protected boolean |
isServiceRunning(Context context,
ComponentName service)
This method will determine if our supplied component name is really running.
|
void |
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.
|
protected static boolean |
setLastRequest(Context context,
String request) |
void |
setSecurityLevel(int securityLevel) |
protected static boolean |
setTrustedList(Context context,
String jsonString)
Saves the list of available applications into user's shared prefs.
|
protected JSONObject |
stringToJson(String json)
Parses a string into a JSON array
|
void |
validateAsync(com.smartdevicelink.transport.RouterServiceValidator.ValidationStatusCallback callback)
Asynchronously validate the target RouterService, which includes finding the right RouterService.
|
protected boolean |
verifyVersion(int version,
JSONArray versions) |
boolean |
wasInstalledByAppStore(String packageName)
Check to see if the app was installed from a trusted app store.
|
public static final String ROUTER_SERVICE_PACKAGE
public static final int FLAG_DEBUG_NONE
public static final int FLAG_DEBUG_PACKAGE_CHECK
public static final int FLAG_DEBUG_VERSION_CHECK
public static final int FLAG_DEBUG_INSTALLED_FROM_CHECK
public static final int FLAG_DEBUG_USE_TIMESTAMP_CHECK
public static final int FLAG_DEBUG_PERFORM_ALL_CHECKS
public RouterServiceValidator(Context context)
public RouterServiceValidator(Context context, ComponentName service)
public RouterServiceValidator(@NonNull
MultiplexTransportConfig config)
public void validateAsync(com.smartdevicelink.transport.RouterServiceValidator.ValidationStatusCallback callback)
callback: - callback gets called when validation finishes.public ComponentName getService()
public void setFlags(int flags)
flags - public void setSecurityLevel(int securityLevel)
protected static long getRefreshRate()
public ComponentName componentNameForServiceRunning(PackageManager pm)
pm - An instance of a package manager. This is no longer used so null can be sent.public boolean wasInstalledByAppStore(String packageName)
packageName - the package name of the app to be testedpublic boolean inDebugMode()
protected boolean verifyVersion(int version,
JSONArray versions)
public static boolean createTrustedListRequest(Context context, boolean forceRefresh)
context - public static boolean createTrustedListRequest(Context context, boolean forceRefresh, RouterServiceValidator.TrustedListCallback listCallback)
protected static boolean createTrustedListRequest(Context context, boolean forceRefresh, HttpRequestTask.HttpRequestTaskCallback cb, RouterServiceValidator.TrustedListCallback listCallback)
protected boolean isServiceRunning(Context context, ComponentName service)
context - service - protected JSONObject stringToJson(String json)
json - public static boolean invalidateList(Context context)
protected static boolean setTrustedList(Context context, String jsonString)
context - The application's environmentjsonString - The JSON string to save.protected static String getTrustedList(Context context)
context - The application's environment.protected static Long getTrustedAppListTimeStamp(Context context)
context - The application's environment.protected static String getLastRequest(Context context)
context - protected static boolean cacheSecurityLevel(Context context, int securityLevel)
protected static int getSecurityLevel(Context context)