Merge "Volume: Use teal color for "End now"." into mnc-dev
diff --git a/api/current.txt b/api/current.txt
index ef2c4da..c5e4bdd 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -7763,7 +7763,6 @@
     field public static final java.lang.String ALARM_SERVICE = "alarm";
     field public static final java.lang.String APPWIDGET_SERVICE = "appwidget";
     field public static final java.lang.String APP_OPS_SERVICE = "appops";
-    field public static final java.lang.String AUDIO_DEVICES_SERVICE = "audio_devices_manager";
     field public static final java.lang.String AUDIO_SERVICE = "audio";
     field public static final java.lang.String BATTERY_SERVICE = "batterymanager";
     field public static final int BIND_ABOVE_CLIENT = 8; // 0x8
@@ -14728,12 +14727,12 @@
     method public android.media.AudioAttributes.Builder setUsage(int);
   }
 
-  public class AudioDeviceInfo {
-    method public java.lang.String getAddress();
+  public final class AudioDeviceInfo {
     method public int[] getChannelCounts();
     method public int[] getChannelMasks();
     method public int[] getFormats();
-    method public java.lang.String getName();
+    method public int getId();
+    method public java.lang.CharSequence getName();
     method public int[] getSampleRates();
     method public int getType();
     method public boolean isSink();
@@ -14760,15 +14759,6 @@
     field public static final int TYPE_WIRED_HEADSET = 3; // 0x3
   }
 
-  public class AudioDevicesManager {
-    method public void addOnAudioDeviceConnectionListener(android.media.OnAudioDeviceConnectionListener, android.os.Handler);
-    method public android.media.AudioDeviceInfo[] listDevices(int);
-    method public void removeOnAudioDeviceConnectionListener(android.media.OnAudioDeviceConnectionListener);
-    field public static final int LIST_DEVICES_ALL = 3; // 0x3
-    field public static final int LIST_DEVICES_INPUTS = 1; // 0x1
-    field public static final int LIST_DEVICES_OUTPUTS = 2; // 0x2
-  }
-
   public class AudioFormat {
     method public int getChannelCount();
     method public int getChannelIndexMask();
@@ -14839,11 +14829,13 @@
 
   public class AudioManager {
     method public int abandonAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener);
+    method public void addOnAudioDeviceConnectionListener(android.media.OnAudioDeviceConnectionListener, android.os.Handler);
     method public void adjustStreamVolume(int, int, int);
     method public void adjustSuggestedStreamVolume(int, int, int);
     method public void adjustVolume(int, int);
     method public void dispatchMediaKeyEvent(android.view.KeyEvent);
     method public int generateAudioSessionId();
+    method public android.media.AudioDeviceInfo[] getDevices(int);
     method public int getMode();
     method public java.lang.String getParameters(java.lang.String);
     method public java.lang.String getProperty(java.lang.String);
@@ -14868,6 +14860,7 @@
     method public deprecated void registerMediaButtonEventReceiver(android.app.PendingIntent);
     method public deprecated void registerRemoteControlClient(android.media.RemoteControlClient);
     method public deprecated boolean registerRemoteController(android.media.RemoteController);
+    method public void removeOnAudioDeviceConnectionListener(android.media.OnAudioDeviceConnectionListener);
     method public int requestAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, int, int);
     method public deprecated void setBluetoothA2dpOn(boolean);
     method public void setBluetoothScoOn(boolean);
@@ -14936,6 +14929,9 @@
     field public static final int FX_KEYPRESS_SPACEBAR = 6; // 0x6
     field public static final int FX_KEYPRESS_STANDARD = 5; // 0x5
     field public static final int FX_KEY_CLICK = 0; // 0x0
+    field public static final int GET_DEVICES_ALL = 3; // 0x3
+    field public static final int GET_DEVICES_INPUTS = 1; // 0x1
+    field public static final int GET_DEVICES_OUTPUTS = 2; // 0x2
     field public static final int MODE_CURRENT = -1; // 0xffffffff
     field public static final int MODE_INVALID = -2; // 0xfffffffe
     field public static final int MODE_IN_CALL = 2; // 0x2
@@ -14984,7 +14980,7 @@
 
   public class AudioRecord {
     ctor public AudioRecord(int, int, int, int, int) throws java.lang.IllegalArgumentException;
-    method public void addOnAudioRecordRoutingListener(android.media.OnAudioRecordRoutingListener, android.os.Handler);
+    method public void addOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener, android.os.Handler);
     method public int getAudioFormat();
     method public int getAudioSessionId();
     method public int getAudioSource();
@@ -14995,7 +14991,7 @@
     method public int getNativeFrameCount() throws java.lang.IllegalStateException;
     method public int getNotificationMarkerPosition();
     method public int getPositionNotificationPeriod();
-    method public android.media.AudioDeviceInfo getPreferredInputDevice();
+    method public android.media.AudioDeviceInfo getPreferredDevice();
     method public int getRecordingState();
     method public android.media.AudioDeviceInfo getRoutedDevice();
     method public int getSampleRate();
@@ -15008,10 +15004,10 @@
     method public int read(java.nio.ByteBuffer, int);
     method public int read(java.nio.ByteBuffer, int, int);
     method public void release();
-    method public void removeOnAudioRecordRoutingListener(android.media.OnAudioRecordRoutingListener);
+    method public void removeOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener);
     method public int setNotificationMarkerPosition(int);
     method public int setPositionNotificationPeriod(int);
-    method public boolean setPreferredInputDevice(android.media.AudioDeviceInfo);
+    method public boolean setPreferredDevice(android.media.AudioDeviceInfo);
     method public void setRecordPositionUpdateListener(android.media.AudioRecord.OnRecordPositionUpdateListener);
     method public void setRecordPositionUpdateListener(android.media.AudioRecord.OnRecordPositionUpdateListener, android.os.Handler);
     method public void startRecording() throws java.lang.IllegalStateException;
@@ -15042,6 +15038,10 @@
     method public abstract void onPeriodicNotification(android.media.AudioRecord);
   }
 
+  public static abstract interface AudioRecord.OnRoutingChangedListener {
+    method public abstract void onRoutingChanged(android.media.AudioRecord);
+  }
+
   public final class AudioTimestamp {
     ctor public AudioTimestamp();
     field public long framePosition;
@@ -15052,7 +15052,7 @@
     ctor public AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
     ctor public AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
     ctor public AudioTrack(android.media.AudioAttributes, android.media.AudioFormat, int, int, int) throws java.lang.IllegalArgumentException;
-    method public void addOnAudioTrackRoutingListener(android.media.OnAudioTrackRoutingListener, android.os.Handler);
+    method public void addOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener, android.os.Handler);
     method public int attachAuxEffect(int);
     method public void flush();
     method public int getAudioFormat();
@@ -15071,7 +15071,7 @@
     method public android.media.PlaybackParams getPlaybackParams();
     method public int getPlaybackRate();
     method public int getPositionNotificationPeriod();
-    method public android.media.AudioDeviceInfo getPreferredOutputDevice();
+    method public android.media.AudioDeviceInfo getPreferredDevice();
     method public android.media.AudioDeviceInfo getRoutedDevice();
     method public int getSampleRate();
     method public int getState();
@@ -15081,7 +15081,7 @@
     method public void play() throws java.lang.IllegalStateException;
     method public void release();
     method public int reloadStaticData();
-    method public void removeOnAudioTrackRoutingListener(android.media.OnAudioTrackRoutingListener);
+    method public void removeOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener);
     method public int setAuxEffectSendLevel(float);
     method public int setLoopPoints(int, int, int);
     method public int setNotificationMarkerPosition(int);
@@ -15091,7 +15091,7 @@
     method public void setPlaybackPositionUpdateListener(android.media.AudioTrack.OnPlaybackPositionUpdateListener, android.os.Handler);
     method public int setPlaybackRate(int);
     method public int setPositionNotificationPeriod(int);
-    method public boolean setPreferredOutputDevice(android.media.AudioDeviceInfo);
+    method public boolean setPreferredDevice(android.media.AudioDeviceInfo);
     method protected deprecated void setState(int);
     method public deprecated int setStereoVolume(float, float);
     method public int setVolume(float);
@@ -15134,6 +15134,10 @@
     method public abstract void onPeriodicNotification(android.media.AudioTrack);
   }
 
+  public static abstract interface AudioTrack.OnRoutingChangedListener {
+    method public abstract void onRoutingChanged(android.media.AudioTrack);
+  }
+
   public class CamcorderProfile {
     method public static android.media.CamcorderProfile get(int);
     method public static android.media.CamcorderProfile get(int, int);
@@ -16501,14 +16505,6 @@
     method public abstract void onAudioDeviceConnection();
   }
 
-  public abstract interface OnAudioRecordRoutingListener {
-    method public abstract void onAudioRecordRouting(android.media.AudioRecord);
-  }
-
-  public abstract interface OnAudioTrackRoutingListener {
-    method public abstract void onAudioTrackRouting(android.media.AudioTrack);
-  }
-
   public final class PlaybackParams {
     ctor public PlaybackParams();
     method public android.media.PlaybackParams allowDefaults();
diff --git a/api/system-current.txt b/api/system-current.txt
index 4508b20..13796ff 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -7978,7 +7978,6 @@
     field public static final java.lang.String ALARM_SERVICE = "alarm";
     field public static final java.lang.String APPWIDGET_SERVICE = "appwidget";
     field public static final java.lang.String APP_OPS_SERVICE = "appops";
-    field public static final java.lang.String AUDIO_DEVICES_SERVICE = "audio_devices_manager";
     field public static final java.lang.String AUDIO_SERVICE = "audio";
     field public static final java.lang.String BACKUP_SERVICE = "backup";
     field public static final java.lang.String BATTERY_SERVICE = "batterymanager";
@@ -15926,12 +15925,12 @@
     method public android.media.AudioAttributes.Builder setUsage(int);
   }
 
-  public class AudioDeviceInfo {
-    method public java.lang.String getAddress();
+  public final class AudioDeviceInfo {
     method public int[] getChannelCounts();
     method public int[] getChannelMasks();
     method public int[] getFormats();
-    method public java.lang.String getName();
+    method public int getId();
+    method public java.lang.CharSequence getName();
     method public int[] getSampleRates();
     method public int getType();
     method public boolean isSink();
@@ -15958,15 +15957,6 @@
     field public static final int TYPE_WIRED_HEADSET = 3; // 0x3
   }
 
-  public class AudioDevicesManager {
-    method public void addOnAudioDeviceConnectionListener(android.media.OnAudioDeviceConnectionListener, android.os.Handler);
-    method public android.media.AudioDeviceInfo[] listDevices(int);
-    method public void removeOnAudioDeviceConnectionListener(android.media.OnAudioDeviceConnectionListener);
-    field public static final int LIST_DEVICES_ALL = 3; // 0x3
-    field public static final int LIST_DEVICES_INPUTS = 1; // 0x1
-    field public static final int LIST_DEVICES_OUTPUTS = 2; // 0x2
-  }
-
   public final class AudioFocusInfo implements android.os.Parcelable {
     method public int describeContents();
     method public android.media.AudioAttributes getAttributes();
@@ -16050,11 +16040,13 @@
   public class AudioManager {
     method public int abandonAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener);
     method public int abandonAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes);
+    method public void addOnAudioDeviceConnectionListener(android.media.OnAudioDeviceConnectionListener, android.os.Handler);
     method public void adjustStreamVolume(int, int, int);
     method public void adjustSuggestedStreamVolume(int, int, int);
     method public void adjustVolume(int, int);
     method public void dispatchMediaKeyEvent(android.view.KeyEvent);
     method public int generateAudioSessionId();
+    method public android.media.AudioDeviceInfo[] getDevices(int);
     method public int getMode();
     method public java.lang.String getParameters(java.lang.String);
     method public java.lang.String getProperty(java.lang.String);
@@ -16081,6 +16073,7 @@
     method public deprecated void registerMediaButtonEventReceiver(android.app.PendingIntent);
     method public deprecated void registerRemoteControlClient(android.media.RemoteControlClient);
     method public deprecated boolean registerRemoteController(android.media.RemoteController);
+    method public void removeOnAudioDeviceConnectionListener(android.media.OnAudioDeviceConnectionListener);
     method public int requestAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, int, int);
     method public int requestAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes, int, int) throws java.lang.IllegalArgumentException;
     method public int requestAudioFocus(android.media.AudioManager.OnAudioFocusChangeListener, android.media.AudioAttributes, int, int, android.media.audiopolicy.AudioPolicy) throws java.lang.IllegalArgumentException;
@@ -16155,6 +16148,9 @@
     field public static final int FX_KEYPRESS_SPACEBAR = 6; // 0x6
     field public static final int FX_KEYPRESS_STANDARD = 5; // 0x5
     field public static final int FX_KEY_CLICK = 0; // 0x0
+    field public static final int GET_DEVICES_ALL = 3; // 0x3
+    field public static final int GET_DEVICES_INPUTS = 1; // 0x1
+    field public static final int GET_DEVICES_OUTPUTS = 2; // 0x2
     field public static final int MODE_CURRENT = -1; // 0xffffffff
     field public static final int MODE_INVALID = -2; // 0xfffffffe
     field public static final int MODE_IN_CALL = 2; // 0x2
@@ -16204,7 +16200,7 @@
   public class AudioRecord {
     ctor public AudioRecord(int, int, int, int, int) throws java.lang.IllegalArgumentException;
     ctor public AudioRecord(android.media.AudioAttributes, android.media.AudioFormat, int, int) throws java.lang.IllegalArgumentException;
-    method public void addOnAudioRecordRoutingListener(android.media.OnAudioRecordRoutingListener, android.os.Handler);
+    method public void addOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener, android.os.Handler);
     method public int getAudioFormat();
     method public int getAudioSessionId();
     method public int getAudioSource();
@@ -16215,7 +16211,7 @@
     method public int getNativeFrameCount() throws java.lang.IllegalStateException;
     method public int getNotificationMarkerPosition();
     method public int getPositionNotificationPeriod();
-    method public android.media.AudioDeviceInfo getPreferredInputDevice();
+    method public android.media.AudioDeviceInfo getPreferredDevice();
     method public int getRecordingState();
     method public android.media.AudioDeviceInfo getRoutedDevice();
     method public int getSampleRate();
@@ -16228,10 +16224,10 @@
     method public int read(java.nio.ByteBuffer, int);
     method public int read(java.nio.ByteBuffer, int, int);
     method public void release();
-    method public void removeOnAudioRecordRoutingListener(android.media.OnAudioRecordRoutingListener);
+    method public void removeOnRoutingChangedListener(android.media.AudioRecord.OnRoutingChangedListener);
     method public int setNotificationMarkerPosition(int);
     method public int setPositionNotificationPeriod(int);
-    method public boolean setPreferredInputDevice(android.media.AudioDeviceInfo);
+    method public boolean setPreferredDevice(android.media.AudioDeviceInfo);
     method public void setRecordPositionUpdateListener(android.media.AudioRecord.OnRecordPositionUpdateListener);
     method public void setRecordPositionUpdateListener(android.media.AudioRecord.OnRecordPositionUpdateListener, android.os.Handler);
     method public void startRecording() throws java.lang.IllegalStateException;
@@ -16264,6 +16260,10 @@
     method public abstract void onPeriodicNotification(android.media.AudioRecord);
   }
 
+  public static abstract interface AudioRecord.OnRoutingChangedListener {
+    method public abstract void onRoutingChanged(android.media.AudioRecord);
+  }
+
   public final class AudioTimestamp {
     ctor public AudioTimestamp();
     field public long framePosition;
@@ -16274,7 +16274,7 @@
     ctor public AudioTrack(int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
     ctor public AudioTrack(int, int, int, int, int, int, int) throws java.lang.IllegalArgumentException;
     ctor public AudioTrack(android.media.AudioAttributes, android.media.AudioFormat, int, int, int) throws java.lang.IllegalArgumentException;
-    method public void addOnAudioTrackRoutingListener(android.media.OnAudioTrackRoutingListener, android.os.Handler);
+    method public void addOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener, android.os.Handler);
     method public int attachAuxEffect(int);
     method public void flush();
     method public int getAudioFormat();
@@ -16293,7 +16293,7 @@
     method public android.media.PlaybackParams getPlaybackParams();
     method public int getPlaybackRate();
     method public int getPositionNotificationPeriod();
-    method public android.media.AudioDeviceInfo getPreferredOutputDevice();
+    method public android.media.AudioDeviceInfo getPreferredDevice();
     method public android.media.AudioDeviceInfo getRoutedDevice();
     method public int getSampleRate();
     method public int getState();
@@ -16303,7 +16303,7 @@
     method public void play() throws java.lang.IllegalStateException;
     method public void release();
     method public int reloadStaticData();
-    method public void removeOnAudioTrackRoutingListener(android.media.OnAudioTrackRoutingListener);
+    method public void removeOnRoutingChangedListener(android.media.AudioTrack.OnRoutingChangedListener);
     method public int setAuxEffectSendLevel(float);
     method public int setLoopPoints(int, int, int);
     method public int setNotificationMarkerPosition(int);
@@ -16313,7 +16313,7 @@
     method public void setPlaybackPositionUpdateListener(android.media.AudioTrack.OnPlaybackPositionUpdateListener, android.os.Handler);
     method public int setPlaybackRate(int);
     method public int setPositionNotificationPeriod(int);
-    method public boolean setPreferredOutputDevice(android.media.AudioDeviceInfo);
+    method public boolean setPreferredDevice(android.media.AudioDeviceInfo);
     method protected deprecated void setState(int);
     method public deprecated int setStereoVolume(float, float);
     method public int setVolume(float);
@@ -16356,6 +16356,10 @@
     method public abstract void onPeriodicNotification(android.media.AudioTrack);
   }
 
+  public static abstract interface AudioTrack.OnRoutingChangedListener {
+    method public abstract void onRoutingChanged(android.media.AudioTrack);
+  }
+
   public class CamcorderProfile {
     method public static android.media.CamcorderProfile get(int);
     method public static android.media.CamcorderProfile get(int, int);
@@ -17726,14 +17730,6 @@
     method public abstract void onAudioDeviceConnection();
   }
 
-  public abstract interface OnAudioRecordRoutingListener {
-    method public abstract void onAudioRecordRouting(android.media.AudioRecord);
-  }
-
-  public abstract interface OnAudioTrackRoutingListener {
-    method public abstract void onAudioTrackRouting(android.media.AudioTrack);
-  }
-
   public final class PlaybackParams {
     ctor public PlaybackParams();
     method public android.media.PlaybackParams allowDefaults();
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index 391131a..0d00908 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -55,7 +55,6 @@
 import android.location.ICountryDetector;
 import android.location.ILocationManager;
 import android.location.LocationManager;
-import android.media.AudioDevicesManager;
 import android.media.AudioManager;
 import android.media.MediaRouter;
 import android.media.midi.IMidiManager;
@@ -701,13 +700,6 @@
             public RadioManager createService(ContextImpl ctx) {
                 return new RadioManager(ctx);
             }});
