122 Commits

Author SHA1 Message Date
Mike Lockwood
20821ecbe8 Eliminate MidiPort base class for MidiInputPort and MidiOutputPort
Change-Id: I628c0468ac980eee909add53a4d6e55e9b358603
2015-03-04 16:15:45 -08:00
Mike Lockwood
c623ec973b Merge "MidiManager: Virtual MIDI devices are now implemented as Services" 2015-03-05 00:01:33 +00:00
Mike Lockwood
11fd96d6ff MidiManager: Virtual MIDI devices are now implemented as Services
To implement a virtual MIDI device, include a subclass of MidiDeviceService in
your application.  This service is identified by an intent filter and meta-data
in the application's manifest to allow the MIDI manager to register the virtual device
without actually running the application. Instead, the application's MidiDeviceService
subclass is started on demand when MIDI manager clients want to open the device.

Here is an example of how the MidiDeviceService might be described in the application manifest:

    <service android:name="VirtualDeviceService">
        <intent-filter>
            <action android:name="android.media.midi.MidiDeviceService" />
        </intent-filter>
        <meta-data android:name="android.media.midi.MidiDeviceService"
            android:resource="@xml/device_info" />
    </service>

and the device_info.xml meta-data:

<devices>
    <device manufacturer="Sample Manufacturer" model="Sample Model" private="false">
        <input-port name="my input port" />
        <output-port name="my output port" />
    </device>
</devices>

(note that the <input-port> and <output-port> names are not currently used, but support for these
will be added in a subsequent change)

Client's of the virtual device will bind directly to the hosting application's MidiDeviceService subclass.
To support this, MidiManager.openDevice() now returns the MidiDevice asynchronously via a callback.

This change also adds a utility class called MidiDispatcher, which is a MidiReceiver
that dispatches all data it receives to a list of other MidiReceivers.
We now use this internally in MidiInputPort and MidiDeviceServer, but developers
may use it for other purposes as well.

Change-Id: Ic3009f06d56f3d5edbd87de3f0c330b51a1c217d
2015-03-04 13:45:38 -08:00
Amith Yamasani
f4a8df4c7e Fix a regression in UsbDebuggingManager
Catch NPE as well if socket object is null.

Bug: 19602060
Change-Id: I7cf9cb16abc3fde626170c1aefeba5fc91c5734f
2015-03-04 10:00:11 -08:00
John Spurlock
7b91c55b3f Merge "Remove unused imports in frameworks/base." 2015-03-02 20:43:50 +00:00
Amith Yamasani
d65ed88144 Merge "Avoid NPE when quickly toggling USB debugging state" 2015-03-02 18:07:58 +00:00
Amith Yamasani
f6197e8fa2 Avoid NPE when quickly toggling USB debugging state
If you try to disable USB debugging before the socket
to listen is opened in the thread, it will end up
with an NPE.

Do some locking around socket creation and closing
to avoid this.

Bug: 18708503
Change-Id: Iac43e4806fff1e411772b1ba1a070d8a7c776fcb
2015-03-02 09:14:23 -08:00
John Spurlock
08c7116ab9 Remove unused imports in frameworks/base.
Change-Id: I031443de83f93eb57a98863001826671b18f3b17
2015-02-28 14:47:49 -05:00
Mike Lockwood
464c655871 Move ALSA utilities to com.android.internal.alsa package
Change-Id: Icbd45ec97a942e44e60f8d4ba0bb58c97f85b55f
2015-02-26 13:50:08 -08:00
Mike Lockwood
b673770f71 Add MIDI Manager API tweaks:
- Change the package name from android.midi to android.media.midi

- Add option for specifying a Handler for DeviceCallback notifications

Change-Id: Ia9e9817a651c06299f4e02ee1da3c9666ff64cb9
2015-02-23 14:32:23 -08:00
Mike Lockwood
c3c2ff70a2 Add support for USB notification when connected as a MIDI peripheral
Change-Id: Ib3efcda6af976c878e63b0d35a8e47a3ea9435a3
2015-02-20 15:10:20 -08:00
Paul McLean
0e4242f9cb Audio Device Enumeration API.
Change-Id: Ic78fda8b2a6f6ac0f37a1f665b29f3359cfc5ecc
2015-02-19 15:03:53 -08:00
Mike Lockwood
5b14d9893a Merge "MidiManager API tweaks:" 2015-02-13 00:01:48 +00:00
Mike Lockwood
90b9a6a4ab MidiManager API tweaks:
Rename MidiReceiver.onPost() to post()

Change MidiManager.DeviceCallback from an interface to a class

