42 Commits

Author SHA1 Message Date
Christopher Tate
765f97d5e6 Make sure to go to the right Settings panel when tapping a notification
We now use Intent.makeRestartActivityTask() to build the notification
PendingIntent objects, so that when tapped they restart the activity
in the desired state.

Fixes bug 5011926

Change-Id: Ie1ec3543cc0f49d1bd407622a617316cf53a078c
2011-08-24 14:06:00 -07:00
Mike Lockwood
fadd2b8e0f UsbManager: Use resource IDs for notification IDs
to avoid ID collisions with other system services.

Bug: 5161005

Change-Id: I069fbc40a8764bc85cceeacd04264abd32b62668
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-08-16 13:45:51 -07:00
Mike Lockwood
1984e79d15 UsbDeviceManager: Fix typo that broke adb on/off setting persistence
Bug: 5108784

Change-Id: I68ed4d442ce4d3f4651cb618902fb226ac5a3673
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-08-03 17:10:43 -04:00
Mike Lockwood
8b4d36e866 USB: Fix NPE that occurred when restoring default function in UsbManager.setEnabledFunctions
Bug: 5110020

Change-Id: I5e4b5c27e4675fa6830823832ae51411dc448191
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-08-02 18:18:09 -04:00
Mike Lockwood
68736cbf93 Clean up USB configuration switching logic and beef up error handling
Bug: 5050853

Change-Id: Ia00698e2adbb8a7d7698e2ae306413f6c715fbdb
2011-07-29 14:41:14 -04:00
Mike Lockwood
a5010431bf UsbDeviceManager: Don't show USB notification for RNDIS
since USB tethering already has a notification.

Bug: 4988511

Change-Id: I928cb1e1d191c77340f7f05edfa80a74cdabe6ed
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-27 09:56:06 -04:00
Mike Lockwood
6e680dea3b UsbDeviceManager: Add USB notification string for USB accessory mode
Bug: 5062341

Change-Id: I93af8274e538009dd8f00d1cea782b62334e43f1
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-21 15:36:09 -07:00
Mike Lockwood
d462ecf8f8 USB: Fix handling USB accessory attached when device is booting
Also defer anything that could start an activity from "system ready"
to "boot completed" time.

Bug: 5051683

Change-Id: I69db751cb991dd247bd0ac3c70a0d84c0d71f365
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-21 14:30:36 -07:00
Mike Lockwood
875c24b897 UsbManager: document that passing null setCurrentFunction restores default function
Change-Id: I4340b336f3e91b3b8242f2a66c34a7a7f5c3021f
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-18 10:54:32 -07:00
Mike Lockwood
3fd13eb632 UsbDeviceManager: clean up HandlerThread creation
Change-Id: I84683b1753fcf3c3b501f8a506d6d890edf2eb37
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-13 09:39:54 -04:00
Mike Lockwood
6ea146c239 UsbDeviceManager: Include kernel USB state in dumpsys output
Change-Id: Ia7f015057e24f376e285a40e583644f9d0b9213e
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-11 18:23:44 -04:00
Mike Lockwood
c264afeb55 UsbDeviceManager: Initialize state based on persist.sys.usb.config rather than current kernel state
This makes it more robust when recovering from runtime restarts

Bug: 4986841

Change-Id: I54b94213447130ca881c66da2d0ce490242f0c96
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-11 18:23:44 -04:00
Mike Lockwood
abc4ac6d48 UsbDeviceManager: Fix indentation
Change-Id: I3eb1d407bdb4bf885d1765eedbfb30555f558b3b
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-11 13:40:08 -04:00
Mike Lockwood
629b149ff5 UsbDeviceManager: Initialize RNDIS ethernet address based on device serial number
Change-Id: I4775e5d8350385777f70f1b28ac00aa22dbd9487
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-06 12:52:49 -04:00
Mike Lockwood
c50bff8528 UsbService: USB connected notification now redirects to USB screen in Settings
Change-Id: I2dc6d1294da53acfa7589ba5b693ec671695cd21
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-02 22:07:35 -04:00
Mike Lockwood
de296f6448 UsbDeviceManager: Reset sys.usb.config if it is "none" at boot
This will allow us to recover if we crash while changing USB configurations

Change-Id: I22ba9a1ff0a8bcbfd4a0f18af0c95a3b66b99060
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-01 14:55:23 -04:00
Mike Lockwood
fdc0c2984d UsbService: Use Slog instead of Log, and disable some logging
Change-Id: I094ab99919055848a9fa76363eae6d0df51de9fd
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-01 14:55:23 -04:00
Mike Lockwood
d8404d2fdd USB: Update strings for USB connected notifications
We now have different strings depending on the current USB mode.

