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

Commit 7b42eed0 authored by Santos Cordon's avatar Santos Cordon Committed by Android Git Automerger
Browse files

am 2dac2b7d: Merge "Call onPhoneDestroyed when the service is unbound." into lmp-dev

* commit '2dac2b7dc74794f8d1bccb2a34584ce9c25eed72':
  Call onPhoneDestroyed when the service is unbound.
parents d81c4b41 0e85f355
Loading
Loading
Loading
Loading
+10 −0
Original line number Original line Diff line number Diff line
@@ -743,6 +743,16 @@ public final class Call {
        fireStartActivity(intent);
        fireStartActivity(intent);
    }
    }


    /** {@hide} */
    final void internalSetDisconnected() {
        if (mState != Call.STATE_DISCONNECTED) {
            mState = Call.STATE_DISCONNECTED;
            fireStateChanged(mState);
            fireCallDestroyed();
            mPhone.internalRemoveCall(this);
        }
    }

    private void fireStateChanged(int newState) {
    private void fireStateChanged(int newState) {
        for (Listener listener : mListeners) {
        for (Listener listener : mListeners) {
            listener.onStateChanged(this, newState);
            listener.onStateChanged(this, newState);
+10 −0
Original line number Original line Diff line number Diff line
@@ -163,6 +163,16 @@ public abstract class InCallService extends Service {
        return new InCallServiceBinder();
        return new InCallServiceBinder();
    }
    }


    @Override
    public boolean onUnbind(Intent intent) {
        Phone oldPhone = mPhone;
        mPhone = null;

        oldPhone.destroy();
        onPhoneDestroyed(oldPhone);
        return false;
    }

    /**
    /**
     * Obtain the {@code Phone} associated with this {@code InCallService}.
     * Obtain the {@code Phone} associated with this {@code InCallService}.
     *
     *
+13 −2
Original line number Original line Diff line number Diff line
@@ -20,7 +20,6 @@ import android.annotation.SystemApi;
import android.app.PendingIntent;
import android.app.PendingIntent;
import android.util.ArrayMap;
import android.util.ArrayMap;


import java.util.ArrayList;
import java.util.Collections;
import java.util.Collections;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
@@ -83,7 +82,7 @@ public final class Phone {


    // A List allows us to keep the Calls in a stable iteration order so that casually developed
    // A List allows us to keep the Calls in a stable iteration order so that casually developed
    // user interface components do not incur any spurious jank
    // user interface components do not incur any spurious jank
    private final List<Call> mCalls = new ArrayList<>();
    private final List<Call> mCalls = new CopyOnWriteArrayList<>();


    // An unmodifiable view of the above List can be safely shared with subclass implementations
    // An unmodifiable view of the above List can be safely shared with subclass implementations
    private final List<Call> mUnmodifiableCalls = Collections.unmodifiableList(mCalls);
    private final List<Call> mUnmodifiableCalls = Collections.unmodifiableList(mCalls);
@@ -159,6 +158,18 @@ public final class Phone {
        }
        }
    }
    }


    /**
     * Called to destroy the phone and cleanup any lingering calls.
     * @hide
     */
    final void destroy() {
        for (Call call : mCalls) {
            if (call.getState() != Call.STATE_DISCONNECTED) {
                call.internalSetDisconnected();
            }
        }
    }

    /**
    /**
     * Adds a listener to this {@code Phone}.
     * Adds a listener to this {@code Phone}.
     *
     *