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

Commit d903d58a authored by Nivedita Sarkar's avatar Nivedita Sarkar
Browse files

Notify video capability to listeners in certain new scenarios

- In certain cases, we have seen that when the phone
  object is deleted/re-created, we fail to notify the
  video capability to the listeners.

- There also seemed to be a race condition when the
  time a listener registers is not in sync with
  the time we are notified of the video capability.

- In order to fix the above two issues, we notify
  registrants when a new phone is created and
  updateParentPhone is called. Also, when a new
  registrant registers with us for video capability
  changed, we immediately notify them of our cached
  capability.

Change-Id: Ic6002c2518104c20b5de10d1081af4559f506ace
CRs-Fixed: 753845
parent 9a4b9030
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -209,6 +209,10 @@ public abstract class PhoneBase extends Handler implements Phone {
    int mCallRingDelay;
    public boolean mIsTheCurrentActivePhone = true;
    boolean mIsVoiceCapable = true;

    // Variable to cache the video capabilitity. In some cases, we lose this info and are unable
    // to recover from the state. So, we cache it and notify listeners when they register.
    private boolean mIsVideoCapable = false;
    protected UiccController mUiccController = null;
    public AtomicReference<IccRecords> mIccRecords = new AtomicReference<IccRecords>();
    public SmsStorageMonitor mSmsStorageMonitor;
@@ -754,6 +758,9 @@ public abstract class PhoneBase extends Handler implements Phone {
        checkCorrectThread(h);

        mVideoCapabilityChangedRegistrants.addUnique(h, what, obj);

        // Notify any registrants of the cached video capability as soon as they register.
        notifyForVideoCapabilityChanged(mIsVideoCapable);
    }

    // Inherited documentation suffices.
@@ -1763,6 +1770,9 @@ public abstract class PhoneBase extends Handler implements Phone {
     * Notify registrants if phone is video capable.
     */
    public void notifyForVideoCapabilityChanged(boolean isVideoCallCapable) {
        // Cache the current video capability so that we don't lose the information.
        mIsVideoCapable = isVideoCallCapable;

        AsyncResult ar = new AsyncResult(null, isVideoCallCapable, null);
        mVideoCapabilityChangedRegistrants.notifyRegistrants(ar);
    }
+10 −0
Original line number Diff line number Diff line
@@ -127,6 +127,10 @@ public class ImsPhone extends ImsPhoneBase {

    private final RegistrantList mSilentRedialRegistrants = new RegistrantList();

    // Variable to cache the video capabilitity. In cases where we delete/re-create the phone
    // this information is getting lost.
    private boolean mIsVideoCapable = false;

    // A runnable which is used to automatically exit from Ecm after a period of time.
    private Runnable mExitEcmRunnable = new Runnable() {
        @Override
@@ -176,6 +180,11 @@ public class ImsPhone extends ImsPhoneBase {
        // synchronization is managed at the PhoneBase scope (which calls this function)
        mDefaultPhone = parentPhone;
        mPhoneId = mDefaultPhone.getPhoneId();

        // When the parent phone is updated, we need to notify listeners of the cached video
        // capability.
        Rlog.d(LOG_TAG, "updateParentPhone - Notify video capability changed " + mIsVideoCapable);
        notifyForVideoCapabilityChanged(mIsVideoCapable);
    }

    @Override
@@ -469,6 +478,7 @@ public class ImsPhone extends ImsPhoneBase {
    }

    public void notifyForVideoCapabilityChanged(boolean isVideoCapable) {
        mIsVideoCapable = isVideoCapable;
        mDefaultPhone.notifyForVideoCapabilityChanged(isVideoCapable);
    }