Change-Id: Icc6392d5700a6fee008b75287d8eb0f06db1d880
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-07-01 14:55:23 -04:00
Mike Lockwood
f59717ddb5 Combine UsbManager.setPrimaryFunction and setDefaultFunction
Due to the property trigger on persist.sys.usb.config,
setting the default function also sets the current function.
Now we combine both of these methods into setCurrentFunction, which has
a "makeDefault" option to make the new function the default.

This change should eliminate some problems with setting properties due to
multiple property triggers happening at the same time.

Change-Id: I9851299e9c2ee20475eada1a8104c0d50bf5a9e1
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-22 15:19:33 -04:00
Mike Lockwood
5787a2d5b4 USB connected notification and temporary USB options dialog
This change adds a notification when USB is connected.
Selecting the notification brings up a dialog to allow switching between
MTP and PTP modes, and also allows mounting a CD image for installing AFT.
The UI design is not final - this is a temporary implementation of the UI.

Change-Id: Idd678537aba595fd4cb183ea755bf437f372d826
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-17 19:49:05 -04:00
Mike Lockwood
02e4569b5f USB: Support for new USB gadget drivers
Change-Id: Id08df50acb873a94f4765a991ee6a6f5b898ddf5
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-17 19:49:05 -04:00
Mike Lockwood
541c9949ae Move adb related functionality from SystemServer and NotificationManagerService to UsbDeviceManager
Change-Id: I9e64b54bc2d027d88ae2d2cd893068e29b6fe237
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-13 22:20:06 -04:00
Mike Lockwood
9eb014aeb0 UsbManager: Clean up extras for ACTION_USB_STATE broadcast
Also added name for new PTP USB function

Change-Id: Ia2775ba2b23ef6a6108ca7e060239eb51c2eecc8
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-06-08 09:17:45 -07:00
Mike Lockwood
46d0adf825 UsbService: Refactor USB host and device support into two separate classes
Host support is in UsbHostManager, device support is in UsbDeviceManager

Renamed UsbDeviceSettingsManager to UsbSettingsManager

Change-Id: Ib76e72957c233fa7f08f454d4d9a2a1da6368cc7
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-05-31 20:52:06 -04:00
Mike Lockwood
4f0f3561ed UsbService: Make USB disconnect handling for accessory mode more robust
Handle the case where the kernel driver is in accessory mode but we failed
to initialize it at the framework level.  On disconnnect, check to see if the
accessory kernel driver is enabled rather than checking mCurrentAccessory.
That way we will restore the USB state in the kernel even if mCurrentAccessory
is null.

Change-Id: I35d458f21a8b21611946da523d0f53723cab0540
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-29 16:59:38 -07:00
Mike Lockwood
1c0e543638 UsbService: Handle the case where a USB accessory connects as the device is booting
Bug: 4129297

Change-Id: I8f9d085805fb598572f9b00952c3cd38cfab461b
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-19 12:03:46 -04:00
Mike Lockwood
bce6f8f249 Add a dialog to ask user to start an application for a USB device or accessory
This is used when there is only one application available and the user has
not chosen to start it by default.
If more than one application is available we continue to use UsbResolverActivity

Bug: 4074719

Change-Id: Id61f2ccc6de5b9ac70fb4670006ff1fee2028d55
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-13 19:18:08 -04:00
Mike Lockwood
c7d32d1065 Clear default for USB device/accessory when new matching app is installed
Bug: 4063041

Change-Id: Ia1b4f29d3e54ec21aa64407720d9d5db62855380
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-11 16:12:07 -05:00
Mike Lockwood
024b4f1494 Support for USB accessory URIs
If a USB accessory is attached and we have no application that supports it,
display a dialog offering the user the option to visit the accessory's website
if the accessory has a URI.

Bug: 4073248

Change-Id: I30e2a802493fb6e203532a7f79402379c40bc3b8
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-10 14:35:33 -05:00
Mike Lockwood
ac36d7c715 UsbAccessory: Add URI string, replace type string with description
This is a first step toward adding USB accessory URI support

BUG: 4073248

Modified USB accessory matching logic to look only at manufacturer, model and version
(description and URI are not considered when matching apps to accessories)

Also added test for USB accessory protocol version to accessorytest

BUG: 4080288

Change-Id: I992a3433c74efa7a7db37bf030f02c1f0c92f9e2
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-09 22:12:49 -05:00
Mike Lockwood
607710ad12 UsbService: Don't require permissions for UsbManager.getCurrentAccessory()
Permission check should only happen in openAccessory()
Otherwise an application will not be able to check for the current accessory
and ask for permissions (if it is a suitable match for the application)

