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 android.service.usb; 19 20option java_multiple_files = true; 21option java_outer_classname = "UsbServiceProto"; 22 23import "frameworks/base/core/proto/android/content/component_name.proto"; 24import "frameworks/base/core/proto/android/privacy.proto"; 25import "frameworks/proto_logging/stats/enums/service/enums.proto"; 26 27message UsbServiceDumpProto { 28 option (android.msg_privacy).dest = DEST_AUTOMATIC; 29 30 optional UsbDeviceManagerProto device_manager = 1; 31 optional UsbHostManagerProto host_manager = 2; 32 optional UsbPortManagerProto port_manager = 3; 33 optional UsbAlsaManagerProto alsa_manager = 4; 34 optional UsbSettingsManagerProto settings_manager = 5; 35 optional UsbPermissionsManagerProto permissions_manager = 6; 36} 37 38message UsbDeviceManagerProto { 39 option (android.msg_privacy).dest = DEST_AUTOMATIC; 40 41 optional UsbHandlerProto handler = 1; 42 optional UsbDebuggingManagerProto debugging_manager = 2; 43} 44 45message UsbHandlerProto { 46 option (android.msg_privacy).dest = DEST_AUTOMATIC; 47 48 /* Same as android.hardware.usb.gadget.GadgetFunction.* */ 49 enum Function { 50 FUNCTION_ADB = 1; 51 FUNCTION_ACCESSORY = 2; 52 FUNCTION_MTP = 4; 53 FUNCTION_MIDI = 8; 54 FUNCTION_PTP = 16; 55 FUNCTION_RNDIS = 32; 56 FUNCTION_AUDIO_SOURCE = 64; 57 FUNCTION_UVC = 128; 58 } 59 60 repeated Function current_functions = 1; 61 optional bool current_functions_applied = 2; 62 repeated Function screen_unlocked_functions = 3; 63 optional bool screen_locked = 4; 64 optional bool connected = 5; 65 optional bool configured = 6; 66 optional UsbAccessoryProto current_accessory = 7; 67 optional bool host_connected = 8; 68 optional bool source_power = 9; 69 optional bool sink_power = 10; 70 optional bool usb_charging = 11; 71 optional bool hide_usb_notification = 12; 72 optional bool audio_accessory_connected = 13; 73 optional bool adb_enabled = 14; 74 optional string kernel_state = 15; 75 optional string kernel_function_list = 16; 76 optional string uevent = 17; 77} 78 79message UsbAccessoryProto { 80 option (android.msg_privacy).dest = DEST_AUTOMATIC; 81 82 optional string manufacturer = 1; 83 optional string model = 2; 84 // For "classical" USB-accessories the manufacturer bakes this into the 85 // firmware of the device. If an Android phone is configured as accessory, the 86 // app that sets up the accessory side of the connection set this. Either way, 87 // these are part of the detection protocol, and so they cannot be user set or 88 // unique. 89 optional string description = 3; 90 optional string version = 4; 91 optional string uri = 5 [ (android.privacy).dest = DEST_EXPLICIT ]; 92 // Non-resettable hardware ID. 93 optional string serial = 6 [ (android.privacy).dest = DEST_LOCAL ]; 94} 95 96message UsbDebuggingManagerProto { 97 option (android.msg_privacy).dest = DEST_AUTOMATIC; 98 99 optional bool connected_to_adb = 1; 100 // A workstation that connects to the phone for debugging is identified by 101 // this key. 102 optional string last_key_received = 2 [ (android.privacy).dest = DEST_EXPLICIT ]; 103 optional string user_keys = 3 [ (android.privacy).dest = DEST_LOCAL ]; 104 optional string system_keys = 4 [ (android.privacy).dest = DEST_LOCAL ]; 105} 106 107message UsbHostManagerProto { 108 option (android.msg_privacy).dest = DEST_AUTOMATIC; 109 110 optional android.content.ComponentNameProto default_usb_host_connection_handler = 1; 111 repeated UsbDeviceProto devices = 2; 112 optional int32 num_connects = 3; 113 repeated UsbConnectionRecordProto connections = 4; 114 repeated UsbDirectMidiDeviceProto midi_devices = 5; 115} 116 117message UsbDeviceProto { 118 option (android.msg_privacy).dest = DEST_AUTOMATIC; 119 120 // Generic USB name, not user-provided. 121 optional string name = 1; 122 // ID specific to the vendor, not the device. 123 optional int32 vendor_id = 2; 124 // ID of this product type: Each vendor gives each product a unique ID. E.g. 125 // all mice of the same model would have the same ID. 126 optional int32 product_id = 3; 127 optional int32 class = 4; 128 optional int32 subclass = 5; 129 optional int32 protocol = 6; 130 optional string manufacturer_name = 7; 131 optional string product_name = 8; 132 optional string version = 9; 133 // Non-resettable hardware ID. 134 optional string serial_number = 10 [ (android.privacy).dest = DEST_LOCAL ]; 135 repeated UsbConfigurationProto configurations = 11; 136} 137 138message UsbConfigurationProto { 139 option (android.msg_privacy).dest = DEST_AUTOMATIC; 140 141 // A single USB device can have several configurations and the app accessing 142 // the USB device can switch between them. At any time only one can be active. 143 // Each configuration can present completely different interfaces end 144 // endpoints, i.e. a completely different behavior. 145 optional int32 id = 1; 146 // Hardware-defined name, not set by the user. 147 optional string name = 2; 148 optional uint32 attributes = 3; 149 optional int32 max_power = 4; 150 repeated UsbInterfaceProto interfaces = 5; 151} 152 153message UsbInterfaceProto { 154 option (android.msg_privacy).dest = DEST_AUTOMATIC; 155 156 // Hardware defined. This is the id used by the app to identify the interface. 157 optional int32 id = 1; 158 optional int32 alternate_settings = 2; 159 optional string name = 3; 160 optional int32 class = 4; 161 optional int32 subclass = 5; 162 optional int32 protocol = 6; 163 repeated UsbEndPointProto endpoints = 7; 164} 165 166message UsbEndPointProto { 167 option (android.msg_privacy).dest = DEST_AUTOMATIC; 168 169 optional int32 endpoint_number = 1; 170 optional android.service.UsbEndPointDirection direction = 2; 171 // The address of the endpoint. Needed to read and write to the endpoint. 172 optional int32 address = 3; 173 optional android.service.UsbEndPointType type = 4; 174 optional uint32 attributes = 5; 175 optional int32 max_packet_size = 6; 176 optional int32 interval = 7; 177} 178 179message UsbConnectionRecordProto { 180 option (android.msg_privacy).dest = DEST_AUTOMATIC; 181 182 // usb device's address, e.g. 001/002, nothing about the phone 183 optional string device_address = 1; 184 optional android.service.UsbConnectionRecordMode mode = 2; 185 optional int64 timestamp = 3; 186 optional int32 manufacturer = 4; 187 optional int32 product = 5; 188 optional UsbIsHeadsetProto is_headset = 6; 189} 190 191message UsbIsHeadsetProto { 192 option (android.msg_privacy).dest = DEST_AUTOMATIC; 193 194 optional bool in = 1; 195 optional bool out = 2; 196} 197 198message UsbPortManagerProto { 199 option (android.msg_privacy).dest = DEST_AUTOMATIC; 200 201 enum HalVersion { 202 V_UNKNOWN = 0; 203 V1_0 = 10; 204 V1_1 = 11; 205 V1_2 = 12; 206 V1_3 = 13; 207 V2 = 20; 208 } 209 210 optional bool is_simulation_active = 1; 211 repeated UsbPortInfoProto usb_ports = 2; 212 optional bool enable_usb_data_signaling = 3; 213 optional HalVersion hal_version = 4; 214} 215 216message UsbPortInfoProto { 217 option (android.msg_privacy).dest = DEST_AUTOMATIC; 218 219 optional UsbPortProto port = 1; 220 optional UsbPortStatusProto status = 2; 221 optional bool can_change_mode = 3; 222 optional bool can_change_power_role = 4; 223 optional bool can_change_data_role = 5; 224 optional int64 connected_at_millis = 6; 225 optional int64 last_connect_duration_millis = 7; 226} 227 228message UsbPortProto { 229 option (android.msg_privacy).dest = DEST_AUTOMATIC; 230 231 /* Same as android.hardware.usb.V1_1.Constants.PortMode_1_1 */ 232 enum Mode { 233 MODE_NONE = 0; 234 MODE_UFP = 1; 235 MODE_DFP = 2; 236 MODE_DRP = 3; 237 MODE_AUDIO_ACCESSORY = 4; 238 MODE_DEBUG_ACCESSORY = 8; 239 } 240 241 enum AltMode { 242 ALT_MODE_DISPLAYPORT = 1; 243 } 244 245 // ID of the port. A device (eg: Chromebooks) might have multiple ports. 246 optional string id = 1; 247 repeated Mode supported_modes = 2; 248 optional bool supports_compliance_warnings = 3; 249 repeated AltMode supported_alt_modes = 4; 250} 251 252message UsbPortStatusProto { 253 option (android.msg_privacy).dest = DEST_AUTOMATIC; 254 255 /* Same as android.hardware.usb.V1_0.Constants.PortPowerRole */ 256 enum PowerRole { 257 POWER_ROLE_NONE = 0; 258 POWER_ROLE_SOURCE = 1; 259 POWER_ROLE_SINK = 2; 260 } 261 262 /* Same as android.hardware.usb.V1_0.Constants.PortDataRole */ 263 enum DataRole { 264 DATA_ROLE_NONE = 0; 265 DATA_ROLE_HOST = 1; 266 DATA_ROLE_DEVICE = 2; 267 } 268 269 optional bool connected = 1; 270 optional UsbPortProto.Mode current_mode = 2; 271 optional PowerRole power_role = 3; 272 optional DataRole data_role = 4; 273 repeated UsbPortStatusRoleCombinationProto role_combinations = 5; 274 optional android.service.ContaminantPresenceStatus contaminant_presence_status = 6; 275 optional string usb_data_status = 7; 276 optional bool is_power_transfer_limited = 8; 277 optional string usb_power_brick_status = 9; 278 optional string compliance_warnings_string = 10; 279 optional string displayport_alt_mode_status = 11; 280} 281 282message UsbPortStatusRoleCombinationProto { 283 option (android.msg_privacy).dest = DEST_AUTOMATIC; 284 285 optional UsbPortStatusProto.PowerRole power_role = 1; 286 optional UsbPortStatusProto.DataRole data_role = 2; 287} 288 289message UsbAlsaManagerProto { 290 option (android.msg_privacy).dest = DEST_AUTOMATIC; 291 292 optional int32 cards_parser = 1; 293 repeated UsbAlsaDeviceProto alsa_devices = 2; 294 reserved 3; // previously midi_devices, now unused 295 repeated UsbAlsaMidiDeviceProto alsa_midi_devices = 4; 296} 297 298message UsbAlsaDeviceProto { 299 option (android.msg_privacy).dest = DEST_AUTOMATIC; 300 301 optional int32 card = 1; 302 optional int32 device = 2; 303 optional string name = 3; 304 optional bool has_playback = 4; 305 optional bool has_capture = 5; 306 // usb device's address, e.g. 001/002, nothing about the phone 307 optional string address = 6; 308} 309 310message UsbAlsaMidiDeviceProto { 311 option (android.msg_privacy).dest = DEST_AUTOMATIC; 312 313 optional int32 card = 1; 314 optional int32 device = 2; 315 // usb device's address, e.g. 001/002, nothing about the phone 316 optional string device_address = 3; 317} 318 319message UsbDirectMidiDeviceProto { 320 option (android.msg_privacy).dest = DEST_AUTOMATIC; 321 322 optional int32 num_inputs = 1; 323 optional int32 num_outputs = 2; 324 optional bool is_universal = 3; 325 optional string name = 4; 326 optional UsbMidiBlockParserProto block_parser = 5; 327} 328 329message UsbMidiBlockParserProto { 330 option (android.msg_privacy).dest = DEST_AUTOMATIC; 331 332 optional int32 length = 1; 333 optional int32 descriptor_type = 2; 334 optional int32 descriptor_subtype = 3; 335 optional int32 total_length = 4; 336 repeated UsbGroupTerminalBlockProto block = 5; 337} 338 339message UsbGroupTerminalBlockProto { 340 option (android.msg_privacy).dest = DEST_AUTOMATIC; 341 342 optional int32 length = 1; 343 optional int32 descriptor_type = 2; 344 optional int32 descriptor_subtype = 3; 345 optional int32 group_block_id = 4; 346 optional int32 group_terminal_block_type = 5; 347 optional int32 group_terminal = 6; 348 optional int32 num_group_terminals = 7; 349 optional int32 block_item = 8; 350 optional int32 midi_protocol = 9; 351 optional int32 max_input_bandwidth = 10; 352 optional int32 max_output_bandwidth = 11; 353} 354 355message UsbSettingsManagerProto { 356 option (android.msg_privacy).dest = DEST_AUTOMATIC; 357 358 repeated UsbUserSettingsManagerProto user_settings = 1; 359 repeated UsbProfileGroupSettingsManagerProto profile_group_settings = 2; 360} 361 362message UsbUserSettingsManagerProto { 363 option (android.msg_privacy).dest = DEST_AUTOMATIC; 364 365 optional int32 user_id = 1; 366 reserved 2; // previously device_permissions, now unused 367 reserved 3; // previously accessory_permissions, now unused 368 repeated UsbDeviceAttachedActivities device_attached_activities = 4; 369 repeated UsbAccessoryAttachedActivities accessory_attached_activities = 5; 370} 371 372message UsbProfileGroupSettingsManagerProto { 373 option (android.msg_privacy).dest = DEST_AUTOMATIC; 374 375 // The user id of the personal profile if the device has a work profile. 376 optional int32 parent_user_id = 1; 377 repeated UsbSettingsDevicePreferenceProto device_preferences = 2; 378 repeated UsbSettingsAccessoryPreferenceProto accessory_preferences = 3; 379 optional string intent = 4; 380} 381 382message UsbSettingsDevicePreferenceProto { 383 option (android.msg_privacy).dest = DEST_AUTOMATIC; 384 385 optional UsbDeviceFilterProto filter = 1; 386 optional UserPackageProto user_package = 2; 387} 388 389message UsbPermissionsManagerProto { 390 option (android.msg_privacy).dest = DEST_AUTOMATIC; 391 392 repeated UsbUserPermissionsManagerProto user_permissions = 1; 393} 394 395message UsbUserPermissionsManagerProto { 396 option (android.msg_privacy).dest = DEST_AUTOMATIC; 397 398 optional int32 user_id = 1; 399 400 repeated UsbDevicePermissionProto device_permissions = 2; 401 repeated UsbAccessoryPermissionProto accessory_permissions = 3; 402 403 repeated UsbDevicePersistentPermissionProto device_persistent_permissions = 4; 404 repeated UsbAccessoryPersistentPermissionProto accessory_persistent_permissions = 5; 405} 406 407message UsbDevicePermissionProto { 408 option (android.msg_privacy).dest = DEST_AUTOMATIC; 409 410 // Name of device set by manufacturer 411 // All devices of the same model have the same name 412 optional string device_name = 1; 413 repeated int32 uids = 2; 414} 415 416message UsbAccessoryPermissionProto { 417 option (android.msg_privacy).dest = DEST_AUTOMATIC; 418 419 // Description of accessory set by manufacturer 420 // All accessories of the same model have the same description 421 optional string accessory_description = 1; 422 repeated int32 uids = 2; 423} 424 425message UsbDevicePersistentPermissionProto { 426 option (android.msg_privacy).dest = DEST_AUTOMATIC; 427 428 optional UsbDeviceFilterProto device_filter = 1; 429 repeated UsbUidPermissionProto permission_values = 2; 430} 431 432message UsbAccessoryPersistentPermissionProto { 433 option (android.msg_privacy).dest = DEST_AUTOMATIC; 434 435 optional UsbAccessoryFilterProto accessory_filter = 1; 436 repeated UsbUidPermissionProto permission_values = 2; 437} 438 439message UsbUidPermissionProto { 440 option (android.msg_privacy).dest = DEST_AUTOMATIC; 441 442 optional int32 uid = 1; 443 optional bool is_granted = 2; 444} 445 446message UsbDeviceFilterProto { 447 option (android.msg_privacy).dest = DEST_AUTOMATIC; 448 449 // Mirrors the vendor_id of UsbDeviceProto. 450 optional int32 vendor_id = 1; 451 optional int32 product_id = 2; 452 optional int32 class = 3; 453 optional int32 subclass = 4; 454 optional int32 protocol = 5; 455 optional string manufacturer_name = 6; 456 optional string product_name = 7; 457 optional string serial_number = 8 [ (android.privacy).dest = DEST_EXPLICIT ]; 458} 459 460message UserPackageProto { 461 option (android.msg_privacy).dest = DEST_AUTOMATIC; 462 463 optional int32 user_id = 1; 464 optional string package_name =2; 465} 466 467message UsbSettingsAccessoryPreferenceProto { 468 option (android.msg_privacy).dest = DEST_AUTOMATIC; 469 470 optional UsbAccessoryFilterProto filter = 1; 471 optional UserPackageProto user_package = 2; 472} 473 474message UsbAccessoryFilterProto { 475 option (android.msg_privacy).dest = DEST_AUTOMATIC; 476 477 optional string manufacturer = 1; 478 optional string model = 2; 479 optional string version = 3; 480} 481 482message UsbDeviceAttachedActivities { 483 option (android.msg_privacy).dest = DEST_AUTOMATIC; 484 485 optional android.content.ComponentNameProto activity = 1; 486 repeated UsbDeviceFilterProto filters = 2; 487} 488 489message UsbAccessoryAttachedActivities { 490 option (android.msg_privacy).dest = DEST_AUTOMATIC; 491 492 optional android.content.ComponentNameProto activity = 1; 493 repeated UsbAccessoryFilterProto filters = 2; 494} 495