Change-Id: I939ba7a7d82e721b90a3d80252a88e7a650c9396
2015-02-12 10:58:52 -08:00
John Spurlock
6156017c22 Move AudioService to services.
...and a few dependencies. Move remaining shared items to AudioSystem.

Change-Id: Ib9623ff867678d34977337856bb0156e8cdaeeb5
2015-02-09 17:13:38 -05:00
Craig Mautner
83f367475b Merge "Revert "Revert "Do not display ADB confirm dialog during boot""" 2015-02-06 00:01:45 +00:00
Craig Mautner
b43d3cff67 Revert "Revert "Do not display ADB confirm dialog during boot""
This reverts commit e37099ffdfc966d52b4323a3705359ea42fa283e.

Fixes bug 18652251

Change-Id: Ib00e8269558aae294ff6453d1f6ceef1771c4572
2015-02-06 00:01:28 +00:00
Craig Mautner
968aca1d7e Merge "Revert "Do not display ADB confirm dialog during boot"" 2015-02-06 00:00:30 +00:00
Craig Mautner
e37099ffdf Revert "Do not display ADB confirm dialog during boot"
This reverts commit 34e90b2214b39db31bccaf24644d0db55bcde965.

Change-Id: Ib385793aa2b7472933bdb0c707b10e2bac1a4cb3
2015-02-06 00:00:17 +00:00
Craig Mautner
b8415ecfe9 Merge "Do not display ADB confirm dialog during boot" 2015-02-05 23:58:16 +00:00
Paul McLean
10804eb281 Add additional info to AudioPort for enum/selection API.
Add "device name" member to AudioPort.
Moved unique device ID from DevicePort to AudioPort.
Straighten out confusion between "name" and "address"
Created string constants for Intent "extra" data keys.
Combine card/address data into "address" at sender.Add additional info to AudioPort for enum/selection API.
Parse out USB Device name in UsbCardsParser.

Change-Id: Ifd76b0298312090a8f39e638339f993b86d47080
2015-02-04 14:37:19 -08:00
Craig Mautner
34e90b2214 Do not display ADB confirm dialog during boot
Wait until after encrypted volume has been mounted.
Also eliminate warning by starting UsbDebuggingActivity as owner.

Fixes bug 19217173.

Change-Id: I6da530259bb02eb1892509ec5085a471f9893714
2015-02-04 09:41:40 -08:00
Mike Lockwood
51936d4260 Merge "UsbAlsaManager: Don't reselect current USB audio device on all USB disconnects" 2015-01-29 21:33:32 +00:00
Mike Lockwood
2a57bc7fd6 MidiManager: Add USB peripheral MIDI support
This allows the android device to appear as a USB MIDI device to
a USB host (like a Mac or a PC) using the f_midi USB gadget driver.

Change-Id: I14f1ba73bcce2c894e77efb8810beac4ffe246d8
2015-01-29 12:59:28 -08:00
Mike Lockwood
9c2d34c764 UsbAlsaManager: Don't reselect current USB audio device on all USB disconnects
Change-Id: I4d3a0d803a6d1eb02ff48a7e8587a1ff6c66a500
2015-01-29 10:41:26 -08:00
Mike Lockwood
cb09627373 MIDI Manager: Remove message packetization from MIDI transport
Instead of attempting to package exactly one MIDI message in each call to
MidiReceiver.onPost(), we now pass messages as a raw stream of bytes.
This means we may now receive multiple MIDI messages in MidiReceiver.onPost().

We make this change to avoid the complexity of taking the single message approach
with SysEx and realtime messages. This shifts some of the burden of parsing
MIDI messages to the client application. But the parsing is best handled in the
application anyway, rather than having the framework impose its own policy
on how the messages are parsed.

Change-Id: Idb6c200037f827cc618bc7d9455a7aa864b494a7
2015-01-29 09:09:00 -08:00
Mike Lockwood
2e3434149e Replace broadcasts with calls to IAudioService.setWiredDeviceConnectionState() to report USB device status
Change-Id: Ic96cffaa63b6c6350b76e7cb29398c5f5dc86962
2015-01-16 09:23:15 -08:00
Mike Lockwood
98cc8e5a64 MidiManager bug fixing:
- fix off by one error that caused failure handling one byte messages

- poll thread now terminates properly in UsbMidiDevice

- fix cleanup logic in MidiDeviceServer

Change-Id: I0c13a98b6542cfb271b51678e81d1822c8da2985
2015-01-15 16:07:28 -08:00
Mike Lockwood
10024b3dc1 MidiManager updates:
MIDI ports are now implemented as file descriptors directly between the sender
and receiver, so the MidiService is no longer in the message path.

