Add logging for activity starts to be blocked as part of go/activity-security

Adds logs for activity starts which don't match the following rules:

1. Only the top activity on a task can start activities on that task
2. Only the top activity on the top task can create new (top) tasks

These logs will be used to determine which valid use cases may be
blocked by the ASM project in the future.

Scenarios which will emit a log:

Here, B1 is com.android.messaging.ui.conversationlist.ConversationListActivity

1. A1 launches B1, then A1 launches A2 on top:

activity_blocked {
     caller_uid: 10111
     caller_activity_class_name: "com.hanikazmi.activitysecuritymodeltasks.A1"
     target_task_top_activity_uid: 10078
     target_task_top_activity_class_name: "com.android.messaging.ui.conversationlist.ConversationListActivity"
     target_task_is_different: false
     target_activity_uid: 10111
     target_activity_class_name: "com.hanikazmi.activitysecuritymodeltasks.A2"
     target_intent_action: ""
     target_intent_flags: 0
}

2. A1 launches B1, then launches A2 into a new task:

activity_blocked {
     caller_uid: 10111
     caller_activity_class_name: "com.hanikazmi.activitysecuritymodeltasks.A1"
     target_task_top_activity_uid: -1
     target_task_top_activity_class_name: ""
     target_task_is_different: true
     target_activity_uid: 10111
     target_activity_class_name: "com.hanikazmi.activitysecuritymodeltasks.A2"
     target_intent_action: ""
     target_intent_flags: 402653184
}

3. A1 finishes itself, then launches A2
4. A1 launching B1 into a new task, then laucnhing B1 again (recycling)
5. A1 launches B1 on top of itself, Then A2 in Task 2 launches A1 again
   (recycling)

Scenarios verified to not log:

1. A1 launching A2 on top of itself
2. A1 launching A2 into a new task
3. A1 launching B1 into a new task
4. A1 launches A2, then finishes itself

Test: statsd_testdrive 494
Test: Manually tested above scenarios and viewed logs
Bug: 229747522
Change-Id: I5228cd9afbc1567bb5e3d245fa7f2701bf2a78d3
Merged-In: I5228cd9afbc1567bb5e3d245fa7f2701bf2a78d3
1 file changed