summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Kirk <askirk@umich.edu>2017-02-08 16:01:42 -0500
committerAustin Kirk <askirk@umich.edu>2017-02-08 16:01:42 -0500
commit555d0a705f5e33093f973fd71fd459afbed3551b (patch)
tree938ab5ec95be0e26a1671ab5eafeae464937e845
parent537240e4b824779361c44d71651086aea74b5c05 (diff)
downloadsdl_android-bugfix/issue_392.tar.gz
Creating pingRouterService methodbugfix/issue_392
Now we can call this in isRouterServiceRunning() so we can iterate through all running services even if one throws a SecurityException
-rw-r--r--sdl_android_lib/src/com/smartdevicelink/transport/SdlBroadcastReceiver.java31
1 files changed, 22 insertions, 9 deletions
diff --git a/sdl_android_lib/src/com/smartdevicelink/transport/SdlBroadcastReceiver.java b/sdl_android_lib/src/com/smartdevicelink/transport/SdlBroadcastReceiver.java
index e32aeff94..d398caaab 100644
--- a/sdl_android_lib/src/com/smartdevicelink/transport/SdlBroadcastReceiver.java
+++ b/sdl_android_lib/src/com/smartdevicelink/transport/SdlBroadcastReceiver.java
@@ -200,15 +200,7 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{
runningBluetoothServicePackage.add(service.service); //Store which instance is running
if(pingService){
- Intent intent = new Intent();
- intent.setClassName(service.service.getPackageName(), service.service.getClassName());
- intent.putExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA, pingService);
- try {
- context.startService(intent);
- }catch (SecurityException e){
- Log.e(TAG, "Security exception, process is bad");
- return false; // Let's exit, we can't start the service
- }
+ pingRouterService(context, service.service.getPackageName(), service.service.getClassName());
}
}
}
@@ -218,6 +210,27 @@ public abstract class SdlBroadcastReceiver extends BroadcastReceiver{
}
/**
+ * Attempts to ping a running router service
+ * @param context A context to access Android system services through.
+ * @param packageName Package name for service to ping
+ * @param className Class name for service to ping
+ */
+ protected static void pingRouterService(Context context, String packageName, String className){
+ if(context == null || packageName == null || className == null){
+ return;
+ }
+ try{
+ Intent intent = new Intent();
+ intent.setClassName(packageName, className);
+ intent.putExtra(TransportConstants.PING_ROUTER_SERVICE_EXTRA, true);
+ context.startService(intent);
+ }catch(SecurityException e){
+ Log.e(TAG, "Security exception, process is bad");
+ // This service could not be started
+ }
+ }
+
+ /**
* This call will reach out to all SDL related router services to check if they're connected. If a the router service is connected, it will react by pinging all clients. This receiver will then
* receive that ping and if the router service is trusted, the onSdlEnabled method will be called.
* @param context