Android ConnectionService - SecurityException when registering phone account
<p>I'm trying to implement <a href="https://developer.android.com/reference/android/telecom/ConnectionService.html" rel="nofollow noreferrer">ConnectionService</a>. For this I need to register a phone account on TelecomService, so the device will know it can use my app for making phone calls.</p>

<p>When I try to register a phone account I get a SecurityException: Package com.xxx.xxx does not belong to 10145. </p>

<p>What am I missing? Here is the code to register a phone account. (I have added the permission to the manifest etc)</p>

<pre><code>PhoneAccountHandle   phoneAccountHandle = new PhoneAccountHandle(new ComponentName("com.mypackage", "com.mypackage.MyConnectionService", "my_phoneHandleId");
PhoneAccount.Builder builder            = PhoneAccount.builder(phoneAccountHandle, "Custom label");

builder.setCapabilities(PhoneAccount.CAPABILITY_CALL_SUBJECT | PhoneAccount.CAPABILITY_CONNECTION_MANAGER);
builder.addSupportedUriScheme("my_scheme");
builder.setAddress(Uri.parse("my_scheme://" + "customNumber"));

PhoneAccount phoneAccount = builder.build();
telecomService.registerPhoneAccount(phoneAccount);
</code></pre>