Skip to content
Commit 182862e5 authored by Adam Bookatz's avatar Adam Bookatz
Browse files

Listener to watch op starts

Currently, there is
onOpNoted - tells listeners that noteOp has occurred
onOpActiveChanged - tells listeners that an op's 'active' state has
changed, i.e. that a successfull startOp or stopOp has happened

There was, however, no way of telling a listener that a startOp has
happened (regardless of whether it was successful). This cl introduces
it, via a OnOpStartedListener.

This is required by the ForegroundServiceAppOpSessionEnded atom,
which counts the number of accepted vs. rejected attempts, and
therefore also needs to know when a rejected start happened.

This cl also contains some cosmetic moving of code so that
startOperation() and noteOperationImpl() are almost
exactly parallel.

* Also *
This cl fixes a bug I discovered in stopWatchingNoted, in which
the callback wasn't fully removed. Consequently, if a callback
was unregistered and then re-registered, the re-registration would
mistakingly be ignored (in direct contradiction to the javadoc).

Test: atest UidAtomTests#testForegroundServiceAccessAppOp
Test: atest AppOpsStartedWatcherTest AppOpsActiveWatcherTest AppOpsNotedWatcherTest
Test: manually monitor: adb shell cmd stats print-logs && adb logcat -v uid -s statsd | grep "statsd  : {" | egrep '\(256\)'
Bug: 152800926
Change-Id: Icdb9edf6b2b7c5807b339c1aabb32e882190b071
parent 98f012c3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment