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

Commit 04b0216a authored by Andrew Lee's avatar Andrew Lee
Browse files

Update internal telephony connection's wifi state.

When the ImsPhoneConnection is updated, pass the state of whether it
is using Wifi to the Telecom Connection. This is done by checking
changes to a Connection's feature capabilities to see if
isVowifiEnabled.

This is a temporary measure. In the long run, this information will
be passed up on the ImsCallSession, and we will need to listen to
WFC handover events.

Bug: 19151548
Change-Id: I53c84cb0169abd72c35407ca3e77952bac30d656
parent 9c74fcdd
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ public abstract class Connection {
        public void onVideoStateChanged(int videoState);
        public void onLocalVideoCapabilityChanged(boolean capable);
        public void onRemoteVideoCapabilityChanged(boolean capable);
        public void onWifiChanged(boolean isWifi);
        public void onVideoProviderChanged(
                android.telecom.Connection.VideoProvider videoProvider);
        public void onAudioQualityChanged(int audioQuality);
@@ -62,6 +63,8 @@ public abstract class Connection {
        @Override
        public void onRemoteVideoCapabilityChanged(boolean capable) {}
        @Override
        public void onWifiChanged(boolean isWifi) {}
        @Override
        public void onVideoProviderChanged(
                android.telecom.Connection.VideoProvider videoProvider) {}
        @Override
@@ -108,6 +111,7 @@ public abstract class Connection {
    private int mVideoState;
    private boolean mLocalVideoCapable;
    private boolean mRemoteVideoCapable;
    private boolean mIsWifi;
    private int mAudioQuality;
    private android.telecom.Connection.VideoProvider mVideoProvider;
    public Call.State mPreHandoverState = Call.State.IDLE;
@@ -486,6 +490,15 @@ public abstract class Connection {
        return mRemoteVideoCapable;
    }

    /**
     * Returns whether the connection is using a wifi network.
     *
     * @return {@code True} if the connection is using a wifi network.
     */
    public boolean isWifi() {
        return mIsWifi;
    }

    /**
     * Returns the {@link android.telecom.Connection.VideoProvider} for the connection.
     *
@@ -541,6 +554,18 @@ public abstract class Connection {
        }
    }

    /**
     * Sets whether a wifi network is used for the connection.
     *
     * @param isWifi {@code True} if wifi is being used.
     */
    public void setWifi(boolean isWifi) {
        mIsWifi = isWifi;
        for (Listener l : mListeners) {
            l.onWifiChanged(mIsWifi);
        }
    }

    /**
     * Set the audio quality for the connection.
     *
+23 −3
Original line number Diff line number Diff line
@@ -1303,17 +1303,37 @@ public final class ImsPhoneCallTracker extends CallTracker {
        public void onFeatureCapabilityChanged(int serviceClass,
                int[] enabledFeatures, int[] disabledFeatures) {
            if (serviceClass == ImsServiceClass.MMTEL) {
                // Check enabledFeatures to determine capabilities. We ignore disabledFeatures.
                for (int  i = ImsConfig.FeatureConstants.FEATURE_TYPE_VOICE_OVER_LTE;
                        i <= ImsConfig.FeatureConstants.FEATURE_TYPE_VIDEO_OVER_WIFI; i++) {
                    if (enabledFeatures[i] == i) {
                        // If the feature is set to its own integer value it is enabled.
                        if (DBG) log("onFeatureCapabilityChanged: i=" + i + ", value=true");
                        mImsFeatureEnabled[i] = true;
                    }
                    if (disabledFeatures[i] == i) {
                    } else if (enabledFeatures[i]
                            == ImsConfig.FeatureConstants.FEATURE_TYPE_UNKNOWN) {
                        // FEATURE_TYPE_UNKNOWN indicates that a feature is disabled.
                        if (DBG) log("onFeatureCapabilityChanged: i=" + i + ", value=false");
                        mImsFeatureEnabled[i] = false;
                    } else {
                        // Feature has unknown state; it is not its own value or -1.
                        if (DBG) {
                            loge("onFeatureCapabilityChanged: i=" + i + ", unexpectedValue="
                                + enabledFeatures[i]);
                        }
                    }
                }

                // TODO: Use the ImsCallSession or ImsCallProfile to tell the initial Wifi state and
                // {@link ImsCallSession.Listener#callSessionHandover} to listen for changes to
                // wifi capability caused by a handover.
                if (DBG) log("onFeatureCapabilityChanged: isVowifiEnabled=" + isVowifiEnabled());
                for (ImsPhoneConnection connection : mConnections) {
                    connection.updateWifiState();
                }
            }
            if (DBG) log("onFeatureCapabilityChanged,  mImsFeatureEnabled=" +  mImsFeatureEnabled);

            if (DBG) log("onFeatureCapabilityChanged: mImsFeatureEnabled=" +  mImsFeatureEnabled);
        }
    };

+19 −1
Original line number Diff line number Diff line
@@ -144,6 +144,8 @@ public class ImsPhoneConnection extends Connection {

        //mIndex = index;

        updateWifiState();

        mParent = parent;
        mParent.attach(this, ImsPhoneCall.State.INCOMING);
    }
@@ -572,7 +574,8 @@ public class ImsPhoneConnection extends Connection {

        boolean updateParent = mParent.update(this, imsCall, state);
        boolean updateMediaCapabilities = updateMediaCapabilities(imsCall);
        return updateParent || updateMediaCapabilities;
        boolean updateWifiState = updateWifiState();
        return updateParent || updateMediaCapabilities || updateWifiState;
    }

    @Override
@@ -673,6 +676,21 @@ public class ImsPhoneConnection extends Connection {
        return changed;
    }

    /**
     * Check for a change in the wifi state of the ImsPhoneCallTracker and update the
     * {@link ImsPhoneConnection} with this information.
     *
     * @return Whether the ImsPhoneCallTracker's usage of wifi has been changed.
     */
    public boolean updateWifiState() {
        Rlog.d(LOG_TAG, "updateWifiState: " + mOwner.isVowifiEnabled());
        if (isWifi() != mOwner.isVowifiEnabled()) {
            setWifi(mOwner.isVowifiEnabled());
            return true;
        }
        return false;
    }

    /**
     * Determines the {@link ImsPhoneConnection} audio quality based on the local and remote
     * {@link ImsCallProfile}. If indicate a HQ audio call if the local stream profile