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

Commit a549fed5 authored by Hall Liu's avatar Hall Liu
Browse files

RTT bugfixes, part 5

* Add a new API to allow Telecom to inform ConnectionServices when the
RTT text stream changes
* No longer set the RTT property from ConnectionService. Client apps
should be setting properties themselves.
* Add Dialer-side RTT property in order to remove the dependence on
checking the RTT streams, which have a complex lifecycle

Bug: 72951201
Bug: 72648661
Test: manual, with real RTT calls and Dialer's SimulatorConnection, also
cts
Change-Id: Ic4c7d883d2dc6baf8e8c0eaa4df58d7de8762b9e
parent fc7423bc
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -36633,6 +36633,7 @@ package android.provider {
    field public static final deprecated java.lang.String RADIO_NFC = "nfc";
    field public static final deprecated java.lang.String RADIO_NFC = "nfc";
    field public static final deprecated java.lang.String RADIO_WIFI = "wifi";
    field public static final deprecated java.lang.String RADIO_WIFI = "wifi";
    field public static final java.lang.String RINGTONE = "ringtone";
    field public static final java.lang.String RINGTONE = "ringtone";
    field public static final java.lang.String RTT_CALLING_MODE = "rtt_calling_mode";
    field public static final java.lang.String SCREEN_BRIGHTNESS = "screen_brightness";
    field public static final java.lang.String SCREEN_BRIGHTNESS = "screen_brightness";
    field public static final java.lang.String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode";
    field public static final java.lang.String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode";
    field public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1; // 0x1
    field public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1; // 0x1
@@ -40637,6 +40638,7 @@ package android.telecom {
    field public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 128; // 0x80
    field public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 128; // 0x80
    field public static final int PROPERTY_HIGH_DEF_AUDIO = 16; // 0x10
    field public static final int PROPERTY_HIGH_DEF_AUDIO = 16; // 0x10
    field public static final int PROPERTY_IS_EXTERNAL_CALL = 64; // 0x40
    field public static final int PROPERTY_IS_EXTERNAL_CALL = 64; // 0x40
    field public static final int PROPERTY_RTT = 1024; // 0x400
    field public static final int PROPERTY_SELF_MANAGED = 256; // 0x100
    field public static final int PROPERTY_SELF_MANAGED = 256; // 0x100
    field public static final int PROPERTY_WIFI = 8; // 0x8
    field public static final int PROPERTY_WIFI = 8; // 0x8
  }
  }
