From f3e130ecc31c806b3466d48551f7a40a7b676b82 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Wed, 13 May 2015 15:16:45 -0700 Subject: Rename AudioState to CallAudioState Deprecate AudioState class and make methods @SystemApi where necessary to minimize impact to SystemApi Replace usages of AudioState inside Telecom sub-systems Fire both onCallAudioStateChanged and onAudioStateChanged callbacks for backward compatibility Support both setAudioState and setCallAudioState for all classes Bug: 21040387 Bug: 21088300 Change-Id: I3ec7b3afdaa344c6d639d1c421f1842d67f7d0f7 --- .../com/android/incallui/AudioModeProvider.java | 10 +++--- .../com/android/incallui/CallButtonFragment.java | 42 +++++++++++----------- .../com/android/incallui/CallButtonPresenter.java | 12 +++---- .../com/android/incallui/InCallServiceImpl.java | 3 +- .../src/com/android/incallui/ProximitySensor.java | 10 +++--- .../com/android/incallui/VideoCallPresenter.java | 6 ++-- 6 files changed, 42 insertions(+), 41 deletions(-) (limited to 'InCallUI/src/com/android/incallui') diff --git a/InCallUI/src/com/android/incallui/AudioModeProvider.java b/InCallUI/src/com/android/incallui/AudioModeProvider.java index dab35d6cf..e7ffecca7 100644 --- a/InCallUI/src/com/android/incallui/AudioModeProvider.java +++ b/InCallUI/src/com/android/incallui/AudioModeProvider.java @@ -16,7 +16,7 @@ package com.android.incallui; -import android.telecom.AudioState; +import android.telecom.CallAudioState; import com.google.common.collect.Lists; @@ -30,17 +30,17 @@ public class AudioModeProvider { static final int AUDIO_MODE_INVALID = 0; private static AudioModeProvider sAudioModeProvider = new AudioModeProvider(); - private int mAudioMode = AudioState.ROUTE_EARPIECE; + private int mAudioMode = CallAudioState.ROUTE_EARPIECE; private boolean mMuted = false; - private int mSupportedModes = AudioState.ROUTE_EARPIECE | AudioState.ROUTE_BLUETOOTH | - AudioState.ROUTE_WIRED_HEADSET | AudioState.ROUTE_SPEAKER; + private int mSupportedModes = CallAudioState.ROUTE_EARPIECE | CallAudioState.ROUTE_BLUETOOTH | + CallAudioState.ROUTE_WIRED_HEADSET | CallAudioState.ROUTE_SPEAKER; private final List mListeners = Lists.newArrayList(); public static AudioModeProvider getInstance() { return sAudioModeProvider; } - public void onAudioStateChanged(AudioState audioState) { + public void onAudioStateChanged(CallAudioState audioState) { onAudioModeChange(audioState.getRoute(), audioState.isMuted()); onSupportedAudioModeChange(audioState.getSupportedRouteMask()); } diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java index 9def35694..0987cacc8 100644 --- a/InCallUI/src/com/android/incallui/CallButtonFragment.java +++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java @@ -27,7 +27,7 @@ import android.graphics.drawable.GradientDrawable; import android.graphics.drawable.RippleDrawable; import android.graphics.drawable.StateListDrawable; import android.os.Bundle; -import android.telecom.AudioState; +import android.telecom.CallAudioState; import android.util.SparseIntArray; import android.view.ContextThemeWrapper; import android.view.HapticFeedbackConstants; @@ -514,20 +514,20 @@ public class CallButtonFragment Log.d(this, " id: " + item.getItemId()); Log.d(this, " title: '" + item.getTitle() + "'"); - int mode = AudioState.ROUTE_WIRED_OR_EARPIECE; + int mode = CallAudioState.ROUTE_WIRED_OR_EARPIECE; switch (item.getItemId()) { case R.id.audio_mode_speaker: - mode = AudioState.ROUTE_SPEAKER; + mode = CallAudioState.ROUTE_SPEAKER; break; case R.id.audio_mode_earpiece: case R.id.audio_mode_wired_headset: - // InCallAudioState.ROUTE_EARPIECE means either the handset earpiece, + // InCallCallAudioState.ROUTE_EARPIECE means either the handset earpiece, // or the wired headset (if connected.) - mode = AudioState.ROUTE_WIRED_OR_EARPIECE; + mode = CallAudioState.ROUTE_WIRED_OR_EARPIECE; break; case R.id.audio_mode_bluetooth: - mode = AudioState.ROUTE_BLUETOOTH; + mode = CallAudioState.ROUTE_BLUETOOTH; break; default: Log.e(this, "onMenuItemClick: unexpected View ID " + item.getItemId() @@ -557,9 +557,9 @@ public class CallButtonFragment */ private void onAudioButtonClicked() { Log.d(this, "onAudioButtonClicked: " + - AudioState.audioRouteToString(getPresenter().getSupportedAudio())); + CallAudioState.audioRouteToString(getPresenter().getSupportedAudio())); - if (isSupported(AudioState.ROUTE_BLUETOOTH)) { + if (isSupported(CallAudioState.ROUTE_BLUETOOTH)) { showAudioModePopup(); } else { getPresenter().toggleSpeakerphone(); @@ -594,8 +594,8 @@ public class CallButtonFragment * are visible based on the supported audio formats. */ private void updateAudioButtons(int supportedModes) { - final boolean bluetoothSupported = isSupported(AudioState.ROUTE_BLUETOOTH); - final boolean speakerSupported = isSupported(AudioState.ROUTE_SPEAKER); + final boolean bluetoothSupported = isSupported(CallAudioState.ROUTE_BLUETOOTH); + final boolean speakerSupported = isSupported(CallAudioState.ROUTE_SPEAKER); boolean audioButtonEnabled = false; boolean audioButtonChecked = false; @@ -615,9 +615,9 @@ public class CallButtonFragment showMoreIndicator = true; // Update desired layers: - if (isAudio(AudioState.ROUTE_BLUETOOTH)) { + if (isAudio(CallAudioState.ROUTE_BLUETOOTH)) { showBluetoothIcon = true; - } else if (isAudio(AudioState.ROUTE_SPEAKER)) { + } else if (isAudio(CallAudioState.ROUTE_SPEAKER)) { showSpeakerphoneIcon = true; } else { showHandsetIcon = true; @@ -636,7 +636,7 @@ public class CallButtonFragment // The audio button *is* a toggle in this state, and indicated the // current state of the speakerphone. - audioButtonChecked = isAudio(AudioState.ROUTE_SPEAKER); + audioButtonChecked = isAudio(CallAudioState.ROUTE_SPEAKER); mAudioButton.setSelected(audioButtonChecked); // update desired layers: @@ -697,20 +697,20 @@ public class CallButtonFragment // If bluetooth is not supported, the audio buttion will toggle, so use the label "speaker". // Otherwise, use the label of the currently selected audio mode. - if (!isSupported(AudioState.ROUTE_BLUETOOTH)) { + if (!isSupported(CallAudioState.ROUTE_BLUETOOTH)) { stringId = R.string.audio_mode_speaker; } else { switch (mode) { - case AudioState.ROUTE_EARPIECE: + case CallAudioState.ROUTE_EARPIECE: stringId = R.string.audio_mode_earpiece; break; - case AudioState.ROUTE_BLUETOOTH: + case CallAudioState.ROUTE_BLUETOOTH: stringId = R.string.audio_mode_bluetooth; break; - case AudioState.ROUTE_WIRED_HEADSET: + case CallAudioState.ROUTE_WIRED_HEADSET: stringId = R.string.audio_mode_wired_headset; break; - case AudioState.ROUTE_SPEAKER: + case CallAudioState.ROUTE_SPEAKER: stringId = R.string.audio_mode_speaker; break; } @@ -740,7 +740,7 @@ public class CallButtonFragment // See comments below for the exact logic. final MenuItem speakerItem = menu.findItem(R.id.audio_mode_speaker); - speakerItem.setEnabled(isSupported(AudioState.ROUTE_SPEAKER)); + speakerItem.setEnabled(isSupported(CallAudioState.ROUTE_SPEAKER)); // TODO: Show speakerItem as initially "selected" if // speaker is on. @@ -749,7 +749,7 @@ public class CallButtonFragment final MenuItem earpieceItem = menu.findItem(R.id.audio_mode_earpiece); final MenuItem wiredHeadsetItem = menu.findItem(R.id.audio_mode_wired_headset); - final boolean usingHeadset = isSupported(AudioState.ROUTE_WIRED_HEADSET); + final boolean usingHeadset = isSupported(CallAudioState.ROUTE_WIRED_HEADSET); earpieceItem.setVisible(!usingHeadset); earpieceItem.setEnabled(!usingHeadset); wiredHeadsetItem.setVisible(usingHeadset); @@ -759,7 +759,7 @@ public class CallButtonFragment // bluetoothIndicatorOn are both false. final MenuItem bluetoothItem = menu.findItem(R.id.audio_mode_bluetooth); - bluetoothItem.setEnabled(isSupported(AudioState.ROUTE_BLUETOOTH)); + bluetoothItem.setEnabled(isSupported(CallAudioState.ROUTE_BLUETOOTH)); // TODO: Show bluetoothItem as initially "selected" if // bluetoothIndicatorOn is true. diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java index d3614789f..4fc60cac8 100644 --- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java +++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java @@ -20,7 +20,7 @@ import static com.android.incallui.CallButtonFragment.Buttons.*; import android.content.Context; import android.os.Bundle; -import android.telecom.AudioState; +import android.telecom.CallAudioState; import android.telecom.InCallService.VideoCall; import android.telecom.VideoProfile; @@ -176,7 +176,7 @@ public class CallButtonPresenter extends Presenter