Varun Shah | e1ba9cd | 2019-08-27 17:11:25 -0700 | [diff] [blame] | 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 | |
| 17 | syntax = "proto2"; |
| 18 | package com.android.server.usage; |
| 19 | import "frameworks/base/core/proto/android/content/configuration.proto"; |
| 20 | import "frameworks/base/core/proto/android/privacy.proto"; |
| 21 | |
| 22 | option java_multiple_files = true; |
| 23 | |
| 24 | /** |
| 25 | * Obfuscated version of android.service.IntervalStatsProto (usagestatsservice.proto). |
| 26 | */ |
| 27 | message 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 | */ |
| 65 | message 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 | */ |
| 89 | message 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 | } |
| 103 | |
| 104 | /** |
| 105 | * This message stores all of the fields in an Event object as strings instead of tokens. |
| 106 | */ |
| 107 | message PendingEventProto { |
| 108 | optional string package_name = 1; |
| 109 | optional string class_name = 2; |
| 110 | optional int64 time_ms = 3; |
| 111 | optional int32 flags = 4; |
| 112 | optional int32 type = 5; |
| 113 | optional .android.content.ConfigurationProto config = 6; |
| 114 | optional string shortcut_id = 7; |
| 115 | optional int32 standby_bucket = 8; |
| 116 | optional string notification_channel_id = 9; |
| 117 | optional int32 instance_id = 10; |
| 118 | optional string task_root_package = 11; |
| 119 | optional string task_root_class = 12; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * A proto message representing the obfuscated tokens mappings for Usage Stats. |
| 124 | */ |
| 125 | message ObfuscatedPackagesProto { |
| 126 | message PackagesMap { |
| 127 | optional int32 package_token = 1; |
| 128 | // The list of strings for each package where their indices are the token |
| 129 | repeated string strings = 2; |
| 130 | } |
| 131 | |
| 132 | optional int32 counter = 1; |
| 133 | // Stores the mappings for every package |
| 134 | repeated PackagesMap packages_map = 2; |
| 135 | } |