1/* 2 * Copyright (C) 2023 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"; 18 19package android.os.statsd.healthfitness.api; 20 21import "frameworks/proto_logging/stats/atoms.proto"; 22import "frameworks/proto_logging/stats/atom_field_options.proto"; 23import "frameworks/proto_logging/stats/enums/healthfitness/api/enums.proto"; 24 25option java_multiple_files = true; 26option java_package = "com.android.os.healthfitness.api"; 27 28extend Atom { 29 optional HealthConnectApiCalled health_connect_api_called = 616 [(module) = "healthfitness"]; 30 31 optional HealthConnectUsageStats health_connect_usage_stats = 617 [(module) = "healthfitness"]; 32 33 optional HealthConnectStorageStats health_connect_storage_stats = 618 [(module) = "healthfitness"]; 34 35 optional HealthConnectApiInvoked health_connect_api_invoked = 643 [(module) = "healthfitness", (restriction_category) = RESTRICTION_DIAGNOSTIC]; 36 37 optional ExerciseRouteApiCalled exercise_route_api_called = 654 [(module) = "healthfitness", (restriction_category) = RESTRICTION_DIAGNOSTIC]; 38 39 optional HealthConnectExportInvoked health_connect_export_invoked = 907 [(module) = "healthfitness"]; 40 41 optional HealthConnectImportInvoked health_connect_import_invoked = 918 [(module) = "healthfitness"]; 42 43 optional HealthConnectExportImportStatsReported health_connect_export_import_stats_reported = 919 [(module) = "healthfitness"]; 44 45 optional HealthConnectPermissionStats health_connect_permission_stats = 963 [(module) = "healthfitness"]; 46 47 optional HealthConnectPhrApiInvoked health_connect_phr_api_invoked = 980 [(module) = "healthfitness", (restriction_category) = RESTRICTION_DIAGNOSTIC]; 48 49 optional HealthConnectPhrUsageStats health_connect_phr_usage_stats = 981 [(module) = "healthfitness"]; 50 51 optional HealthConnectPhrStorageStats health_connect_phr_storage_stats = 984 [(module) = "healthfitness"]; 52 53 optional HealthConnectRestrictedEcosystemStats health_connect_restricted_ecosystem_stats = 985 [(module) = "healthfitness", (restriction_category) = RESTRICTION_DIAGNOSTIC]; 54 55 optional HealthConnectEcosystemStats health_connect_ecosystem_stats = 986 [(module) = "healthfitness"]; 56 57 optional HealthConnectDataBackupInvoked health_connect_data_backup_invoked = 1023 [(module) = "healthfitness"]; 58 59 optional HealthConnectSettingsBackupInvoked health_connect_settings_backup_invoked = 1024 [(module) = "healthfitness"]; 60 61 optional HealthConnectDataRestoreInvoked health_connect_data_restore_invoked = 1025 [(module) = "healthfitness"]; 62 63 optional HealthConnectSettingsRestoreInvoked health_connect_settings_restore_invoked = 1026 [(module) = "healthfitness"]; 64 65 optional HealthConnectRestoreEligibilityChecked health_connect_restore_eligibility_checked = 1027 [(module) = "healthfitness"]; 66} 67 68// Track HealthDataService API operations. 69message HealthConnectApiCalled { 70 71 // API method invoked. 72 optional android.healthfitness.api.ApiMethod api_method = 1; 73 74 // Status whether the API call executed successfully or not. 75 optional android.healthfitness.api.ApiStatus api_status = 2; 76 77 // Only relevant when status == ERROR; 78 optional int32 error_code = 3; 79 80 // Total API call duration in milliseconds. 81 optional int64 duration_millis = 4; 82 83 // Number of records being inserted/updated etc. (If any) 84 optional int32 number_of_records = 5; 85 86 // Type of rate limiting being used (If any) 87 optional android.healthfitness.api.RateLimit rate_limit = 6; 88 89 // The API caller's foreground status 90 optional android.healthfitness.api.ForegroundState caller_foreground_state = 7; 91 92 // Package calling the API. We will remove any package with less than certain number of installs (500k for now) from aggregations. 93 optional string package_name = 8; 94} 95 96// Track if users are connecting apps with Health Connect 97message HealthConnectUsageStats { 98 99 // Number of connected apps 100 optional int32 connected_apps_count = 1; 101 102 // Number of apps on device that can be connected to Health Connect. 103 optional int32 available_apps_count = 2; 104 105 // Set true is the user has one app reading or writing in past 30 days 106 optional bool is_monthly_active_user = 3; 107 108} 109 110// Track if users are connecting personal health record apps with Health Connect 111message HealthConnectPhrUsageStats { 112 113 // Number of connected medical data sources 114 optional int32 connected_medical_datasource_count = 1; 115 116 // Number of stored medical resources. 117 optional int32 medical_resource_count = 2; 118 119 // Set true if the user has one read medical resources API call in past 30 120 // days. PHR stands for Personal Health Record. 121 optional bool is_monthly_active_phr_user = 3; 122 123 // Number of apps that have been granted at least one medical data read 124 // permission. PHR stands for Personal Health Record. 125 optional int32 granted_phr_apps_count = 4; 126 127} 128 129/** 130 * Tracks the daily usage stats of the Health Connect export/import feature. 131 * 132 * Logged from: 133 * packages/modules/HealthFitness/service/java/com/android/server/healthconnect/logging/UsageStatsLogger.java 134 * 135 * Estimated Logging Rate: 136 * Avg: 1 per device per day 137 * 138 */ 139message HealthConnectExportImportStatsReported { 140 141 // Configured export frequency of the user 142 optional int32 export_frequency = 1; 143 144} 145 146// Monitor Health Connect database 147message HealthConnectStorageStats { 148 149 // Size of database 150 optional int64 database_size = 1; 151 152 // Total number of instant records in the database. 153 optional int64 instant_data_count = 2; 154 155 // Total number of interval records in the database. 156 optional int64 interval_data_count = 3; 157 158 // Total number of series records in the database. 159 optional int64 series_data_count = 4; 160 161 // Total number of changelog counts. 162 optional int64 changelog_count = 5; 163} 164 165// Monitor PHR database in HC (PHR stands for Personal Health Record) 166message HealthConnectPhrStorageStats { 167 optional int64 phr_data_size = 1; 168} 169 170// Track when ExerciseRoute is being read/written. 171message ExerciseRouteApiCalled { 172 173 // Read/write. 174 optional android.healthfitness.api.Operation operation = 1; 175 176 // Package name of the client that invoked the API. 177 optional string package_name = 2; 178 179 // Number of records under operation 180 optional int32 number_of_records = 3; 181 182} 183 184/** 185 * Tracks when a data export is started or changes status. 186 */ 187message HealthConnectExportInvoked { 188 189 // Status of the export (started/success/failure) 190 optional android.healthfitness.api.ExportStatus status = 1; 191 192 // Time taken between the start of the export and its conclusion. 193 optional int32 time_to_succeed_or_fail_millis = 2; 194 195 // Size of the original data before it is compressed for the export. 196 optional int32 original_data_size_kb = 3; 197 198 // Size of the compressed data being exported. 199 optional int32 compressed_data_size_kb = 4; 200 201 // The number of export attempts that have failed with the same error code 202 // as the current export attempt. It is 0 if the current export is a regular 203 // scheduled export rather than a retry. 204 optional int32 repeat_error_on_retry_count = 5; 205} 206 207/** 208 * Tracks when a data import is started or changes status. 209 */ 210message HealthConnectImportInvoked { 211 212 // Status of the import (started/success/failure) 213 optional android.healthfitness.api.ImportStatus status = 1; 214 215 // Time taken between the start of the import and its conclusion. 216 optional int32 time_to_succeed_or_fail_millis = 2; 217 218 // Size of the original data after it is decompressed after the import. 219 optional int32 original_data_size_kb = 3; 220 221 // Size of the compressed data being imported. 222 optional int32 compressed_data_size_kb = 4; 223} 224 225/** 226 * Track when a Backup and Restore data backup is invoked. 227 * Logged from: 228 * packages/modules/HealthFitness/service/java/com/android/server/healthconnect/logging/BackupRestoreLogger.java 229 * 230 * Estimated Logging Rate: 231 * Avg: 1 per device per day 232 */ 233message HealthConnectDataBackupInvoked { 234 235 // Status of the data backup (started/success/failure) 236 optional android.healthfitness.api.DataBackupStatus status = 1; 237 238 // Time taken between the start of the data backup and its conclusion. 239 optional int32 time_to_succeed_or_fail_millis = 2; 240 241 // Size of the data being backed up. 242 optional int32 data_size_kb = 3; 243 244 // Data backup type (full/incremental). 245 optional android.healthfitness.api.DataBackupType backup_type = 4; 246} 247 248/** 249 * Track when a Backup and Restore settings backup is invoked. 250 * Logged from: 251 * packages/modules/HealthFitness/service/java/com/android/server/healthconnect/logging/BackupRestoreLogger.java 252 * 253 * Estimated Logging Rate: 254 * Avg: 1 per device per day 255 */ 256message HealthConnectSettingsBackupInvoked { 257 258 // Status of the settings backup (started/success/failure) 259 optional android.healthfitness.api.SettingsBackupStatus status = 1; 260 261 // Time taken between the start of the settings backup and its conclusion. 262 optional int32 time_to_succeed_or_fail_millis = 2; 263 264 // Size of the settings being backed up. 265 optional int32 settings_size_kb = 3; 266} 267 268/** 269 * Track when a Backup and Restore data restore is invoked. 270 * Logged from: 271 * packages/modules/HealthFitness/service/java/com/android/server/healthconnect/logging/BackupRestoreLogger.java 272 * 273 * Estimated Logging Rate: 274 * Avg: <1 per device per day 275 */ 276message HealthConnectDataRestoreInvoked { 277 278 // Status of the data restore (started/success/failure) 279 optional android.healthfitness.api.DataRestoreStatus status = 1; 280 281 // Time taken between the start of the data restore and its conclusion. 282 optional int32 time_to_succeed_or_fail_millis = 2; 283 284 // Size of the data being restored. 285 optional int32 data_size_kb = 3; 286} 287 288/** 289 * Track when a Backup and Restore settings restore is invoked. 290 * Logged from: 291 * packages/modules/HealthFitness/service/java/com/android/server/healthconnect/logging/BackupRestoreLogger.java 292 * 293 * Estimated Logging Rate: 294 * Avg: <1 per device per day 295 */ 296message HealthConnectSettingsRestoreInvoked { 297 298 // Status of the settings restore (started/success/failure) 299 optional android.healthfitness.api.SettingsRestoreStatus status = 1; 300 301 // Time taken between the start of the settings restore and its conclusion. 302 optional int32 time_to_succeed_or_fail_millis = 2; 303 304 // Size of the settings being restored. 305 optional int32 settings_size_kb = 3; 306} 307 308// Track when the eligibility of a Backup and Restore restore is checked. 309message HealthConnectRestoreEligibilityChecked { 310 optional bool is_eligible = 1; 311} 312 313// Track Health Connect API operations stats. 314message HealthConnectApiInvoked { 315 316 // API method invoked. 317 optional android.healthfitness.api.ApiMethod api_method = 1; 318 319 // Status whether the API call executed successfully or not. 320 optional android.healthfitness.api.ApiStatus api_status = 2; 321 322 // Only relevant when status == ERROR; 323 optional int32 error_code = 3; 324 325 // Total API call duration in milliseconds. 326 optional int64 duration_millis = 4; 327 328 // Package name of the client that invoked the API. 329 optional string package_name = 5; 330 331 // Data types under consideration in the API call (if any) 332 optional android.healthfitness.api.DataType data_type_one = 6 333 [(field_restriction_option).health_connect = true]; 334 335 optional android.healthfitness.api.DataType data_type_two = 7 336 [(field_restriction_option).health_connect = true]; 337 338 optional android.healthfitness.api.DataType data_type_three = 8 339 [(field_restriction_option).health_connect = true]; 340 341 optional android.healthfitness.api.DataType data_type_four = 9 342 [(field_restriction_option).health_connect = true]; 343 344 optional android.healthfitness.api.DataType data_type_five = 10 345 [(field_restriction_option).health_connect = true]; 346 347 optional android.healthfitness.api.DataType data_type_six = 11 348 [(field_restriction_option).health_connect = true]; 349 350} 351 352// Track Health Connect API operations stats. 353message HealthConnectPhrApiInvoked { 354 355 // API method invoked. 356 optional android.healthfitness.api.ApiMethod api_method = 1; 357 358 // Status whether the API call executed successfully or not. 359 optional android.healthfitness.api.ApiStatus api_status = 2; 360 361 // Package name of the client that invoked the API. 362 optional string package_name = 3; 363 364 // Medical resource type under consideration in the API call (if any). 365 // When there are multiple resource types in an API call, multiple HealthConnectPhrApiInvoked 366 // messages will be created and logged. 367 optional android.healthfitness.api.MedicalResourceType medical_resource_type = 4 368 [(field_restriction_option).health_connect = true]; 369} 370 371/** 372 * Information about a permission granted to each package using HC. 373 */ 374message HealthConnectPermissionStats { 375 376 // Name of package. We will remove any package with less than certain number of installs (500k for now) from aggregations. 377 optional string package_name = 1; 378 379 // Health Connect permission granted to the given package 380 repeated string permission_name = 2; 381} 382 383/** 384 * Information about Health Connect Ecosystem for the user. 385 */ 386message HealthConnectEcosystemStats { 387 388 // Datatypes read or written in past 30 days 389 repeated android.healthfitness.api.DataType read_or_write = 1; 390 391 // Datatypes read in past 30 days 392 repeated android.healthfitness.api.DataType read = 2; 393 394 // Datatypes written in past 30 days 395 repeated android.healthfitness.api.DataType write = 3; 396 397 // Datatypes shared in past 30 days 398 repeated android.healthfitness.api.DataType shared = 4; 399 400 // Number of apps sharing data 401 optional int32 number_of_app_pairings = 5; 402 403} 404 405/** 406 * Sensitive Ecosystem metrics being collected via PWW. 407 */ 408message HealthConnectRestrictedEcosystemStats { 409 410 // Package name writing data in directional pairings. 411 // First package name alphabetically for non-directional pairings. 412 optional string package_name_one = 1; 413 414 // Package name reading data in directional pairings. 415 // Second package name alphabetically for non-directional pairings. 416 optional string package_name_two = 2; 417 418 // Data type being shared among packages. 419 optional android.healthfitness.api.DataType data_type = 3 420 [(field_restriction_option).health_connect = true]; 421 422 // Enum telling which metric is being represented by the atom. 423 optional android.healthfitness.api.MetricType metric_type = 4; 424 425} 426