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

Commit 344b2eb9 authored by Tyler Gunn's avatar Tyler Gunn Committed by android-build-merger
Browse files

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

am: 4a65d03d

Change-Id: I80a78627e7998cf6180cfd28e0f6d3616f03c519
parents af6e532d 4a65d03d
Loading
Loading
Loading
Loading
+0 −6
Original line number Original line Diff line number Diff line
@@ -295,12 +295,6 @@
                android:exported="false"
                android:exported="false"
                android:process=":ui" />
                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"
        <service android:name=".components.BluetoothPhoneService"
                android:singleUser="true"
                android:singleUser="true"
                android:process="system">
                android:process="system">
+27 −0
Original line number Original line Diff line number Diff line
@@ -1472,6 +1472,33 @@ public class TelecomServiceImpl {
                Log.endSession();
                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 Original line 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 Original line 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
     * Potentially trampolines the intent to Telecom via TelecomServiceImpl.
     * user.  If the caller is local to the Telecom service, we send the intent to Telecom without
     * If the caller is local to the Telecom service, we send the intent to Telecom without
     * rebroadcasting it.
     * sending it through TelecomServiceImpl.
     */
     */
    private boolean sendIntentToDestination(Intent intent, boolean isLocalInvocation) {
    private boolean sendIntentToDestination(Intent intent, boolean isLocalInvocation) {
        intent.putExtra(CallIntentProcessor.KEY_IS_INCOMING_CALL, false);
        intent.putExtra(CallIntentProcessor.KEY_IS_INCOMING_CALL, false);
        intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        intent.setClass(mContext, PrimaryCallReceiver.class);
        if (isLocalInvocation) {
        if (isLocalInvocation) {
            // We are invoking this from TelecomServiceImpl, so TelecomSystem is available.  Don't
            // 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.
            // 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
            // 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.
            // process; we need to trampoline to TelecomSystem in the system server process.
            Log.i(this, "sendIntentToDestination: trampoline to Telecom.");
            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;
        return true;
    }
    }
+7 −2
Original line number Original line Diff line number Diff line
@@ -1053,8 +1053,13 @@ public class BasicCallTests extends TelecomSystemTest {
                mConnectionServiceFixtureA);
                mConnectionServiceFixtureA);


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


    /**
    /**
Loading