1/* 2 * Copyright (C) 2018 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 24message IntervalStatsProto { 25 message StringPool { 26 optional int32 size = 1; 27 repeated string strings = 2; 28 } 29 30 message CountAndTime { 31 optional int32 count = 1; 32 optional int64 time_ms = 2; 33 } 34 35 // Stores the relevant information from a UsageStats 36 message UsageStats { 37 message ChooserAction { 38 message CategoryCount { 39 optional string name = 1; 40 optional int32 count = 3; 41 } 42 optional string name = 1; 43 repeated CategoryCount counts = 3; 44 } 45 optional string package = 1; 46 // package_index contains the index + 1 of the package name in the string pool 47 optional int32 package_index = 2; 48 // Time attributes stored as an offset of the IntervalStats's beginTime. 49 optional int64 last_time_active_ms = 3; 50 optional int64 total_time_active_ms = 4; 51 optional int32 last_event = 5; 52 optional int32 app_launch_count = 6; 53 repeated ChooserAction chooser_actions = 7; 54 // Time attributes stored as an offset of the IntervalStats's beginTime. 55 optional int64 last_time_service_used_ms = 8; 56 optional int64 total_time_service_used_ms = 9; 57 // Time attributes stored as an offset of the IntervalStats's beginTime. 58 optional int64 last_time_visible_ms = 10; 59 optional int64 total_time_visible_ms = 11; 60 } 61 62 // Stores the relevant information an IntervalStats will have about a Configuration 63 message Configuration { 64 optional .android.content.ConfigurationProto config = 1; 65 optional int64 last_time_active_ms = 2; 66 optional int64 total_time_active_ms = 3; 67 optional int32 count = 4; 68 optional bool active = 5; 69 } 70 71 // Stores the relevant information from a UsageEvents.Event 72 message Event { 73 optional string package = 1; 74 // package_index contains the index + 1 of the package name in the string pool 75 optional int32 package_index = 2; 76 optional string class = 3; 77 // class_index contains the index + 1 of the class name in the string pool 78 optional int32 class_index = 4; 79 optional int64 time_ms = 5; 80 optional int32 flags = 6; 81 optional int32 type = 7; 82 optional .android.content.ConfigurationProto config = 8; 83 optional string shortcut_id = 9; 84 optional int32 standby_bucket = 11; 85 optional string notification_channel = 12; 86 // notification_channel_index contains the index + 1 of the channel name in the string pool 87 optional int32 notification_channel_index = 13; 88 // If class field is an Activity, instance_id is a unique id of the 89 // Activity object. 90 optional int32 instance_id = 14; 91 // task_root_package_index contains the index + 1 of the task root package name in the string 92 // pool 93 optional int32 task_root_package_index = 15; 94 // task_root_class_index contains the index + 1 of the task root class name in the string pool 95 optional int32 task_root_class_index = 16; 96 } 97 98 // The following fields contain supplemental data used to build IntervalStats, such as a string 99 // pool. 100 optional int64 end_time_ms = 1; 101 // stringpool contains all the package and class names used by UsageStats and Event 102 // They will hold a number that is equal to the index + 1 of their string in the pool 103 optional StringPool stringpool = 2; 104 optional int32 major_version = 3; 105 optional int32 minor_version = 4; 106 107 // The following fields contain aggregated usage stats data 108 optional CountAndTime interactive = 10; 109 optional CountAndTime non_interactive = 11; 110 optional CountAndTime keyguard_shown = 12; 111 optional CountAndTime keyguard_hidden = 13; 112 113 // The following fields contain listed usage stats data 114 repeated UsageStats packages = 20; 115 repeated Configuration configurations = 21; 116 repeated Event event_log = 22; 117} 118