Record MediaCodec video playback duration

The algorithm accumulates the duration of time each frame is active
for the attached surface using the onFrameRendered timestamps. It
ignores counting duration where the attached surface is not being
sent to the screen. It also ignores counting frames that are
active for a long period of time (e.g. pauses, rebuffers, etc.).

Test: Tested manually across a variety of apps by comparing
the dumpsys metrics with the duration displayed in the app UI.
The results were accurate to the second, even with multiple
fast-forwards, rewinds, rebufferings and pauses for both tunnel
mode and non-tunnel mode.

Bug: 184112407
Change-Id: I5d9ae2359ca5ead8d444cffc2ff36946228748cd
3 files changed