Loading media/java/android/media/MediaRouter.java +19 −18 Original line number Original line Diff line number Diff line Loading @@ -43,8 +43,8 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.ServiceManager; import android.os.UserHandle; import android.os.UserHandle; import android.text.TextUtils; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import android.util.Log; import android.util.SparseIntArray; import android.view.Display; import android.view.Display; import android.view.DisplayAddress; import android.view.DisplayAddress; Loading @@ -55,7 +55,6 @@ import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.ArrayList; import java.util.HashMap; import java.util.HashMap; import java.util.List; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Objects; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList; Loading Loading @@ -99,6 +98,7 @@ public class MediaRouter { RouteInfo mDefaultAudioVideo; RouteInfo mDefaultAudioVideo; RouteInfo mBluetoothA2dpRoute; RouteInfo mBluetoothA2dpRoute; boolean mIsBluetoothA2dpOn; RouteInfo mSelectedRoute; RouteInfo mSelectedRoute; Loading @@ -113,11 +113,16 @@ public class MediaRouter { IMediaRouterClient mClient; IMediaRouterClient mClient; MediaRouterClientState mClientState; MediaRouterClientState mClientState; Map<Integer, Integer> mStreamVolume = new ArrayMap<>(); SparseIntArray mStreamVolume = new SparseIntArray(); final IAudioRoutesObserver.Stub mAudioRoutesObserver = new IAudioRoutesObserver.Stub() { final IAudioRoutesObserver.Stub mAudioRoutesObserver = new IAudioRoutesObserver.Stub() { @Override @Override public void dispatchAudioRoutesChanged(final AudioRoutesInfo newRoutes) { public void dispatchAudioRoutesChanged(final AudioRoutesInfo newRoutes) { try { mIsBluetoothA2dpOn = mAudioService.isBluetoothA2dpOn(); } catch (RemoteException e) { Log.e(TAG, "Error querying Bluetooth A2DP state", e); } mHandler.post(new Runnable() { mHandler.post(new Runnable() { @Override public void run() { @Override public void run() { updateAudioRoutes(newRoutes); updateAudioRoutes(newRoutes); Loading Loading @@ -267,23 +272,23 @@ public class MediaRouter { } } int getStreamVolume(int streamType) { int getStreamVolume(int streamType) { if (!mStreamVolume.containsKey(streamType)) { int idx = mStreamVolume.indexOfKey(streamType); if (idx < 0) { int volume = 0; try { try { mStreamVolume.put(streamType, mAudioService.getStreamVolume(streamType)); volume = mAudioService.getStreamVolume(streamType); mStreamVolume.put(streamType, volume); } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, "Error getting local stream volume", e); Log.e(TAG, "Error getting local stream volume", e); } finally { return volume; } } } } return mStreamVolume.get(streamType); return mStreamVolume.valueAt(idx); } } boolean isBluetoothA2dpOn() { boolean isBluetoothA2dpOn() { try { return mBluetoothA2dpRoute != null && mIsBluetoothA2dpOn; return mBluetoothA2dpRoute != null && mAudioService.isBluetoothA2dpOn(); } catch (RemoteException e) { Log.e(TAG, "Error querying Bluetooth A2DP state", e); return false; } } } void updateDiscoveryRequest() { void updateDiscoveryRequest() { Loading Loading @@ -1444,12 +1449,8 @@ public class MediaRouter { selectedRoute == sStatic.mDefaultAudioVideo) { selectedRoute == sStatic.mDefaultAudioVideo) { dispatchRouteVolumeChanged(selectedRoute); dispatchRouteVolumeChanged(selectedRoute); } else if (sStatic.mBluetoothA2dpRoute != null) { } else if (sStatic.mBluetoothA2dpRoute != null) { try { dispatchRouteVolumeChanged(sStatic.mIsBluetoothA2dpOn dispatchRouteVolumeChanged(sStatic.mAudioService.isBluetoothA2dpOn() ? ? sStatic.mBluetoothA2dpRoute : sStatic.mDefaultAudioVideo); sStatic.mBluetoothA2dpRoute : sStatic.mDefaultAudioVideo); } catch (RemoteException e) { Log.e(TAG, "Error checking Bluetooth A2DP state to report volume change", e); } } else { } else { dispatchRouteVolumeChanged(sStatic.mDefaultAudioVideo); dispatchRouteVolumeChanged(sStatic.mDefaultAudioVideo); } } Loading Loading
media/java/android/media/MediaRouter.java +19 −18 Original line number Original line Diff line number Diff line Loading @@ -43,8 +43,8 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.ServiceManager; import android.os.UserHandle; import android.os.UserHandle; import android.text.TextUtils; import android.text.TextUtils; import android.util.ArrayMap; import android.util.Log; import android.util.Log; import android.util.SparseIntArray; import android.view.Display; import android.view.Display; import android.view.DisplayAddress; import android.view.DisplayAddress; Loading @@ -55,7 +55,6 @@ import java.lang.annotation.RetentionPolicy; import java.util.ArrayList; import java.util.ArrayList; import java.util.HashMap; import java.util.HashMap; import java.util.List; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Objects; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList; Loading Loading @@ -99,6 +98,7 @@ public class MediaRouter { RouteInfo mDefaultAudioVideo; RouteInfo mDefaultAudioVideo; RouteInfo mBluetoothA2dpRoute; RouteInfo mBluetoothA2dpRoute; boolean mIsBluetoothA2dpOn; RouteInfo mSelectedRoute; RouteInfo mSelectedRoute; Loading @@ -113,11 +113,16 @@ public class MediaRouter { IMediaRouterClient mClient; IMediaRouterClient mClient; MediaRouterClientState mClientState; MediaRouterClientState mClientState; Map<Integer, Integer> mStreamVolume = new ArrayMap<>(); SparseIntArray mStreamVolume = new SparseIntArray(); final IAudioRoutesObserver.Stub mAudioRoutesObserver = new IAudioRoutesObserver.Stub() { final IAudioRoutesObserver.Stub mAudioRoutesObserver = new IAudioRoutesObserver.Stub() { @Override @Override public void dispatchAudioRoutesChanged(final AudioRoutesInfo newRoutes) { public void dispatchAudioRoutesChanged(final AudioRoutesInfo newRoutes) { try { mIsBluetoothA2dpOn = mAudioService.isBluetoothA2dpOn(); } catch (RemoteException e) { Log.e(TAG, "Error querying Bluetooth A2DP state", e); } mHandler.post(new Runnable() { mHandler.post(new Runnable() { @Override public void run() { @Override public void run() { updateAudioRoutes(newRoutes); updateAudioRoutes(newRoutes); Loading Loading @@ -267,23 +272,23 @@ public class MediaRouter { } } int getStreamVolume(int streamType) { int getStreamVolume(int streamType) { if (!mStreamVolume.containsKey(streamType)) { int idx = mStreamVolume.indexOfKey(streamType); if (idx < 0) { int volume = 0; try { try { mStreamVolume.put(streamType, mAudioService.getStreamVolume(streamType)); volume = mAudioService.getStreamVolume(streamType); mStreamVolume.put(streamType, volume); } catch (RemoteException e) { } catch (RemoteException e) { Log.e(TAG, "Error getting local stream volume", e); Log.e(TAG, "Error getting local stream volume", e); } finally { return volume; } } } } return mStreamVolume.get(streamType); return mStreamVolume.valueAt(idx); } } boolean isBluetoothA2dpOn() { boolean isBluetoothA2dpOn() { try { return mBluetoothA2dpRoute != null && mIsBluetoothA2dpOn; return mBluetoothA2dpRoute != null && mAudioService.isBluetoothA2dpOn(); } catch (RemoteException e) { Log.e(TAG, "Error querying Bluetooth A2DP state", e); return false; } } } void updateDiscoveryRequest() { void updateDiscoveryRequest() { Loading Loading @@ -1444,12 +1449,8 @@ public class MediaRouter { selectedRoute == sStatic.mDefaultAudioVideo) { selectedRoute == sStatic.mDefaultAudioVideo) { dispatchRouteVolumeChanged(selectedRoute); dispatchRouteVolumeChanged(selectedRoute); } else if (sStatic.mBluetoothA2dpRoute != null) { } else if (sStatic.mBluetoothA2dpRoute != null) { try { dispatchRouteVolumeChanged(sStatic.mIsBluetoothA2dpOn dispatchRouteVolumeChanged(sStatic.mAudioService.isBluetoothA2dpOn() ? ? sStatic.mBluetoothA2dpRoute : sStatic.mDefaultAudioVideo); sStatic.mBluetoothA2dpRoute : sStatic.mDefaultAudioVideo); } catch (RemoteException e) { Log.e(TAG, "Error checking Bluetooth A2DP state to report volume change", e); } } else { } else { dispatchRouteVolumeChanged(sStatic.mDefaultAudioVideo); dispatchRouteVolumeChanged(sStatic.mDefaultAudioVideo); } } Loading