Remove CallAudioStateCompat
am: e4be64852d

* commit 'e4be64852dac9e2c55ce8dd5b7063b0c21b9700e':
  Remove CallAudioStateCompat
diff --git a/InCallUI/src/com/android/incallui/AudioModeProvider.java b/InCallUI/src/com/android/incallui/AudioModeProvider.java
index 961fb11..ea56dd6 100644
--- a/InCallUI/src/com/android/incallui/AudioModeProvider.java
+++ b/InCallUI/src/com/android/incallui/AudioModeProvider.java
@@ -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 @@
     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() {
diff --git a/InCallUI/src/com/android/incallui/CallButtonFragment.java b/InCallUI/src/com/android/incallui/CallButtonFragment.java
index d9e474d..9859f4e 100644
--- a/InCallUI/src/com/android/incallui/CallButtonFragment.java
+++ b/InCallUI/src/com/android/incallui/CallButtonFragment.java
@@ -39,6 +39,7 @@
 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 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 @@
         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 @@
      */
     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 @@
      * 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 @@
             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 @@
 
             // 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 @@
 
         // 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 @@
         // 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 @@
         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 @@
         // 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.
 
diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
index fd0dd76..e8c2d4b 100644
--- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
@@ -31,12 +31,12 @@
 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 @@
         // 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 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 @@
             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);
diff --git a/InCallUI/src/com/android/incallui/ProximitySensor.java b/InCallUI/src/com/android/incallui/ProximitySensor.java
index 733a67d..3c9fd93 100644
--- a/InCallUI/src/com/android/incallui/ProximitySensor.java
+++ b/InCallUI/src/com/android/incallui/ProximitySensor.java
@@ -23,9 +23,9 @@
 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 @@
         // 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 @@
                     .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) {
diff --git a/InCallUI/src/com/android/incallui/ringtone/InCallTonePlayer.java b/InCallUI/src/com/android/incallui/ringtone/InCallTonePlayer.java
index 6ef4e25..d930a92 100644
--- a/InCallUI/src/com/android/incallui/ringtone/InCallTonePlayer.java
+++ b/InCallUI/src/com/android/incallui/ringtone/InCallTonePlayer.java
@@ -23,9 +23,9 @@
 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 @@
     }
 
     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;
         }
