[MS45] Expose SystemApis to query summary and history with template

This includes:
1. queryDetailsForDevice: get history of network stats that
   matches the given template.
2. querySummaryForDevice: similar to the above one, but the
   result is aggregated over time.
3. queryDetailsForUidTagState: get history of uid stats that
   matches the given template, uid, tag and other conditions.
4. querySummary: similar to the above one, but the
   result is aggregated over time.
5. queryTaggedSummary: similar to the above one, but only
   return tagged data.

Test: TH
Bug: 204830222
Change-Id: Ic18010822a33e340b954e9c53dc515f3b6224d6d
This commit is contained in:
Junyu Lai
2022-01-07 14:46:26 +00:00
parent bb459aeaba
commit 84316eb4b6

View File

@@ -211,9 +211,10 @@ public class NetworkStatsManager {
*/
@NonNull
@WorkerThread
// @SystemApi(client = MODULE_LIBRARIES)
@SystemApi(client = MODULE_LIBRARIES)
public Bucket querySummaryForDevice(@NonNull NetworkTemplate template,
long startTime, long endTime) {
Objects.requireNonNull(template);
try {
NetworkStats stats =
new NetworkStats(mContext, template, mFlags, startTime, endTime, mService);
@@ -385,10 +386,11 @@ public class NetworkStatsManager {
* @hide
*/
@NonNull
// @SystemApi(client = MODULE_LIBRARIES)
@SystemApi(client = MODULE_LIBRARIES)
@WorkerThread
public NetworkStats querySummary(@NonNull NetworkTemplate template, long startTime,
long endTime) throws SecurityException {
Objects.requireNonNull(template);
try {
NetworkStats result =
new NetworkStats(mContext, template, mFlags, startTime, endTime, mService);
@@ -418,10 +420,11 @@ public class NetworkStatsManager {
* @hide
*/
@NonNull
// @SystemApi(client = MODULE_LIBRARIES)
@SystemApi(client = MODULE_LIBRARIES)
@WorkerThread
public NetworkStats queryTaggedSummary(@NonNull NetworkTemplate template, long startTime,
long endTime) throws SecurityException {
Objects.requireNonNull(template);
try {
NetworkStats result =
new NetworkStats(mContext, template, mFlags, startTime, endTime, mService);
@@ -453,10 +456,11 @@ public class NetworkStatsManager {
* @hide
*/
@NonNull
// @SystemApi(client = MODULE_LIBRARIES)
@SystemApi(client = MODULE_LIBRARIES)
@WorkerThread
public NetworkStats queryDetailsForDevice(@NonNull NetworkTemplate template,
long startTime, long endTime) {
Objects.requireNonNull(template);
try {
final NetworkStats result =
new NetworkStats(mContext, template, mFlags, startTime, endTime, mService);
@@ -580,10 +584,11 @@ public class NetworkStatsManager {
* @hide
*/
@NonNull
// @SystemApi(client = MODULE_LIBRARIES)
@SystemApi(client = MODULE_LIBRARIES)
@WorkerThread
public NetworkStats queryDetailsForUidTagState(@NonNull NetworkTemplate template,
long startTime, long endTime, int uid, int tag, int state) throws SecurityException {
Objects.requireNonNull(template);
try {
final NetworkStats result = new NetworkStats(
mContext, template, mFlags, startTime, endTime, mService);