Merge "Set the type of system routes" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
71c824f92b
@@ -215,7 +215,6 @@ class BluetoothRouteProvider {
|
|||||||
.setConnectionState(MediaRoute2Info.CONNECTION_STATE_DISCONNECTED)
|
.setConnectionState(MediaRoute2Info.CONNECTION_STATE_DISCONNECTED)
|
||||||
.setDescription(mContext.getResources().getText(
|
.setDescription(mContext.getResources().getText(
|
||||||
R.string.bluetooth_a2dp_audio_route_name).toString())
|
R.string.bluetooth_a2dp_audio_route_name).toString())
|
||||||
//TODO: Set type correctly (BLUETOOTH_A2DP or HEARING_AID)
|
|
||||||
.setType(MediaRoute2Info.TYPE_BLUETOOTH_A2DP)
|
.setType(MediaRoute2Info.TYPE_BLUETOOTH_A2DP)
|
||||||
.setVolumeHandling(MediaRoute2Info.PLAYBACK_VOLUME_VARIABLE)
|
.setVolumeHandling(MediaRoute2Info.PLAYBACK_VOLUME_VARIABLE)
|
||||||
.build();
|
.build();
|
||||||
@@ -236,6 +235,8 @@ class BluetoothRouteProvider {
|
|||||||
// Update volume when the connection state is changed.
|
// Update volume when the connection state is changed.
|
||||||
MediaRoute2Info.Builder builder = new MediaRoute2Info.Builder(btRoute.route)
|
MediaRoute2Info.Builder builder = new MediaRoute2Info.Builder(btRoute.route)
|
||||||
.setConnectionState(state);
|
.setConnectionState(state);
|
||||||
|
builder.setType(btRoute.connectedProfiles.get(BluetoothProfile.HEARING_AID, false)
|
||||||
|
? MediaRoute2Info.TYPE_HEARING_AID : MediaRoute2Info.TYPE_BLUETOOTH_A2DP);
|
||||||
|
|
||||||
if (state == MediaRoute2Info.CONNECTION_STATE_CONNECTED) {
|
if (state == MediaRoute2Info.CONNECTION_STATE_CONNECTED) {
|
||||||
int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
int maxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ package com.android.server.media;
|
|||||||
import static android.media.MediaRoute2Info.FEATURE_LIVE_AUDIO;
|
import static android.media.MediaRoute2Info.FEATURE_LIVE_AUDIO;
|
||||||
import static android.media.MediaRoute2Info.FEATURE_LIVE_VIDEO;
|
import static android.media.MediaRoute2Info.FEATURE_LIVE_VIDEO;
|
||||||
import static android.media.MediaRoute2Info.TYPE_BUILTIN_SPEAKER;
|
import static android.media.MediaRoute2Info.TYPE_BUILTIN_SPEAKER;
|
||||||
|
import static android.media.MediaRoute2Info.TYPE_DOCK;
|
||||||
|
import static android.media.MediaRoute2Info.TYPE_HDMI;
|
||||||
|
import static android.media.MediaRoute2Info.TYPE_USB_DEVICE;
|
||||||
|
import static android.media.MediaRoute2Info.TYPE_WIRED_HEADPHONES;
|
||||||
|
import static android.media.MediaRoute2Info.TYPE_WIRED_HEADSET;
|
||||||
|
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
@@ -194,19 +199,27 @@ class SystemMediaRoute2Provider extends MediaRoute2Provider {
|
|||||||
|
|
||||||
private void updateDeviceRoute(AudioRoutesInfo newRoutes) {
|
private void updateDeviceRoute(AudioRoutesInfo newRoutes) {
|
||||||
int name = R.string.default_audio_route_name;
|
int name = R.string.default_audio_route_name;
|
||||||
|
int type = TYPE_BUILTIN_SPEAKER;
|
||||||
if (newRoutes != null) {
|
if (newRoutes != null) {
|
||||||
mCurAudioRoutesInfo.mainType = newRoutes.mainType;
|
mCurAudioRoutesInfo.mainType = newRoutes.mainType;
|
||||||
if ((newRoutes.mainType & AudioRoutesInfo.MAIN_HEADPHONES) != 0
|
if ((newRoutes.mainType & AudioRoutesInfo.MAIN_HEADPHONES) != 0) {
|
||||||
|| (newRoutes.mainType & AudioRoutesInfo.MAIN_HEADSET) != 0) {
|
type = TYPE_WIRED_HEADPHONES;
|
||||||
|
name = com.android.internal.R.string.default_audio_route_name_headphones;
|
||||||
|
} else if ((newRoutes.mainType & AudioRoutesInfo.MAIN_HEADSET) != 0) {
|
||||||
|
type = TYPE_WIRED_HEADSET;
|
||||||
name = com.android.internal.R.string.default_audio_route_name_headphones;
|
name = com.android.internal.R.string.default_audio_route_name_headphones;
|
||||||
} else if ((newRoutes.mainType & AudioRoutesInfo.MAIN_DOCK_SPEAKERS) != 0) {
|
} else if ((newRoutes.mainType & AudioRoutesInfo.MAIN_DOCK_SPEAKERS) != 0) {
|
||||||
|
type = TYPE_DOCK;
|
||||||
name = com.android.internal.R.string.default_audio_route_name_dock_speakers;
|
name = com.android.internal.R.string.default_audio_route_name_dock_speakers;
|
||||||
} else if ((newRoutes.mainType & AudioRoutesInfo.MAIN_HDMI) != 0) {
|
} else if ((newRoutes.mainType & AudioRoutesInfo.MAIN_HDMI) != 0) {
|
||||||
|
type = TYPE_HDMI;
|
||||||
name = com.android.internal.R.string.default_audio_route_name_hdmi;
|
name = com.android.internal.R.string.default_audio_route_name_hdmi;
|
||||||
} else if ((newRoutes.mainType & AudioRoutesInfo.MAIN_USB) != 0) {
|
} else if ((newRoutes.mainType & AudioRoutesInfo.MAIN_USB) != 0) {
|
||||||
|
type = TYPE_USB_DEVICE;
|
||||||
name = com.android.internal.R.string.default_audio_route_name_usb;
|
name = com.android.internal.R.string.default_audio_route_name_usb;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mDeviceRoute = new MediaRoute2Info.Builder(
|
mDeviceRoute = new MediaRoute2Info.Builder(
|
||||||
DEVICE_ROUTE_ID, mContext.getResources().getText(name).toString())
|
DEVICE_ROUTE_ID, mContext.getResources().getText(name).toString())
|
||||||
.setVolumeHandling(mAudioManager.isVolumeFixed()
|
.setVolumeHandling(mAudioManager.isVolumeFixed()
|
||||||
@@ -214,8 +227,7 @@ class SystemMediaRoute2Provider extends MediaRoute2Provider {
|
|||||||
: MediaRoute2Info.PLAYBACK_VOLUME_VARIABLE)
|
: MediaRoute2Info.PLAYBACK_VOLUME_VARIABLE)
|
||||||
.setVolumeMax(mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC))
|
.setVolumeMax(mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC))
|
||||||
.setVolume(mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC))
|
.setVolume(mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC))
|
||||||
//TODO: Guess the exact type using AudioDevice
|
.setType(type)
|
||||||
.setType(TYPE_BUILTIN_SPEAKER)
|
|
||||||
.addFeature(FEATURE_LIVE_AUDIO)
|
.addFeature(FEATURE_LIVE_AUDIO)
|
||||||
.addFeature(FEATURE_LIVE_VIDEO)
|
.addFeature(FEATURE_LIVE_VIDEO)
|
||||||
.setConnectionState(MediaRoute2Info.CONNECTION_STATE_CONNECTED)
|
.setConnectionState(MediaRoute2Info.CONNECTION_STATE_CONNECTED)
|
||||||
|
|||||||
Reference in New Issue
Block a user