Commit Graph

576 Commits

Author SHA1 Message Date
TreeHugger Robot
0c5ae34ce5 Merge "Revert "Increase debounce time for DISCONNECT processing"" into sc-dev am: 3e46e3bd10 am: e9e9ca1813
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16439364

Change-Id: I1ac7b09884ccc4a44612b6dbb25c57bcfc7ce326
2021-12-21 19:06:37 +00:00
James Wei
54f4c1843d Revert "Increase debounce time for DISCONNECT processing"
This reverts commit 5a14ba6861.
(from AOSP)

Bug: 207057578
Test: manual: switch to MTP mode then re-plug

Change-Id: I1e0b33395e164e566df6c8b5007e4cc1d5cd73b9
2021-12-13 02:54:01 +00:00
Paul Murphy
9c60898386 Merge "Add implicit broadcast exception for USB_ACCESSORY_HANDSHAKE" am: 1e47688982 am: 7d700b13de am: 5e7c0f1d38 am: 418595d76d am: 5a0b7578e1
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1866191

Change-Id: I9840bb6e93193b210917abee45957caed1284cf3
2021-10-29 18:45:00 +00:00
Paul Murphy
418595d76d Merge "Add implicit broadcast exception for USB_ACCESSORY_HANDSHAKE" am: 1e47688982 am: 7d700b13de am: 5e7c0f1d38
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1866191

Change-Id: I429ff633dd411e159147e72110b310bb2864bebc
2021-10-29 18:17:50 +00:00
Paul Murphy
5e7c0f1d38 Merge "Add implicit broadcast exception for USB_ACCESSORY_HANDSHAKE" am: 1e47688982 am: 7d700b13de
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1866191

Change-Id: I1cc174c7d6384508399d3b6ce8820ce8b05cf8f3
2021-10-29 18:01:27 +00:00
Paul Murphy
dc8bccf4a2 Add implicit broadcast exception for USB_ACCESSORY_HANDSHAKE
Test: Manually tested
Bug: b/186495257
Change-Id: I896afc6049a927ac23717c765098b2b4566e9c09
2021-10-28 23:26:41 +00:00
TreeHugger Robot
7a46f462fa Merge "Use USB API to get # of i/o ports for MIDI with USB." 2021-09-28 18:49:52 +00:00
Robert Wu
ce8791c18e Use USB API to get # of i/o ports for MIDI with USB.
Currently, the number of MIDI devices is determined using an ALSA ioctl.
This method is flaky on devices that don't simply have one input port
and one output port. This change allows us to query the number of MIDI
devices through USB instead of through an ALSA ioctl. USB MIDI should
now function correctly even with varying number of ports.

Bug: 28269065
Test: MIDI apps work for Alesis Recital and on M-Audio KeyStudio.
Android device also works as a peripheral to another Android device.

Change-Id: Id19748fbe1c8aa4913cf4925e0fec9316617409e
2021-09-28 16:49:51 +00:00
TreeHugger Robot
11bb10fdb2 Merge "USB: Adjust exception message in dealing with permission check #2" into sc-qpr1-dev am: 8173263d78 am: efc5d07b7a am: 8d57294965
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15794990

Change-Id: I58c63650ae1ad9d429fab22a8575dcb0fb246211
2021-09-10 06:43:46 +00:00
James Wei
da0cc0a308 USB: Adjust exception message in dealing with permission check #2
Add SafetyNet logging

Bug: 180104273
Test: CtsVerifier USB Device Test
Change-Id: I88fca08da5a3b4c1693fcd5b5e90af12a43cb482
2021-09-09 21:06:35 +08:00
TreeHugger Robot
9ca7052183 Merge "USB: Adjust exception message in dealing with permission check" into sc-qpr1-dev 2021-09-06 09:42:41 +00:00
James Wei
bf0d59726a USB: Adjust exception message in dealing with permission check
Bug: 180104273
Test: CtsVerifier USB Device Test
Change-Id: Ic676b0d16e7d34b8ddf9dcb218eed0aa41e36cc7
(cherry picked from commit 0304248350)
Merged-In: Ic676b0d16e7d34b8ddf9dcb218eed0aa41e36cc7
2021-09-02 09:57:42 +00:00
James Wei
f68f66f683 USB: Correct title bar notification am: c0162a74b9 am: 5402c211af am: 430fcbba06 am: 510e8d8857
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15580595

