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
diff --git a/telecomm/java/android/telecom/InCallService.java b/telecomm/java/android/telecom/InCallService.java
index 182a7f5..e37cff7 100644
--- a/telecomm/java/android/telecom/InCallService.java
+++ b/telecomm/java/android/telecom/InCallService.java
@@ -52,7 +52,7 @@
     private static final int MSG_ADD_CALL = 2;
     private static final int MSG_UPDATE_CALL = 3;
     private static final int MSG_SET_POST_DIAL_WAIT = 4;
-    private static final int MSG_ON_AUDIO_STATE_CHANGED = 5;
+    private static final int MSG_ON_CALL_AUDIO_STATE_CHANGED = 5;
     private static final int MSG_BRING_TO_FOREGROUND = 6;
     private static final int MSG_ON_CAN_ADD_CALL_CHANGED = 7;
 
@@ -87,8 +87,8 @@
                     }
                     break;
                 }
-                case MSG_ON_AUDIO_STATE_CHANGED:
-                    mPhone.internalAudioStateChanged((AudioState) msg.obj);
+                case MSG_ON_CALL_AUDIO_STATE_CHANGED:
+                    mPhone.internalCallAudioStateChanged((CallAudioState) msg.obj);
                     break;
                 case MSG_BRING_TO_FOREGROUND:
                     mPhone.internalBringToForeground(msg.arg1 == 1);
@@ -133,8 +133,8 @@
         }
 
         @Override
-        public void onAudioStateChanged(AudioState audioState) {
-            mHandler.obtainMessage(MSG_ON_AUDIO_STATE_CHANGED, audioState).sendToTarget();
+        public void onCallAudioStateChanged(CallAudioState callAudioState) {
+            mHandler.obtainMessage(MSG_ON_CALL_AUDIO_STATE_CHANGED, callAudioState).sendToTarget();
         }
 
         @Override
@@ -156,6 +156,10 @@
             InCallService.this.onAudioStateChanged(audioState);
         }
 
+        public void onCallAudioStateChanged(Phone phone, CallAudioState callAudioState) {
+            InCallService.this.onCallAudioStateChanged(callAudioState);
+        };
+
         /** ${inheritDoc} */
         @Override
         public void onBringToForeground(Phone phone, boolean showDialpad) {
@@ -248,14 +252,27 @@
      *
      * @return An object encapsulating the audio state. Returns null if the service is not
      *         fully initialized.
+     * @deprecated Use {@link #getCallAudioState()} instead.
+     * @hide
      */
+    @Deprecated
     public final AudioState getAudioState() {
         return mPhone == null ? null : mPhone.getAudioState();
     }
 
     /**
+     * Obtains the current phone call audio state.
+     *
+     * @return An object encapsulating the audio state. Returns null if the service is not
+     *         fully initialized.
+     */
+    public final CallAudioState getCallAudioState() {
+        return mPhone == null ? null : mPhone.getCallAudioState();
+    }
+
+    /**
      * Sets the microphone mute state. When this request is honored, there will be change to
-     * the {@link #getAudioState()}.
+     * the {@link #getCallAudioState()}.
      *
      * @param state {@code true} if the microphone should be muted; {@code false} otherwise.
      */
@@ -267,7 +284,7 @@
 
     /**
      * Sets the audio route (speaker, bluetooth, etc...).  When this request is honored, there will
-     * be change to the {@link #getAudioState()}.
+     * be change to the {@link #getCallAudioState()}.
      *
      * @param route The audio route to use.
      */
@@ -311,11 +328,22 @@
      * Called when the audio state changes.
      *
      * @param audioState The new {@link AudioState}.
+     * @deprecated Use {@link #onCallAudioStateChanged(CallAudioState) instead}.
+     * @hide
      */
+    @Deprecated
     public void onAudioStateChanged(AudioState audioState) {
     }
 
     /**
+     * Called when the audio state changes.
+     *
+     * @param audioState The new {@link CallAudioState}.
+     */
+    public void onCallAudioStateChanged(CallAudioState audioState) {
+    }
+
+    /**
      * Called to bring the in-call screen to the foreground. The in-call experience should
      * respond immediately by coming to the foreground to inform the user of the state of
      * ongoing {@code Call}s.