Broadcast phone account registrations
This is cherry-picked from master
Change-Id: I1ad86c6fde042f1b3b38687800e434dfc82c75e4
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 9a47d30..bbdb9a4 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -38,6 +38,7 @@
<uses-permission android:name="android.permission.BIND_INCALL_SERVICE" />
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
<uses-permission android:name="android.permission.BROADCAST_CALLLOG_INFO" />
+ <uses-permission android:name="android.permission.BROADCAST_PHONE_ACCOUNT_REGISTRATION" />
<permission
android:name="android.permission.BROADCAST_CALLLOG_INFO"
@@ -49,6 +50,16 @@
android:label="Register to handle the broadcasted call type/duration information"
android:protectionLevel="signature|system"/>
+ <permission
+ android:name="android.permission.BROADCAST_PHONE_ACCOUNT_REGISTRATION"
+ android:label="Broadcast phone account registration"
+ android:protectionLevel="signature|system"/>
+
+ <permission
+ android:name="android.permission.PROCESS_PHONE_ACCOUNT_REGISTRATION"
+ android:label="Process phone account registration"
+ android:protectionLevel="signature|system"/>
+
<!-- Declare which SDK level this application was built against. This is needed so that IDEs
can check for incompatible APIs. -->
<uses-sdk android:minSdkVersion="19" />
diff --git a/src/com/android/server/telecom/TelecomServiceImpl.java b/src/com/android/server/telecom/TelecomServiceImpl.java
index c52c525..e1e7075 100644
--- a/src/com/android/server/telecom/TelecomServiceImpl.java
+++ b/src/com/android/server/telecom/TelecomServiceImpl.java
@@ -54,6 +54,9 @@
* Implementation of the ITelecom interface.
*/
public class TelecomServiceImpl {
+ private static final String PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION =
+ "android.permission.PROCESS_PHONE_ACCOUNT_REGISTRATION";
+
/** The context. */
private Context mContext;
@@ -370,6 +373,16 @@
enforceUserHandleMatchesCaller(account.getAccountHandle());
TelecomSystem.getInstance().getPhoneAccountRegistrar().registerPhoneAccount(account);
+
+ // Broadcast an intent indicating the phone account which was registered.
+ long token = Binder.clearCallingIdentity();
+ Intent intent = new Intent(TelecomManager.ACTION_PHONE_ACCOUNT_REGISTERED);
+ intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE,
+ account.getAccountHandle());
+ Log.i(this, "Sending phone-account intent as user");
+ sendBroadcastAsUser(intent, UserHandle.ALL,
+ PERMISSION_PROCESS_PHONE_ACCOUNT_REGISTRATION);
+ Binder.restoreCallingIdentity(token);
} catch (Exception e) {
Log.e(this, e, "registerPhoneAccount %s", account);
throw e;