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

Commit b02ef450 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Set calling ownerinfo for outbound connection service RPCs.

For all outbound calls from Telecom into the connection service, ensure
we specify an originating package abbreviation as part of the external
session info.

Also, cleaned up the debug-level logging in ConnectionServiceWrapper to
use the same package abbreviations we're now using elsewhere.

Test: Manual testing of connection manager logging.
Bug: 153899641
Change-Id: I63a2520402a13a31fcb7f559f8328466316d9603
parent 832c26fb
Loading
Loading
Loading
Loading
+61 −38
Original line number Diff line number Diff line
@@ -69,6 +69,8 @@ import java.util.concurrent.ConcurrentHashMap;
public class ConnectionServiceWrapper extends ServiceBinder implements
        ConnectionServiceFocusManager.ConnectionServiceFocus {

    private static final String TELECOM_ABBREVIATION = "cast";

    private final class Adapter extends IConnectionServiceAdapter.Stub {

        @Override
@@ -1232,7 +1234,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                            connectionRequest,
                            call.shouldAttachToExistingConnection(),
                            call.isUnknown(),
                            Log.getExternalSession());
                            Log.getExternalSession(TELECOM_ABBREVIATION));

                } catch (RemoteException e) {
                    Log.e(this, e, "Failure to createConference -- %s", getComponentName());
@@ -1321,7 +1323,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                            connectionRequest,
                            call.shouldAttachToExistingConnection(),
                            call.isUnknown(),
                            Log.getExternalSession());
                            Log.getExternalSession(TELECOM_ABBREVIATION));

                } catch (RemoteException e) {
                    Log.e(this, e, "Failure to createConnection -- %s", getComponentName());
@@ -1368,7 +1370,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                                        callId,
                                        false),
                                call.isIncoming(),
                                Log.getExternalSession());
                                Log.getExternalSession(TELECOM_ABBREVIATION));
                        call.setDisconnectCause(new DisconnectCause(DisconnectCause.CANCELED));
                        call.disconnect();
                    } catch (RemoteException e) {
@@ -1414,7 +1416,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                                        callId,
                                        false),
                                call.isIncoming(),
                                Log.getExternalSession());
                                Log.getExternalSession(TELECOM_ABBREVIATION));
                        call.setDisconnectCause(new DisconnectCause(DisconnectCause.CANCELED));
                        call.disconnect();
                    } catch (RemoteException e) {
@@ -1452,7 +1454,9 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                                        call.getIntentExtras(),
                                        call.getVideoState(),
                                        callId,
                                        false), reason, Log.getExternalSession());
                                        false),
                                reason,
                                Log.getExternalSession(TELECOM_ABBREVIATION));
                    } catch (RemoteException e) {
                    }
                }
@@ -1480,7 +1484,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                    try {
                        mServiceInterface.handoverComplete(
                                callId,
                                Log.getExternalSession());
                                Log.getExternalSession(TELECOM_ABBREVIATION));
                    } catch (RemoteException e) {
                    }
                }
@@ -1506,7 +1510,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("abort")) {
            try {
                logOutgoing("abort %s", callId);
                mServiceInterface.abort(callId, Log.getExternalSession());
                mServiceInterface.abort(callId, Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException e) {
            }
        }
@@ -1520,7 +1524,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("silence")) {
            try {
                logOutgoing("silence %s", callId);
                mServiceInterface.silence(callId, Log.getExternalSession());
                mServiceInterface.silence(callId, Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException e) {
            }
        }
@@ -1532,7 +1536,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("hold")) {
            try {
                logOutgoing("hold %s", callId);
                mServiceInterface.hold(callId, Log.getExternalSession());
                mServiceInterface.hold(callId, Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException e) {
            }
        }
@@ -1544,7 +1548,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("unhold")) {
            try {
                logOutgoing("unhold %s", callId);
                mServiceInterface.unhold(callId, Log.getExternalSession());
                mServiceInterface.unhold(callId, Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException e) {
            }
        }
@@ -1558,7 +1562,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            try {
                logOutgoing("onCallAudioStateChanged %s %s", callId, audioState);
                mServiceInterface.onCallAudioStateChanged(callId, audioState,
                        Log.getExternalSession());
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException e) {
            }
        }
