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

Commit a32555d3 authored by Nivedita Sarkar's avatar Nivedita Sarkar Committed by Android Git Automerger
Browse files

am 54e059a5: am 21048a2b: IMS: Decouple Call Extras from call state change notification.

* commit '54e059a5':
  IMS: Decouple Call Extras from call state change notification.
parents 9db557c8 54e059a5
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ public abstract class Connection {
        public void onCallSubstateChanged(int callSubstate);
        public void onMultipartyStateChanged(boolean isMultiParty);
        public void onConferenceMergedFailed();
        public void onExtrasChanged(Bundle extras);
    }

    /**
@@ -81,6 +82,8 @@ public abstract class Connection {
        public void onMultipartyStateChanged(boolean isMultiParty) {}
        @Override
        public void onConferenceMergedFailed() {}
        @Override
        public void onExtrasChanged(Bundle extras) {}
    }

    public static final int AUDIO_QUALITY_STANDARD = 1;
@@ -301,15 +304,6 @@ public abstract class Connection {
        return mPreHandoverState;
   }

   /**
     * getExtras returns the extras associated with a connection.
     * @return null. Subclasses of Connection that support call extras need
     * to override this method to return the extras.
     */
    public Bundle getExtras() {
        return null;
    }

    /**
     * Get the details of conference participants. Expected to be
     * overwritten by the Connection subclasses.
@@ -633,6 +627,16 @@ public abstract class Connection {
        }
    }

    /**
     * Notifies listeners that connection extras has changed.
     * @param extras New connection extras.
     */
    public void setConnectionExtras(Bundle extras) {
        for (Listener l : mListeners) {
            l.onExtrasChanged(extras);
        }
    }

    /**
     * Sets the call substate for the current connection and reports the changes to all listeners.
     * Valid call substates are defined in {@link android.telecom.Connection}.
+1 −0
Original line number Diff line number Diff line
@@ -1003,6 +1003,7 @@ public final class ImsPhoneCallTracker extends CallTracker {
        // i.e. onCallHeld, onCallResume, etc and conn.update will be responsible for the update
        if (ignoreState) {
            conn.updateMediaCapabilities(imsCall);
            conn.updateExtras(imsCall);
            return;
        }

+55 −19
Original line number Diff line number Diff line
@@ -45,6 +45,8 @@ import com.android.internal.telephony.UUSInfo;
import com.android.ims.ImsCall;
import com.android.ims.ImsCallProfile;

import java.util.Objects;

/**
 * {@hide}
 */
@@ -57,6 +59,7 @@ public class ImsPhoneConnection extends Connection {
    private ImsPhoneCallTracker mOwner;
    private ImsPhoneCall mParent;
    private ImsCall mImsCall;
    private Bundle mExtras = new Bundle();

    private String mPostDialString;      // outgoing calls only
    private boolean mDisconnected;
@@ -638,8 +641,11 @@ public class ImsPhoneConnection extends Connection {
        boolean updateParent = mParent.update(this, imsCall, state);
        boolean updateWifiState = updateWifiState();
        boolean updateAddressDisplay = updateAddressDisplay(imsCall);
        boolean updateMediaCapabilities = updateMediaCapabilities(imsCall);
        boolean updateExtras = updateExtras(imsCall);

        return updateParent || updateWifiState || updateAddressDisplay;
        return updateParent || updateWifiState || updateAddressDisplay || updateMediaCapabilities
                || updateExtras;
    }

    @Override
@@ -816,6 +822,54 @@ public class ImsPhoneConnection extends Connection {
        return false;
    }

    /**
     * Check for a change in call extras of {@link ImsCall}, and
     * update the {@link ImsPhoneConnection} accordingly.
     *
     * @param imsCall The call to check for changes in extras.
     * @return Whether the extras fields have been changed.
     */
     boolean updateExtras(ImsCall imsCall) {
        if (imsCall == null) {
            return false;
        }

        final ImsCallProfile callProfile = imsCall.getCallProfile();
        final Bundle extras = callProfile != null ? callProfile.mCallExtras : null;
        if (extras == null && DBG) {
            Rlog.d(LOG_TAG, "Call profile extras are null.");
        }

        final boolean changed = !areBundlesEqual(extras, mExtras);
        if (changed) {
            mExtras.clear();
            mExtras.putAll(extras);
            setConnectionExtras(mExtras);
        }
        return changed;
    }

    private static boolean areBundlesEqual(Bundle extras, Bundle newExtras) {
        if (extras == null || newExtras == null) {
            return extras == newExtras;
        }

        if (extras.size() != newExtras.size()) {
            return false;
        }

        for(String key : extras.keySet()) {
            if (key != null) {
                final Object value = extras.get(key);
                final Object newValue = newExtras.get(key);
                if (!Objects.equals(value, newValue)) {
                    return false;
                }
            }
        }
        return true;
    }

    /**
     * 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
@@ -840,24 +894,6 @@ public class ImsPhoneConnection extends Connection {
        return isHighDef ? AUDIO_QUALITY_HIGH_DEFINITION : AUDIO_QUALITY_STANDARD;
    }

    @Override
    public Bundle getExtras() {
        Bundle extras = null;
        final ImsCall call = getImsCall();

        if (call != null) {
            final ImsCallProfile callProfile = call.getCallProfile();
            if (callProfile != null) {
                extras = callProfile.mCallExtras;
            }
        }
        if (extras == null) {
            if (DBG) Rlog.d(LOG_TAG, "Call profile extras are null.");
            return null;
        }
        return extras;
    }

    /**
     * Provides a string representation of the {@link ImsPhoneConnection}.  Primarily intended for
     * use in log statements.