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

Commit 43541c16 authored by Santos Cordon's avatar Santos Cordon
Browse files

Only initialize Telecomm for the primary user.

Bug: 17579886
Change-Id: Ie88229bddbe84ba3103a1c423b8d4504849d8a08
parent 1c5926fc
Loading
Loading
Loading
Loading
+31 −40
Original line number Diff line number Diff line
@@ -28,9 +28,6 @@ import android.os.ServiceManager;
 */
public final class TelecomApp extends Application {

    /** Singleton instance of TelecomApp. */
    private static TelecomApp sInstance;

    /**
     * The Telecom service implementation.
     */
@@ -58,16 +55,18 @@ public final class TelecomApp extends Application {
    private TelecomBroadcastReceiver mTelecomBroadcastReceiver;

    /**
     * The {@link android.telecomm.PhoneAccount} broadcast receiver.
     * The {@link android.telecom.PhoneAccount} broadcast receiver.
     */
    private PhoneAccountBroadcastReceiver mPhoneAccountBroadcastReceiver;

    /** {@inheritDoc} */
    @Override public void onCreate() {
    @Override
    public void onCreate() {
        super.onCreate();
        sInstance = this;

        // Note: This style of initialization mimics what will be performed once Telecom is moved
        if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
            // Note: This style of initialization mimics what will be performed once Telecom is
            // moved
            // to run in the system service. The emphasis is on ensuring that initialization of all
            // telecom classes happens in one place without relying on Singleton initialization.
            mMissedCallNotifier = new MissedCallNotifier(this);
@@ -79,12 +78,10 @@ public final class TelecomApp extends Application {
            mTelecomService = new TelecomServiceImpl(mMissedCallNotifier, mPhoneAccountRegistrar,
                    mCallsManager, this);
            ServiceManager.addService(Context.TELECOM_SERVICE, mTelecomService);
        mPhoneAccountBroadcastReceiver = new PhoneAccountBroadcastReceiver(mPhoneAccountRegistrar);
            mPhoneAccountBroadcastReceiver = new PhoneAccountBroadcastReceiver(
                    mPhoneAccountRegistrar);
            mTelecomBroadcastReceiver = new TelecomBroadcastReceiver(mMissedCallNotifier);

        if (UserHandle.myUserId() == UserHandle.USER_OWNER) {
            //TelecomServiceImpl.init(mMissedCallNotifier, mPhoneAccountRegistrar);
        }
            // Setup broadcast listener for telecom intents.
            IntentFilter telecomFilter = new IntentFilter();
            telecomFilter.addAction(TelecomBroadcastReceiver.ACTION_CALL_BACK_FROM_NOTIFICATION);
@@ -97,12 +94,6 @@ public final class TelecomApp extends Application {
            phoneAccountFilter.addDataScheme("package");
            registerReceiver(mPhoneAccountBroadcastReceiver, phoneAccountFilter);
        }

    public static TelecomApp getInstance() {
        if (null == sInstance) {
            throw new IllegalStateException("No TelecomApp running.");
        }
        return sInstance;
    }

    MissedCallNotifier getMissedCallNotifier() {