Example #1
0
 public static void enableDefaultRouting(Context context) {
   AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
   am.setSpeakerphoneOn(false);
   am.setBluetoothScoOn(false);
   Log.d(TAG, "Set default audio routing");
 }
Example #2
0
 public static void enableBluetoothRouting(Context context) {
   AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
   am.startBluetoothSco();
   am.setBluetoothScoOn(true);
 }
  @SuppressWarnings("deprecation")
  @TestTargets({
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "setBluetoothA2dpOn",
        args = {boolean.class}),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "setBluetoothScoOn",
        args = {boolean.class}),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "getRouting",
        args = {int.class}),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "isBluetoothA2dpOn",
        args = {}),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "isBluetoothScoOn",
        args = {}),
    @TestTargetNew(
        level = TestLevel.NOT_FEASIBLE,
        method = "setRouting",
        args = {int.class, int.class, int.class}),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "setSpeakerphoneOn",
        args = {boolean.class}),
    @TestTargetNew(
        level = TestLevel.COMPLETE,
        method = "isSpeakerphoneOn",
        args = {})
  })
  @ToBeFixed(
      bug = "1713090",
      explanation =
          "setRouting() has not only been deprecated, but is no" + " longer having any effect.")
  public void testRouting() throws Exception {
    // setBluetoothA2dpOn is a no-op, and getRouting should always return -1
    // AudioManager.MODE_CURRENT
    boolean oldA2DP = mAudioManager.isBluetoothA2dpOn();
    mAudioManager.setBluetoothA2dpOn(true);
    assertEquals(oldA2DP, mAudioManager.isBluetoothA2dpOn());
    mAudioManager.setBluetoothA2dpOn(false);
    assertEquals(oldA2DP, mAudioManager.isBluetoothA2dpOn());

    assertEquals(AudioManager.MODE_CURRENT, mAudioManager.getRouting(MODE_RINGTONE));
    assertEquals(AudioManager.MODE_CURRENT, mAudioManager.getRouting(MODE_NORMAL));
    assertEquals(AudioManager.MODE_CURRENT, mAudioManager.getRouting(MODE_IN_CALL));

    mAudioManager.setBluetoothScoOn(true);
    assertTrue(mAudioManager.isBluetoothScoOn());
    assertEquals(AudioManager.MODE_CURRENT, mAudioManager.getRouting(MODE_RINGTONE));
    assertEquals(AudioManager.MODE_CURRENT, mAudioManager.getRouting(MODE_NORMAL));
    assertEquals(AudioManager.MODE_CURRENT, mAudioManager.getRouting(MODE_IN_CALL));

    mAudioManager.setBluetoothScoOn(false);
    assertFalse(mAudioManager.isBluetoothScoOn());
    assertEquals(AudioManager.MODE_CURRENT, mAudioManager.getRouting(MODE_RINGTONE));
    assertEquals(AudioManager.MODE_CURRENT, mAudioManager.getRouting(MODE_NORMAL));
    assertEquals(AudioManager.MODE_CURRENT, mAudioManager.getRouting(MODE_IN_CALL));

    mAudioManager.setSpeakerphoneOn(true);
    assertTrue(mAudioManager.isSpeakerphoneOn());
    assertEquals(AudioManager.MODE_CURRENT, mAudioManager.getRouting(MODE_IN_CALL));
    mAudioManager.setSpeakerphoneOn(false);
    assertFalse(mAudioManager.isSpeakerphoneOn());
    assertEquals(AudioManager.MODE_CURRENT, mAudioManager.getRouting(MODE_IN_CALL));
  }