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

Commit fe2b2222 authored by Brad Ebinger's avatar Brad Ebinger
Browse files

Moves IMS Emergency Calling state

The IMS Emergency Calling availability state
used to be stored in the ImsServiceController and
polled when needed. This change moves the
state to MmTelFeatureConnection via an update.

By moving it here, we can reduce the number of
calls through TelephonyManager and support
MSIM.

Bug: 74389647
Test: Telephony Unit Tests, Telephony Test ImsService app
Merged-In: I692cd6b41f787bb1f75d696f2f2a73c79b03e0e8
Change-Id: I35ff8723afff2e69ab36e6e99c2efd5ae7a4868a
parent d24b6858
Loading
Loading
Loading
Loading
+41 −16
Original line number Diff line number Diff line
@@ -60,12 +60,13 @@ public class MmTelFeatureConnection {
    protected IBinder mBinder;
    private Context mContext;

    // Start by assuming the proxy is available for usage.
    private volatile boolean mIsAvailable = true;
    private volatile boolean mIsAvailable = false;
    // ImsFeature Status from the ImsService. Cached.
    private Integer mFeatureStateCached = null;
    private IFeatureUpdate mStatusCallback;
    private final Object mLock = new Object();
    // Updated by IImsServiceFeatureCallback when FEATURE_EMERGENCY_MMTEL is sent.
    private boolean mSupportsEmergencyCalling = false;

    private MmTelFeature.Listener mMmTelFeatureListener;

@@ -297,27 +298,53 @@ public class MmTelFeatureConnection {

        @Override
        public void imsFeatureCreated(int slotId, int feature) throws RemoteException {
            // The feature has been re-enabled. This may happen when the service crashes.
            // The feature has been enabled. This happens when the feature is first created and may
            // happen when the feature is re-enabled.
            synchronized (mLock) {
                if (!mIsAvailable && mSlotId == slotId && feature == ImsFeature.FEATURE_MMTEL) {
                    Log.i(TAG, "Feature enabled on slotId: " + slotId + " for feature: " +
                            feature);
                if(mSlotId != slotId) {
                    return;
                }
                switch (feature) {
                    case ImsFeature.FEATURE_MMTEL: {
                        if (!mIsAvailable) {
                            Log.i(TAG, "MmTel enabled on slotId: " + slotId);
                            mIsAvailable = true;
                        }
                        break;
                    }
                    case ImsFeature.FEATURE_EMERGENCY_MMTEL: {
                        mSupportsEmergencyCalling = true;
                        Log.i(TAG, "Emergency calling enabled on slotId: " + slotId);
                        break;
                    }
                }

            }
        }

        @Override
        public void imsFeatureRemoved(int slotId, int feature) throws RemoteException {
            synchronized (mLock) {
                if (mIsAvailable && mSlotId == slotId && feature == ImsFeature.FEATURE_MMTEL) {
                    Log.i(TAG, "Feature disabled on slotId: " + slotId + " for feature: " +
                            feature);
                if(mSlotId != slotId) {
                    return;
                }
                switch (feature) {
                    case ImsFeature.FEATURE_MMTEL: {
                        if (mIsAvailable) {
                            Log.i(TAG, "MmTel disabled on slotId: " + slotId);
                            mIsAvailable = false;
                            if (mStatusCallback != null) {
                                mStatusCallback.notifyUnavailable();
                            }
                        }
                        break;
                    }
                    case ImsFeature.FEATURE_EMERGENCY_MMTEL : {
                        mSupportsEmergencyCalling = false;
                        Log.i(TAG, "Emergency calling disabled on slotId: " + slotId);
                        break;
                    }
                }
            }
        }

@@ -352,8 +379,7 @@ public class MmTelFeatureConnection {
    }

    public boolean isEmergencyMmTelAvailable() {
        TelephonyManager tm = getTelephonyManager(mContext);
        return tm != null ? tm.isEmergencyMmTelAvailable(mSlotId) : false;
        return mSupportsEmergencyCalling;
    }

    public IImsServiceFeatureCallback getListener() {
@@ -565,7 +591,6 @@ public class MmTelFeatureConnection {
    public int getFeatureState() {
        synchronized (mLock) {
            if (isBinderAlive() && mFeatureStateCached != null) {
                Log.i(TAG, "getFeatureState - returning cached: " + mFeatureStateCached);
                return mFeatureStateCached;
            }
        }