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

Commit 84a7063c authored by Tyler Gunn's avatar Tyler Gunn Committed by Automerger Merge Worker
Browse files

Merge "Set calling ownerinfo for outbound connection service RPCs." into...

Merge "Set calling ownerinfo for outbound connection service RPCs." into rvc-dev am: e2883de2 am: 3ff3f6ec

Change-Id: Ieeb03f663f992bdeba0e293412ab99354c368adf
parents e865e3f0 3ff3f6ec
Loading
Loading
Loading
Loading
+61 −38
Original line number Original line Diff line number Diff line
@@ -69,6 +69,8 @@ import java.util.concurrent.ConcurrentHashMap;
public class ConnectionServiceWrapper extends ServiceBinder implements
public class ConnectionServiceWrapper extends ServiceBinder implements
        ConnectionServiceFocusManager.ConnectionServiceFocus {
        ConnectionServiceFocusManager.ConnectionServiceFocus {


    private static final String TELECOM_ABBREVIATION = "cast";

    private final class Adapter extends IConnectionServiceAdapter.Stub {
    private final class Adapter extends IConnectionServiceAdapter.Stub {


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


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


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


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


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


    private void logOutgoing(String msg, Object... 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);
                + msg, params);
    }
    }


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


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


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


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


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


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


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


@@ -450,32 +448,4 @@ public abstract class ServiceBinder {
     * Removes the service interface before the service is unbound.
     * Removes the service interface before the service is unbound.
     */
     */
    protected abstract void removeServiceInterface();
    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(""));
    }
}
}