@@ -1570,7 +1574,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("disconnect")) {
            try {
                logOutgoing("disconnect %s", callId);
                mServiceInterface.disconnect(callId, Log.getExternalSession());
                mServiceInterface.disconnect(callId, Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException e) {
            }
        }
@@ -1583,9 +1587,10 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            try {
                logOutgoing("answer %s %d", callId, videoState);
                if (VideoProfile.isAudioOnly(videoState)) {
                    mServiceInterface.answer(callId, Log.getExternalSession());
                    mServiceInterface.answer(callId, Log.getExternalSession(TELECOM_ABBREVIATION));
                } else {
                    mServiceInterface.answerVideo(callId, videoState, Log.getExternalSession());
                    mServiceInterface.answerVideo(callId, videoState,
                            Log.getExternalSession(TELECOM_ABBREVIATION));
                }
            } catch (RemoteException e) {
            }
@@ -1598,7 +1603,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("deflect")) {
            try {
                logOutgoing("deflect %s", callId);
                mServiceInterface.deflect(callId, address, Log.getExternalSession());
                mServiceInterface.deflect(callId, address,
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException e) {
            }
        }
@@ -1613,9 +1619,10 @@ public class ConnectionServiceWrapper extends ServiceBinder implements

                if (rejectWithMessage && call.can(
                        Connection.CAPABILITY_CAN_SEND_RESPONSE_VIA_CONNECTION)) {
                    mServiceInterface.rejectWithMessage(callId, message, Log.getExternalSession());
                    mServiceInterface.rejectWithMessage(callId, message,
                            Log.getExternalSession(TELECOM_ABBREVIATION));
                } else {
                    mServiceInterface.reject(callId, Log.getExternalSession());
                    mServiceInterface.reject(callId, Log.getExternalSession(TELECOM_ABBREVIATION));
                }
            } catch (RemoteException e) {
            }
@@ -1629,7 +1636,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            try {
                logOutgoing("rejectReason %s, %d", callId, rejectReason);

                mServiceInterface.rejectWithReason(callId, rejectReason, Log.getExternalSession());
                mServiceInterface.rejectWithReason(callId, rejectReason,
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException e) {
            }
        }
@@ -1642,7 +1650,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            try {
                logOutgoing("transfer %s", callId);
                mServiceInterface.transfer(callId, number, isConfirmationRequired,
                        Log.getExternalSession());
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException e) {
            }
        }
@@ -1656,7 +1664,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            try {
                logOutgoing("consultativeTransfer %s", callId);
                mServiceInterface.consultativeTransfer(callId, otherCallId,
                        Log.getExternalSession());
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException e) {
            }
        }
@@ -1668,7 +1676,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("playDtmfTone")) {
            try {
                logOutgoing("playDtmfTone %s %c", callId, digit);
                mServiceInterface.playDtmfTone(callId, digit, Log.getExternalSession());
                mServiceInterface.playDtmfTone(callId, digit,
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException e) {
            }
        }
@@ -1680,7 +1689,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("stopDtmfTone")) {
            try {
                logOutgoing("stopDtmfTone %s", callId);
                mServiceInterface.stopDtmfTone(callId, Log.getExternalSession());
                mServiceInterface.stopDtmfTone(callId,
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException e) {
            }
        }
@@ -1727,7 +1737,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("onPostDialContinue")) {
            try {
                logOutgoing("onPostDialContinue %s %b", callId, proceed);
                mServiceInterface.onPostDialContinue(callId, proceed, Log.getExternalSession());
                mServiceInterface.onPostDialContinue(callId, proceed,
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException ignored) {
            }
        }
@@ -1739,7 +1750,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && otherCallId != null && isServiceValid("conference")) {
            try {
                logOutgoing("conference %s %s", callId, otherCallId);
                mServiceInterface.conference(callId, otherCallId, Log.getExternalSession());
                mServiceInterface.conference(callId, otherCallId,
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException ignored) {
            }
        }
@@ -1750,7 +1762,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("splitFromConference")) {
            try {
                logOutgoing("splitFromConference %s", callId);
                mServiceInterface.splitFromConference(callId, Log.getExternalSession());
                mServiceInterface.splitFromConference(callId,
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException ignored) {
            }
        }
@@ -1761,7 +1774,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("mergeConference")) {
            try {
                logOutgoing("mergeConference %s", callId);
                mServiceInterface.mergeConference(callId, Log.getExternalSession());
                mServiceInterface.mergeConference(callId,
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException ignored) {
            }
        }
@@ -1772,7 +1786,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("swapConference")) {
            try {
                logOutgoing("swapConference %s", callId);
                mServiceInterface.swapConference(callId, Log.getExternalSession());
                mServiceInterface.swapConference(callId,
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException ignored) {
            }
        }
@@ -1784,7 +1799,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            try {
                logOutgoing("addConferenceParticipants %s", callId);
                mServiceInterface.addConferenceParticipants(callId, participants,
                        Log.getExternalSession());
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException ignored) {
            }
        }
