Finalize implementation of Remote Connection Service (2/4)

Change-Id: I6525ff7d7e5fbb06a45d4811ebbc319a4b32fd6b
diff --git a/src/com/android/telecomm/TelecommServiceImpl.java b/src/com/android/telecomm/TelecommServiceImpl.java
index 3598422..9366f84 100644
--- a/src/com/android/telecomm/TelecommServiceImpl.java
+++ b/src/com/android/telecomm/TelecommServiceImpl.java
@@ -44,7 +44,8 @@
  * Implementation of the ITelecomm interface.
  */
 public class TelecommServiceImpl extends ITelecommService.Stub {
-    private static final String TELEPHONY_PACKAGE_NAME = "com.android.phone";
+    private static final String REGISTER_PROVIDER_OR_SUBSCRIPTION =
+            "com.android.telecomm.permission.REGISTER_PROVIDER_OR_SUBSCRIPTION";
 
     /** ${inheritDoc} */
     @Override
@@ -195,7 +196,7 @@
                     account.getAccountHandle().getComponentName().getPackageName());
             if (PhoneAccountRegistrar.has(account, PhoneAccount.CAPABILITY_CALL_PROVIDER) ||
                 PhoneAccountRegistrar.has(account, PhoneAccount.CAPABILITY_SIM_SUBSCRIPTION)) {
-                enforceModifyPermissionOrCallingPackage(TELEPHONY_PACKAGE_NAME);
+                enforceRegisterProviderOrSubscriptionPermission();
             }
             mPhoneAccountRegistrar.registerPhoneAccount(account);
         } catch (Exception e) {
@@ -410,6 +411,11 @@
         }
     }
 
+    private void enforceRegisterProviderOrSubscriptionPermission() {
+        TelecommApp.getInstance().enforceCallingOrSelfPermission(
+                REGISTER_PROVIDER_OR_SUBSCRIPTION, null);
+    }
+
     private void enforceModifyPermissionOrCallingPackage(String packageName) {
         // TODO(santoscordon): Use a new telecomm permission for this instead of reusing modify.
         try {