Change-Id: Ibd777d8d51d7e0fa89f552a725cdcc4bb1c24175
2021-08-16 11:18:09 +00:00
James Wei
c0162a74b9 USB: Correct title bar notification
Change notification in accordance with additional tethering support on NCM

Bug: 196240561
Test: Manual test: Switch USB tethering to and from MTP / Charge Only
Change-Id: I7a5e1d7066774d60c3ba7f453554dc3a25b0af69
2021-08-16 17:13:47 +08:00
Philip Junker
2684254374 Disallow usb access to camera and mic devices if global privacy toggle is active
Note that this will not prevent currently running apps from accessing
usb devies to which a connection has already been established.
Removed isCameraDevicePresent() as this has been implemented as well in
UsbDevice#getHasVideoCapture().

Bug: 189915399
Test: Install nExt Camera - USB app, verify that camera is not accessible when camera privacy toggle is disabled.
Change-Id: Ie60adfe9fc667d883ad4a6b8d7582a4bc17d1549
Merged-In: Ie60adfe9fc667d883ad4a6b8d7582a4bc17d1549
(cherry picked from commit f063780d43)
(cherry picked from commit 79023f08d3)
2021-08-13 19:39:51 +00:00
TreeHugger Robot
9964de6fd1 Merge "[Android Auto] Add USB UEVENT and broadcast intent history in dump_sys" 2021-08-12 07:41:17 +00:00
James Wei
c376a1982a Merge "USB: Adjust exception message in dealing with permission check" 2021-08-11 06:44:41 +00:00
Philip Junker
79023f08d3 Disallow usb access to camera and mic devices if global privacy toggle is active
Note that this will not prevent currently running apps from accessing
usb devies to which a connection has already been established.
Removed isCameraDevicePresent() as this has been implemented as well in
UsbDevice#getHasVideoCapture().

Bug: 189915399
Test: Install nExt Camera - USB app, verify that camera is not accessible when camera privacy toggle is disabled.
Change-Id: Ie60adfe9fc667d883ad4a6b8d7582a4bc17d1549
Merged-In: Ie60adfe9fc667d883ad4a6b8d7582a4bc17d1549
(cherry picked from commit f063780d43)
2021-08-05 08:09:10 +00:00
Ricky Niu
f28066d4a4 [Android Auto] Add USB UEVENT and broadcast intent history in dump_sys
Record all USB Uevent and broadcast intent history in dumpsys.
This will not be covered by other system log and kernel log.

Test: Android Auto team checked
Bug: 186495455
Signed-off-by: Ricky Niu <rickyniu@google.com>
Change-Id: I914969bd67c40f5f56218154521dd48681b6b1dd
2021-08-03 14:15:22 +08:00
James Wei
0304248350 USB: Adjust exception message in dealing with permission check
Bug: 180104273
Test: CtsVerifier USB Device Test
Change-Id: Ic676b0d16e7d34b8ddf9dcb218eed0aa41e36cc7
2021-07-26 21:25:17 +08:00
Philip Junker
f063780d43 Disallow usb access to camera and mic devices if global privacy toggle is active
Note that this will not prevent currently running apps from accessing
usb devies to which a connection has already been established.
Removed isCameraDevicePresent() as this has been implemented as well in
UsbDevice#getHasVideoCapture().

Bug: 189915399
Test: Install nExt Camera - USB app, verify that camera is not accessible when camera privacy toggle is disabled.
Change-Id: Ie60adfe9fc667d883ad4a6b8d7582a4bc17d1549
2021-07-23 14:07:10 +00:00
Albert Wang
9f56092ce9 Merge "Update USB HAL version early" into sc-dev am: 039b7ccc83 am: a642dcc7b7
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15142887

