Expose app op mode getter/setter/change listener directly on policy.

This allows the compat layer to call them with less ceremony of going
through URIs.

Also call UserState.requestWrite() upon changes.

It is unfortunate that we have to duplicate some code this way, but we
have to do it because Java/Kotlin generics doesn't allow primitive
ints and we want to avoid auto-boxing.

Also made mutateState()'s lambda crossinline so that the caller don't
accidentally stop the state mutation mid-way.

Bug: 182523293
Test: presubmit
Change-Id: I1f61c35352a9c614939976bf98ee2eeb9bb8d0e0
6 files changed