Improve wiring of Phone Accounts

Change-Id: I891224e09a1d2bf81ffa887e1d077f6f64f73022
diff --git a/src/com/android/telecomm/TelecommServiceImpl.java b/src/com/android/telecomm/TelecommServiceImpl.java
index e08571a..b0fc709 100644
--- a/src/com/android/telecomm/TelecommServiceImpl.java
+++ b/src/com/android/telecomm/TelecommServiceImpl.java
@@ -44,6 +44,8 @@
  * Implementation of the ITelecomm interface.
  */
 public class TelecommServiceImpl extends ITelecommService.Stub {
+    private static final String TELEPHONY_PACKAGE_NAME = "com.android.phone";
+
     /** ${inheritDoc} */
     @Override
     public IBinder asBinder() {
@@ -191,6 +193,9 @@
         try {
             enforceModifyPermissionOrCallingPackage(
                     account.getAccountHandle().getComponentName().getPackageName());
+            if ((account.getCapabilities() & PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION) != 0) {
+                enforceModifyPermissionOrCallingPackage(TELEPHONY_PACKAGE_NAME);
+            }
             mPhoneAccountRegistrar.registerPhoneAccount(account);
         } catch (Exception e) {
             Log.e(this, e, "registerPhoneAccount %s", account);