To facilitate the above, each port has its own file descriptor, rather than multiplexing
all ports on a device through a single socket.

Added a new class MidiDeviceServer, which is used by implementors of MIDI devices.
This replaces the MidiVirtualDevice class (which only was included in changes that were reviewed but never submitted).

The USB MIDI implementation has moved from the MIDI service to the USB service.
The USB MIDI implementation uses MidiDeviceServer as its interface, so we now have a common
interface for all MIDI device implementations.

Change-Id: I8effd1583f344beb6c940c3a24dbf20b477a6436
2015-01-14 16:51:54 -08:00
Paul McLean
0a8f06922f Support for simultaneous USB Audio Devices connect/disconnect
Attach/Detach logic
Decoupling card# and list index
Modern loop constructs
Consistent logging flags
Add class/type flags to device "address" string.
Factored UsbAudioDevice out of UsbAudioManager.

Bug: 18399845
Bug: 18717784

Change-Id: I6f185e1c24091d4c0d21eb7e922a1496748d32c3
2015-01-09 14:56:43 -08:00
Mike Lockwood
d2de5a421a Rename UsbAudioManager to UsbAlsaManager
Change-Id: I53b084400ef3e0692415cc5af91c8b500ffd8346
2014-12-19 10:08:36 -08:00
Zoltan Szatmary-Ban
d00c3752e6 am 32ed193b: am f5e44c29: am c5c93edd: Merge "When switching to default USB function set, check restriction" into lmp-mr1-dev
* commit '32ed193bb5396451401e62493f83664da9228729':
  When switching to default USB function set, check restriction
2014-12-09 22:22:17 +00:00
Mike Lockwood
67f8e8bd89 MIDI Manager work in progress
Still to do:

Add MidiInputPort and MidiOutputPort classes
Schedule sending MIDI events in the future
Security/permissions
Reconsider interface for virtual devices
Look into performance optimizations

Change-Id: I9b7d63b196996a04be0a830efa913043da1328a8
2014-12-08 10:45:37 -08:00
Zoltan Szatmary-Ban
469c15d6af When switching to default USB function set, check restriction
The user restriction DISALLOW_USB_FILE_TRANSFER has to be respected
when switching USB function set.

Bug: 18532487
Change-Id: I16fda6358027a659e3bfa0c5f3bf6b3918d0bced
2014-12-05 17:14:43 +00:00
Mike Lockwood
fb0a22eb62 Remove polling for ALSA device files in USB audio device detection.
Change-Id: I993fe41707fc02c9449800c7325aaf7270fb892e
2014-12-01 12:21:41 -08:00
Geoffrey Borggaard
b66252fb42 Setting ADB_ENABLED may result in a SecurityException.
If the restriction UserManager.DISALLOW_DEBUGGING_FEATURES is enforced,
then any attempt to set ADB_ENABLED will result in a SecurityException.
This can result in the device not being able to boot.
Bug: 18433477

Change-Id: I21e4b406ad0fa89b7d4b678eac1baf212a3c7acd
(cherry picked from commit ba45b96a378623e3392da65e81e67dabdf4f0678)
2014-11-20 15:39:23 +00:00
Nick Kralevich
451a6f8f9a fix crash on invalid base64 key
An invalid adb public key can cause a system server crash.

  AndroidRuntime: *** FATAL EXCEPTION IN SYSTEM PROCESS: android.fg
  AndroidRuntime: java.lang.IllegalArgumentException: bad base-64
  AndroidRuntime:        at android.util.Base64.decode(Base64.java:161)
  AndroidRuntime:        at android.util.Base64.decode(Base64.java:136)
  AndroidRuntime:        at com.android.server.usb.UsbDebuggingManager.getFingerprints(UsbDebuggingManager.java:235)
  AndroidRuntime:        at com.android.server.usb.UsbDebuggingManager.access$500(UsbDebuggingManager.java:49)
  AndroidRuntime:        at com.android.server.usb.UsbDebuggingManager$UsbDebuggingHandler.handleMessage(UsbDebuggingManager.java:210)
  AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:102)
  AndroidRuntime:        at android.os.Looper.loop(Looper.java:135)
  AndroidRuntime:        at android.os.HandlerThread.run(HandlerThread.java:61)
  AndroidRuntime:        at com.android.server.ServiceThread.run(ServiceThread.java:46)
  Process : Sending signal. PID: 824 SIG: 9