diff --git a/src/com/android/dialer/compat/CallAudioStateCompat.java b/src/com/android/dialer/compat/CallAudioStateCompat.java
deleted file mode 100644
index 51009d0..0000000
--- a/src/com/android/dialer/compat/CallAudioStateCompat.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.dialer.compat;
-
-import android.os.Build;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.telecom.CallAudioState;
-
-import com.android.contacts.common.compat.SdkVersionOverride;
-
-import java.util.Locale;
-
-/**
- * Compatibility class for {@link CallAudioState}
- */
-public class CallAudioStateCompat {
-
-    /**
-     * Direct the audio stream through the device's earpiece.
-     */
-    public static final int ROUTE_EARPIECE = CallAudioState.ROUTE_EARPIECE;
-
-    /**
-     * Direct the audio stream through Bluetooth.
-     */
-    public static final int ROUTE_BLUETOOTH = CallAudioState.ROUTE_BLUETOOTH;
-
-    /**
-     * Direct the audio stream through a wired headset.
-     */
-    public static final int ROUTE_WIRED_HEADSET = CallAudioState.ROUTE_WIRED_HEADSET;
-
-    /**
-     * Direct the audio stream through the device's speakerphone.
-     */
-    public static final int ROUTE_SPEAKER = CallAudioState.ROUTE_SPEAKER;
-
-    /**
-     * Direct the audio stream through the device's earpiece or wired headset if one is connected.
-     */
-    public static final int ROUTE_WIRED_OR_EARPIECE = CallAudioState.ROUTE_WIRED_OR_EARPIECE;
-
-    private final CallAudioStateImpl mCallAudioState;
-
-    /**
-     * Constructor for a {@link CallAudioStateCompat} object.
-     *
-     * @param muted {@code true} if the call is muted, {@code false} otherwise.
-     * @param route The current audio route being used. Allowed values: {@link #ROUTE_EARPIECE}
-     * {@link #ROUTE_BLUETOOTH} {@link #ROUTE_WIRED_HEADSET} {@link #ROUTE_SPEAKER}
-     * @param supportedRouteMask Bit mask of all routes supported by this call. This should be a
-     * bitwise combination of the following values: {@link #ROUTE_EARPIECE} {@link #ROUTE_BLUETOOTH}
-     * {@link #ROUTE_WIRED_HEADSET} {@link #ROUTE_SPEAKER}
-     */
-    public CallAudioStateCompat(boolean muted, int route, int supportedRouteMask) {
-        if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M)
-                < Build.VERSION_CODES.M) {
-            mCallAudioState = new CallAudioStateBase(muted, route, supportedRouteMask);
-        } else {
-            mCallAudioState = new CallAudioStateMarshmallow(muted, route, supportedRouteMask);
-        }
-    }
-
-    /**
-     * @return {@code true} if the call is muted, {@code false} otherwise.
-     */
-    public boolean isMuted() {
-        return mCallAudioState.isMuted();
-    }
-
-    /**
-     * @return The current audio route being used.
-     */
-    public int getRoute() {
-        return mCallAudioState.getRoute();
-    }
-
-    /**
-     * @return Bit mask of all routes supported by this call.
-     */
-    public int getSupportedRouteMask() {
-        return mCallAudioState.getSupportedRouteMask();
-    }
-
-    /**
-     * Converts the provided audio route into a human readable string representation.
-     *
-     * @param route to convert into a string.
-     * @return String representation of the provided audio route.
-     */
-    public static String audioRouteToString(int route) {
-        if (SdkVersionOverride.getSdkVersion(Build.VERSION_CODES.M)
-                < Build.VERSION_CODES.M) {
-            return CallAudioStateBase.audioRouteToString(route);
-        }
-        return CallAudioStateMarshmallow.audioRouteToString(route);
-    }
-
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) {
-            return true;
-        }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-
-        CallAudioStateCompat that = (CallAudioStateCompat) o;
-
-        return mCallAudioState.equals(that.mCallAudioState);
-
-    }
-
-    @Override
-    public int hashCode() {
-        return mCallAudioState.hashCode();
-    }
-
-    @Override
-    public String toString() {
-        return mCallAudioState.toString();
-    }
-
-    private interface CallAudioStateImpl {
-        boolean isMuted();
-        int getRoute();
-        int getSupportedRouteMask();
-    }
-
-    /**
-     * CallAudioStateImpl to use if the Sdk version is lower than
-     * {@link android.os.Build.VERSION_CODES.M}
-     *
-     * Coped from {@link android.telecom.CallAudioState}
-     *
-     * Encapsulates the telecom audio state, including the current audio routing, supported audio
-     * routing and mute.
-     */
-    private static class CallAudioStateBase implements CallAudioStateImpl, Parcelable {
-
-        /**
-         * Bit mask of all possible audio routes.
-         */
-        private static final int ROUTE_ALL = ROUTE_EARPIECE | ROUTE_BLUETOOTH | ROUTE_WIRED_HEADSET
-                | ROUTE_SPEAKER;
-
-        private final boolean isMuted;
-        private final int route;
-        private final int supportedRouteMask;
-
-        /**
-         * Constructor for a {@link CallAudioStateBase} object.
-         *
-         * @param muted {@code true} if the call is muted, {@code false} otherwise.
-         * @param route The current audio route being used. Allowed values: {@link #ROUTE_EARPIECE}
-         *      {@link #ROUTE_BLUETOOTH}, {@link #ROUTE_WIRED_HEADSET}, {@link #ROUTE_SPEAKER}
-         * @param supportedRouteMask Bit mask of all routes supported by this call. This should be a
-         *      bitwise combination of the following values: {@link #ROUTE_EARPIECE},
-         *      {@link #ROUTE_BLUETOOTH}, {@link #ROUTE_WIRED_HEADSET}, {@link #ROUTE_SPEAKER}
-         */
-        public CallAudioStateBase(boolean muted, int route, int supportedRouteMask) {
-            this.isMuted = muted;
-            this.route = route;
-            this.supportedRouteMask = supportedRouteMask;
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (obj == null) {
-                return false;
-            }
-            if (!(obj instanceof CallAudioStateBase)) {
-                return false;
-            }
-            CallAudioStateBase state = (CallAudioStateBase) obj;
-            return isMuted() == state.isMuted() && getRoute() == state.getRoute() &&
-                    getSupportedRouteMask() == state.getSupportedRouteMask();
-        }
-
-        @Override
-        public String toString() {
-            return String.format(Locale.US,
-                    "[AudioState isMuted: %b, route: %s, supportedRouteMask: %s]",
-                    isMuted,
-                    audioRouteToString(route),
-                    audioRouteToString(supportedRouteMask));
-        }
-
-        /**
-         * @return {@code true} if the call is muted, {@code false} otherwise.
-         */
-        @Override
-        public boolean isMuted() {
-            return isMuted;
-        }
-
-        /**
-         * @return The current audio route being used.
-         */
-        public int getRoute() {
-            return route;
-        }
-
-        /**
-         * @return Bit mask of all routes supported by this call.
-         */
-        public int getSupportedRouteMask() {
-            return supportedRouteMask;
-        }
-
-        /**
-         * Converts the provided audio route into a human readable string representation.
-         *
-         * @param route to convert into a string.
-         * @return String representation of the provided audio route.
-         */
-        public static String audioRouteToString(int route) {
-            if (route == 0 || (route & ~ROUTE_ALL) != 0x0) {
-                return "UNKNOWN";
-            }
-
-            StringBuffer buffer = new StringBuffer();
-            if ((route & ROUTE_EARPIECE) == ROUTE_EARPIECE) {
-                listAppend(buffer, "EARPIECE");
-            }
-            if ((route & ROUTE_BLUETOOTH) == ROUTE_BLUETOOTH) {
-                listAppend(buffer, "BLUETOOTH");
-            }
-            if ((route & ROUTE_WIRED_HEADSET) == ROUTE_WIRED_HEADSET) {
-                listAppend(buffer, "WIRED_HEADSET");
-            }
-            if ((route & ROUTE_SPEAKER) == ROUTE_SPEAKER) {
-                listAppend(buffer, "SPEAKER");
-            }
-
-            return buffer.toString();
-        }
-
-        /**
-         * Responsible for creating AudioState objects for deserialized Parcels.
-         */
-        public static final Parcelable.Creator<CallAudioStateBase> CREATOR =
-                new Parcelable.Creator<CallAudioStateBase>() {
-
-                    @Override
-                    public CallAudioStateBase createFromParcel(Parcel source) {
-                        boolean isMuted = source.readByte() == 0 ? false : true;
-                        int route = source.readInt();
-                        int supportedRouteMask = source.readInt();
-                        return new CallAudioStateBase(isMuted, route, supportedRouteMask);
-                    }
-
-                    @Override
-                    public CallAudioStateBase[] newArray(int size) {
-                        return new CallAudioStateBase[size];
-                    }
-                };
-
-        /**
-         * {@inheritDoc}
-         */
-        @Override
-        public int describeContents() {
-            return 0;
-        }
-
-        /**
-         * Writes AudioState object into a serializeable Parcel.
-         */
-        @Override
-        public void writeToParcel(Parcel destination, int flags) {
-            destination.writeByte((byte) (isMuted ? 1 : 0));
-            destination.writeInt(route);
-            destination.writeInt(supportedRouteMask);
-        }
-
-        private static void listAppend(StringBuffer buffer, String str) {
-            if (buffer.length() > 0) {
-                buffer.append(", ");
-            }
-            buffer.append(str);
-        }
-    }
-
-    /**
-     * CallAudioStateImpl to use if the Sdk version is at least
-     * {@link android.os.Build.VERSION_CODES.M}
-     */
-    private static class CallAudioStateMarshmallow implements CallAudioStateImpl {
-
-        private final CallAudioState mCallAudioStateDelegate;
-
-        public CallAudioStateMarshmallow(boolean muted, int route, int supportedRouteMask) {
-            mCallAudioStateDelegate = new CallAudioState(muted, route, supportedRouteMask);
-        }
-
-        @Override
-        public boolean isMuted() {
-            return mCallAudioStateDelegate.isMuted();
-        }
-
-        @Override
-        public int getRoute() {
-            return mCallAudioStateDelegate.getRoute();
-        }
-
-        @Override
-        public int getSupportedRouteMask() {
-            return mCallAudioStateDelegate.getSupportedRouteMask();
-        }
-
-        public static String audioRouteToString(int route) {
-            return CallAudioState.audioRouteToString(route);
-        }
-    }
-}
diff --git a/src/com/android/dialer/voicemail/VoicemailAudioManager.java b/src/com/android/dialer/voicemail/VoicemailAudioManager.java
index 712b20b..fe6cf5f 100644
--- a/src/com/android/dialer/voicemail/VoicemailAudioManager.java
+++ b/src/com/android/dialer/voicemail/VoicemailAudioManager.java
@@ -19,10 +19,9 @@
 import android.content.Context;
 import android.media.AudioManager;
 import android.media.AudioManager.OnAudioFocusChangeListener;