Change-Id: I35bdfa08551ec7cf1599909ad917fbd3ef53e488
2021-07-12 13:25:58 +00:00
Jimmy Hu
810915add5 Update USB HAL version early
USB API could be used before USB HAL version is updated.
Update USB HAL version early and log it.

Bug: 180711938
Test: USB HAL version updated normally
Signed-off-by: Jimmy Hu <hhhuuu@google.com>
Change-Id: If63c848e9643e9144662f031c981fad16d0a0fd6
2021-07-12 15:54:12 +08:00
Alex Johnston
64378e4d23 Merge "DISALLOW_USB_FILE_TRANSFER update user restrictions" into sc-dev am: 4d2eee78b1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14294135

Change-Id: I832dacf11f94d4d50d4a48d29edcb82aef95a0b3
2021-04-30 09:59:19 +00:00
Alex Johnston
3eadf0dbc9 DISALLOW_USB_FILE_TRANSFER update user restrictions
Background
* On an org-owned device with a managed profile,
  the admin can apply some user restrictions on the
  personal profile (incl DISALLOW_USB_FILE_TRANSFER)
* When the admin applied DISALLOW_USB_FILE_TRANSFER,
  the device should stop the existing 'File transfer'
  mode USB connnection.

Change
* The broadcast recevier in UsbService should pick
  up receive broadcast intents for all users.

Manual testing
* Set up device in COPE mode
* Turn on USB 'File transfer' via Settings
* Open internal storage on computer connected via USB
  and browse some files on the device
* Apply DISALLOW_USB_FILE_TRANSFER
* Verify device no longer shows up in internal storage

Bug: 175757373
Test: manual testing
      atest UsbBackendTest
Change-Id: I8d47e728a26ba99dc3b5223d0d7d29085484f8f0
2021-04-26 11:28:03 +01:00
TreeHugger Robot
f7ee18e8fd Merge "Check usb functions support with USB Gadget Hal version" into sc-dev am: bbf0d29880
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14124573

Change-Id: I41e0983603511c6b2ac22bac9e7ab01946d122bd
2021-04-15 17:33:17 +00:00
TreeHugger Robot
bbf0d29880 Merge "Check usb functions support with USB Gadget Hal version" into sc-dev 2021-04-15 17:07:19 +00:00
Ray Chi
6e0af90a70 Check usb functions support with USB Gadget Hal version
Currently, UsbDeviceManager will send usb functions in
GadgetFunction to Hal implementation without any check.
It is possible to send the functions defined in newer Hal
to older Hal implementation.

This patch will add a check to avoid this symptom before
sending the usb function.

Bug: 182507868
Test: verified pass
Change-Id: I621809b8c7236937ab4c76e3fa943d00f761922f
2021-04-15 06:08:56 +00:00
TreeHugger Robot
826fe598b7 Merge "usb: Address some API review comments" into sc-dev am: 0a0ddadab5
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13921669

Change-Id: I06e3e7be6dad6dfa84d5b756ce33e35af8316adf
2021-04-09 05:35:35 +00:00
TreeHugger Robot
0a0ddadab5 Merge "usb: Address some API review comments" into sc-dev 2021-04-09 05:14:47 +00:00
Paul McLean
1ef085ab31 GreenLog fixit - changing non-error logs to Log.i()
Bug: 181269159
Test: Build, flash, boot.
Change-Id: Id2991cc53d5e39fff196e9fda502019f69e5df77
2021-04-01 15:39:57 -06:00
Ricky Niu
65c23abeab Merge "Remove redundant variable" 2021-03-30 08:21:07 +00:00
Treehugger Robot
38dcf6a83c Merge "Fix null pointer exception if USBPort is removed" am: 066cd28370 am: fd5364769f am: 616b2a267f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1308901

