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

Commit 4a65d03d authored by Tyler Gunn's avatar Tyler Gunn Committed by Gerrit Code Review
Browse files

Merge "Eliminate dependence on broadcasts to trampoline calls to Telecom."

parents 8d919cb0 d0b48848
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -295,12 +295,6 @@
                android:exported="false"
                android:process=":ui" />

        <receiver android:name=".components.PrimaryCallReceiver"
                android:exported="true"
                android:permission="android.permission.MODIFY_PHONE_STATE"
                android:process="system">
        </receiver>

        <service android:name=".components.BluetoothPhoneService"
                android:singleUser="true"
                android:process="system">
+27 −0
Original line number Diff line number Diff line
@@ -1472,6 +1472,33 @@ public class TelecomServiceImpl {
                Log.endSession();
            }
        }

        /**
         * See {@link TelecomManager#handleCallIntent(Intent)} ()}
         */
        @Override
        public void handleCallIntent(Intent intent) {
            try {
                Log.startSession("TSI.hCI");
                synchronized (mLock) {
                    int callingUid = Binder.getCallingUid();

                    long token = Binder.clearCallingIdentity();
                    if (callingUid != Process.myUid()) {
                        throw new SecurityException("handleCallIntent is for Telecom only");
                    }
                    try {
                        Log.i(this, "handleCallIntent: handling call intent");
                        mCallIntentProcessorAdapter.processOutgoingCallIntent(mContext,
                                mCallsManager, intent);
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
                }
            } finally {
                Log.endSession();
            }
        }
    };

    /**
+0 −31
Original line number Diff line number Diff line
package com.android.server.telecom.components;

import com.android.server.telecom.TelecomSystem;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telecom.Log;

/**
 * Single point of entry for all outgoing and incoming calls. {@link UserCallIntentProcessor} serves
 * as a trampoline that captures call intents for individual users and forwards it to
 * the {@link PrimaryCallReceiver} which interacts with the rest of Telecom, both of which run only as
 * the primary user.
 */
public class PrimaryCallReceiver extends BroadcastReceiver implements TelecomSystem.Component {

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.startSession("PCR.oR");
        synchronized (getTelecomSystem().getLock()) {
            getTelecomSystem().getCallIntentProcessor().processIntent(intent);
        }
        Log.endSession();
    }

    @Override
    public TelecomSystem getTelecomSystem() {
        return TelecomSystem.getInstance();
    }
}
+5 −5
Original line number Diff line number Diff line
@@ -189,14 +189,13 @@ public class UserCallIntentProcessor {
    }

    /**
     * Potentially trampolines the intent to the broadcast receiver that runs only as the primary
     * user.  If the caller is local to the Telecom service, we send the intent to Telecom without
     * rebroadcasting it.
     * Potentially trampolines the intent to Telecom via TelecomServiceImpl.
     * If the caller is local to the Telecom service, we send the intent to Telecom without
     * sending it through TelecomServiceImpl.
     */
    private boolean sendIntentToDestination(Intent intent, boolean isLocalInvocation) {
        intent.putExtra(CallIntentProcessor.KEY_IS_INCOMING_CALL, false);
        intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        intent.setClass(mContext, PrimaryCallReceiver.class);
        if (isLocalInvocation) {
            // We are invoking this from TelecomServiceImpl, so TelecomSystem is available.  Don't
            // bother trampolining the intent, just sent it directly to the call intent processor.
@@ -209,7 +208,8 @@ public class UserCallIntentProcessor {
            // We're calling from the UserCallActivity, so the TelecomSystem is not in the same
            // process; we need to trampoline to TelecomSystem in the system server process.
            Log.i(this, "sendIntentToDestination: trampoline to Telecom.");
            mContext.sendBroadcastAsUser(intent, UserHandle.SYSTEM);
            TelecomManager tm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
            tm.handleCallIntent(intent);
        }
        return true;
    }
+7 −2
Original line number Diff line number Diff line
@@ -1053,8 +1053,13 @@ public class BasicCallTests extends TelecomSystemTest {
                mConnectionServiceFixtureA);

        // Should have reverted back to earpiece.
        assertEquals(CallAudioState.ROUTE_EARPIECE,
                mInCallServiceFixtureX.mCallAudioState.getRoute());
        assertTrueWithTimeout(new Predicate<Void>() {
            @Override
            public boolean apply(Void aVoid) {
                return mInCallServiceFixtureX.mCallAudioState.getRoute()
                        == CallAudioState.ROUTE_EARPIECE;
            }
        });
    }

    /**
Loading