Bug: 17389885
Change-Id: Id20d7c0ee35229b14c800fd9e07716239179989c
2014-11-12 13:40:30 -08:00
Mike Lockwood
3d50308c7f Fix USB audio disconnect logic
Previously, disconnecting any USB device would terminate USB audio playback.

Also moved USB audio support to a separate class and did some prep work for
multiple USB audio device support.

Bug: 18203024
Change-Id: I49822c2c47428e658c853b2ec83c7313e626a1cb
2014-10-31 15:28:52 -07:00
Jean-Michel Trivi
c5258433dd Move *_AUDIO_PLUG actions from Intent to android.media.AudioManager
For ACTION_HEADSET_PLUG (already in SDK):
 - duplicated definition in AudioManager and moved
  javadoc there. Javadoc in Intent points to AudioManager.
 - the String value is not changed

For ACTION_HDMI_AUDIO_PLUG (being added in SDK):
 - moved defintion from Intent to AudioManager
 - updated String value to reflect package name "android.media"
  instead of using "android.intent"
 - added definition of the extras, but removed "name".

For ACTION_ANALOG_AUDIO_DOCK_PLUG,
    ACTION_DIGITAL_AUDIO_DOCK_PLUG,
    ACTION_USB_AUDIO_ACCESSORY_PLUG,
    ACTION_USB_AUDIO_DEVICE_PLUG, all hidden:
 - moved definition from Intent to AudioManager,
 - changed the value from "android.intent.*" to "android.media.*"

Updated AudioService, UsbDeviceManager and UsbHostManager
 to refer to the actions in AudioManager, not Intent.

Bug 17289385

Change-Id: I61dd73140022d2bb9a676a57f595092c8fa89dcc
2014-08-29 17:29:27 -07:00
Selim Cinek
255dd04271 Added notification color to all system notifications
Bug: 17128331
Change-Id: I81a94510ef51b99916f314c0dd65852426a1fbeb
2014-08-20 14:25:18 +02:00
Paul McLean
c7f084f61c Fix ALSA initialized wait for input-only USB Audio devices
Bug 17012266

Change-Id: I09427bb924f895bf66af9ef7ad4f0882746d03c4
2014-08-14 07:42:49 -07:00
Emily Bernier
9769ef9f8a Restore user switching logic.
Change-Id: I859145efc8e7f426ca7f7ad915b082b7e8a2c516
2014-07-14 10:40:54 -04:00
Emily Bernier
1848d31c2c Prevent users from mounting USB, if restricted.
Bug: 13585295

Change-Id: I6b7905fad06bf2e1d4dd629a266280ddff9b3121
2014-07-09 13:23:15 -04:00
Mike Lockwood
2471e02c19 UsbDebuggingManager: remove log spam when disconnecting USB
Bug: 15112047
Change-Id: Ia07895ee166fa87c88d0443f0745bc9384dac10c
2014-06-05 08:24:16 -07:00
Paul McLean
65a30ab519 Changed namespace of AlsaParser (and components) to correctly reflect their place
in the directory hierarchy.

Change-Id: I33a5a34a31d5811cfb5167843dc185ba94d236fd
2014-05-15 13:22:37 -07:00
Dianne Hackborn
d83a096f29 Bump up priority of system receiving BOOT_COMPLETED.
Change-Id: I5166f88f11f781914312e867cb653c8ecbefa705
2014-05-02 16:29:10 -07:00
Aaron Whyte
8aa68921a5 am ee5d512d: am 4980996b: Merge "Allowed custom secure-adb confirmation via Activity or Service. It used to only be available via an Activity." into klp-modular-dev
* commit 'ee5d512d624c15fa0c7e179ace24c7055a9f539d':
  Allowed custom secure-adb confirmation via Activity or Service. It used to only be available via an Activity.
2014-04-16 23:56:07 +00:00
Aaron Whyte
ee5d512d62 am 4980996b: Merge "Allowed custom secure-adb confirmation via Activity or Service. It used to only be available via an Activity." into klp-modular-dev
* commit '4980996bcc4e8065cf5dff1cf989d73face38281':
  Allowed custom secure-adb confirmation via Activity or Service. It used to only be available via an Activity.
2014-04-16 23:49:20 +00:00
Aaron Whyte
d1931ffc07 Allowed custom secure-adb confirmation via Activity or Service.
It used to only be available via an Activity.

Change-Id: Id79a99a70e721f3b567e75d45ffeba779264ec1e
2014-04-16 14:50:14 -07:00
Paul McLean
fd7d31087b Merge "Implement USB Audio across Nexus Devices Fix issues with connecting non-audio USB devices." 2014-04-11 21:18:51 +00:00