Change-Id: I07eedad3dff519386abb45a172e8c26d837574e5
2021-03-25 04:31:45 +00:00
Treehugger Robot
066cd28370 Merge "Fix null pointer exception if USBPort is removed" 2021-03-25 03:14:45 +00:00
Ricky Niu
f6602fe2a9 Remove redundant variable
The variable only used once

Bug: 183184249
Test: Build pass and boot to home

Signed-off-by: Ricky Niu <rickyniu@google.com>
Change-Id: Icfc73a7f248ace6398d27966a7b2b6b279b92bb0
2021-03-25 01:46:58 +00:00
Ray Chi
5603742b00 usb: Address some API review comments
- Add the missing annotation for the permission in UsbService
- Enforce the permission in UsbManager

Test: atest CtsUsbManagerTestCases
Bug: 179389205
Change-Id: I9cb3a0f24367f0b28417588e03db882db159f7a7
2021-03-20 12:48:27 +00:00
Tej Singh
91bceaae7a Move service/enums.proto to proto_logging
Add usb contaminent status to service/enums.proto. It was previously in
usb.proto, but is an enum. Enums.proto is a better fit because other
enums in usb.proto are located in enums.proto, and the enum is also used
by atoms.proto.

Additionally, move the enums.proto file to proto_logging, since all
atoms.proto dependencies should be in proto_logging.

Test: m
Bug: 182392879
Change-Id: I9ea0a1482336694c446e950ea5cb46b95372b76d
Merged-In: I9ea0a1482336694c446e950ea5cb46b95372b76d
2021-03-18 21:04:48 -07:00
Tej Singh
51cffe5260 Move service/enums.proto to proto_logging
Add usb contaminent status to service/enums.proto. It was previously in
usb.proto, but is an enum. Enums.proto is a better fit because other
enums in usb.proto are located in enums.proto, and the enum is also used
by atoms.proto.

Additionally, move the enums.proto file to proto_logging, since all
atoms.proto dependencies should be in proto_logging.

Test: m
Bug: 182392879
Change-Id: I9ea0a1482336694c446e950ea5cb46b95372b76d
2021-03-17 17:57:43 -07:00
Albert Wang
3596d05271 Fix USB HAL interface binder
Bug: 180538375
Test: USB HAL loaded normally
Signed-off-by: Albert Wang <albertccwang@google.com>
Change-Id: Ie7081523441b60628076928aad8a1ddec820bc1e
2021-02-18 15:59:15 +00:00
Albert Wang
619abd21d9 Support USB V1.3 HAL
USB V1.3 HAL include:
1. Add api to enable/disable USB data signaling
2. Add api to inquiry HAL version

Bug: 161414036
Test: build pass and functions are working normally
Signed-off-by: Albert Wang <albertccwang@google.com>
Change-Id: Idb946de553b63f1d9da565133306117a6a4a7dd8
Merged-In: Idb946de553b63f1d9da565133306117a6a4a7dd8
(cherry picked from commit bd9dfea480)
2021-02-16 15:25:29 +00:00
Treehugger Robot
76b6d14f29 Merge "Increase debounce time for DISCONNECT processing" am: a1be0e120a am: 91c1b1c056 am: 49698f5cb0
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1539944

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I1beb97b73c67bb4e4b004c47f3ec8ce61296a460
2021-01-11 06:15:39 +00:00
Sriharsha Allenki
5a14ba6861 Increase debounce time for DISCONNECT processing
During composition switch, some host PCs are taking more
time in processing the disconnect of previous functions and
enumerating the new functions. This causes the delay in
receiving the CONNECTED uevent which triggers the fallback
to default composition. Prevent this by increasing the
debounce time from 1s to 3s (which is the average time
taken by these PCs to enumerate the new functions) for
device mode state update, while keeping the debounce time
for host mode as is at 1s.

