Merge "Add functions for setting/getting phone accounts." into lmp-dev
diff --git a/telecomm/java/android/telecomm/TelecommManager.java b/telecomm/java/android/telecomm/TelecommManager.java
index 868282f..2243288 100644
--- a/telecomm/java/android/telecomm/TelecommManager.java
+++ b/telecomm/java/android/telecomm/TelecommManager.java
@@ -285,6 +285,20 @@
     }
 
     /**
+     * Sets the default account for making outgoing phone calls.
+     * @hide
+     */
+    public void setDefaultOutgoingPhoneAccount(PhoneAccountHandle accountHandle) {
+        try {
+            if (isServiceConnected()) {
+                getTelecommService().setDefaultOutgoingPhoneAccount(accountHandle);
+            }
+        } catch (RemoteException e) {
+            Log.e(TAG, "Error calling ITelecommService#setDefaultOutgoingPhoneAccount");
+        }
+    }
+
+    /**
      * Return a list of {@link PhoneAccountHandle}s which can be used to make and receive phone
      * calls.
      *
@@ -303,6 +317,55 @@
     }
 
     /**
+     * Returns the current SIM call manager. Apps must be prepared for this method to return
+     * {@code null}, indicating that there currently exists no user-chosen default
+     * {@code PhoneAccount}.
+     * @return The phone account handle of the current sim call manager.
+     * @hide
+     */
+    public PhoneAccountHandle getSimCallManager() {
+        try {
+            if (isServiceConnected()) {
+                return getTelecommService().getSimCallManager();
+            }
+        } catch (RemoteException e) {
+            Log.e(TAG, "Error calling ITelecommService#getSimCallManager");
+        }
+        return null;
+    }
+
+    /**
+     * Sets the SIM call manager to the specified phone account.
+     * @param accountHandle The phone account handle of the account to set as the sim call manager.
+     * @hide
+     */
+    public void setSimCallManager(PhoneAccountHandle accountHandle) {
+        try {
+            if (isServiceConnected()) {
+                getTelecommService().setSimCallManager(accountHandle);
+            }
+        } catch (RemoteException e) {
+            Log.e(TAG, "Error calling ITelecommService#setSimCallManager");
+        }
+    }
+
+    /**
+     * Returns the list of registered SIM call managers.
+     * @return List of registered SIM call managers.
+     * @hide
+     */
+    public List<PhoneAccountHandle> getSimCallManagers() {
+        try {
+            if (isServiceConnected()) {
+                return getTelecommService().getSimCallManagers();
+            }
+        } catch (RemoteException e) {
+            Log.e(TAG, "Error calling ITelecommService#getSimCallManagers");
+        }
+        return new ArrayList<>();
+    }
+
+    /**
      * Determine whether the device has more than one account registered and enabled.
      *
      * @return {@code true} if the device has more than one account registered and enabled and
@@ -614,4 +677,4 @@
         }
         return isConnected;
     }
-}
+}
\ No newline at end of file
diff --git a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl
index 0ac5078..131307a 100644
--- a/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl
+++ b/telecomm/java/com/android/internal/telecomm/ITelecommService.aidl
@@ -35,37 +35,57 @@
     void showInCallScreen(boolean showDialpad);
 
     /**
-     * @see TelecommManager#getDefaultOutgoingPhoneAccount
+     * @see TelecommServiceImpl#getDefaultOutgoingPhoneAccount
      */
     PhoneAccountHandle getDefaultOutgoingPhoneAccount();
 
     /**
-     * @see TelecommManager#getOutgoingPhoneAccounts
+     * @see TelecommServiceImpl#setDefaultOutgoingPhoneAccount
+     */
+    void setDefaultOutgoingPhoneAccount(in PhoneAccountHandle account);
+
+    /**
+     * @see TelecommServiceImpl#getOutgoingPhoneAccounts
      */
     List<PhoneAccountHandle> getOutgoingPhoneAccounts();
 
     /**
-     * @see TelecommManager#getPhoneAccount
+     * @see TelecommServiceImpl#getPhoneAccount
      */
     PhoneAccount getPhoneAccount(in PhoneAccountHandle account);
 
     /**
-     * @see TelecommManager#registerPhoneAccount
+     * @see TelecommServiceImpl#getSimCallManager
+     */
+    PhoneAccountHandle getSimCallManager();
+
+    /**
+     * @see TelecommServiceImpl#setSimCallManager
+     */
+    void setSimCallManager(in PhoneAccountHandle account);
+
+    /**
+     * @see TelecommServiceImpl#getSimCallManagers
+     */
+    List<PhoneAccountHandle> getSimCallManagers();
+
+    /**
+     * @see TelecommServiceImpl#registerPhoneAccount
      */
     void registerPhoneAccount(in PhoneAccount metadata);
 
     /**
-     * @see TelecommManager#unregisterPhoneAccount
+     * @see TelecommServiceImpl#unregisterPhoneAccount
      */
     void unregisterPhoneAccount(in PhoneAccountHandle account);
 
     /**
-     * @see TelecommManager#clearAccounts
+     * @see TelecommServiceImpl#clearAccounts
      */
     void clearAccounts(String packageName);
 
     /**
-     * @see TelecommManager#getDefaultPhoneApp
+     * @see TelecommServiceImpl#getDefaultPhoneApp
      */
     ComponentName getDefaultPhoneApp();
 
@@ -74,52 +94,52 @@
     //
 
     /**
-     * @see TelecommManager#silenceRinger
+     * @see TelecommServiceImpl#silenceRinger
      */
     void silenceRinger();
 
     /**
-     * @see TelecommManager#isInCall
+     * @see TelecommServiceImpl#isInCall
      */
     boolean isInCall();
 
     /**
-     * @see TelecomManager#isRinging
+     * @see TelecommServiceImpl#isRinging
      */
     boolean isRinging();
 
     /**
-     * @see TelecommManager#endCall
+     * @see TelecommServiceImpl#endCall
      */
     boolean endCall();
 
     /**
-     * @see TelecommManager#acceptRingingCall
+     * @see TelecommServiceImpl#acceptRingingCall
      */
     void acceptRingingCall();
 
     /**
-     * @see TelecommManager#cancelMissedCallsNotification
+     * @see TelecommServiceImpl#cancelMissedCallsNotification
      */
     void cancelMissedCallsNotification();
 
     /**
-     * @see TelecommManager#handleMmi
+     * @see TelecommServiceImpl#handleMmi
      */
     boolean handlePinMmi(String dialString);
 
     /**
-     * @see TelecomManager#isTtySupported
+     * @see TelecommServiceImpl#isTtySupported
      */
     boolean isTtySupported();
 
     /**
-     * @see TelecomManager#getCurrentTtyMode
+     * @see TelecommServiceImpl#getCurrentTtyMode
      */
     int getCurrentTtyMode();
 
     /**
-     * @see TelecommManager#addNewIncomingCall
+     * @see TelecommServiceImpl#addNewIncomingCall
      */
     void addNewIncomingCall(in PhoneAccountHandle phoneAccount, in Bundle extras);
 }