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