+import android.telecom.CallAudioState;
 import android.util.Log;
 
-import com.android.dialer.compat.CallAudioStateCompat;
-
 import java.util.concurrent.RejectedExecutionException;
 
 /**
@@ -38,7 +37,7 @@
     private VoicemailPlaybackPresenter mVoicemailPlaybackPresenter;
     private WiredHeadsetManager mWiredHeadsetManager;
     private boolean mWasSpeakerOn;
-    private CallAudioStateCompat mCallAudioState;
+    private CallAudioState mCallAudioState;
 
     public VoicemailAudioManager(Context context,
             VoicemailPlaybackPresenter voicemailPlaybackPresenter) {
@@ -82,26 +81,25 @@
 
         int newRoute = mCallAudioState.getRoute();  // start out with existing route
         if (newIsPluggedIn) {
-            newRoute = CallAudioStateCompat.ROUTE_WIRED_HEADSET;
+            newRoute = CallAudioState.ROUTE_WIRED_HEADSET;
         } else {
             if (mWasSpeakerOn) {
-                newRoute = CallAudioStateCompat.ROUTE_SPEAKER;
+                newRoute = CallAudioState.ROUTE_SPEAKER;
             } else {
-                newRoute = CallAudioStateCompat.ROUTE_EARPIECE;
+                newRoute = CallAudioState.ROUTE_EARPIECE;
             }
         }
 
-        mVoicemailPlaybackPresenter.setSpeakerphoneOn(newRoute == CallAudioStateCompat.ROUTE_SPEAKER);
+        mVoicemailPlaybackPresenter.setSpeakerphoneOn(newRoute == CallAudioState.ROUTE_SPEAKER);
 
         // We need to call this every time even if we do not change the route because the supported
         // routes changed either to include or not include WIRED_HEADSET.
         setSystemAudioState(
-                new CallAudioStateCompat(false /* muted */, newRoute, calculateSupportedRoutes()));
+                new CallAudioState(false /* muted */, newRoute, calculateSupportedRoutes()));
     }
 
     public void setSpeakerphoneOn(boolean on) {
-        setAudioRoute(on ? CallAudioStateCompat.ROUTE_SPEAKER
-                : CallAudioStateCompat.ROUTE_WIRED_OR_EARPIECE);
+        setAudioRoute(on ? CallAudioState.ROUTE_SPEAKER : CallAudioState.ROUTE_WIRED_OR_EARPIECE);
     }
 
     public boolean isWiredHeadsetPluggedIn() {
@@ -120,10 +118,10 @@
     /**
      * Change the audio route, for example from earpiece to speakerphone.
      *
-     * @param route The new audio route to use. See {@link CallAudioStateCompat}.
+     * @param route The new audio route to use. See {@link CallAudioState}.
      */
     void setAudioRoute(int route) {
-        Log.v(TAG, "setAudioRoute, route: " + CallAudioStateCompat.audioRouteToString(route));
+        Log.v(TAG, "setAudioRoute, route: " + CallAudioState.audioRouteToString(route));
 
         // Change ROUTE_WIRED_OR_EARPIECE to a single entry.
         int newRoute = selectWiredOrEarpiece(route, mCallAudioState.getSupportedRouteMask());
@@ -137,25 +135,25 @@
         if (mCallAudioState.getRoute() != newRoute) {
             // Remember the new speaker state so it can be restored when the user plugs and unplugs
             // a headset.
-            mWasSpeakerOn = newRoute == CallAudioStateCompat.ROUTE_SPEAKER;
-            setSystemAudioState(new CallAudioStateCompat(false /* muted */, newRoute,
+            mWasSpeakerOn = newRoute == CallAudioState.ROUTE_SPEAKER;
+            setSystemAudioState(new CallAudioState(false /* muted */, newRoute,
                     mCallAudioState.getSupportedRouteMask()));
         }
     }
 
-    private CallAudioStateCompat getInitialAudioState() {
+    private CallAudioState getInitialAudioState() {
         int supportedRouteMask = calculateSupportedRoutes();
-        int route = selectWiredOrEarpiece(CallAudioStateCompat.ROUTE_WIRED_OR_EARPIECE,
+        int route = selectWiredOrEarpiece(CallAudioState.ROUTE_WIRED_OR_EARPIECE,
                 supportedRouteMask);
-        return new CallAudioStateCompat(false /* muted */, route, supportedRouteMask);
+        return new CallAudioState(false /* muted */, route, supportedRouteMask);
     }
 
     private int calculateSupportedRoutes() {
-        int routeMask = CallAudioStateCompat.ROUTE_SPEAKER;
+        int routeMask = CallAudioState.ROUTE_SPEAKER;
         if (mWiredHeadsetManager.isPluggedIn()) {
-            routeMask |= CallAudioStateCompat.ROUTE_WIRED_HEADSET;
+            routeMask |= CallAudioState.ROUTE_WIRED_HEADSET;
         } else {
-            routeMask |= CallAudioStateCompat.ROUTE_EARPIECE;
+            routeMask |= CallAudioState.ROUTE_EARPIECE;
         }
         return routeMask;
     }
@@ -164,29 +162,29 @@
         // Since they are mutually exclusive and one is ALWAYS valid, we allow a special input of
         // ROUTE_WIRED_OR_EARPIECE so that callers don't have to make a call to check which is
         // supported before calling setAudioRoute.
-        if (route == CallAudioStateCompat.ROUTE_WIRED_OR_EARPIECE) {
-            route = CallAudioStateCompat.ROUTE_WIRED_OR_EARPIECE & supportedRouteMask;
+        if (route == CallAudioState.ROUTE_WIRED_OR_EARPIECE) {
+            route = CallAudioState.ROUTE_WIRED_OR_EARPIECE & supportedRouteMask;
             if (route == 0) {
                 Log.wtf(TAG, "One of wired headset or earpiece should always be valid.");
                 // assume earpiece in this case.
-                route = CallAudioStateCompat.ROUTE_EARPIECE;
+                route = CallAudioState.ROUTE_EARPIECE;
             }
         }
         return route;
     }
 
-    private void setSystemAudioState(CallAudioStateCompat callAudioState) {
-        CallAudioStateCompat oldAudioState = mCallAudioState;
+    private void setSystemAudioState(CallAudioState callAudioState) {
+        CallAudioState oldAudioState = mCallAudioState;
         mCallAudioState = callAudioState;
 
         Log.i(TAG, "setSystemAudioState: changing from " + oldAudioState + " to "
                 + mCallAudioState);
 
         // Audio route.
-        if (mCallAudioState.getRoute() == CallAudioStateCompat.ROUTE_SPEAKER) {
+        if (mCallAudioState.getRoute() == CallAudioState.ROUTE_SPEAKER) {
             turnOnSpeaker(true);
-        } else if (mCallAudioState.getRoute() == CallAudioStateCompat.ROUTE_EARPIECE ||
-                mCallAudioState.getRoute() == CallAudioStateCompat.ROUTE_WIRED_HEADSET) {
+        } else if (mCallAudioState.getRoute() == CallAudioState.ROUTE_EARPIECE ||
+                mCallAudioState.getRoute() == CallAudioState.ROUTE_WIRED_HEADSET) {
             // Just handle turning off the speaker, the system will handle switching between wired
             // headset and earpiece.
             turnOnSpeaker(false);
@@ -199,4 +197,4 @@
             mAudioManager.setSpeakerphoneOn(on);
         }
     }
-}
\ No newline at end of file
+}