am 05a2c7ef: Merge "Remove ability to enable/disable phoneaccounts (1/6)" into lmp-dev

* commit '05a2c7ef905777fdbc1129146df6f389e2e6980a':
  Remove ability to enable/disable phoneaccounts (1/6)
diff --git a/api/current.txt b/api/current.txt
index f9913fa..c4bc62f 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -28219,7 +28219,6 @@
     method public android.net.Uri getSubscriptionAddress();
     method public java.util.List<java.lang.String> getSupportedUriSchemes();
     method public boolean hasCapabilities(int);
-    method public boolean isEnabled();
     method public boolean supportsUriScheme(java.lang.String);
     method public void writeToParcel(android.os.Parcel, int);
     field public static final int CAPABILITY_CONNECTION_MANAGER = 1; // 0x1
@@ -28349,21 +28348,19 @@
     method public void addNewIncomingCall(android.telecom.PhoneAccountHandle, android.os.Bundle);
     method public void cancelMissedCallsNotification();
     method public void clearAccounts();
+    method public java.util.List<android.telecom.PhoneAccountHandle> getCallCapablePhoneAccounts();
     method public android.telecom.PhoneAccountHandle getConnectionManager();
     method public android.telecom.PhoneAccountHandle getDefaultOutgoingPhoneAccount(java.lang.String);
-    method public java.util.List<android.telecom.PhoneAccountHandle> getEnabledPhoneAccounts();
     method public android.telecom.PhoneAccount getPhoneAccount(android.telecom.PhoneAccountHandle);
     method public java.util.List<android.telecom.PhoneAccountHandle> getPhoneAccountsSupportingScheme(java.lang.String);
     method public boolean handleMmi(java.lang.String);
-    method public boolean hasMultipleEnabledAccounts();
+    method public boolean hasMultipleCallCapableAccounts();
     method public boolean isInCall();
     method public void registerPhoneAccount(android.telecom.PhoneAccount);
     method public void showInCallScreen(boolean);
     method public void unregisterPhoneAccount(android.telecom.PhoneAccountHandle);
     field public static final java.lang.String ACTION_CHANGE_PHONE_ACCOUNTS = "android.telecom.action.CHANGE_PHONE_ACCOUNTS";
     field public static final java.lang.String ACTION_CONNECTION_SERVICE_CONFIGURE = "android.telecom.action.CONNECTION_SERVICE_CONFIGURE";
-    field public static final java.lang.String ACTION_PHONE_ACCOUNT_DISABLED = "android.telecom.action.PHONE_ACCOUNT_DISABLED";
-    field public static final java.lang.String ACTION_PHONE_ACCOUNT_ENABLED = "android.telecom.action.PHONE_ACCOUNT_ENABLED";
     field public static final java.lang.String ACTION_SHOW_CALL_SETTINGS = "android.telecom.action.SHOW_CALL_SETTINGS";
     field public static final char DTMF_CHARACTER_PAUSE = 44; // 0x002c ','
     field public static final char DTMF_CHARACTER_WAIT = 59; // 0x003b ';'
diff --git a/telecomm/java/android/telecom/PhoneAccount.java b/telecomm/java/android/telecom/PhoneAccount.java
index 0c233eb..4b059b2 100644
--- a/telecomm/java/android/telecom/PhoneAccount.java
+++ b/telecomm/java/android/telecom/PhoneAccount.java
@@ -91,17 +91,6 @@
     public static final int CAPABILITY_PLACE_EMERGENCY_CALLS = 0x10;
 
     /**
-     * Flag indicating that this {@code PhoneAccount} is always enabled and cannot be disabled by
-     * the user.
-     * This capability is reserved for important {@code PhoneAccount}s such as the emergency calling
-     * only {@code PhoneAccount}.
-     * <p>
-     * See {@link #getCapabilities}
-     * @hide
-     */
-    public static final int CAPABILITY_ALWAYS_ENABLED = 0x20;
-
-    /**
      * URI scheme for telephone number URIs.
      */
     public static final String SCHEME_TEL = "tel";
