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

Commit 21048a2b authored by Nivedita Sarkar's avatar Nivedita Sarkar Committed by Anthony Lee
Browse files

IMS: Decouple Call Extras from call state change notification.

Currently call extras are closely coupled with call state changes.
To propagate call extras from internal.telephony.Connection the
PRECISE_CALL_STATE_CHANGED event shall be triggered which is genarally
triggered when phone/call changes its state. This change removes the
above mentioned dependency by raising onExtrasChanged event when
changes in extras are detected.

Bug: 22329706

Change-Id: I7c0f5dc3229b2d7ae83d06a8e3fade45d1b62c90
parent f4f3b372
Loading
Loading
Loading
Loading
+13 −9
Original line number Original line Diff line number Diff line
@@ -54,6 +54,7 @@ public abstract class Connection {
        public void onCallSubstateChanged(int callSubstate);
        public void onCallSubstateChanged(int callSubstate);
        public void onMultipartyStateChanged(boolean isMultiParty);
        public void onMultipartyStateChanged(boolean isMultiParty);
        public void onConferenceMergedFailed();
        public void onConferenceMergedFailed();
        public void onExtrasChanged(Bundle extras);
    }
    }


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


    public static final int AUDIO_QUALITY_STANDARD = 1;
    public static final int AUDIO_QUALITY_STANDARD = 1;
@@ -301,15 +304,6 @@ public abstract class Connection {
        return mPreHandoverState;
        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
     * Get the details of conference participants. Expected to be
     * overwritten by the Connection subclasses.
     * 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.
     * 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}.
     * Valid call substates are defined in {@link android.telecom.Connection}.
+1 −0
Original line number Original line 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
        // i.e. onCallHeld, onCallResume, etc and conn.update will be responsible for the update
        if (ignoreState) {
        if (ignoreState) {
            conn.updateMediaCapabilities(imsCall);
            conn.updateMediaCapabilities(imsCall);
            conn.updateExtras(imsCall);
            return;
            return;
        }
        }


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


import java.util.Objects;

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


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


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


    @Override
    @Override
@@ -816,6 +822,54 @@ public class ImsPhoneConnection extends Connection {
        return false;
        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
     * 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
     * {@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;
        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
     * Provides a string representation of the {@link ImsPhoneConnection}.  Primarily intended for
     * use in log statements.
     * use in log statements.