Пример #1
0
 @SuppressWarnings("deprecation")
 public static void getAudioRoute(AudioManager am) {
   if (am.isBluetoothA2dpOn()) {
     am.setBluetoothA2dpOn(true);
   } else if (am.isSpeakerphoneOn()) {
     am.setSpeakerphoneOn(true);
   } else if (am.isWiredHeadsetOn()) {
     am.setWiredHeadsetOn(true);
   }
 }
Пример #2
0
  @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));
  }