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

Commit 6c912b7d authored by Santos Cordon's avatar Santos Cordon
Browse files

Make add-call a global property of telecom. (1/4)

ADD_CALL didn't make sense as a property of Connection or Call.
This changes it to be a global property instead.

Bug: 18285352
Change-Id: I658e7a6977a848600272cde2914612c8691bb801
parent a0ecc714
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -28314,8 +28314,7 @@ package android.telecom {
  public final class PhoneCapabilities {
    method public static java.lang.String toString(int);
    field public static final int ADD_CALL = 16; // 0x10
    field public static final int ALL = 12543; // 0x30ff
    field public static final int ALL = 12527; // 0x30ef
    field public static final int DISCONNECT_FROM_CONFERENCE = 8192; // 0x2000
    field public static final int HOLD = 1; // 0x1
    field public static final int MANAGE_CONFERENCE = 128; // 0x80
+10 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ public abstract class InCallService extends Service {
    private static final int MSG_SET_POST_DIAL_WAIT = 4;
    private static final int MSG_ON_AUDIO_STATE_CHANGED = 5;
    private static final int MSG_BRING_TO_FOREGROUND = 6;
    private static final int MSG_ON_CAN_ADD_CALL_CHANGED = 7;

    /** Default Handler used to consolidate binder method calls onto a single thread. */
    private final Handler mHandler = new Handler(Looper.getMainLooper()) {
@@ -91,6 +92,9 @@ public abstract class InCallService extends Service {
                case MSG_BRING_TO_FOREGROUND:
                    mPhone.internalBringToForeground(msg.arg1 == 1);
                    break;
                case MSG_ON_CAN_ADD_CALL_CHANGED:
                    mPhone.internalSetCanAddCall(msg.arg1 == 1);
                    break;
                default:
                    break;
            }
@@ -136,6 +140,12 @@ public abstract class InCallService extends Service {
        public void bringToForeground(boolean showDialpad) {
            mHandler.obtainMessage(MSG_BRING_TO_FOREGROUND, showDialpad ? 1 : 0, 0).sendToTarget();
        }

        @Override
        public void onCanAddCallChanged(boolean canAddCall) {
            mHandler.obtainMessage(MSG_ON_CAN_ADD_CALL_CHANGED, canAddCall ? 1 : 0, 0)
                    .sendToTarget();
        }
    }

    private Phone mPhone;
+35 −0
Original line number Diff line number Diff line
@@ -74,6 +74,16 @@ public final class Phone {
         * @param call A newly removed {@code Call}.
         */
        public void onCallRemoved(Phone phone, Call call) { }

        /**
         * Called when the {@code Phone} ability to add more calls changes.  If the phone cannot
         * support more calls then {@code canAddCall} is set to {@code false}.  If it can, then it
         * is set to {@code true}.
         *
         * @param phone The {@code Phone} calling this method.
         * @param canAddCall Indicates whether an additional call can be added.
         */
        public void onCanAddCallChanged(Phone phone, boolean canAddCall) { }
    }

    // A Map allows us to track each Call by its Telecom-specified call ID
@@ -92,6 +102,8 @@ public final class Phone {

    private final List<Listener> mListeners = new CopyOnWriteArrayList<>();

    private boolean mCanAddCall = true;

    /** {@hide} */
    Phone(InCallAdapter adapter) {
        mInCallAdapter = adapter;
@@ -149,6 +161,14 @@ public final class Phone {
        fireBringToForeground(showDialpad);
    }

    /** {@hide} */
    final void internalSetCanAddCall(boolean canAddCall) {
        if (mCanAddCall != canAddCall) {
            mCanAddCall = canAddCall;
            fireCanAddCallChanged(canAddCall);
        }
    }

    /**
     * Called to destroy the phone and cleanup any lingering calls.
     * @hide
@@ -190,6 +210,15 @@ public final class Phone {
        return mUnmodifiableCalls;
    }

    /**
     * Returns if the {@code Phone} can support additional calls.
     *
     * @return Whether the phone supports adding more calls.
     */
    public final boolean canAddCall() {
        return mCanAddCall;
    }

    /**
     * Sets the microphone mute state. When this request is honored, there will be change to
     * the {@link #getAudioState()}.
@@ -266,6 +295,12 @@ public final class Phone {
        }
    }

    private void fireCanAddCallChanged(boolean canAddCall) {
        for (Listener listener : mListeners) {
            listener.onCanAddCallChanged(this, canAddCall);
        }
    }

    private void checkCallTree(ParcelableCall parcelableCall) {
        if (parcelableCall.getParentCallId() != null &&
                !mCallByTelecomCallId.containsKey(parcelableCall.getParentCallId())) {
+5 −6
Original line number Diff line number Diff line
@@ -46,8 +46,10 @@ public final class PhoneCapabilities {
     */
    public static final int SWAP_CONFERENCE    = 0x00000008;

    /** Call currently supports adding another call to this one. */
    public static final int ADD_CALL           = 0x00000010;
    /**
     * @hide
     */
    public static final int UNUSED             = 0x00000010;

    /** Call supports responding via text option. */
    public static final int RESPOND_VIA_TEXT   = 0x00000020;
@@ -96,7 +98,7 @@ public final class PhoneCapabilities {
    public static final int DISCONNECT_FROM_CONFERENCE = 0x00002000;

    public static final int ALL = HOLD | SUPPORT_HOLD | MERGE_CONFERENCE | SWAP_CONFERENCE
            | ADD_CALL | RESPOND_VIA_TEXT | MUTE | MANAGE_CONFERENCE | SEPARATE_FROM_CONFERENCE
            | RESPOND_VIA_TEXT | MUTE | MANAGE_CONFERENCE | SEPARATE_FROM_CONFERENCE
            | DISCONNECT_FROM_CONFERENCE;

    /**
@@ -136,9 +138,6 @@ public final class PhoneCapabilities {
        if (can(capabilities, SWAP_CONFERENCE)) {
            builder.append(" SWAP_CONFERENCE");
        }
        if (can(capabilities, ADD_CALL)) {
            builder.append(" ADD_CALL");
        }
        if (can(capabilities, RESPOND_VIA_TEXT)) {
            builder.append(" RESPOND_VIA_TEXT");
        }
+2 −0
Original line number Diff line number Diff line
@@ -43,4 +43,6 @@ oneway interface IInCallService {
    void onAudioStateChanged(in AudioState audioState);

    void bringToForeground(boolean showDialpad);

    void onCanAddCallChanged(boolean canAddCall);
}