Implement logging for ContentOrFileUriEventReported

This change covers event type 1
CONTENT_URI_WITHOUT_CALLER_READ_PERMISSION, i.e. when an app launches an
activity with requireContentUriPermissionFromCaller set to "none", and
the launching app passes content URIs it doesn't have permission to
read.

Processing activity launches can happen concurrently, hence it's
important to distinguish which content URIs belong to a specific
activity launch. For that, this change uses Request#hashCode to uniquely
identify launches inside UriGrantsManagerService to collect the required
content URIs for logging. Once the activity launch is completed and the
WindowManager lock is released (to ensure no deadlocking),
ActivityStarter will notify UriGrantsManagerService that the activity
launch has been completed.

If the launch was successful, then UriGrantsManagerService will log the
event and clear the collected content URIs. If the launch was
unsuccessful, then UriGrantsManagerService will simply clear the
collected content URIs.

To collect the content URIs, UriGrantsManagerService uses a new array
map from launch ids to sets of content URIs and guards it by a lock. To
accommodate that, all the methods around
requireContentUriPermissionFromCaller have also been renamed to
indicate whether they should be called in the unlocked or locked state.

Bug: 314273739
Test: statsd_testdrive 933
Flag: EXEMPT metrics
Change-Id: I8a78d8d9d079c93e50de39235e269294aff02884
3 files changed