Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6f5c08d3 authored by Nancy Chen's avatar Nancy Chen
Browse files

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
parent 150d8684
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -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"
+1 −11
Original line number Diff line number Diff line
@@ -35,16 +35,6 @@ import java.lang.String;
 * 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 @@ public class PhoneAccountBroadcastReceiver extends BroadcastReceiver {
     * @param packageName The name of the removed package.
     */
    private void handlePackageRemoved(Context context, String packageName) {
        mPhoneAccountRegistrar.clearAccounts(packageName);
        CallsManager.getInstance().getPhoneAccountRegistrar().clearAccounts(packageName);
    }
}
+0 −26
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.os.ServiceManager;
 * Top-level Application class for Telecom.
 */
public final class TelecomApp extends Application {

    /**
     * The Telecom service implementation.
     */
@@ -49,16 +48,6 @@ public final class TelecomApp extends Application {
     */
    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 @@ public final class TelecomApp extends Application {
            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);
        }
    }

+5 −10
Original line number Diff line number Diff line
@@ -38,13 +38,6 @@ public final class TelecomBroadcastReceiver extends BroadcastReceiver {
    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 @@ public final class TelecomBroadcastReceiver extends BroadcastReceiver {

        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 @@ public final class TelecomBroadcastReceiver extends BroadcastReceiver {
        } 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 @@ public final class TelecomBroadcastReceiver extends BroadcastReceiver {

        // Clear the missed call notification and call log entries.
        } else if (ACTION_CLEAR_MISSED_CALLS.equals(action)) {
            mMissedCallNotifier.clearMissedCalls();
            missedCallNotifier.clearMissedCalls();
        }
    }