+4 −7
Original line number Original line Diff line number Diff line
@@ -3692,18 +3692,15 @@ public final class Settings {
                new SettingsValidators.InclusiveIntegerRangeValidator(0, 3);
                new SettingsValidators.InclusiveIntegerRangeValidator(0, 3);


        /**
        /**
         * User-selected RTT mode
         * User-selected RTT mode. When on, outgoing and incoming calls will be answered as RTT
         * calls when supported by the device and carrier. Boolean value.
         * 0 = OFF
         * 0 = OFF
         * 1 = FULL
         * 1 = ON
         * 2 = VCO
         * 3 = HCO
         * Uses the same constants as TTY (e.g. {@link android.telecom.TelecomManager#TTY_MODE_OFF})
         * @hide
         */
         */
        public static final String RTT_CALLING_MODE = "rtt_calling_mode";
        public static final String RTT_CALLING_MODE = "rtt_calling_mode";


        /** @hide */
        /** @hide */
        public static final Validator RTT_CALLING_MODE_VALIDATOR = TTY_MODE_VALIDATOR;
        public static final Validator RTT_CALLING_MODE_VALIDATOR = BOOLEAN_VALIDATOR;


        /**
        /**
         * Whether the sounds effects (key clicks, lid open ...) are enabled. The value is
         * Whether the sounds effects (key clicks, lid open ...) are enabled. The value is
+27 −3
Original line number Original line Diff line number Diff line
@@ -425,8 +425,14 @@ public final class Call {
         */
         */
        public static final int PROPERTY_ASSISTED_DIALING_USED = 0x00000200;
        public static final int PROPERTY_ASSISTED_DIALING_USED = 0x00000200;


        /**
         * Indicates that the call is an RTT call. Use {@link #getRttCall()} to get the
         * {@link RttCall} object that is used to send and receive text.
         */
        public static final int PROPERTY_RTT = 0x00000400;

        //******************************************************************************************
        //******************************************************************************************
        // Next PROPERTY value: 0x00000400
        // Next PROPERTY value: 0x00000800
        //******************************************************************************************
        //******************************************************************************************


        private final String mTelecomCallId;
        private final String mTelecomCallId;
@@ -1189,6 +1195,23 @@ public final class Call {
                return null;
                return null;
            }
            }
        }
        }

        /**
         * Closes the underlying file descriptors
         * @hide
         */
        public void close() {
            try {
                mReceiveStream.close();
            } catch (IOException e) {
                // ignore
            }
            try {
                mTransmitStream.close();
            } catch (IOException e) {
                // ignore
            }
        }
    }
    }


    /**
    /**
@@ -1664,7 +1687,7 @@ public final class Call {
     * @return true if there is a connection, false otherwise.
     * @return true if there is a connection, false otherwise.
     */
     */
    public boolean isRttActive() {
    public boolean isRttActive() {
        return mRttCall != null;
        return mRttCall != null && mDetails.hasProperty(Details.PROPERTY_RTT);
    }
    }


    /**
    /**
@@ -1867,7 +1890,8 @@ public final class Call {


        boolean isRttChanged = false;
        boolean isRttChanged = false;
        boolean rttModeChanged = false;
        boolean rttModeChanged = false;
        if (parcelableCall.getParcelableRttCall() != null && parcelableCall.getIsRttCallChanged()) {
        if (parcelableCall.getIsRttCallChanged()
                && mDetails.hasProperty(Details.PROPERTY_RTT)) {
            ParcelableRttCall parcelableRttCall = parcelableCall.getParcelableRttCall();
            ParcelableRttCall parcelableRttCall = parcelableCall.getParcelableRttCall();
            InputStreamReader receiveStream = new InputStreamReader(
            InputStreamReader receiveStream = new InputStreamReader(
                    new ParcelFileDescriptor.AutoCloseInputStream(
                    new ParcelFileDescriptor.AutoCloseInputStream(
+9 −23
Original line number Original line Diff line number Diff line
@@ -41,6 +41,8 @@ import android.os.SystemClock;
import android.util.ArraySet;
import android.util.ArraySet;
import android.view.Surface;
import android.view.Surface;


import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.OutputStreamWriter;
@@ -860,18 +862,19 @@ public abstract class Connection extends Conferenceable {
            mFdFromInCall = fromInCall;
            mFdFromInCall = fromInCall;
            mFdToInCall = toInCall;
            mFdToInCall = toInCall;
            mPipeFromInCall = new InputStreamReader(
            mPipeFromInCall = new InputStreamReader(
                    new ParcelFileDescriptor.AutoCloseInputStream(fromInCall));
                    new FileInputStream(fromInCall.getFileDescriptor()));
            mPipeToInCall = new OutputStreamWriter(
            mPipeToInCall = new OutputStreamWriter(
                    new ParcelFileDescriptor.AutoCloseOutputStream(toInCall));
                    new FileOutputStream(toInCall.getFileDescriptor()));
        }
        }


        /**
        /**
         * Writes the string {@param input} into the text stream to the UI for this RTT call. Since
         * Writes the string {@param input} into the text stream to the UI for this RTT call. Since
         * RTT transmits text in real-time, this method should be called as often as text snippets
         * RTT transmits text in real-time, this method should be called as often as text snippets
         * are received from the remote user, even if it is only one character.
         * are received from the remote user, even if it is only one character.
         *
         * <p>
         * This method is not thread-safe -- calling it from multiple threads simultaneously may
         * This method is not thread-safe -- calling it from multiple threads simultaneously may
         * lead to interleaved text.
         * lead to interleaved text.
         *
         * @param input The message to send to the in-call app.
         * @param input The message to send to the in-call app.
         */
         */
        public void write(String input) throws IOException {
        public void write(String input) throws IOException {
@@ -884,9 +887,10 @@ public abstract class Connection extends Conferenceable {
         * Reads a string from the in-call app, blocking if there is no data available. Returns
         * Reads a string from the in-call app, blocking if there is no data available. Returns
         * {@code null} if the RTT conversation has been terminated and there is no further data
         * {@code null} if the RTT conversation has been terminated and there is no further data
         * to read.
         * to read.
         *
         * <p>
         * This method is not thread-safe -- calling it from multiple threads simultaneously may
         * This method is not thread-safe -- calling it from multiple threads simultaneously may
         * lead to interleaved text.
         * lead to interleaved text.
         *
         * @return A string containing text entered by the user, or {@code null} if the
         * @return A string containing text entered by the user, or {@code null} if the
         * conversation has been terminated or if there was an error while reading.
         * conversation has been terminated or if there was an error while reading.
         */
         */
@@ -901,6 +905,7 @@ public abstract class Connection extends Conferenceable {
        /**
        /**
         * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
         * Non-blocking version of {@link #read()}. Returns {@code null} if there is nothing to
         * be read.
         * be read.
         *
         * @return A string containing text entered by the user, or {@code null} if the user has
         * @return A string containing text entered by the user, or {@code null} if the user has
         * not entered any new text yet.
         * not entered any new text yet.
         */
         */
@@ -2635,7 +2640,6 @@ public abstract class Connection extends Conferenceable {
     * {@link #onStartRtt(RttTextStream)} has succeeded.
     * {@link #onStartRtt(RttTextStream)} has succeeded.
     */
     */
    public final void sendRttInitiationSuccess() {
    public final void sendRttInitiationSuccess() {
        setRttProperty();
        mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
        mListeners.forEach((l) -> l.onRttInitiationSuccess(Connection.this));
    }
    }


@@ -2647,7 +2651,6 @@ public abstract class Connection extends Conferenceable {
     *               exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
     *               exception of {@link RttModifyStatus#SESSION_MODIFY_REQUEST_SUCCESS}.
     */
     */
    public final void sendRttInitiationFailure(int reason) {
    public final void sendRttInitiationFailure(int reason) {
        unsetRttProperty();
        mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
        mListeners.forEach((l) -> l.onRttInitiationFailure(Connection.this, reason));
    }
    }


@@ -2656,7 +2659,6 @@ public abstract class Connection extends Conferenceable {
     * side of the coll.
     * side of the coll.
     */
     */
    public final void sendRttSessionRemotelyTerminated() {
    public final void sendRttSessionRemotelyTerminated() {
        unsetRttProperty();
        mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
        mListeners.forEach((l) -> l.onRttSessionRemotelyTerminated(Connection.this));
    }
    }


@@ -2914,22 +2916,6 @@ public abstract class Connection extends Conferenceable {
     */
     */
    public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}
    public void handleRttUpgradeResponse(@Nullable RttTextStream rttTextStream) {}


    /**
     * Internal method to set {@link #PROPERTY_IS_RTT}.
     * @hide
     */
    void setRttProperty() {
        setConnectionProperties(getConnectionProperties() | PROPERTY_IS_RTT);
    }

    /**
     * Internal method to un-set {@link #PROPERTY_IS_RTT}.
     * @hide
     */
    void unsetRttProperty() {
        setConnectionProperties(getConnectionProperties() & (~PROPERTY_IS_RTT));
    }

    static String toLogSafePhoneNumber(String number) {
    static String toLogSafePhoneNumber(String number) {
        // For unknown number, log empty string.
        // For unknown number, log empty string.
        if (number == null) {
        if (number == null) {
+6 −1
Original line number Original line Diff line number Diff line
@@ -143,6 +143,8 @@ public final class ConnectionRequest implements Parcelable {
    private final boolean mShouldShowIncomingCallUi;
    private final boolean mShouldShowIncomingCallUi;
    private final ParcelFileDescriptor mRttPipeToInCall;
    private final ParcelFileDescriptor mRttPipeToInCall;
    private final ParcelFileDescriptor mRttPipeFromInCall;
    private final ParcelFileDescriptor mRttPipeFromInCall;
    // Cached return value of getRttTextStream -- we don't want to wrap it more than once.
    private Connection.RttTextStream mRttTextStream;


    /**
    /**
     * @param accountHandle The accountHandle which should be used to place the call.
     * @param accountHandle The accountHandle which should be used to place the call.
@@ -312,7 +314,10 @@ public final class ConnectionRequest implements Parcelable {
     */
     */
    public Connection.RttTextStream getRttTextStream() {
    public Connection.RttTextStream getRttTextStream() {
        if (isRequestingRtt()) {
        if (isRequestingRtt()) {
            return new Connection.RttTextStream(mRttPipeToInCall, mRttPipeFromInCall);
            if (mRttTextStream == null) {
                mRttTextStream = new Connection.RttTextStream(mRttPipeToInCall, mRttPipeFromInCall);
            }
            return mRttTextStream;
        } else {
        } else {
            return null;
            return null;
        }
        }
Loading