@@ -124,7 +113,6 @@
     private final CharSequence mLabel;
     private final CharSequence mShortDescription;
     private final List<String> mSupportedUriSchemes;
-    private final boolean mIsEnabled;
 
     public static class Builder {
         private PhoneAccountHandle mAccountHandle;
@@ -135,7 +123,6 @@
         private CharSequence mLabel;
         private CharSequence mShortDescription;
         private List<String> mSupportedUriSchemes = new ArrayList<String>();
-        private boolean mIsEnabled = false;
 
         public Builder(PhoneAccountHandle accountHandle, CharSequence label) {
             this.mAccountHandle = accountHandle;
@@ -157,7 +144,6 @@
             mLabel = phoneAccount.getLabel();
             mShortDescription = phoneAccount.getShortDescription();
             mSupportedUriSchemes.addAll(phoneAccount.getSupportedUriSchemes());
-            mIsEnabled = phoneAccount.isEnabled();
         }
 
         public Builder setAddress(Uri value) {
@@ -217,19 +203,6 @@
         }
 
         /**
-         * Specifies whether the {@link PhoneAccount} is enabled or not.  {@link PhoneAccount}s are
-         * by default not enabled.
-         *
-         * @param value {@code True} if the {@link PhoneAccount} is enabled.
-         * @return The Builder.
-         * @hide
-         */
-        public Builder setEnabled(boolean value) {
-            this.mIsEnabled = value;
-            return this;
-        }
-
-        /**
          * Creates an instance of a {@link PhoneAccount} based on the current builder settings.
          *
          * @return The {@link PhoneAccount}.
@@ -248,8 +221,7 @@
                     mIconResId,
                     mLabel,
                     mShortDescription,
-                    mSupportedUriSchemes,
-                    mIsEnabled);
+                    mSupportedUriSchemes);
         }
     }
 
@@ -261,8 +233,7 @@
             int iconResId,
             CharSequence label,
             CharSequence shortDescription,
-            List<String> supportedUriSchemes,
-            boolean enabled) {
+            List<String> supportedUriSchemes) {
         mAccountHandle = account;
         mAddress = address;
         mSubscriptionAddress = subscriptionAddress;
@@ -271,7 +242,6 @@
         mLabel = label;
         mShortDescription = shortDescription;
         mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
-        mIsEnabled = enabled;
     }
 
     public static Builder builder(
@@ -392,15 +362,6 @@
     }
 
     /**
-     * Determines whether this {@code PhoneAccount} is enabled.
-     *
-     * @return {@code True} if this {@code PhoneAccount} is enabled..
-     */
-    public boolean isEnabled() {
-        return mIsEnabled;
-    }
-
-    /**
      * The icon resource ID for the icon of this {@code PhoneAccount}.
      *
      * @return A resource ID.
@@ -455,7 +416,6 @@
         out.writeCharSequence(mLabel);
         out.writeCharSequence(mShortDescription);
         out.writeList(mSupportedUriSchemes);
-        out.writeInt(mIsEnabled ? 1 : 0);
     }
 
     public static final Creator<PhoneAccount> CREATOR
@@ -485,6 +445,5 @@
         List<String> supportedUriSchemes = new ArrayList<>();
         in.readList(supportedUriSchemes, classLoader);
         mSupportedUriSchemes = Collections.unmodifiableList(supportedUriSchemes);
-        mIsEnabled = in.readInt() == 1;
     }
 }
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 4d438ed..a91d92f 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -71,24 +71,6 @@
             "android.telecom.action.CHANGE_PHONE_ACCOUNTS";
 
     /**
-     * The {@link android.content.Intent} action used to inform a
-     * {@link android.telecom.ConnectionService} that one of its {@link PhoneAccount}s has been
-     * enabled.  The {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} extra is used to indicate
-     * which {@link PhoneAccount} has been enabled.
-     */
-    public static final String ACTION_PHONE_ACCOUNT_ENABLED =
-            "android.telecom.action.PHONE_ACCOUNT_ENABLED";
-
-    /**
-     * The {@link android.content.Intent} action used to inform a
-     * {@link android.telecom.ConnectionService} that one of its {@link PhoneAccount}s has been
-     * disabled.  The {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} extra is used to indicate
-     * which {@link PhoneAccount} has been disabled.
-     */
-    public static final String ACTION_PHONE_ACCOUNT_DISABLED =
-            "android.telecom.action.PHONE_ACCOUNT_DISABLED";
-
-    /**
      * Optional extra for {@link android.content.Intent#ACTION_CALL} containing a boolean that
      * determines whether the speakerphone should be automatically turned on for an outgoing call.
      */
@@ -325,14 +307,14 @@
     /**
      * Return the {@link PhoneAccount} which is the user-chosen default for making outgoing phone
      * calls with a specified URI scheme. This {@code PhoneAccount} will always be a member of the
-     * list which is returned from calling {@link #getEnabledPhoneAccounts()}.
+     * list which is returned from calling {@link #getCallCapablePhoneAccounts()}.
      * <p>
      * Apps must be prepared for this method to return {@code null}, indicating that there currently
      * exists no user-chosen default {@code PhoneAccount}. In this case, apps wishing to initiate a
      * phone call must either create their {@link android.content.Intent#ACTION_CALL} or
      * {@link android.content.Intent#ACTION_DIAL} {@code Intent} with no
      * {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE}, or present the user with an affordance to
-     * select one of the elements of {@link #getEnabledPhoneAccounts()}.
+     * select one of the elements of {@link #getCallCapablePhoneAccounts()}.
      * <p>
      * An {@link android.content.Intent#ACTION_CALL} or {@link android.content.Intent#ACTION_DIAL}
      * {@code Intent} with no {@link TelecomManager#EXTRA_PHONE_ACCOUNT_HANDLE} is valid, and
@@ -355,7 +337,7 @@
     /**
      * Return the {@link PhoneAccount} which is the user-chosen default for making outgoing phone
      * calls. This {@code PhoneAccount} will always be a member of the list which is returned from
-     * calling {@link #getEnabledPhoneAccounts()}
+     * calling {@link #getCallCapablePhoneAccounts()}
      *
      * Apps must be prepared for this method to return {@code null}, indicating that there currently
      * exists no user-chosen default {@code PhoneAccount}.
@@ -389,19 +371,19 @@
     }
 
     /**
-     * Return a list of enabled {@link PhoneAccountHandle}s which can be used to make and receive
-     * phone calls.
+     * Return a list of {@link PhoneAccountHandle}s which can be used to make and receive phone
+     * calls.
      *
      * @see #EXTRA_PHONE_ACCOUNT_HANDLE
      * @return A list of {@code PhoneAccountHandle} objects.
      */
-    public List<PhoneAccountHandle> getEnabledPhoneAccounts() {
+    public List<PhoneAccountHandle> getCallCapablePhoneAccounts() {
         try {
             if (isServiceConnected()) {
-                return getTelecomService().getEnabledPhoneAccounts();
+                return getTelecomService().getCallCapablePhoneAccounts();
             }
         } catch (RemoteException e) {
-            Log.e(TAG, "Error calling ITelecomService#getEnabledPhoneAccounts", e);
+            Log.e(TAG, "Error calling ITelecomService#getCallCapablePhoneAccounts", e);
         }
         return new ArrayList<>();
     }
@@ -467,8 +449,8 @@
     }
 
     /**
-     * Returns a list of the enabled {@link PhoneAccountHandle}s which can be used to make and
-     * receive phone calls which support the specified URI scheme.
+     * Returns a list of the {@link PhoneAccountHandle}s which can be used to make and receive phone
+     * calls which support the specified URI scheme.
      * <P>
      * For example, invoking with {@code "tel"} will find all {@link PhoneAccountHandle}s which
      * support telephone calls (e.g. URIs such as {@code tel:555-555-1212}).  Invoking with
@@ -490,13 +472,14 @@
     }
 
     /**
-     * Determine whether the device has more than one account registered and enabled.
+     * Determine whether the device has more than one account registered that can make and receive
+     * phone calls.
      *
-     * @return {@code true} if the device has more than one account registered and enabled and
-     * {@code false} otherwise.
+     * @return {@code true} if the device has more than one account registered and {@code false}
+     * otherwise.
      */
-    public boolean hasMultipleEnabledAccounts() {
-        return getEnabledPhoneAccounts().size() > 1;
+    public boolean hasMultipleCallCapableAccounts() {
+        return getCallCapablePhoneAccounts().size() > 1;
     }
 
     /**
@@ -518,9 +501,9 @@
     }
 
     /**
-     * Returns a count of enabled and disabled {@link PhoneAccount}s.
+     * Returns a count of all {@link PhoneAccount}s.
      *
-     * @return The count of enabled and disabled {@link PhoneAccount}s.
+     * @return The count of {@link PhoneAccount}s.
      * @hide
      */
     @SystemApi
@@ -572,24 +555,6 @@
     }
 
     /**
-     * Enables or disables a {@link PhoneAccount}.
-     *
-     * @param account The {@link PhoneAccountHandle} to enable or disable.
-     * @param isEnabled {@code True} if the phone account should be enabled.
-     * @hide
-     */
-    @SystemApi
-    public void setPhoneAccountEnabled(PhoneAccountHandle account, boolean isEnabled) {
-        try {
-            if (isServiceConnected()) {
-                getTelecomService().setPhoneAccountEnabled(account, isEnabled);
-            }
-        } catch (RemoteException e) {
-            Log.e(TAG, "Error calling ITelecomService#setPhoneAccountEnabled", e);
-        }
-    }
-
-    /**
      * Register a {@link PhoneAccount} for use by the system.
      *
      * @param account The complete {@link PhoneAccount}.
@@ -797,9 +762,8 @@
     /**
      * Registers a new incoming call. A {@link ConnectionService} should invoke this method when it
      * has an incoming call. The specified {@link PhoneAccountHandle} must have been registered
-     * with {@link #registerPhoneAccount} and subsequently enabled by the user within the phone's
-     * settings. Once invoked, this method will cause the system to bind to the
-     * {@link ConnectionService} associated with the {@link PhoneAccountHandle} and request
+     * with {@link #registerPhoneAccount}. Once invoked, this method will cause the system to bind
+     * to the {@link ConnectionService} associated with the {@link PhoneAccountHandle} and request
      * additional information about the call (See
      * {@link ConnectionService#onCreateIncomingConnection}) before starting the incoming call UI.
      *
diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
index 4875cc3..77a80fe 100644
--- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
+++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
@@ -50,9 +50,9 @@
     void setUserSelectedOutgoingPhoneAccount(in PhoneAccountHandle account);
 
     /**
-     * @see TelecomServiceImpl#getEnabledPhoneAccounts
+     * @see TelecomServiceImpl#getCallCapablePhoneAccounts
      */
-    List<PhoneAccountHandle> getEnabledPhoneAccounts();
+    List<PhoneAccountHandle> getCallCapablePhoneAccounts();
 
     /**
      * @see TelecomManager#getPhoneAccountsSupportingScheme
@@ -95,11 +95,6 @@
     List<PhoneAccountHandle> getSimCallManagers();
 
     /**
-     * @see TelecomServiceImpl#setPhoneAccountEnabled
-     */
-    void setPhoneAccountEnabled(in PhoneAccountHandle account, in boolean isEnabled);
-
-    /**
      * @see TelecomServiceImpl#registerPhoneAccount
      */
     void registerPhoneAccount(in PhoneAccount metadata);