Bug: 176779207
Test: Verified enumeration of device with the delay
Change-Id: I7ff58a1a9755939ccb26dad61969902ec91f2225
2021-01-08 05:12:13 +00:00
tengw
7c1f88023d Suppress USB sharing notification for wear
Bug: 159955492
Change-Id: I69ef3be40f0aed2175ffb37a6d1f7b57fb5d93db
(cherry picked from commit 945c267f8413f32623d58a394241326cea203555)
2020-11-25 03:23:19 +00:00
TreeHugger Robot
baf630d362 Merge changes from topic "USB-GADGET-HAL-v1.2"
* changes:
  Add methods for Usb Gadget Hal v1.2
  Support USB Gadget V1.2 HAL
2020-11-16 10:43:46 +00:00
Jeff Sharkey
8099e30b73 Mechanical refactoring to new XML resolvers.
Related changes are introducing new TypedXmlSerializer and
TypedXmlPullParser interfaces which offer efficient access to
primitive attributes.

This change is a purely mechanical refactoring to prepare for
upcoming data format shifts, and has no behavior changes.

Bug: 171832118
Test: manual
Exempt-From-Owner-Approval: trivial no-op refactoring
Change-Id: Ib8045ddba489c254641d6331b64355709c3f6dd7
2020-11-13 14:48:32 -07:00
raychi
88254a2b56 Support USB Gadget V1.2 HAL
USB Gadget V1.2 HAL include:
1. support NCM function
2. add api to inquiry USB speed
3. add api to inquiry HAL version

Bug: 168282708
Test: build pass and functions are working normally
Change-Id: Idd07c55f4610740c0cf9023391125a86ba39ddee
2020-11-12 10:59:40 +08:00
Jeff Sharkey
864524af17 Apply FLAG_IMMUTABLE to various PendingIntents.
Some careful spot-checking has revealed common cases where it's
reasonable to blanket apply the new FLAG_IMMUTABLE option to newly
created PendingIntents.  Specifically these situations:

-- Simple notification content clicks are immutable; there's no need
to communicate customized data back to the creator
-- Simple notification action clicks are immutable; there's no need
to communicate customized data back to the creator
-- Broadcast intents sent by AlarmManager are immutable; the system
dispatches them without customization.

Bug: 170165227, 170424283, 170425388, 170425877
Bug: 169791183, 170771965, 170226088, 170224928, 170767530
Test: none
Change-Id: I5ed68710d2ccad4635a30fd91136a9e6ad76a01d
2020-10-20 16:20:54 -06:00
Philip P. Moltmann
066479a2ad Merge "fix broadcast receivers overflow for system_server" am: 9ba1a0d576 am: ad9467332c am: ea66dd6ca5 am: a942c4780f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1339995

Change-Id: Ie0865afbb416da48da47650139eb72ce91543069
2020-10-14 22:46:30 +00:00
Jeff Sharkey
b93712f623 Tighten up Binder.clearCallingIdentity() usage.
This is a third CL in a chain that adjusts existing malformed code
to follow AndroidFrameworkBinderIdentity best-practices.

Specifically, if a thread clears an identity they need to restore it
to avoid obscure security vulnerabilities.  In addition, the relevant
"try" block must start immediately after the identity is cleared to
ensure that its restored if/when any exceptions are thrown.

Bug: 155703208
Test: make
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: I74cb958b68d55a647547aae21baff6ddc364859b
2020-10-07 21:24:05 -06:00
Jeff Sharkey
2d2e07e2ff Tighten up Binder.clearCallingIdentity() usage.
The recently added AndroidFrameworkBinderIdentity Error Prone checker
examines code to ensure that any cleared identities are restored to
avoid obscure security vulnerabilities.

This change is a purely mechanical refactoring that adds the "final"
keyword to the cleared identity to ensure that it's not accidentally
modified before eventually being cleared.  Here's the exact command
used to generate this CL:

$ find . -name "*.java" -exec sed -Ei \
    's/    (long \w+ = .+?clearCallingIdentity)/    final \1/' \
    {} \;

Bug: 155703208
Test: make
Exempt-From-Owner-Approval: trivial refactoring
Change-Id: I832c9d70c3dfcd8d669cf71939d97837becc973a
2020-10-06 11:18:09 -06:00