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

Commit 6908075d authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Handle Telecom binder death." into oc-mr1-dev

parents 20bbecfd f7d32b57
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1812,10 +1812,12 @@ public class CallsManager extends Call.ListenerBase
     */
    void handleConnectionServiceDeath(ConnectionServiceWrapper service) {
        if (service != null) {
            Log.i(this, "handleConnectionServiceDeath: service %s died", service);
            for (Call call : mCalls) {
                if (call.getConnectionService() == service) {
                    if (call.getState() != CallState.DISCONNECTED) {
                        markCallAsDisconnected(call, new DisconnectCause(DisconnectCause.ERROR));
                        markCallAsDisconnected(call, new DisconnectCause(DisconnectCause.ERROR,
                                "CS_DEATH"));
                    }
                    markCallAsRemoved(call);
                }
+1 −1
Original line number Diff line number Diff line
@@ -1375,7 +1375,7 @@ public class ConnectionServiceWrapper extends ServiceBinder {
            mPendingResponses.clear();
            for (int i = 0; i < responses.length; i++) {
                responses[i].handleCreateConnectionFailure(
                        new DisconnectCause(DisconnectCause.ERROR));
                        new DisconnectCause(DisconnectCause.ERROR, "CS_DEATH"));
            }
        }
        mCallIdMapper.clear();
+33 −30
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import android.telecom.Log;
import android.telecom.Logging.Session;

import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.Preconditions;

// TODO: Needed for move to system service: import com.android.internal.R;

@@ -86,6 +85,7 @@ public class DtmfLocalTonePlayer {

        @Override
        public void handleMessage(Message msg) {
            try {
                if (msg.obj instanceof Session) {
                    Log.continueSession((Session) msg.obj, "DLTP.TH");
                }
@@ -118,6 +118,9 @@ public class DtmfLocalTonePlayer {
                        Log.w(this, "Unknown message: %d", msg.what);
                        break;
                }
            } finally {
                Log.endSession();
            }
        }
    }

+49 −9
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.RemoteException;
import android.os.UserHandle;
import android.telecom.Log;
import android.text.TextUtils;
@@ -104,6 +105,29 @@ abstract class ServiceBinder {
        }
    }

    private class ServiceDeathRecipient implements IBinder.DeathRecipient {

        private ComponentName mComponentName;

        ServiceDeathRecipient(ComponentName name) {
            mComponentName = name;
        }

        @Override
        public void binderDied() {
            try {
                synchronized (mLock) {
                    Log.startSession("SDR.bD");
                    Log.i(this, "binderDied: ConnectionService %s died.", mComponentName);
                    logServiceDisconnected("binderDied");
                    handleDisconnect();
                }
            } finally {
                Log.endSession();
            }
        }
    }

    private final class ServiceBinderConnection implements ServiceConnection {
        /**
         * The initial call for which the service was bound.
@@ -132,10 +156,20 @@ abstract class ServiceBinder {
                        handleFailedConnection();
                        return;
                    }

                    if (binder != null) {
                        mServiceDeathRecipient = new ServiceDeathRecipient(componentName);
                        try {
                            binder.linkToDeath(mServiceDeathRecipient, 0);
                            mServiceConnection = this;
                            setBinder(binder);
                            handleSuccessfulConnection();
                        } catch (RemoteException e) {
                            Log.w(this, "onServiceConnected: %s died.");
                            if (mServiceDeathRecipient != null) {
                                mServiceDeathRecipient.binderDied();
                            }
                        }
                    }
                }
            } finally {
                Log.endSession();
@@ -148,11 +182,7 @@ abstract class ServiceBinder {
                Log.startSession("SBC.oSD");
                synchronized (mLock) {
                    logServiceDisconnected("onServiceDisconnected");

                    mServiceConnection = null;
                    clearAbort();

                    handleServiceDisconnected();
                    handleDisconnect();
                }
            } finally {
                Log.endSession();
@@ -160,6 +190,13 @@ abstract class ServiceBinder {
        }
    }

    private void handleDisconnect() {
        mServiceConnection = null;
        clearAbort();

        handleServiceDisconnected();
    }

    /** The application context. */
    private final Context mContext;

@@ -178,6 +215,9 @@ abstract class ServiceBinder {
    /** Used to bind and unbind from the service. */
    private ServiceConnection mServiceConnection;

    /** Used to handle death of the service. */
    private ServiceDeathRecipient mServiceDeathRecipient;

    /** {@link UserHandle} to use for binding, to support work profiles and multi-user. */
    private UserHandle mUserHandle;