This change is the main check in for the historical app op feature. The idea is to store a historical data about past app op rejections, accesses, and durations per op for any UID state indefinitely. Keeping all operations on record is not practical as app ops are very frequently performed. To address this we are storing aggregated data as snapshots where we store for every UID and its packages how many times each op was accessed, rejected, lasted as an aggregate. To allow history scaling indefinitely we are taking a logarithmic approach with only the most recent state stored in memory and all preceding state stored on disk. State on disk is stored in separate files where each preceding file, i.e. for an older period, would cover X times longer period with X number of snapshots covering X times longer period. Initially X is ten but can be tweaked. For example, the first file could contain data for ten days with daily snapshots, while the file for older period would have data for a hundred days with snapshots every ten days, etc. The implementation is optimized for fast history update and no impact on system runtime performance and minimizing memory footprint. We are lazily persisting state to disk on a dedicated thread as this is slow. We are also reading the relevant historical files on a query as this is very rare as opposed to state updates. The base snapshot interval, i.e. snapshot time span, in the initial iteration and the logarithmic step are configurable. These can be changed dynamically and the history would be rewriten to take this into account. Test: atest CtsAppOpsTestCases bug:111061782 Change-Id: I55c32c79911ba12b2ace58d2a782b8df1e6bff60
Conventions for the protos in this directory:
-
As in the rest of Android, use 4 spaces to indent instead of 2.
-
For protos based on Java files, use the same package as the Java file. For example,
com.android.server.thinginstead ofcom.android.server.thing.proto. -
If the proto describes the top level output of dumpsys, it should contain
Dump. This makes it easy to understand that the proto is the dumpsys output of a certain service, not the data structure of that service, e.g.WindowManagerServiceDumpProtovsWindowManagerServiceProto.- Inner messages whose containing messages have the
Protosuffix do not need to have aProtosuffix. E.g:
- Inner messages whose containing messages have the
message FooProto {
message Bar {
...
}
}
vs
message FooProto {
message BarProto {
...
}
}
-
If the proto represents the structure of an object, it should have
Protoas its suffix. Please also include the full package path of the original object as a comment to the proto message. -
Include units in the field names. For example,
screen_time_msvsscreen_time, orfile_size_bytesorfile_size_mebibytesvsfile_size. -
Leave field numbers 50,000 - 100,000 reserved for OEMs.