-
-        registerService(Context.AUDIO_DEVICES_SERVICE, AudioDevicesManager.class,
-                new CachedServiceFetcher<AudioDevicesManager>() {
-            @Override
-            public AudioDevicesManager createService(ContextImpl ctx) {
-                return new AudioDevicesManager(ctx);
-            }});
     }
 
     /**
@@ -726,7 +718,7 @@
     }
 
     /**
-     * Gets the name of the system-level service that is represented by the specified class. 
+     * Gets the name of the system-level service that is represented by the specified class.
      */
     public static String getSystemServiceName(Class<?> serviceClass) {
         return SYSTEM_SERVICE_NAMES.get(serviceClass);
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 8687c6b..6a98950 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -3133,16 +3133,6 @@
     public static final String RADIO_SERVICE = "radio";
 
     /**
-     * Use with {@link #getSystemService} to retrieve a
-     * {@link android.media.AudioDevicesManager} for handling device enumeration & notification.
-     *
-     * @see #getSystemService
-     * @see android.media.AudioDevicesManager
-     */
-    public static final String AUDIO_DEVICES_SERVICE = "audio_devices_manager";
-
-
-    /**
      * Determine whether the given permission is allowed for a particular
      * process and user ID running in the system.
      *
diff --git a/core/java/com/android/internal/widget/FloatingToolbar.java b/core/java/com/android/internal/widget/FloatingToolbar.java
index 3f7696f..f98fbfc 100644
--- a/core/java/com/android/internal/widget/FloatingToolbar.java
+++ b/core/java/com/android/internal/widget/FloatingToolbar.java
@@ -1247,9 +1247,13 @@
     }
 
     private static int getAdjustedToolbarWidth(Context context, int width) {
-        if (width <= 0 || width > getScreenWidth(context)) {
-            width = context.getResources()
-                    .getDimensionPixelSize(R.dimen.floating_toolbar_default_width);
+        int maximumWidth = getScreenWidth(context) - 2 * context.getResources()
+                .getDimensionPixelSize(R.dimen.floating_toolbar_horizontal_margin);
+
+        if (width <= 0 || width > maximumWidth) {
+            int defaultWidth = context.getResources()
+                    .getDimensionPixelSize(R.dimen.floating_toolbar_preferred_width);
+            width = Math.min(defaultWidth, maximumWidth);
         }
         return width;
     }
diff --git a/core/res/res/values-land/dimens.xml b/core/res/res/values-land/dimens.xml
index 640ca1e..4f0c0fb 100644
--- a/core/res/res/values-land/dimens.xml
+++ b/core/res/res/values-land/dimens.xml
@@ -67,4 +67,7 @@
     <!-- width of ImmersiveModeConfirmation (-1 for match_parent) -->
     <dimen name="immersive_mode_cling_width">380dp</dimen>
 
+     <!-- Floating toolbar dimensions -->
+     <dimen name="floating_toolbar_preferred_width">544dp</dimen>
+
 </resources>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index bbba712..84747f1 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -391,7 +391,7 @@
      <dimen name="floating_toolbar_overflow_side_padding">18dp</dimen>
      <dimen name="floating_toolbar_text_size">14sp</dimen>
      <dimen name="floating_toolbar_menu_button_minimum_width">48dp</dimen>
-     <dimen name="floating_toolbar_default_width">264dp</dimen>
+     <dimen name="floating_toolbar_preferred_width">328dp</dimen>
      <dimen name="floating_toolbar_minimum_overflow_height">144dp</dimen>
      <dimen name="floating_toolbar_horizontal_margin">16dp</dimen>
      <dimen name="floating_toolbar_vertical_margin">8dp</dimen>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 801a98a..11583b3 100755
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -2241,7 +2241,7 @@
   <java-symbol type="dimen" name="floating_toolbar_overflow_side_padding" />
   <java-symbol type="dimen" name="floating_toolbar_text_size" />
   <java-symbol type="dimen" name="floating_toolbar_menu_button_minimum_width" />
-  <java-symbol type="dimen" name="floating_toolbar_default_width" />
+  <java-symbol type="dimen" name="floating_toolbar_preferred_width" />
   <java-symbol type="dimen" name="floating_toolbar_minimum_overflow_height" />
   <java-symbol type="dimen" name="floating_toolbar_horizontal_margin" />
   <java-symbol type="dimen" name="floating_toolbar_vertical_margin" />
diff --git a/media/java/android/media/AudioDeviceInfo.java b/media/java/android/media/AudioDeviceInfo.java
index d58b1d1..566f8dc 100644
--- a/media/java/android/media/AudioDeviceInfo.java
+++ b/media/java/android/media/AudioDeviceInfo.java
@@ -21,7 +21,7 @@
 /**
  * Class to provide information about the audio devices.
  */
-public class AudioDeviceInfo {
+public final class AudioDeviceInfo {
 
     /**
      * A device type associated with an unknown or uninitialized device.
@@ -112,7 +112,6 @@
     }
 
     /**
-     * @hide
      * @return The internal device ID.
      */
     public int getId() {
@@ -122,15 +121,15 @@
     /**
      * @return The human-readable name of the audio device.
      */
-    public String getName() {
+    public CharSequence getName() {
         return mPort.name();
     }
 
     /**
+     * @hide
      * @return The "address" string of the device. This generally contains device-specific
      * parameters.
      */
-    // TODO Is there a compelling reason to expose this?
     public String getAddress() {
         return mPort.address();
     }
@@ -157,15 +156,18 @@
     }
 
     /**
-     * @return An array of channel masks supported by the audio device (defined in
-     * AudioFormat.java).
+     * @return An array of channel masks ({@link AudioFormat#CHANNEL_IN_STEREO},
+     * {@link AudioFormat#CHANNEL_OUT_7POINT1) for which this audio device can be configured.
+     *
+     * @see AudioFormat
      */
     public int[] getChannelMasks() {
         return mPort.channelMasks();
     }
 
     /**
-     * @return An array of channel counts supported by the audio device.
+     * @return An array of channel counts (1, 2, 4....) for which this audio device
+     * can be configured.
      */
     public int[] getChannelCounts() {
         int[] masks = getChannelMasks();
@@ -179,8 +181,10 @@
     }
 
     /**
-     * @return An array of audio format IDs supported by the audio device (defined in
-     * AudioFormat.java)
+     * @return An array of audio format IDs (@link AudioFormat#ENCODING_PCM_16BIT,
+     * {@link AudioFormat#ENCODING_PCM_FLOAT}...) supported by the audio device.
+     *
+     * @see AudioFormat
      */
     public int[] getFormats() {
         return mPort.formats();
diff --git a/media/java/android/media/AudioDevicesManager.java b/media/java/android/media/AudioDevicesManager.java
deleted file mode 100644
index 8b83c17..0000000
--- a/media/java/android/media/AudioDevicesManager.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.media;
-
-import android.content.Context;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
-import android.util.ArrayMap;
-import android.util.Pair;
-import android.util.Slog;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-
-/**
- * AudioDevicesManager implements the Android Media Audio device enumeration and notification
- * functionality.  This functionality is in two comlementary parts.
- * <ol>
- * <li>{@link AudioDevicesManager#listDevices(int)} gets the list of current audio devices
- * </li>
- * <li>{@link AudioDevicesManager#addOnAudioDeviceConnectionListener(OnAudioDeviceConnectionListener, android.os.Handler)}
- *  provides a mechanism for applications to be informed of audio device connect/disconnect events.
- * </li>
- * </ol>
- */
-public class AudioDevicesManager {
-
-    private static String TAG = "AudioDevicesManager";
-
-    private static boolean DEBUG = false;
-
-    private AudioManager mAudioManager = null;
-
-    private OnAmPortUpdateListener mPortListener = null;
-
-    /**
-     * The message sent to apps when the contents of the device list changes if they provide
-     * a {#link Handler} object to addOnAudioDeviceConnectionListener().
-     */
-    private final static int MSG_DEVICES_LIST_CHANGE = 0;
-
-    private ArrayMap<OnAudioDeviceConnectionListener, NativeEventHandlerDelegate>
-        mDeviceConnectionListeners =
-            new ArrayMap<OnAudioDeviceConnectionListener, NativeEventHandlerDelegate>();
-
-    /**
-     * @hide
-     * The AudioDevicesManager class is used to enumerate the physical audio devices connected
-     * to the system.  See also {@link AudioDeviceInfo}.
-     */
-    public AudioDevicesManager(Context context) {
-        mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
-        mPortListener = new OnAmPortUpdateListener();
-        mAudioManager.registerAudioPortUpdateListener(mPortListener);
-    }
-
-    /**
-     * Specifies to the {@link AudioDevicesManager#listDevices(int)} method to include
-     * source (i.e. input) audio devices.
-     */
-    public static final int LIST_DEVICES_INPUTS    = 0x0001;
-
-    /**
-     * Specifies to the {@link AudioDevicesManager#listDevices(int)} method to include
-     * sink (i.e. output) audio devices.
-     */
-    public static final int LIST_DEVICES_OUTPUTS   = 0x0002;
-
-    /**
-     * Specifies to the {@link AudioDevicesManager#listDevices(int)} method to include both
-     * source and sink devices.
-     */
-    public static final int LIST_DEVICES_ALL = LIST_DEVICES_OUTPUTS | LIST_DEVICES_INPUTS;
-
-    /**
-     * Determines if a given AudioDevicePort meets the specified filter criteria.
-     * @param port  The port to test.
-     * @param flags A set of bitflags specifying the criteria to test.
-     * @see {@link LIST_DEVICES_OUTPUTS} and {@link LIST_DEVICES_INPUTS}
-     **/
-    private static boolean checkFlags(AudioDevicePort port, int flags) {
-        return port.role() == AudioPort.ROLE_SINK && (flags & LIST_DEVICES_OUTPUTS) != 0 ||
-               port.role() == AudioPort.ROLE_SOURCE && (flags & LIST_DEVICES_INPUTS) != 0;
-    }
-
-    /**
-     * Generates a list of AudioDeviceInfo objects corresponding to the audio devices currently
-     * connected to the system and meeting the criteria specified in the <code>flags</code>
-     * parameter.
-     * @param flags A set of bitflags specifying the criteria to test.
-     * @see {@link LIST_DEVICES_OUTPUTS}, {@link LIST_DEVICES_INPUTS} and {@link LIST_DEVICES_ALL}.
-     * @return A (possibly zero-length) array of AudioDeviceInfo objects.
-     */
-    public AudioDeviceInfo[] listDevices(int flags) {
-        return listDevicesStatic(flags);
-    }
-
-    /**
-     * Generates a list of AudioDeviceInfo objects corresponding to the audio devices currently
-     * connected to the system and meeting the criteria specified in the <code>flags</code>
-     * parameter.
-     * @param flags A set of bitflags specifying the criteria to test.
-     * @see {@link LIST_DEVICES_OUTPUTS}, {@link LIST_DEVICES_INPUTS} and {@link LIST_DEVICES_ALL}.
-     * @return A (possibly zero-length) array of AudioDeviceInfo objects.
-     * @hide
-     */
-    public static AudioDeviceInfo[] listDevicesStatic(int flags) {
-        ArrayList<AudioDevicePort> ports = new ArrayList<AudioDevicePort>();
-        int status = AudioManager.listAudioDevicePorts(ports);
-        if (status != AudioManager.SUCCESS) {
-            // fail and bail!
-            return new AudioDeviceInfo[0];
-        }
-
-        // figure out how many AudioDeviceInfo we need space for
-        int numRecs = 0;
-        for (AudioDevicePort port : ports) {
-            if (checkFlags(port, flags)) {
-                numRecs++;
-            }
-        }
-
-        // Now load them up
-        AudioDeviceInfo[] deviceList = new AudioDeviceInfo[numRecs];
-        int slot = 0;
-        for (AudioDevicePort port : ports) {
-            if (checkFlags(port, flags)) {
-                deviceList[slot++] = new AudioDeviceInfo(port);
-            }
-        }
-
-        return deviceList;
-    }
-
-    /**
-     * Adds an {@link OnAudioDeviceConnectionListener} to receive notifications of changes
-     * to the set of connected audio devices.
-     */
-    public void addOnAudioDeviceConnectionListener(OnAudioDeviceConnectionListener listener,
-            android.os.Handler handler) {
-        if (listener != null && !mDeviceConnectionListeners.containsKey(listener)) {
-            synchronized (mDeviceConnectionListeners) {
-                mDeviceConnectionListeners.put(
-                    listener, new NativeEventHandlerDelegate(listener, handler));
-            }
-        }
-    }
-
-    /**
-     * Removes an {@link OnAudioDeviceConnectionListener} which has been previously registered
-     * to receive notifications of changes to the set of connected audio devices.
-     */
-    public void removeOnAudioDeviceConnectionListener(OnAudioDeviceConnectionListener listener) {
-        synchronized (mDeviceConnectionListeners) {
-            if (mDeviceConnectionListeners.containsKey(listener)) {
-                mDeviceConnectionListeners.remove(listener);
-            }
-        }
-    }
-
-    /**
-     * Sends device list change notification to all listeners.
-     */
-    private void broadcastDeviceListChange() {
-        Collection<NativeEventHandlerDelegate> values;
-        synchronized (mDeviceConnectionListeners) {
-            values = mDeviceConnectionListeners.values();
-        }
-        for(NativeEventHandlerDelegate delegate : values) {
-            Handler handler = delegate.getHandler();
-            if (handler != null) {
-                handler.sendEmptyMessage(MSG_DEVICES_LIST_CHANGE);
-            }
-        }
-    }
-
-    /**
-     * Handles Port list update notifications from the AudioManager
-     */
-    private class OnAmPortUpdateListener implements AudioManager.OnAudioPortUpdateListener {
-        static final String TAG = "OnAmPortUpdateListener";
-        public void onAudioPortListUpdate(AudioPort[] portList) {
-            broadcastDeviceListChange();
-        }
-
-        /**
-         * Callback method called upon audio patch list update.
-         * @param patchList the updated list of audio patches
-         */
-        public void onAudioPatchListUpdate(AudioPatch[] patchList) {
-            if (DEBUG) {
-                Slog.d(TAG, "onAudioPatchListUpdate() " + patchList.length + " patches.");
-            }
-        }
-
-        /**
-         * Callback method called when the mediaserver dies
-         */
-        public void onServiceDied() {
-            if (DEBUG) {
-                Slog.i(TAG, "onServiceDied()");
-            }
-
-            broadcastDeviceListChange();
-        }
-    }
-
-    //---------------------------------------------------------
-    // Inner classes
-    //--------------------
-    /**
-     * Helper class to handle the forwarding of native events to the appropriate listener
-     * (potentially) handled in a different thread.
-     */
-    private class NativeEventHandlerDelegate {
-        private final Handler mHandler;
-
-        NativeEventHandlerDelegate(final OnAudioDeviceConnectionListener listener,
-                                   Handler handler) {
-            // find the looper for our new event handler
-            Looper looper;
-            if (handler != null) {
-                looper = handler.getLooper();
-            } else {
-                // no given handler, use the looper the addListener call was called in
-                looper = Looper.getMainLooper();
-            }
-
-            // construct the event handler with this looper
-            if (looper != null) {
-                // implement the event handler delegate
-                mHandler = new Handler(looper) {
-                    @Override
-                    public void handleMessage(Message msg) {
-                        switch(msg.what) {
-                        case MSG_DEVICES_LIST_CHANGE:
-                            // call the OnAudioDeviceConnectionListener
-                            if (listener != null) {
-                                listener.onAudioDeviceConnection();
-                            }
-                            break;
-                        default:
-                            Slog.e(TAG, "Unknown native event type: " + msg.what);
-                            break;
-                        }
-                    }
-                };
-            } else {
-                mHandler = null;
-            }
-        }
-
-        Handler getHandler() {
-            return mHandler;
-        }
-    }
-}
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index 56f0400f..cba83f9 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -42,10 +42,13 @@
 import android.os.SystemClock;
 import android.os.ServiceManager;
 import android.provider.Settings;
+import android.util.ArrayMap;
 import android.util.Log;
+import android.util.Pair;
 import android.view.KeyEvent;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 
@@ -628,6 +631,9 @@
         mUseFixedVolume = getContext().getResources().getBoolean(
                 com.android.internal.R.bool.config_useFixedVolume);
         sAudioPortEventHandler.init();
+
+        mPortListener = new OnAmPortUpdateListener();
+        registerAudioPortUpdateListener(mPortListener);
     }
 
     private Context getContext() {
@@ -3697,4 +3703,210 @@
                                                  portCfg.format(),
                                                  gainCfg);
     }
+
+    private OnAmPortUpdateListener mPortListener = null;
+
+    /**
+     * The message sent to apps when the contents of the device list changes if they provide
+     * a {#link Handler} object to addOnAudioDeviceConnectionListener().
+     */
+    private final static int MSG_DEVICES_LIST_CHANGE = 0;
+
+    private ArrayMap<OnAudioDeviceConnectionListener, NativeEventHandlerDelegate>
+        mDeviceConnectionListeners =
+            new ArrayMap<OnAudioDeviceConnectionListener, NativeEventHandlerDelegate>();
+
+    /**
+     * Specifies to the {@link AudioManager#getDevices(int)} method to include
+     * source (i.e. input) audio devices.
+     */
+    public static final int GET_DEVICES_INPUTS    = 0x0001;
+
+    /**
+     * Specifies to the {@link AudioManager#getDevices(int)} method to include
+     * sink (i.e. output) audio devices.
+     */
+    public static final int GET_DEVICES_OUTPUTS   = 0x0002;
+
+    /**
+     * Specifies to the {@link AudioManager#getDevices(int)} method to include both
+     * source and sink devices.
+     */
+    public static final int GET_DEVICES_ALL = GET_DEVICES_OUTPUTS | GET_DEVICES_INPUTS;
+
+    /**
+     * Determines if a given AudioDevicePort meets the specified filter criteria.
+     * @param port  The port to test.
+     * @param flags A set of bitflags specifying the criteria to test.
+     * @see {@link GET_DEVICES_OUTPUTS} and {@link GET_DEVICES_INPUTS}
+     **/
+    private static boolean checkFlags(AudioDevicePort port, int flags) {
+        return port.role() == AudioPort.ROLE_SINK && (flags & GET_DEVICES_OUTPUTS) != 0 ||
+               port.role() == AudioPort.ROLE_SOURCE && (flags & GET_DEVICES_INPUTS) != 0;
+    }
+
+    /**
+     * Generates a list of AudioDeviceInfo objects corresponding to the audio devices currently
+     * connected to the system and meeting the criteria specified in the <code>flags</code>
+     * parameter.
+     * @param flags A set of bitflags specifying the criteria to test.
+     * @see {@link GET_DEVICES_OUTPUTS}, {@link GET_DEVICES_INPUTS} and {@lGET_DEVICES_CES_ALL}.
+     * @return A (possibly zero-length) array of AudioDeviceInfo objects.
+     */
+    public AudioDeviceInfo[] getDevices(int flags) {
+        return getDevicesStatic(flags);
+    }
+
+    /**
+     * Generates a list of AudioDeviceInfo objects corresponding to the audio devices currently
+     * connected to the system and meeting the criteria specified in the <code>flags</code>
+     * parameter.
+     * @param flags A set of bitflags specifying the criteria to test.
+     * @see {@link GET_DEVICES_OUTPUTS}, {@link GET_DEVICES_INPUTS} and {@link GET_DEVICES_ALL}.
+     * @return A (possibly zero-length) array of AudioDeviceInfo objects.
+     * @hide
+     */
+    public static AudioDeviceInfo[] getDevicesStatic(int flags) {
+        ArrayList<AudioDevicePort> ports = new ArrayList<AudioDevicePort>();
+        int status = AudioManager.listAudioDevicePorts(ports);
+        if (status != AudioManager.SUCCESS) {
+            // fail and bail!
+            return new AudioDeviceInfo[0];
+        }
+
+        // figure out how many AudioDeviceInfo we need space for
+        int numRecs = 0;
+        for (AudioDevicePort port : ports) {
+            if (checkFlags(port, flags)) {
+                numRecs++;
+            }
+        }
+
+        // Now load them up
+        AudioDeviceInfo[] deviceList = new AudioDeviceInfo[numRecs];
+        int slot = 0;
+        for (AudioDevicePort port : ports) {
+            if (checkFlags(port, flags)) {
+                deviceList[slot++] = new AudioDeviceInfo(port);
+            }
+        }
+
+        return deviceList;
+    }
+
+    /**
+     * Adds an {@link OnAudioDeviceConnectionListener} to receive notifications of changes
+     * to the set of connected audio devices.
+     */
+    public void addOnAudioDeviceConnectionListener(OnAudioDeviceConnectionListener listener,
+            android.os.Handler handler) {
+        if (listener != null && !mDeviceConnectionListeners.containsKey(listener)) {
+            synchronized (mDeviceConnectionListeners) {
+                mDeviceConnectionListeners.put(
+                    listener, new NativeEventHandlerDelegate(listener, handler));
+            }
+        }
+    }
+
+    /**
+     * Removes an {@link OnAudioDeviceConnectionListener} which has been previously registered
+     * to receive notifications of changes to the set of connected audio devices.
+     */
+    public void removeOnAudioDeviceConnectionListener(OnAudioDeviceConnectionListener listener) {
+        synchronized (mDeviceConnectionListeners) {
+            if (mDeviceConnectionListeners.containsKey(listener)) {
+                mDeviceConnectionListeners.remove(listener);
+            }
+        }
+    }
+
+    /**
+     * Sends device list change notification to all listeners.
+     */
+    private void broadcastDeviceListChange() {
+        Collection<NativeEventHandlerDelegate> values;
+        synchronized (mDeviceConnectionListeners) {
+            values = mDeviceConnectionListeners.values();
+        }
+        for (NativeEventHandlerDelegate delegate : values) {
+            Handler handler = delegate.getHandler();
+            if (handler != null) {
+                handler.sendEmptyMessage(MSG_DEVICES_LIST_CHANGE);
+            }
+        }
+    }
+
+    /**
+     * Handles Port list update notifications from the AudioManager
+     */
+    private class OnAmPortUpdateListener implements AudioManager.OnAudioPortUpdateListener {
+        static final String TAG = "OnAmPortUpdateListener";
+        public void onAudioPortListUpdate(AudioPort[] portList) {
+            broadcastDeviceListChange();
+        }
+
+        /**
+         * Callback method called upon audio patch list update.
+         * @param patchList the updated list of audio patches
+         */
+        public void onAudioPatchListUpdate(AudioPatch[] patchList) {}
+
+        /**
+         * Callback method called when the mediaserver dies
+         */
+        public void onServiceDied() {
+            broadcastDeviceListChange();
+        }
+    }
+
+    //---------------------------------------------------------
+    // Inner classes
+    //--------------------
+    /**
+     * Helper class to handle the forwarding of native events to the appropriate listener
+     * (potentially) handled in a different thread.
+     */
+    private class NativeEventHandlerDelegate {
+        private final Handler mHandler;
+
+        NativeEventHandlerDelegate(final OnAudioDeviceConnectionListener listener,
+                                   Handler handler) {
+            // find the looper for our new event handler
+            Looper looper;
+            if (handler != null) {
+                looper = handler.getLooper();
+            } else {
+                // no given handler, use the looper the addListener call was called in
+                looper = Looper.getMainLooper();
+            }
+
+            // construct the event handler with this looper
+            if (looper != null) {
+                // implement the event handler delegate
+                mHandler = new Handler(looper) {
+                    @Override
+                    public void handleMessage(Message msg) {
+                        switch(msg.what) {
+                        case MSG_DEVICES_LIST_CHANGE:
+                            // call the OnAudioDeviceConnectionListener
+                            if (listener != null) {
+                                listener.onAudioDeviceConnection();
+                            }
+                            break;
+                        default:
+                            Log.e(TAG, "Unknown native event type: " + msg.what);
+                            break;
+                        }
+                    }
+                };
+            } else {
+                mHandler = null;
+            }
+        }
+
+        Handler getHandler() {
+            return mHandler;
+        }
+    }
+
 }
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java
index 11671d8..c720e2a 100644
--- a/media/java/android/media/AudioRecord.java
+++ b/media/java/android/media/AudioRecord.java
@@ -1202,6 +1202,14 @@
     //--------------------------------------------------------------------------
     // (Re)Routing Info
     //--------------------
+    public interface OnRoutingChangedListener {
+        /**
+         * Called when the routing of an AudioRecord changes from either and explicit or
+         * policy rerouting.
+         */
+        public void onRoutingChanged(AudioRecord audioRecord);
+    }
+
     /**
      * Returns an {@link AudioDeviceInfo} identifying the current routing of this AudioRecord.
      */
@@ -1211,7 +1219,7 @@
             return null;
         }
         AudioDeviceInfo[] devices =
-                AudioDevicesManager.listDevicesStatic(AudioDevicesManager.LIST_DEVICES_INPUTS);
+                AudioManager.getDevicesStatic(AudioManager.GET_DEVICES_INPUTS);
         for (int i = 0; i < devices.length; i++) {
             if (devices[i].getId() == deviceId) {
                 return devices[i];
@@ -1222,17 +1230,17 @@
 
     /**
      * The message sent to apps when the routing of this AudioRecord changes if they provide
-     * a {#link Handler} object to addOnAudioRecordRoutingListener().
+     * a {#link Handler} object to addOnRoutingChangeListener().
      */
-    private ArrayMap<OnAudioRecordRoutingListener, NativeRoutingEventHandlerDelegate>
+    private ArrayMap<OnRoutingChangedListener, NativeRoutingEventHandlerDelegate>
         mRoutingChangeListeners =
-            new ArrayMap<OnAudioRecordRoutingListener, NativeRoutingEventHandlerDelegate>();
+            new ArrayMap<OnRoutingChangedListener, NativeRoutingEventHandlerDelegate>();
 
     /**
-     * Adds an {@link OnAudioRecordRoutingListener} to receive notifications of routing changes
+     * Adds an {@link OnRoutingChangedListener} to receive notifications of routing changes
      * on this AudioRecord.
      */
-    public void addOnAudioRecordRoutingListener(OnAudioRecordRoutingListener listener,
+    public void addOnRoutingChangedListener(OnRoutingChangedListener listener,
             android.os.Handler handler) {
         if (listener != null && !mRoutingChangeListeners.containsKey(listener)) {
             synchronized (mRoutingChangeListeners) {
@@ -1246,10 +1254,10 @@
     }
 
     /**
-     * Removes an {@link OnAudioRecordRoutingListener} which has been previously added
+     * Removes an {@link OnRoutingChangedListener} which has been previously added
      * to receive notifications of changes to the set of connected audio devices.
      */
-    public void removeOnAudioRecordRoutingListener(OnAudioRecordRoutingListener listener) {
+    public void removeOnRoutingChangedListener(OnRoutingChangedListener listener) {
         synchronized (mRoutingChangeListeners) {
             if (mRoutingChangeListeners.containsKey(listener)) {
                 mRoutingChangeListeners.remove(listener);
@@ -1268,7 +1276,7 @@
         private final Handler mHandler;
 
         NativeRoutingEventHandlerDelegate(final AudioRecord record,
-                                   final OnAudioRecordRoutingListener listener,
+                                   final OnRoutingChangedListener listener,
                                    Handler handler) {
             // find the looper for our new event handler
             Looper looper;
@@ -1291,7 +1299,7 @@
                         switch(msg.what) {
                         case AudioSystem.NATIVE_EVENT_ROUTING_CHANGE:
                             if (listener != null) {
-                                listener.onAudioRecordRouting(record);
+                                listener.onRoutingChanged(record);
                             }
                             break;
                         default:
@@ -1354,7 +1362,7 @@
      * @return true if successful, false if the specified {@link AudioDeviceInfo} is non-null and
      * does not correspond to a valid audio input device.
      */
-    public boolean setPreferredInputDevice(AudioDeviceInfo deviceInfo) {
+    public boolean setPreferredDevice(AudioDeviceInfo deviceInfo) {
         // Do some validation....
         if (deviceInfo != null && !deviceInfo.isSource()) {
             return false;
@@ -1371,10 +1379,10 @@
     }
 
     /**
-     * Returns the selected input specified by {@link #setPreferredInputDevice}. Note that this
+     * Returns the selected input specified by {@link #setPreferredDevice}. Note that this
      * is not guarenteed to correspond to the actual device being used for recording.
      */
-    public AudioDeviceInfo getPreferredInputDevice() {
+    public AudioDeviceInfo getPreferredDevice() {
         synchronized (this) {
             return mPreferredDevice;
         }
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index dc37700..eda14a7 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -2046,7 +2046,7 @@
      * @return true if succesful, false if the specified {@link AudioDeviceInfo} is non-null and
      * does not correspond to a valid audio output device.
      */
-    public boolean setPreferredOutputDevice(AudioDeviceInfo deviceInfo) {
+    public boolean setPreferredDevice(AudioDeviceInfo deviceInfo) {
         // Do some validation....
         if (deviceInfo != null && !deviceInfo.isSink()) {
             return false;
@@ -2062,10 +2062,10 @@
     }
 
     /**
-     * Returns the selected output specified by {@link #setPreferredOutputDevice}. Note that this
+     * Returns the selected output specified by {@link #setPreferredDevice}. Note that this
      * is not guaranteed to correspond to the actual device being used for playback.
      */
-    public AudioDeviceInfo getPreferredOutputDevice() {
+    public AudioDeviceInfo getPreferredDevice() {
         synchronized (this) {
             return mPreferredDevice;
         }
@@ -2074,6 +2074,14 @@
     //--------------------------------------------------------------------------
     // (Re)Routing Info
     //--------------------
+    public interface OnRoutingChangedListener {
+        /**
+         * Called when the routing of an AudioTrack changes from either and explicit or
+         * policy rerouting.
+         */
+        public void onRoutingChanged(AudioTrack audioTrack);
+    }
+
     /**
      * Returns an {@link AudioDeviceInfo} identifying the current routing of this AudioTrack.
      */
@@ -2083,7 +2091,7 @@
             return null;
         }
         AudioDeviceInfo[] devices =
-                AudioDevicesManager.listDevicesStatic(AudioDevicesManager.LIST_DEVICES_OUTPUTS);
+                AudioManager.getDevicesStatic(AudioManager.GET_DEVICES_OUTPUTS);
         for (int i = 0; i < devices.length; i++) {
             if (devices[i].getId() == deviceId) {
                 return devices[i];
@@ -2094,17 +2102,17 @@
 
     /**
      * The message sent to apps when the routing of this AudioTrack changes if they provide
-     * a {#link Handler} object to addOnAudioTrackRoutingListener().
+     * a {#link Handler} object to addOnRoutingChangedListener().
      */
-    private ArrayMap<OnAudioTrackRoutingListener, NativeRoutingEventHandlerDelegate>
+    private ArrayMap<OnRoutingChangedListener, NativeRoutingEventHandlerDelegate>
         mRoutingChangeListeners =
-            new ArrayMap<OnAudioTrackRoutingListener, NativeRoutingEventHandlerDelegate>();
+            new ArrayMap<OnRoutingChangedListener, NativeRoutingEventHandlerDelegate>();
 
     /**
-     * Adds an {@link OnAudioTrackRoutingListener} to receive notifications of routing changes
+     * Adds an {@link OnRoutingChangedListener} to receive notifications of routing changes
      * on this AudioTrack.
      */
-    public void addOnAudioTrackRoutingListener(OnAudioTrackRoutingListener listener,
+    public void addOnRoutingChangedListener(OnRoutingChangedListener listener,
             android.os.Handler handler) {
         if (listener != null && !mRoutingChangeListeners.containsKey(listener)) {
             synchronized (mRoutingChangeListeners) {
@@ -2118,10 +2126,10 @@
     }
 
     /**
-     * Removes an {@link OnAudioTrackRoutingListener} which has been previously added
+     * Removes an {@link OnRoutingChangedListener} which has been previously added
      * to receive notifications of changes to the set of connected audio devices.
      */
-    public void removeOnAudioTrackRoutingListener(OnAudioTrackRoutingListener listener) {
+    public void removeOnRoutingChangedListener(OnRoutingChangedListener listener) {
         synchronized (mRoutingChangeListeners) {
             if (mRoutingChangeListeners.containsKey(listener)) {
                 mRoutingChangeListeners.remove(listener);
@@ -2236,7 +2244,7 @@
         private final Handler mHandler;
 
         NativeRoutingEventHandlerDelegate(final AudioTrack track,
-                                   final OnAudioTrackRoutingListener listener,
+                                   final OnRoutingChangedListener listener,
                                    Handler handler) {
             // find the looper for our new event handler
             Looper looper;
@@ -2259,7 +2267,7 @@
                         switch(msg.what) {
                         case AudioSystem.NATIVE_EVENT_ROUTING_CHANGE:
                             if (listener != null) {
-                                listener.onAudioTrackRouting(track);
+                                listener.onRoutingChanged(track);
                             }
                             break;
                         default:
diff --git a/media/java/android/media/OnAudioDeviceConnectionListener.java b/media/java/android/media/OnAudioDeviceConnectionListener.java
index 71c135a..57e9e17 100644
--- a/media/java/android/media/OnAudioDeviceConnectionListener.java
+++ b/media/java/android/media/OnAudioDeviceConnectionListener.java
@@ -18,13 +18,13 @@
 
 /**
  * OnAudioDeviceConnectionListener defines the interface for notification listeners in the
- * {@link AudioDevicesManager}
+ * {@link AudioManager}
  */
 public interface OnAudioDeviceConnectionListener {
     /**
-     * Called by the {@link AudioDevicesManager} to indicate that an audio device has been
+     * Called by the {@link AudioManager} to indicate that an audio device has been
      * connected or disconnected. A listener will probably call the
-     * {@link AudioDevicesManager#listDevices} method to retrieve the current list of audio
+     * {@link AudioManager#getDevices} method to retrieve the current list of audio
      * devices.
      */
     public void onAudioDeviceConnection();
diff --git a/media/java/android/media/OnAudioRecordRoutingListener.java b/media/java/android/media/OnAudioRecordRoutingListener.java
deleted file mode 100644
index 8ff41c5..0000000
--- a/media/java/android/media/OnAudioRecordRoutingListener.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.media;
-
-/**
- * OnAudioDeviceConnectionListener defines the interface for notification listeners in the
- * {@link AudioDevicesManager}
- */
-public interface OnAudioRecordRoutingListener {
-    /**
-     * Called when the routing of an AudioRecord changes from either and explicit or
-     * policy rerouting.
-     */
-    public void onAudioRecordRouting(AudioRecord audioRecord);
-}
diff --git a/media/java/android/media/OnAudioTrackRoutingListener.java b/media/java/android/media/OnAudioTrackRoutingListener.java
deleted file mode 100644
index 18c72ef..0000000
--- a/media/java/android/media/OnAudioTrackRoutingListener.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.media;
-
-/**
- * OnAudioDeviceConnectionListener defines the interface for notification listeners in the
- * {@link AudioDevicesManager}
- */
-public interface OnAudioTrackRoutingListener {
-    /**
-     * Called when the routing of an AudioTrack changes from either and explicit or
-     * policy rerouting.
-     */
-    public void onAudioTrackRouting(AudioTrack audioTrack);
-}