title: AudioManager.startBluetoothSco() crashes on Android Lollipop
body: <p>When making a call to <a href="http://developer.android.com/reference/android/media/AudioManager.html#startBluetoothSco()" rel="noreferrer">AudioManager.startBluetoothSCO()</a> while targeting API level 18 or above in the Manifest, the documentation states that a raw audio connection is established, and if targeting API 17 or below a virtual voice call is used. </p>
  
  <p>Up until API level 20 (Android L Preview) this worked fine, targeting any API. However, when using the latest Android Lollipop build LPX13D and targeting API level 18 or above I get a crash with the following stack trace:</p>
  
  <p>E/AndroidRuntime(31705): Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.bluetooth.BluetoothDevice.getAddress()' on a null object reference
  E/AndroidRuntime(31705):    at android.os.Parcel.readException(Parcel.java:1546)
  E/AndroidRuntime(31705):    at android.os.Parcel.readException(Parcel.java:1493)
  E/AndroidRuntime(31705):    at android.media.IAudioService$Stub$Proxy.startBluetoothSco(IAudioService.java:1587)
  E/AndroidRuntime(31705):    at android.media.AudioManager.startBluetoothSco(AudioManager.java:1468)</p>
  
  <p>If I target API level 17 or below on Android Lollipop everything works as expected.</p>
  
  <p>I believe the source of the problem lies in a change to Android's audio code that happened in API level 21 in the file AudioService.java line 2392:</p>
  
  <pre><code>public void startBluetoothSco(IBinder cb, int targetSdkVersion) {
      int scoAudioMode =
              (targetSdkVersion &lt; Build.VERSION_CODES.JELLY_BEAN_MR2) ?
                      SCO_MODE_VIRTUAL_CALL : SCO_MODE_UNDEFINED;
      startBluetoothScoInt(cb, scoAudioMode);
  }
  </code></pre>
  
  <p>It looks like SCO_MODE_UNDEFINED should instead be SCO_MODE_RAW. If you look through the file you can see that SCO_MODE_RAW is checked for in a few places, but is never actually passed in anywhere.</p>
  
  <p>Is anybody else experiencing this crash? Does anyone know of a better fix than downgrading the target SDK to 17? If not, could you please star the <a href="https://code.google.com/p/android/issues/detail?id=78404" rel="noreferrer">bug report</a> I filed with Google to increase the chance that it will be looked at :-)</p>