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