@@ -1796,7 +1811,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("pullExternalCall")) {
            try {
                logOutgoing("pullExternalCall %s", callId);
                mServiceInterface.pullExternalCall(callId, Log.getExternalSession());
                mServiceInterface.pullExternalCall(callId,
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException ignored) {
            }
        }
@@ -1807,7 +1823,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("sendCallEvent")) {
            try {
                logOutgoing("sendCallEvent %s %s", callId, event);
                mServiceInterface.sendCallEvent(callId, event, extras, Log.getExternalSession());
                mServiceInterface.sendCallEvent(callId, event, extras,
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException ignored) {
            }
        }
@@ -1818,7 +1835,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("onExtrasChanged")) {
            try {
                logOutgoing("onExtrasChanged %s %s", callId, extras);
                mServiceInterface.onExtrasChanged(callId, extras, Log.getExternalSession());
                mServiceInterface.onExtrasChanged(callId, extras,
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException ignored) {
            }
        }
@@ -1829,7 +1847,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("startRtt")) {
            try {
                logOutgoing("startRtt: %s %s %s", callId, fromInCall, toInCall);
                mServiceInterface.startRtt(callId, fromInCall, toInCall, Log.getExternalSession());
                mServiceInterface.startRtt(callId, fromInCall, toInCall,
                        Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException ignored) {
            }
        }
@@ -1840,7 +1859,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
        if (callId != null && isServiceValid("stopRtt")) {
            try {
                logOutgoing("stopRtt: %s", callId);
                mServiceInterface.stopRtt(callId, Log.getExternalSession());
                mServiceInterface.stopRtt(callId, Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException ignored) {
            }
        }
@@ -1853,7 +1872,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            try {
                logOutgoing("respondToRttRequest: %s %s %s", callId, fromInCall, toInCall);
                mServiceInterface.respondToRttUpgradeRequest(
                        callId, fromInCall, toInCall, Log.getExternalSession());
                        callId, fromInCall, toInCall, Log.getExternalSession(TELECOM_ABBREVIATION));
            } catch (RemoteException ignored) {
            }
        }
