Refactor checking for inserting activity into existing task.

Inserting into existing task is a large chunk of code with very deep
indentation. This removes 2 levels of indentation by checking them
together and returning final result.

CL also includes moving some of the permission checking code into a
separate method.

Change-Id: Ieba82ef9e410094de229b0d25b2a60bf18a1e869
1 file changed