BUG: 4069037

Change-Id: If5b44ebda2e8077598d96629163cc74aa336589e
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-09 16:43:35 -05:00
Mike Lockwood
c6f23e8521 Change UsbManager.requestPermission to only grant permission temporarily
If the user approves an application to access a USB device or accessory
without choosing it as the default application, then permission is granted
only until the device or accessory is disconnected.
Only applications chosen as the default choice have permissions assigned persistently.

BUG: 4061035

Change-Id: Ic4f6271a91b2fc56bbeef82c579e26d88c63ae56
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-09 12:33:00 -05:00
Mike Lockwood
3a68b8338b USB: Add API and dialog for apps to request permissions for USB devices and accessories
New APIs:

UsbManager.hasPermission returns true if the caller has permission
for the given device or accessory

UsbManager.requestPermission poses a dialog to allow the user to give the caller
permission for the device or accessory.
Result is returned via a PendingIntent.
No dialog is displayed if the caller already has permission.

Also moved UsbResolverActivity to SystemUI package

BUG: 4069037

Change-Id: I93be769501a8776b49ac26e468af19f8fa2114c9
2011-03-08 21:22:19 -05:00
Mike Lockwood
8c7d8c3ccb UsbService: Automatically use system apps by default if it is the only choice
If only one app is installed that supports a USB device or accessory
and that app is in the system partition, then use that activity by default
and rather than displaying the USB app chooser dialog.

BUG: 4060064

Change-Id: I49bf22a439e9676039b6f612c9bb622ab426066c
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-08 20:32:15 -05:00
Mike Lockwood
805b6bbea9 UsbManager: Don't display activity picker if there are no apps available for an accessory
Change-Id: I3ef569121e8d7d45584dbca9761451cbdf99a3e9
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-02 21:53:39 -08:00
Mike Lockwood
cb067ef52a UsbManager: Don't display activity picker if there are no apps available for a device
BUG: 3506988

Change-Id: Iaf3c50b9ba422e6bcd687338db996a4193441c97
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-02 21:10:07 -08:00
Mike Lockwood
b98d02b8b2 UsbService: Make sure the USB accessory function is disabled when we disconnect
BUG: 3493041

Change-Id: I95a34742d4b670a13ba5717f0551f3ce40af3c24
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-02 17:58:48 -08:00
Mike Lockwood
31ad11eb44 UsbDeviceSettingsManager: don't write settings file when not necessary
Change-Id: I48772f71822e3489f9e6c640985055569a656124
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-01 11:03:19 -08:00
Mike Lockwood
7a976a4370 Fix UsbDeviceSettingsManager locking.
Change-Id: I93117ce791de95b0ab95017601f5d90ed5dd7a6a
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-01 09:40:07 -08:00
Mike Lockwood
c4308f01c9 Move USB framework support from android.hardware to android.hardware.usb package
Change-Id: I00fd4f0caaa4aebe48f71c576bb211b5f38bf88d
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-03-01 08:07:20 -08:00
Mike Lockwood
f4ca247158 Add platform features for USB host and USB accessory support.
Also removed config_hasUsbHostSupport framework resource, which is now obsolete.

Change-Id: I6f18cc1c4f68085de8b8363e1b5edff79aff404f
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-02-28 17:00:46 -08:00
Mike Lockwood
02eb8746de UsbManager: Enhancements for managing USB devices and accessories
When a USB device or accessory is connected, the UsbService now asks the
user which application to associate with the device or accessory.
Applications interested in devices or accessories must specify the
devices they work with via meta-data attached to their manifest.
Permission to communicate with the device is assigned when the user chooses
the activity to use for the device.
The user has the option of clicking the "always use this application" checkbox
to make the assignment automatic in the future.
The user may later clear this preference and revoke permission for an application
to have permission to communicate with the device by clicking the "Clear defaults"
button for the activity in the Manage Applications panel in Settings.

Added class UsbResolveActivity (a subclass or ResolveActivity for choosing
an activity for a USB device or accessory)

Added UsbDeviceManager, which manages the mapping between USB devices/accessories
and applications, including default applications for devices and accessories,
and manages application permissions.

Add interface to allow Settings to clear device and accessory
preferences and permissions for an application.

Remove obsolete ACCESS_USB permission.

Add new signatureOrSystem MANAGE_USB permission to allow administrating
preferences and permissions.

Moved UsbService.java to a "usb" subdirectory, along with new classes
UsbResolveActivity and UsbDeviceManager.

Change-Id: I92554381e9779e68ce380daaee4e1401fb875703
Signed-off-by: Mike Lockwood <lockwood@android.com>
2011-02-28 17:00:45 -08:00