@@ -1892,7 +1911,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            @Override
            public void onSuccess() {
                try {
                    mServiceInterface.connectionServiceFocusLost(Log.getExternalSession());
                    mServiceInterface.connectionServiceFocusLost(
                            Log.getExternalSession(TELECOM_ABBREVIATION));
                } catch (RemoteException ignored) {
                    Log.d(this, "failed to inform the focus lost event");
                }
@@ -1910,7 +1930,8 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
            @Override
            public void onSuccess() {
                try {
                    mServiceInterface.connectionServiceFocusGained(Log.getExternalSession());
                    mServiceInterface.connectionServiceFocusGained(
                            Log.getExternalSession(TELECOM_ABBREVIATION));
                } catch (RemoteException ignored) {
                    Log.d(this, "failed to inform the focus gained event");
                }
@@ -2002,12 +2023,14 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
    }

    private void logIncoming(String msg, Object... params) {
        Log.d(this, "ConnectionService -> Telecom[" + mComponentName.flattenToShortString() + "]: "
        // Keep these as debug; the incoming logging is traced on a package level through the
        // session logging.
        Log.d(this, "CS -> TC[" + Log.getPackageAbbreviation(mComponentName) + "]: "
                + msg, params);
    }

    private void logOutgoing(String msg, Object... params) {
        Log.d(this, "Telecom -> ConnectionService[" + mComponentName.flattenToShortString() + "]: "
        Log.d(this, "TC -> CS[" + Log.getPackageAbbreviation(mComponentName) + "]: "
                + msg, params);
    }

+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ class InCallAdapter extends IInCallAdapter.Stub {
        mCallIdMapper = callIdMapper;
        mLock = lock;
        mOwnerPackageName = ownerPackageName;
        mOwnerPackageAbbreviation = ServiceBinder.getPackageAbbreviation(ownerPackageName);
        mOwnerPackageAbbreviation = Log.getPackageAbbreviation(ownerPackageName);
    }

    @Override
+4 −5
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo;
@@ -195,7 +194,7 @@ public class InCallController extends CallsManagerListenerBase {
        private final ServiceConnection mServiceConnection = new ServiceConnection() {
            @Override
            public void onServiceConnected(ComponentName name, IBinder service) {
                Log.startSession("ICSBC.oSC", ServiceBinder.getPackageAbbreviation(name));
                Log.startSession("ICSBC.oSC", Log.getPackageAbbreviation(name));
                synchronized (mLock) {
                    try {
                        Log.d(this, "onServiceConnected: %s %b %b", name, mIsBound, mIsConnected);
@@ -212,7 +211,7 @@ public class InCallController extends CallsManagerListenerBase {

            @Override
            public void onServiceDisconnected(ComponentName name) {
                Log.startSession("ICSBC.oSD", ServiceBinder.getPackageAbbreviation(name));
                Log.startSession("ICSBC.oSD", Log.getPackageAbbreviation(name));
                synchronized (mLock) {
                    try {
                        Log.d(this, "onDisconnected: %s", name);
@@ -226,7 +225,7 @@ public class InCallController extends CallsManagerListenerBase {

            @Override
            public void onNullBinding(ComponentName name) {
                Log.startSession("ICSBC.oNB", ServiceBinder.getPackageAbbreviation(name));
                Log.startSession("ICSBC.oNB", Log.getPackageAbbreviation(name));
                synchronized (mLock) {
                    try {
                        Log.d(this, "onNullBinding: %s", name);
@@ -241,7 +240,7 @@ public class InCallController extends CallsManagerListenerBase {

            @Override
            public void onBindingDied(ComponentName name) {
                Log.startSession("ICSBC.oBD", ServiceBinder.getPackageAbbreviation(name));
                Log.startSession("ICSBC.oBD", Log.getPackageAbbreviation(name));
                synchronized (mLock) {
                    try {
                        Log.d(this, "onBindingDied: %s", name);
+4 −34
Original line number Diff line number Diff line
@@ -30,11 +30,9 @@ import android.util.ArraySet;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.Preconditions;

import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

/**
 * Abstract class to perform the work of binding and unbinding to the specified service interface.
@@ -123,7 +121,7 @@ public abstract class ServiceBinder {
            try {
                synchronized (mLock) {
                    Log.startSession("SDR.bD",
                            ServiceBinder.getPackageAbbreviation(mComponentName));
                            Log.getPackageAbbreviation(mComponentName));
                    Log.i(this, "binderDied: ConnectionService %s died.", mComponentName);
                    logServiceDisconnected("binderDied");
                    handleDisconnect();
@@ -147,7 +145,7 @@ public abstract class ServiceBinder {
        @Override
        public void onServiceConnected(ComponentName componentName, IBinder binder) {
            try {
                Log.startSession("SBC.oSC", getPackageAbbreviation(componentName));
                Log.startSession("SBC.oSC", Log.getPackageAbbreviation(componentName));
                synchronized (mLock) {
                    Log.i(this, "Service bound %s", componentName);

@@ -185,7 +183,7 @@ public abstract class ServiceBinder {
        @Override
        public void onServiceDisconnected(ComponentName componentName) {
            try {
                Log.startSession("SBC.oSD", getPackageAbbreviation(componentName));
                Log.startSession("SBC.oSD", Log.getPackageAbbreviation(componentName));
                synchronized (mLock) {
                    logServiceDisconnected("onServiceDisconnected");
                    handleDisconnect();
@@ -269,7 +267,7 @@ public abstract class ServiceBinder {
        mLock = lock;
        mServiceAction = serviceAction;
        mComponentName = componentName;
        mPackageAbbreviation = getPackageAbbreviation(componentName);
        mPackageAbbreviation = Log.getPackageAbbreviation(componentName);
        mUserHandle = userHandle;
    }

@@ -450,32 +448,4 @@ public abstract class ServiceBinder {
     * Removes the service interface before the service is unbound.
     */
    protected abstract void removeServiceInterface();

    /**
     * Generates an abbreviated version of the package name from a component.
     * E.g. com.android.phone becomes cap
     * @param componentName The component name to abbreviate.
     * @return Abbreviation of empty string if component is null.
     */
    public static String getPackageAbbreviation(ComponentName componentName) {
        if (componentName == null) {
            return "";
        }
        return getPackageAbbreviation(componentName.getPackageName());
    }

    /**
     * Generates an abbreviated version of the package name.
     * E.g. com.android.phone becomes cap
     * @param packageName The packageName name to abbreviate.
     * @return Abbreviation of empty string if package is null.
     */
    public static String getPackageAbbreviation(String packageName) {
        if (packageName == null) {
            return "";
        }
        return Arrays.stream(packageName.split("\\."))
                .map(s -> s.substring(0,1))
                .collect(Collectors.joining(""));
    }
}