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

Commit 5e135330 authored by Etan Cohen's avatar Etan Cohen Committed by Android (Google) Code Review
Browse files

Merge changes from topic 'mwd-merge-062315' into mnc-vt-dev

* changes:
  Fix build due to merge of pag/217347 - "Auto-downgrade emergency vt ..."
  Merge commit '43ee71fd' into merge
  Merge commit '8560465c' into merge
  Merge commit '2b3d690d' into merge
parents 9c31457a 025c0192
Loading
Loading
Loading
Loading
+47 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.os.AsyncResult;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.PersistableBundle;
import android.os.Registrant;
import android.os.RegistrantList;
import android.os.RemoteException;
@@ -40,10 +41,12 @@ import android.widget.Toast;
import android.preference.PreferenceManager;
import android.telecom.ConferenceParticipant;
import android.telecom.VideoProfile;
import android.telephony.CarrierConfigManager;
import android.telephony.DisconnectCause;
import android.telephony.PhoneNumberUtils;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.SubscriptionManager;

import com.android.ims.ImsCall;
import com.android.ims.ImsCallProfile;
@@ -137,6 +140,15 @@ public final class ImsPhoneCallTracker extends CallTracker {
                    loge("onReceive : exception " + e);
                } catch (RemoteException e) {
                }
            } else if (intent.getAction().equals(
                    CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED)) {
                int subId = intent.getIntExtra(PhoneConstants.SUBSCRIPTION_KEY,
                        SubscriptionManager.INVALID_SUBSCRIPTION_ID);
                if (subId == mPhone.getSubId()) {
                    mAllowEmergencyVideoCalls = isEmergencyVtCallAllowed(subId);
                    log("onReceive : Updating mAllowEmergencyVideoCalls = " +
                            mAllowEmergencyVideoCalls);
                }
            }
        }
    };
@@ -188,6 +200,7 @@ public final class ImsPhoneCallTracker extends CallTracker {
    private boolean pendingCallInEcm = false;
    private boolean mSwitchingFgAndBgCalls = false;
    private ImsCall mCallExpectedToResume = null;
    private boolean mAllowEmergencyVideoCalls = false;

    //***** Events

@@ -199,7 +212,9 @@ public final class ImsPhoneCallTracker extends CallTracker {

        IntentFilter intentfilter = new IntentFilter();
        intentfilter.addAction(ImsManager.ACTION_IMS_INCOMING_CALL);
        intentfilter.addAction(CarrierConfigManager.ACTION_CARRIER_CONFIG_CHANGED);
        mPhone.getContext().registerReceiver(mReceiver, intentfilter);
        mAllowEmergencyVideoCalls = isEmergencyVtCallAllowed(mPhone.getSubId());

        Thread t = new Thread() {
            public void run() {
@@ -318,6 +333,14 @@ public final class ImsPhoneCallTracker extends CallTracker {
            handleEcmTimer(ImsPhone.CANCEL_ECM_TIMER);
        }

        // If the call is to an emergency number and the carrier does not support video emergency
        // calls, dial as an audio-only call.
        if (isEmergencyNumber && VideoProfile.isVideo(videoState) &&
                !mAllowEmergencyVideoCalls) {
            loge("dial: carrier does not support video emergency calls; downgrade to audio-only");
            videoState = VideoProfile.STATE_AUDIO_ONLY;
        }

        boolean holdBeforeDial = false;

        // The new call must be assigned to the foreground call.
@@ -384,6 +407,30 @@ public final class ImsPhoneCallTracker extends CallTracker {
        return mPendingMO;
    }

    /**
     * Determines if the carrier associated with the specified SubId supports making video emergency
     * calls.
     *
     * @param subId The sub id.
     * @return {@code true} if video emergency calls are supported, {@code false} otherwise.
     */
    private boolean isEmergencyVtCallAllowed(int subId) {
        CarrierConfigManager carrierConfigManager = (CarrierConfigManager)
                mPhone.getContext().getSystemService(Context.CARRIER_CONFIG_SERVICE);
        if (carrierConfigManager == null) {
            loge("isEmergencyVideoCallsSupported: No carrier config service found.");
            return false;
        }

        PersistableBundle carrierConfig = carrierConfigManager.getConfigForSubId(subId);
        if (carrierConfig == null) {
            loge("isEmergencyVideoCallsSupported: Empty carrier config.");
            return false;
        }

        return carrierConfig.getBoolean(CarrierConfigManager.BOOL_ALLOW_EMERGENCY_VIDEO_CALLS);
    }

    private void handleEcmTimer(int action) {
        mPhone.handleTimerInEmergencyCallbackMode(action);
        switch (action) {