1/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17syntax = "proto2";
18package com.android.server.usage;
19import "frameworks/base/core/proto/android/content/configuration.proto";
20import "frameworks/base/core/proto/android/privacy.proto";
21
22option java_multiple_files = true;
23
24/**
25 * Obfuscated version of android.service.IntervalStatsProto (usagestatsservice.proto).
26 */
27message IntervalStatsObfuscatedProto {
28
29  message CountAndTime {
30    optional int32 count = 1;
31    optional int64 time_ms = 2;
32  }
33
34  // Stores the relevant information an IntervalStats will have about a Configuration
35  message Configuration {
36    optional .android.content.ConfigurationProto config = 1;
37    optional int64 last_time_active_ms = 2;
38    optional int64 total_time_active_ms = 3;
39    optional int32 count = 4;
40    optional bool active = 5;
41  }
42
43  // The following fields contain supplemental data used to build IntervalStats.
44  optional int64 end_time_ms = 1;
45  optional int32 major_version = 2;
46  optional int32 minor_version = 3;
47
48  // The following fields contain aggregated usage stats data
49  optional CountAndTime interactive = 10;
50  optional CountAndTime non_interactive = 11;
51  optional CountAndTime keyguard_shown = 12;
52  optional CountAndTime keyguard_hidden = 13;
53
54  // The following fields contain listed usage stats data
55  repeated UsageStatsObfuscatedProto packages = 20;
56  repeated Configuration configurations = 21;
57  repeated EventObfuscatedProto event_log = 22;
58  // The following field is only used to persist the reported events before a user unlock
59  repeated PendingEventProto pending_events = 23;
60}
61
62/**
63 * Stores the relevant information from an obfuscated UsageStats.
64 */
65message UsageStatsObfuscatedProto {
66  message ChooserAction {
67    message CategoryCount {
68      optional int32 category_token = 1;
69      optional int32 count = 2;
70    }
71    optional int32 action_token = 1;
72    repeated CategoryCount counts = 2;
73  }
74  optional int32 package_token = 1;
75  optional int64 last_time_active_ms = 3;
76  optional int64 total_time_active_ms = 4;
77  optional int32 last_event = 5;
78  optional int32 app_launch_count = 6;
79  repeated ChooserAction chooser_actions = 7;
80  optional int64 last_time_service_used_ms = 8;
81  optional int64 total_time_service_used_ms = 9;
82  optional int64 last_time_visible_ms = 10;
83  optional int64 total_time_visible_ms = 11;
84}
85
86/**
87 * Stores the relevant information from an obfuscated Event.
88 */
89message EventObfuscatedProto {
90  optional int32 package_token = 1;
91  optional int32 class_token = 2;
92  optional int64 time_ms = 3;
93  optional int32 flags = 4;
94  optional int32 type = 5;
95  optional .android.content.ConfigurationProto config = 6;
96  optional int32 shortcut_id_token = 7;
97  optional int32 standby_bucket = 8;
98  optional int32 notification_channel_id_token = 9;
99  optional int32 instance_id = 10;
100  optional int32 task_root_package_token = 11;
101  optional int32 task_root_class_token = 12;
102  optional int32 locus_id_token = 13;
103}
104
105/**
106 * This message stores all of the fields in an Event object as strings instead of tokens.
107 */
108message PendingEventProto {
109  optional string package_name = 1;
110  optional string class_name = 2;
111  optional int64 time_ms = 3;
112  optional int32 flags = 4;
113  optional int32 type = 5;
114  optional .android.content.ConfigurationProto config = 6;
115  optional string shortcut_id = 7 [(.android.privacy).dest = DEST_EXPLICIT];
116  optional int32 standby_bucket = 8;
117  optional string notification_channel_id = 9 [(.android.privacy).dest = DEST_EXPLICIT];
118  optional int32 instance_id = 10;
119  optional string task_root_package = 11;
120  optional string task_root_class = 12;
121  optional string locus_id = 13 [(.android.privacy).dest = DEST_EXPLICIT];
122}
123
124/**
125 * A proto message representing the obfuscated tokens mappings for Usage Stats.
126 */
127message ObfuscatedPackagesProto {
128  message PackagesMap {
129    optional int32 package_token = 1;
130    // The list of strings for each package where their indices are the token
131    repeated string strings = 2 [(.android.privacy).dest = DEST_EXPLICIT];
132  }
133
134  optional int32 counter = 1;
135  // Stores the mappings for every package
136  repeated PackagesMap packages_map = 2;
137}
138