Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4be6485 authored by Sailesh Nepal's avatar Sailesh Nepal
Browse files

Remove CallAudioStateCompat

Now that we're no longer backwards compatible with Lollipop we don't
need CallAudioStateCompat. See ag/870962 for more info.

Bug: 26676586
Change-Id: I7c754d89a6c9e13bf5a004b7c5b15b88b9aff9ad
parent 68d86c65
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -16,9 +16,9 @@

package com.android.incallui;

import com.google.common.collect.Lists;
import android.telecom.CallAudioState;

import com.android.dialer.compat.CallAudioStateCompat;
import com.google.common.collect.Lists;

import java.util.List;

@@ -30,11 +30,11 @@ public class AudioModeProvider {
    static final int AUDIO_MODE_INVALID = 0;

    private static AudioModeProvider sAudioModeProvider = new AudioModeProvider();
    private int mAudioMode = CallAudioStateCompat.ROUTE_EARPIECE;
    private int mAudioMode = CallAudioState.ROUTE_EARPIECE;
    private boolean mMuted = false;
    private int mSupportedModes = CallAudioStateCompat.ROUTE_EARPIECE
            | CallAudioStateCompat.ROUTE_BLUETOOTH | CallAudioStateCompat.ROUTE_WIRED_HEADSET
            | CallAudioStateCompat.ROUTE_SPEAKER;
    private int mSupportedModes = CallAudioState.ROUTE_EARPIECE
            | CallAudioState.ROUTE_BLUETOOTH | CallAudioState.ROUTE_WIRED_HEADSET
            | CallAudioState.ROUTE_SPEAKER;
    private final List<AudioModeListener> mListeners = Lists.newArrayList();

    public static AudioModeProvider getInstance() {
+20 −20
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.RippleDrawable;
import android.graphics.drawable.StateListDrawable;
import android.os.Bundle;
import android.telecom.CallAudioState;
import android.util.SparseIntArray;
import android.view.ContextThemeWrapper;
import android.view.HapticFeedbackConstants;
@@ -55,7 +56,6 @@ import android.widget.PopupMenu.OnMenuItemClickListener;

import com.android.contacts.common.util.MaterialColorMapUtils.MaterialPalette;
import com.android.dialer.R;
import com.android.dialer.compat.CallAudioStateCompat;

/**
 * Fragment for call control buttons
@@ -523,17 +523,17 @@ public class CallButtonFragment
        Log.d(this, "  id: " + item.getItemId());
        Log.d(this, "  title: '" + item.getTitle() + "'");

        int mode = CallAudioStateCompat.ROUTE_WIRED_OR_EARPIECE;
        int mode = CallAudioState.ROUTE_WIRED_OR_EARPIECE;
        int resId = item.getItemId();

        if (resId == R.id.audio_mode_speaker) {
            mode = CallAudioStateCompat.ROUTE_SPEAKER;
            mode = CallAudioState.ROUTE_SPEAKER;
        } else if (resId == R.id.audio_mode_earpiece || resId == R.id.audio_mode_wired_headset) {
            // InCallCallAudioState.ROUTE_EARPIECE means either the handset earpiece,
            // or the wired headset (if connected.)
            mode = CallAudioStateCompat.ROUTE_WIRED_OR_EARPIECE;
            mode = CallAudioState.ROUTE_WIRED_OR_EARPIECE;
        } else if (resId == R.id.audio_mode_bluetooth) {
            mode = CallAudioStateCompat.ROUTE_BLUETOOTH;
            mode = CallAudioState.ROUTE_BLUETOOTH;
        } else {
            Log.e(this, "onMenuItemClick:  unexpected View ID " + item.getItemId()
                    + " (MenuItem = '" + item + "')");
@@ -561,9 +561,9 @@ public class CallButtonFragment
     */
    private void onAudioButtonClicked() {
        Log.d(this, "onAudioButtonClicked: " +
                CallAudioStateCompat.audioRouteToString(getPresenter().getSupportedAudio()));
                CallAudioState.audioRouteToString(getPresenter().getSupportedAudio()));

        if (isSupported(CallAudioStateCompat.ROUTE_BLUETOOTH)) {
        if (isSupported(CallAudioState.ROUTE_BLUETOOTH)) {
            showAudioModePopup();
        } else {
            getPresenter().toggleSpeakerphone();
@@ -598,8 +598,8 @@ public class CallButtonFragment
     * are visible based on the supported audio formats.
     */
    private void updateAudioButtons(int supportedModes) {
        final boolean bluetoothSupported = isSupported(CallAudioStateCompat.ROUTE_BLUETOOTH);
        final boolean speakerSupported = isSupported(CallAudioStateCompat.ROUTE_SPEAKER);
        final boolean bluetoothSupported = isSupported(CallAudioState.ROUTE_BLUETOOTH);
        final boolean speakerSupported = isSupported(CallAudioState.ROUTE_SPEAKER);

        boolean audioButtonEnabled = false;
        boolean audioButtonChecked = false;
@@ -619,9 +619,9 @@ public class CallButtonFragment
            showMoreIndicator = true;

            // Update desired layers:
            if (isAudio(CallAudioStateCompat.ROUTE_BLUETOOTH)) {
            if (isAudio(CallAudioState.ROUTE_BLUETOOTH)) {
                showBluetoothIcon = true;
            } else if (isAudio(CallAudioStateCompat.ROUTE_SPEAKER)) {
            } else if (isAudio(CallAudioState.ROUTE_SPEAKER)) {
                showSpeakerphoneIcon = true;
            } else {
                showHandsetIcon = true;
@@ -640,7 +640,7 @@ public class CallButtonFragment

            // The audio button *is* a toggle in this state, and indicated the
            // current state of the speakerphone.
            audioButtonChecked = isAudio(CallAudioStateCompat.ROUTE_SPEAKER);
            audioButtonChecked = isAudio(CallAudioState.ROUTE_SPEAKER);
            mAudioButton.setSelected(audioButtonChecked);

            // update desired layers:
@@ -701,20 +701,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(CallAudioStateCompat.ROUTE_BLUETOOTH)) {
        if (!isSupported(CallAudioState.ROUTE_BLUETOOTH)) {
            stringId = R.string.audio_mode_speaker;
        } else {
            switch (mode) {
                case CallAudioStateCompat.ROUTE_EARPIECE:
                case CallAudioState.ROUTE_EARPIECE:
                    stringId = R.string.audio_mode_earpiece;
                    break;
                case CallAudioStateCompat.ROUTE_BLUETOOTH:
                case CallAudioState.ROUTE_BLUETOOTH:
                    stringId = R.string.audio_mode_bluetooth;
                    break;
                case CallAudioStateCompat.ROUTE_WIRED_HEADSET:
                case CallAudioState.ROUTE_WIRED_HEADSET:
                    stringId = R.string.audio_mode_wired_headset;
                    break;
                case CallAudioStateCompat.ROUTE_SPEAKER:
                case CallAudioState.ROUTE_SPEAKER:
                    stringId = R.string.audio_mode_speaker;
                    break;
            }
@@ -744,7 +744,7 @@ public class CallButtonFragment
        // See comments below for the exact logic.

        final MenuItem speakerItem = menu.findItem(R.id.audio_mode_speaker);
        speakerItem.setEnabled(isSupported(CallAudioStateCompat.ROUTE_SPEAKER));
        speakerItem.setEnabled(isSupported(CallAudioState.ROUTE_SPEAKER));
        // TODO: Show speakerItem as initially "selected" if
        // speaker is on.

@@ -753,7 +753,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(CallAudioStateCompat.ROUTE_WIRED_HEADSET);
        final boolean usingHeadset = isSupported(CallAudioState.ROUTE_WIRED_HEADSET);
        earpieceItem.setVisible(!usingHeadset);
        earpieceItem.setEnabled(!usingHeadset);
        wiredHeadsetItem.setVisible(usingHeadset);
@@ -763,7 +763,7 @@ public class CallButtonFragment
        // bluetoothIndicatorOn are both false.

        final MenuItem bluetoothItem = menu.findItem(R.id.audio_mode_bluetooth);
        bluetoothItem.setEnabled(isSupported(CallAudioStateCompat.ROUTE_BLUETOOTH));
        bluetoothItem.setEnabled(isSupported(CallAudioState.ROUTE_BLUETOOTH));
        // TODO: Show bluetoothItem as initially "selected" if
        // bluetoothIndicatorOn is true.

+6 −6
Original line number Diff line number Diff line
@@ -31,12 +31,12 @@ import static com.android.incallui.CallButtonFragment.Buttons.BUTTON_UPGRADE_TO_
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.telecom.CallAudioState;
import android.telecom.InCallService.VideoCall;
import android.telecom.VideoProfile;

import com.android.contacts.common.compat.CallSdkCompat;
import com.android.contacts.common.compat.SdkVersionOverride;
import com.android.dialer.compat.CallAudioStateCompat;
import com.android.dialer.compat.UserManagerCompat;
import com.android.incallui.AudioModeProvider.AudioModeListener;
import com.android.incallui.InCallCameraManager.Listener;
@@ -189,7 +189,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
        // an update for onAudioMode().  This will make UI response immediate
        // if it turns out to be slow

        Log.d(this, "Sending new Audio Mode: " + CallAudioStateCompat.audioRouteToString(mode));
        Log.d(this, "Sending new Audio Mode: " + CallAudioState.audioRouteToString(mode));
        TelecomAdapter.getInstance().setAudioRoute(mode);
    }

@@ -198,7 +198,7 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
     */
    public void toggleSpeakerphone() {
        // this function should not be called if bluetooth is available
        if (0 != (CallAudioStateCompat.ROUTE_BLUETOOTH & getSupportedAudio())) {
        if (0 != (CallAudioState.ROUTE_BLUETOOTH & getSupportedAudio())) {

            // It's clear the UI is wrong, so update the supported mode once again.
            Log.e(this, "toggling speakerphone not allowed when bluetooth supported.");
@@ -206,11 +206,11 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
            return;
        }

        int newMode = CallAudioStateCompat.ROUTE_SPEAKER;
        int newMode = CallAudioState.ROUTE_SPEAKER;

        // if speakerphone is already on, change to wired/earpiece
        if (getAudioMode() == CallAudioStateCompat.ROUTE_SPEAKER) {
            newMode = CallAudioStateCompat.ROUTE_WIRED_OR_EARPIECE;
        if (getAudioMode() == CallAudioState.ROUTE_SPEAKER) {
            newMode = CallAudioState.ROUTE_WIRED_OR_EARPIECE;
        }

        setAudioMode(newMode);
+5 −5
Original line number Diff line number Diff line
@@ -23,9 +23,9 @@ import android.content.res.Configuration;
import android.hardware.display.DisplayManager;
import android.hardware.display.DisplayManager.DisplayListener;
import android.os.PowerManager;
import android.telecom.CallAudioState;
import android.view.Display;

import com.android.dialer.compat.CallAudioStateCompat;
import com.android.incallui.AudioModeProvider.AudioModeListener;
import com.android.incallui.InCallPresenter.InCallState;
import com.android.incallui.InCallPresenter.InCallStateListener;
@@ -228,9 +228,9 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene
        // turn proximity sensor off and turn screen on immediately if
        // we are using a headset, the keyboard is open, or the device
        // is being held in a horizontal position.
            boolean screenOnImmediately = (CallAudioStateCompat.ROUTE_WIRED_HEADSET == audioMode
                    || CallAudioStateCompat.ROUTE_SPEAKER == audioMode
                    || CallAudioStateCompat.ROUTE_BLUETOOTH == audioMode
            boolean screenOnImmediately = (CallAudioState.ROUTE_WIRED_HEADSET == audioMode
                    || CallAudioState.ROUTE_SPEAKER == audioMode
                    || CallAudioState.ROUTE_BLUETOOTH == audioMode
                    || mIsHardKeyboardOpen);

            // We do not keep the screen off when the user is outside in-call screen and we are
@@ -254,7 +254,7 @@ public class ProximitySensor implements AccelerometerListener.OrientationListene
                    .add("offhook", mIsPhoneOffhook ? 1 : 0)
                    .add("hor", horizontal ? 1 : 0)
                    .add("ui", mUiShowing ? 1 : 0)
                    .add("aud", CallAudioStateCompat.audioRouteToString(audioMode))
                    .add("aud", CallAudioState.audioRouteToString(audioMode))
                    .toString());

            if (mIsPhoneOffhook && !screenOnImmediately) {
+2 −2
Original line number Diff line number Diff line
@@ -23,9 +23,9 @@ 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.dialer.compat.CallAudioStateCompat;
import com.android.incallui.AudioModeProvider;
import com.android.incallui.Log;
import com.android.incallui.async.PausableExecutor;
@@ -110,7 +110,7 @@ public class InCallTonePlayer {
    }

    private int getPlaybackStream() {
        if (mAudioModeProvider.getAudioMode() == CallAudioStateCompat.ROUTE_BLUETOOTH) {
        if (mAudioModeProvider.getAudioMode() == CallAudioState.ROUTE_BLUETOOTH) {
            // TODO (maxwelb): b/26932998 play through bluetooth
            // return AudioManager.STREAM_BLUETOOTH_SCO;
        }
Loading