Register TelecomBroadcastReceiver through AndroidManifest
Moving broadcast receiver from AndroidManifest to TelecomApp caused the
MissedCallNotifier to stop working, therefore restoring back to
AndroidManifest.
Bug: 17613424
Change-Id: I24e4c00655f1b8714fc7aed72b7ed27b0a436e83
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 706dda7..2c1cd7b 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -178,8 +178,20 @@
</intent-filter>
</activity-alias>
- <!-- Note: Broadcast receivers are now set up in TelecomApp as a step in the transition to
- running under the system process. -->
+ <receiver android:name="TelecomBroadcastReceiver" android:exported="false">
+ <intent-filter>
+ <action android:name="com.android.server.telecom.ACTION_CALL_BACK_FROM_NOTIFICATION" />
+ <action android:name="com.android.server.telecom.ACTION_CALL_BACK_FROM_NOTIFICATION" />
+ <action android:name="com.android.server.telecom.ACTION_SEND_SMS_FROM_NOTIFICATION" />
+ </intent-filter>
+ </receiver>
+
+ <receiver android:name="PhoneAccountBroadcastReceiver">
+ <intent-filter>
+ <action android:name="android.intent.action.PACKAGE_FULLY_REMOVED" />
+ <data android:scheme="package" />
+ </intent-filter>
+ </receiver>
<activity android:name=".RespondViaSmsSettings$Settings"
android:label="@string/respond_via_sms_setting_title"
diff --git a/src/com/android/server/telecom/PhoneAccountBroadcastReceiver.java b/src/com/android/server/telecom/PhoneAccountBroadcastReceiver.java
index d2516b1..1104518 100644
--- a/src/com/android/server/telecom/PhoneAccountBroadcastReceiver.java
+++ b/src/com/android/server/telecom/PhoneAccountBroadcastReceiver.java
@@ -35,16 +35,6 @@
* the enabled state of the accounts is retained.
*/
public class PhoneAccountBroadcastReceiver extends BroadcastReceiver {
-
- /**
- * The {@link PhoneAccountRegistrar}.
- */
- private final PhoneAccountRegistrar mPhoneAccountRegistrar;
-
- public PhoneAccountBroadcastReceiver(PhoneAccountRegistrar phoneAccountRegistrar) {
- mPhoneAccountRegistrar = phoneAccountRegistrar;
- }
-
/**
* Receives the intents the class is configured to received.
*
@@ -71,6 +61,6 @@
* @param packageName The name of the removed package.
*/
private void handlePackageRemoved(Context context, String packageName) {
- mPhoneAccountRegistrar.clearAccounts(packageName);
+ CallsManager.getInstance().getPhoneAccountRegistrar().clearAccounts(packageName);
}
}
diff --git a/src/com/android/server/telecom/TelecomApp.java b/src/com/android/server/telecom/TelecomApp.java
index e8288f8..eaa89ac 100644
--- a/src/com/android/server/telecom/TelecomApp.java
+++ b/src/com/android/server/telecom/TelecomApp.java
@@ -27,7 +27,6 @@
* Top-level Application class for Telecom.
*/
public final class TelecomApp extends Application {
-
/**
* The Telecom service implementation.
*/
@@ -49,16 +48,6 @@
*/
private CallsManager mCallsManager;
- /**
- * The Telecom broadcast receiver.
- */
- private TelecomBroadcastReceiver mTelecomBroadcastReceiver;
-
- /**
- * The {@link android.telecom.PhoneAccount} broadcast receiver.
- */
- private PhoneAccountBroadcastReceiver mPhoneAccountBroadcastReceiver;
-
/** {@inheritDoc} */
@Override
public void onCreate() {
@@ -78,21 +67,6 @@
mTelecomService = new TelecomServiceImpl(mMissedCallNotifier, mPhoneAccountRegistrar,
mCallsManager, this);
ServiceManager.addService(Context.TELECOM_SERVICE, mTelecomService);
- mPhoneAccountBroadcastReceiver = new PhoneAccountBroadcastReceiver(
- mPhoneAccountRegistrar);
- mTelecomBroadcastReceiver = new TelecomBroadcastReceiver(mMissedCallNotifier);
-
- // Setup broadcast listener for telecom intents.
- IntentFilter telecomFilter = new IntentFilter();
- telecomFilter.addAction(TelecomBroadcastReceiver.ACTION_CALL_BACK_FROM_NOTIFICATION);
- telecomFilter.addAction(TelecomBroadcastReceiver.ACTION_CALL_BACK_FROM_NOTIFICATION);
- telecomFilter.addAction(TelecomBroadcastReceiver.ACTION_SEND_SMS_FROM_NOTIFICATION);
- registerReceiver(mTelecomBroadcastReceiver, telecomFilter);
-
- IntentFilter phoneAccountFilter = new IntentFilter();
- phoneAccountFilter.addAction(Intent.ACTION_PACKAGE_FULLY_REMOVED);
- phoneAccountFilter.addDataScheme("package");
- registerReceiver(mPhoneAccountBroadcastReceiver, phoneAccountFilter);
}
}
diff --git a/src/com/android/server/telecom/TelecomBroadcastReceiver.java b/src/com/android/server/telecom/TelecomBroadcastReceiver.java
index 9a777d6..cc5116d 100644
--- a/src/com/android/server/telecom/TelecomBroadcastReceiver.java
+++ b/src/com/android/server/telecom/TelecomBroadcastReceiver.java
@@ -38,13 +38,6 @@
static final String ACTION_CLEAR_MISSED_CALLS =
"com.android.server.telecom.ACTION_CLEAR_MISSED_CALLS";
- /** The missed call notifier. */
- private final MissedCallNotifier mMissedCallNotifier;
-
- public TelecomBroadcastReceiver(MissedCallNotifier missedCallNotifier) {
- mMissedCallNotifier = missedCallNotifier;
- }
-
/** {@inheritDoc} */
@Override
public void onReceive(Context context, Intent intent) {
@@ -52,11 +45,13 @@
Log.v(this, "Action received: %s.", action);
+ MissedCallNotifier missedCallNotifier = CallsManager.getInstance().getMissedCallNotifier();
+
// Send an SMS from the missed call notification.
if (ACTION_SEND_SMS_FROM_NOTIFICATION.equals(action)) {
// Close the notification shade and the notification itself.
closeSystemDialogs(context);
- mMissedCallNotifier.clearMissedCalls();
+ missedCallNotifier.clearMissedCalls();
Intent callIntent = new Intent(Intent.ACTION_SENDTO, intent.getData());
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -66,7 +61,7 @@
} else if (ACTION_CALL_BACK_FROM_NOTIFICATION.equals(action)) {
// Close the notification shade and the notification itself.
closeSystemDialogs(context);
- mMissedCallNotifier.clearMissedCalls();
+ missedCallNotifier.clearMissedCalls();
Intent callIntent = new Intent(Intent.ACTION_CALL_PRIVILEGED, intent.getData());
callIntent.setFlags(
@@ -75,7 +70,7 @@
// Clear the missed call notification and call log entries.
} else if (ACTION_CLEAR_MISSED_CALLS.equals(action)) {
- mMissedCallNotifier.clearMissedCalls();
+ missedCallNotifier.clearMissedCalls();
}
}