Unfinal getPhone.

The change to make it final was breaking existing apps.

...and other changes.

Bug: 20283873
Change-Id: I8db4243850ad15f688dbca59ff5427b4799cbd1b
diff --git a/api/current.txt b/api/current.txt
index deaf400..a6110a5 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -30229,25 +30229,6 @@
     method public abstract void onVideoQualityChanged(int);
   }
 
-  public final class Phone {
-    method public final void addListener(android.telecom.Phone.Listener);
-    method public final boolean canAddCall();
-    method public final android.telecom.AudioState getAudioState();
-    method public final java.util.List<android.telecom.Call> getCalls();
-    method public final void removeListener(android.telecom.Phone.Listener);
-    method public final void setAudioRoute(int);
-    method public final void setMuted(boolean);
-  }
-
-  public static abstract class Phone.Listener {
-    ctor public Phone.Listener();
-    method public void onAudioStateChanged(android.telecom.Phone, android.telecom.AudioState);
-    method public void onBringToForeground(android.telecom.Phone, boolean);
-    method public void onCallAdded(android.telecom.Phone, android.telecom.Call);
-    method public void onCallRemoved(android.telecom.Phone, android.telecom.Call);
-    method public void onCanAddCallChanged(android.telecom.Phone, boolean);
-  }
-
   public class PhoneAccount implements android.os.Parcelable {
     method public static android.telecom.PhoneAccount.Builder builder(android.telecom.PhoneAccountHandle, java.lang.CharSequence);
     method public android.graphics.drawable.Drawable createIconDrawable(android.content.Context);
diff --git a/api/system-current.txt b/api/system-current.txt
index 611b9ae..667b627 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -32292,15 +32292,15 @@
     method public final boolean canAddCall();
     method public final android.telecom.AudioState getAudioState();
     method public final java.util.List<android.telecom.Call> getCalls();
-    method public final android.telecom.Phone getPhone();
+    method public deprecated android.telecom.Phone getPhone();
     method public void onAudioStateChanged(android.telecom.AudioState);
     method public android.os.IBinder onBind(android.content.Intent);
     method public void onBringToForeground(boolean);
     method public void onCallAdded(android.telecom.Call);
     method public void onCallRemoved(android.telecom.Call);
     method public void onCanAddCallChanged(boolean);
-    method public void onPhoneCreated(android.telecom.Phone);
-    method public void onPhoneDestroyed(android.telecom.Phone);
+    method public deprecated void onPhoneCreated(android.telecom.Phone);
+    method public deprecated void onPhoneDestroyed(android.telecom.Phone);
     method public final void setAudioRoute(int);
     method public final void setMuted(boolean);
     field public static final java.lang.String SERVICE_INTERFACE = "android.telecom.InCallService";
@@ -32332,7 +32332,7 @@
     method public abstract void onVideoQualityChanged(int);
   }
 
-  public final class Phone {
+  public final deprecated class Phone {
     method public final void addListener(android.telecom.Phone.Listener);
     method public final boolean canAddCall();
     method public final android.telecom.AudioState getAudioState();
diff --git a/telecomm/java/android/telecom/InCallService.java b/telecomm/java/android/telecom/InCallService.java
index a17474a..8d6ae82 100644
--- a/telecomm/java/android/telecom/InCallService.java
+++ b/telecomm/java/android/telecom/InCallService.java
@@ -216,9 +216,11 @@
      *         if the {@code InCallService} is not in a state where it has an associated
      *         {@code Phone}.
      * @hide
+     * @deprecated Use direct methods on InCallService instead of {@link Phone}.
      */
     @SystemApi
-    public final Phone getPhone() {
+    @Deprecated
+    public Phone getPhone() {
         return mPhone;
     }
 
@@ -282,8 +284,10 @@
      *
      * @param phone The {@code Phone} object associated with this {@code InCallService}.
      * @hide
+     * @deprecated Use direct methods on InCallService instead of {@link Phone}.
      */
     @SystemApi
+    @Deprecated
     public void onPhoneCreated(Phone phone) {
     }
 
@@ -295,8 +299,10 @@
      *
      * @param phone The {@code Phone} object associated with this {@code InCallService}.
      * @hide
+     * @deprecated Use direct methods on InCallService instead of {@link Phone}.
      */
     @SystemApi
+    @Deprecated
     public void onPhoneDestroyed(Phone phone) {
     }
 
diff --git a/telecomm/java/android/telecom/Phone.java b/telecomm/java/android/telecom/Phone.java
index d9a9cdf..c1c1129 100644
--- a/telecomm/java/android/telecom/Phone.java
+++ b/telecomm/java/android/telecom/Phone.java
@@ -16,6 +16,7 @@
 
 package android.telecom;
 
+import android.annotation.SystemApi;
 import android.util.ArrayMap;
 
 import java.util.Collections;
@@ -26,7 +27,12 @@
 
 /**
  * A unified virtual device providing a means of voice (and other) communication on a device.
+ *
+ * @hide
+ * @deprecated Use {@link InCallService} directly instead of using this class.
  */
+@SystemApi
+@Deprecated
 public final class Phone {
 
     public abstract static class Listener {
@@ -100,12 +106,10 @@
 
     private boolean mCanAddCall = true;
 
-    /** {@hide} */
     Phone(InCallAdapter adapter) {
         mInCallAdapter = adapter;
     }
 
-    /** {@hide} */
     final void internalAddCall(ParcelableCall parcelableCall) {
         Call call = new Call(this, parcelableCall.getId(), mInCallAdapter);
         mCallByTelecomCallId.put(parcelableCall.getId(), call);
@@ -115,14 +119,12 @@
         fireCallAdded(call);
      }
 
-    /** {@hide} */
     final void internalRemoveCall(Call call) {
         mCallByTelecomCallId.remove(call.internalGetCallId());
         mCalls.remove(call);
         fireCallRemoved(call);
     }
 
-    /** {@hide} */
     final void internalUpdateCall(ParcelableCall parcelableCall) {
          Call call = mCallByTelecomCallId.get(parcelableCall.getId());
          if (call != null) {
@@ -131,7 +133,6 @@
          }
      }
 
-    /** {@hide} */
     final void internalSetPostDialWait(String telecomId, String remaining) {
         Call call = mCallByTelecomCallId.get(telecomId);
         if (call != null) {
@@ -139,7 +140,6 @@
         }
     }
 
-    /** {@hide} */
     final void internalAudioStateChanged(AudioState audioState) {
         if (!Objects.equals(mAudioState, audioState)) {
             mAudioState = audioState;
@@ -147,17 +147,14 @@
         }
     }
 
-    /** {@hide} */
     final Call internalGetCallByTelecomId(String telecomId) {
         return mCallByTelecomCallId.get(telecomId);
     }
 
-    /** {@hide} */
     final void internalBringToForeground(boolean showDialpad) {
         fireBringToForeground(showDialpad);
     }
 
-    /** {@hide} */
     final void internalSetCanAddCall(boolean canAddCall) {
         if (mCanAddCall != canAddCall) {
             mCanAddCall = canAddCall;
@@ -167,7 +164,6 @@
 
     /**
      * Called to destroy the phone and cleanup any lingering calls.
-     * @hide
      */
     final void destroy() {
         for (Call call : mCalls) {