diff options
author | Brandon Maxwell <maxwelb@google.com> | 2016-03-10 17:00:57 -0800 |
---|---|---|
committer | Brandon Maxwell <maxwelb@google.com> | 2016-03-10 17:39:14 -0800 |
commit | 5558f89b14af81d38364afe9e51a56f8557fd282 (patch) | |
tree | 0774e3d2abcf9a00d95f3d0ae3735a7ca094eb5f /InCallUI | |
parent | bb293bfd56125febe42ddef5cdcb630abf1b12c9 (diff) |
Removing unneed bluetooth code
+ By playing through AudioManager.STREAM_VOICE_CALL, routing audio to
bluetooth is handled properly for us.
+ This change removes the code that was preparing to manually play
the call waiting tone through bluetooth.
+ Small fix ups for javadoc
Bug: 26932998
Change-Id: Ib5f872c72cdfa44ab0bc2ff5d7e41645aba813ff
Diffstat (limited to 'InCallUI')
3 files changed, 14 insertions, 37 deletions
diff --git a/InCallUI/src/com/android/incallui/StatusBarNotifier.java b/InCallUI/src/com/android/incallui/StatusBarNotifier.java index 946e0ebd0..173fe42ec 100644 --- a/InCallUI/src/com/android/incallui/StatusBarNotifier.java +++ b/InCallUI/src/com/android/incallui/StatusBarNotifier.java @@ -100,10 +100,7 @@ public class StatusBarNotifier implements InCallPresenter.InCallStateListener, mNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); mDialerRingtoneManager = new DialerRingtoneManager( - new InCallTonePlayer( - AudioModeProvider.getInstance(), - new ToneGeneratorFactory(), - new PausableExecutorImpl()), + new InCallTonePlayer(new ToneGeneratorFactory(), new PausableExecutorImpl()), CallList.getInstance()); mCurrentNotification = NOTIFICATION_NONE; } diff --git a/InCallUI/src/com/android/incallui/ringtone/InCallTonePlayer.java b/InCallUI/src/com/android/incallui/ringtone/InCallTonePlayer.java index d930a92fd..3a8b03d91 100644 --- a/InCallUI/src/com/android/incallui/ringtone/InCallTonePlayer.java +++ b/InCallUI/src/com/android/incallui/ringtone/InCallTonePlayer.java @@ -21,20 +21,14 @@ import com.google.common.base.Preconditions; import android.media.AudioManager; import android.media.ToneGenerator; -import android.provider.MediaStore.Audio; import android.support.annotation.Nullable; -import android.telecom.CallAudioState; -import com.android.contacts.common.testing.NeededForTesting; -import com.android.incallui.AudioModeProvider; import com.android.incallui.Log; import com.android.incallui.async.PausableExecutor; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; -import javax.annotation.concurrent.NotThreadSafe; - /** * Class responsible for playing in-call related tones in a background thread. This class only * allows one tone to be played at a time. @@ -45,7 +39,6 @@ public class InCallTonePlayer { public static final int VOLUME_RELATIVE_HIGH_PRIORITY = 80; - private final AudioModeProvider mAudioModeProvider; private final ToneGeneratorFactory mToneGeneratorFactory; private final PausableExecutor mExecutor; private @Nullable CountDownLatch mNumPlayingTones; @@ -53,23 +46,19 @@ public class InCallTonePlayer { /** * Creates a new InCallTonePlayer. * - * @param audioModeProvider the {@link AudioModeProvider} used to determine through which stream - * to play tones. * @param toneGeneratorFactory the {@link ToneGeneratorFactory} used to create * {@link ToneGenerator}s. * @param executor the {@link PausableExecutor} used to play tones in a background thread. * @throws NullPointerException if audioModeProvider, toneGeneratorFactory, or executor are * {@code null}. */ - public InCallTonePlayer(AudioModeProvider audioModeProvider, - ToneGeneratorFactory toneGeneratorFactory, PausableExecutor executor) { - mAudioModeProvider = Preconditions.checkNotNull(audioModeProvider); + public InCallTonePlayer(ToneGeneratorFactory toneGeneratorFactory, PausableExecutor executor) { mToneGeneratorFactory = Preconditions.checkNotNull(toneGeneratorFactory); mExecutor = Preconditions.checkNotNull(executor); } /** - * @return {@code true} if a tone is currently playing, {@code false} otherwise + * @return {@code true} if a tone is currently playing, {@code false} otherwise. */ public boolean isPlayingTone() { return mNumPlayingTones != null && mNumPlayingTones.getCount() > 0; @@ -79,8 +68,8 @@ public class InCallTonePlayer { * Plays the given tone in a background thread. * * @param tone the tone to play. - * @throws IllegalStateException if a tone is already playing - * @throws IllegalArgumentException if the tone is invalid + * @throws IllegalStateException if a tone is already playing. + * @throws IllegalArgumentException if the tone is invalid. */ public void play(int tone) { if (isPlayingTone()) { @@ -97,26 +86,24 @@ public class InCallTonePlayer { } private ToneGeneratorInfo getToneGeneratorInfo(int tone) { - int stream = getPlaybackStream(); switch (tone) { case TONE_CALL_WAITING: + /* + * Call waiting tones play until they're stopped either by the user accepting or + * declining the call so the tone length is set at what's effectively forever. The + * tone is played at a high priority volume and through STREAM_VOICE_CALL since it's + * call related and using that stream will route it through bluetooth devices + * appropriately. + */ return new ToneGeneratorInfo(ToneGenerator.TONE_SUP_CALL_WAITING, VOLUME_RELATIVE_HIGH_PRIORITY, Integer.MAX_VALUE, - stream); + AudioManager.STREAM_VOICE_CALL); default: throw new IllegalArgumentException("Bad tone: " + tone); } } - private int getPlaybackStream() { - if (mAudioModeProvider.getAudioMode() == CallAudioState.ROUTE_BLUETOOTH) { - // TODO (maxwelb): b/26932998 play through bluetooth - // return AudioManager.STREAM_BLUETOOTH_SCO; - } - return AudioManager.STREAM_VOICE_CALL; - } - private void playOnBackgroundThread(ToneGeneratorInfo info) { ToneGenerator toneGenerator = null; try { diff --git a/InCallUI/tests/src/com/android/incallui/ringtone/InCallTonePlayerTest.java b/InCallUI/tests/src/com/android/incallui/ringtone/InCallTonePlayerTest.java index 59611f701..bde5c50e4 100644 --- a/InCallUI/tests/src/com/android/incallui/ringtone/InCallTonePlayerTest.java +++ b/InCallUI/tests/src/com/android/incallui/ringtone/InCallTonePlayerTest.java @@ -21,7 +21,6 @@ import android.media.ToneGenerator; import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; -import com.android.incallui.AudioModeProvider; import com.android.incallui.async.PausableExecutor; import com.android.incallui.async.SingleProdThreadExecutor; @@ -32,7 +31,6 @@ import org.mockito.MockitoAnnotations; @SmallTest public class InCallTonePlayerTest extends AndroidTestCase { - @Mock private AudioModeProvider mAudioModeProvider; @Mock private ToneGeneratorFactory mToneGeneratorFactory; @Mock private ToneGenerator mToneGenerator; private InCallTonePlayer mInCallTonePlayer; @@ -52,8 +50,7 @@ public class InCallTonePlayerTest extends AndroidTestCase { Mockito.when(mToneGeneratorFactory.newInCallToneGenerator(Mockito.anyInt(), Mockito.anyInt())).thenReturn(mToneGenerator); mExecutor = new SingleProdThreadExecutor(); - mInCallTonePlayer = new InCallTonePlayer(mAudioModeProvider, mToneGeneratorFactory, - mExecutor); + mInCallTonePlayer = new InCallTonePlayer(mToneGeneratorFactory, mExecutor); } @Override @@ -92,10 +89,6 @@ public class InCallTonePlayerTest extends AndroidTestCase { } catch (IllegalStateException e) {} } - public void testPlay_BlueToothStream() { - // TODO (maxwelb): b/26932998 play through bluetooth - } - public void testPlay_VoiceCallStream() throws InterruptedException { mInCallTonePlayer.play(InCallTonePlayer.TONE_CALL_WAITING); mExecutor.awaitMilestoneForTesting(); |