Merge "Add address to MediaRoute2Info" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
55e5ac8fc0
@@ -317,9 +317,10 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
@ConnectionState
|
@ConnectionState
|
||||||
final int mConnectionState;
|
final int mConnectionState;
|
||||||
final String mClientPackageName;
|
final String mClientPackageName;
|
||||||
final int mVolume;
|
|
||||||
final int mVolumeMax;
|
|
||||||
final int mVolumeHandling;
|
final int mVolumeHandling;
|
||||||
|
final int mVolumeMax;
|
||||||
|
final int mVolume;
|
||||||
|
final String mAddress;
|
||||||
final Bundle mExtras;
|
final Bundle mExtras;
|
||||||
final String mProviderId;
|
final String mProviderId;
|
||||||
|
|
||||||
@@ -336,6 +337,7 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
mVolumeHandling = builder.mVolumeHandling;
|
mVolumeHandling = builder.mVolumeHandling;
|
||||||
mVolumeMax = builder.mVolumeMax;
|
mVolumeMax = builder.mVolumeMax;
|
||||||
mVolume = builder.mVolume;
|
mVolume = builder.mVolume;
|
||||||
|
mAddress = builder.mAddress;
|
||||||
mExtras = builder.mExtras;
|
mExtras = builder.mExtras;
|
||||||
mProviderId = builder.mProviderId;
|
mProviderId = builder.mProviderId;
|
||||||
}
|
}
|
||||||
@@ -353,6 +355,7 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
mVolumeHandling = in.readInt();
|
mVolumeHandling = in.readInt();
|
||||||
mVolumeMax = in.readInt();
|
mVolumeMax = in.readInt();
|
||||||
mVolume = in.readInt();
|
mVolume = in.readInt();
|
||||||
|
mAddress = in.readString();
|
||||||
mExtras = in.readBundle();
|
mExtras = in.readBundle();
|
||||||
mProviderId = in.readString();
|
mProviderId = in.readString();
|
||||||
}
|
}
|
||||||
@@ -483,6 +486,15 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
return mVolume;
|
return mVolume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the hardware address of the route if available.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getAddress() {
|
||||||
|
return mAddress;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Bundle getExtras() {
|
public Bundle getExtras() {
|
||||||
return mExtras == null ? null : new Bundle(mExtras);
|
return mExtras == null ? null : new Bundle(mExtras);
|
||||||
@@ -564,6 +576,7 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
&& (mVolumeHandling == other.mVolumeHandling)
|
&& (mVolumeHandling == other.mVolumeHandling)
|
||||||
&& (mVolumeMax == other.mVolumeMax)
|
&& (mVolumeMax == other.mVolumeMax)
|
||||||
&& (mVolume == other.mVolume)
|
&& (mVolume == other.mVolume)
|
||||||
|
&& Objects.equals(mAddress, other.mAddress)
|
||||||
&& Objects.equals(mProviderId, other.mProviderId);
|
&& Objects.equals(mProviderId, other.mProviderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,7 +585,7 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
// Note: mExtras is not included.
|
// Note: mExtras is not included.
|
||||||
return Objects.hash(mId, mName, mFeatures, mType, mIsSystem, mIconUri, mDescription,
|
return Objects.hash(mId, mName, mFeatures, mType, mIsSystem, mIconUri, mDescription,
|
||||||
mConnectionState, mClientPackageName, mVolumeHandling, mVolumeMax, mVolume,
|
mConnectionState, mClientPackageName, mVolumeHandling, mVolumeMax, mVolume,
|
||||||
mProviderId);
|
mAddress, mProviderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -614,6 +627,7 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
dest.writeInt(mVolumeHandling);
|
dest.writeInt(mVolumeHandling);
|
||||||
dest.writeInt(mVolumeMax);
|
dest.writeInt(mVolumeMax);
|
||||||
dest.writeInt(mVolume);
|
dest.writeInt(mVolume);
|
||||||
|
dest.writeString(mAddress);
|
||||||
dest.writeBundle(mExtras);
|
dest.writeBundle(mExtras);
|
||||||
dest.writeString(mProviderId);
|
dest.writeString(mProviderId);
|
||||||
}
|
}
|
||||||
@@ -637,6 +651,7 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
int mVolumeHandling = PLAYBACK_VOLUME_FIXED;
|
int mVolumeHandling = PLAYBACK_VOLUME_FIXED;
|
||||||
int mVolumeMax;
|
int mVolumeMax;
|
||||||
int mVolume;
|
int mVolume;
|
||||||
|
String mAddress;
|
||||||
Bundle mExtras;
|
Bundle mExtras;
|
||||||
String mProviderId;
|
String mProviderId;
|
||||||
|
|
||||||
@@ -669,24 +684,7 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
* @param routeInfo the existing instance to copy data from.
|
* @param routeInfo the existing instance to copy data from.
|
||||||
*/
|
*/
|
||||||
public Builder(@NonNull MediaRoute2Info routeInfo) {
|
public Builder(@NonNull MediaRoute2Info routeInfo) {
|
||||||
Objects.requireNonNull(routeInfo, "routeInfo must not be null");
|
this(routeInfo.mId, routeInfo);
|
||||||
|
|
||||||
mId = routeInfo.mId;
|
|
||||||
mName = routeInfo.mName;
|
|
||||||
mFeatures = new ArrayList<>(routeInfo.mFeatures);
|
|
||||||
mType = routeInfo.mType;
|
|
||||||
mIsSystem = routeInfo.mIsSystem;
|
|
||||||
mIconUri = routeInfo.mIconUri;
|
|
||||||
mDescription = routeInfo.mDescription;
|
|
||||||
mConnectionState = routeInfo.mConnectionState;
|
|
||||||
mClientPackageName = routeInfo.mClientPackageName;
|
|
||||||
mVolumeHandling = routeInfo.mVolumeHandling;
|
|
||||||
mVolumeMax = routeInfo.mVolumeMax;
|
|
||||||
mVolume = routeInfo.mVolume;
|
|
||||||
if (routeInfo.mExtras != null) {
|
|
||||||
mExtras = new Bundle(routeInfo.mExtras);
|
|
||||||
}
|
|
||||||
mProviderId = routeInfo.mProviderId;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -715,6 +713,7 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
mVolumeHandling = routeInfo.mVolumeHandling;
|
mVolumeHandling = routeInfo.mVolumeHandling;
|
||||||
mVolumeMax = routeInfo.mVolumeMax;
|
mVolumeMax = routeInfo.mVolumeMax;
|
||||||
mVolume = routeInfo.mVolume;
|
mVolume = routeInfo.mVolume;
|
||||||
|
mAddress = routeInfo.mAddress;
|
||||||
if (routeInfo.mExtras != null) {
|
if (routeInfo.mExtras != null) {
|
||||||
mExtras = new Bundle(routeInfo.mExtras);
|
mExtras = new Bundle(routeInfo.mExtras);
|
||||||
}
|
}
|
||||||
@@ -864,6 +863,16 @@ public final class MediaRoute2Info implements Parcelable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the hardware address of the route.
|
||||||
|
* @hide
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
public Builder setAddress(String address) {
|
||||||
|
mAddress = address;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a bundle of extras for the route.
|
* Sets a bundle of extras for the route.
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -430,7 +430,7 @@ public class InfoMediaManager extends MediaManager {
|
|||||||
case TYPE_HEARING_AID:
|
case TYPE_HEARING_AID:
|
||||||
case TYPE_BLUETOOTH_A2DP:
|
case TYPE_BLUETOOTH_A2DP:
|
||||||
final BluetoothDevice device =
|
final BluetoothDevice device =
|
||||||
BluetoothAdapter.getDefaultAdapter().getRemoteDevice(route.getOriginalId());
|
BluetoothAdapter.getDefaultAdapter().getRemoteDevice(route.getAddress());
|
||||||
final CachedBluetoothDevice cachedDevice =
|
final CachedBluetoothDevice cachedDevice =
|
||||||
mBluetoothManager.getCachedDeviceManager().findDevice(device);
|
mBluetoothManager.getCachedDeviceManager().findDevice(device);
|
||||||
if (cachedDevice != null) {
|
if (cachedDevice != null) {
|
||||||
|
|||||||
@@ -681,7 +681,7 @@ public class InfoMediaManagerTest {
|
|||||||
assertThat(mInfoMediaManager.mMediaDevices.get(0) instanceof PhoneMediaDevice).isTrue();
|
assertThat(mInfoMediaManager.mMediaDevices.get(0) instanceof PhoneMediaDevice).isTrue();
|
||||||
|
|
||||||
when(route2Info.getType()).thenReturn(TYPE_BLUETOOTH_A2DP);
|
when(route2Info.getType()).thenReturn(TYPE_BLUETOOTH_A2DP);
|
||||||
when(route2Info.getOriginalId()).thenReturn("00:00:00:00:00:00");
|
when(route2Info.getAddress()).thenReturn("00:00:00:00:00:00");
|
||||||
when(mLocalBluetoothManager.getCachedDeviceManager())
|
when(mLocalBluetoothManager.getCachedDeviceManager())
|
||||||
.thenReturn(cachedBluetoothDeviceManager);
|
.thenReturn(cachedBluetoothDeviceManager);
|
||||||
when(cachedBluetoothDeviceManager.findDevice(any(BluetoothDevice.class)))
|
when(cachedBluetoothDeviceManager.findDevice(any(BluetoothDevice.class)))
|
||||||
@@ -703,7 +703,7 @@ public class InfoMediaManagerTest {
|
|||||||
mock(CachedBluetoothDeviceManager.class);
|
mock(CachedBluetoothDeviceManager.class);
|
||||||
|
|
||||||
when(route2Info.getType()).thenReturn(TYPE_BLUETOOTH_A2DP);
|
when(route2Info.getType()).thenReturn(TYPE_BLUETOOTH_A2DP);
|
||||||
when(route2Info.getOriginalId()).thenReturn("00:00:00:00:00:00");
|
when(route2Info.getAddress()).thenReturn("00:00:00:00:00:00");
|
||||||
when(mLocalBluetoothManager.getCachedDeviceManager())
|
when(mLocalBluetoothManager.getCachedDeviceManager())
|
||||||
.thenReturn(cachedBluetoothDeviceManager);
|
.thenReturn(cachedBluetoothDeviceManager);
|
||||||
when(cachedBluetoothDeviceManager.findDevice(any(BluetoothDevice.class)))
|
when(cachedBluetoothDeviceManager.findDevice(any(BluetoothDevice.class)))
|
||||||
|
|||||||
@@ -247,6 +247,7 @@ class BluetoothRouteProvider {
|
|||||||
.setType(type)
|
.setType(type)
|
||||||
.setVolumeHandling(MediaRoute2Info.PLAYBACK_VOLUME_VARIABLE)
|
.setVolumeHandling(MediaRoute2Info.PLAYBACK_VOLUME_VARIABLE)
|
||||||
.setVolumeMax(mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC))
|
.setVolumeMax(mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC))
|
||||||
|
.setAddress(device.getAddress())
|
||||||
.build();
|
.build();
|
||||||
return newBtRoute;
|
return newBtRoute;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user