Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/issue 392 #409

Merged
merged 4 commits into from
Feb 9, 2017
Merged

Bugfix/issue 392 #409

merged 4 commits into from
Feb 9, 2017

Conversation

askirk
Copy link
Contributor

@askirk askirk commented Jan 31, 2017

-Protecting against SecurityException found in issue #392

@askirk askirk self-assigned this Jan 31, 2017
context.startService(intent);
}catch (SecurityException e){
Log.e(TAG, "Process is bad");
android.os.Process.killProcess(android.os.Process.myPid()); // Let's exit, we can't start our service
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to do this. Killing myPid process will actually kill the entire app. We just want to fail silently here, add a return statement there instead.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we actually can't just return false blindly here. If you take a look at the return statement after this for loop you can see we need to actually return something meaningful. I'd move the ping code into a separate method with the try/catch so that we can continue through the loop and return something meaningful.

Something like this:

	protected 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){
			
		}
	}

Now we can call this in isRouterServiceRunning() so we can iterate through all running services even if one throws a SecurityException
@joeygrover joeygrover merged commit 7159d5b into develop Feb 9, 2017
@joeygrover joeygrover deleted the bugfix/issue_392 branch February 9, 2017 22:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants