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

Commit 3afbdf00 authored by Santos Cordon's avatar Santos Cordon
Browse files

Update showCallScreen to use Telecomm (6/6)

Use TelephonyManager instead of ITelephony for showCallScreen so that
the invocation routed to telecomm instead.

Bug: 15008165
Change-Id: Ib674e2e48efaa1cc97d1513dc2c2b27fdb343657
parent d4757e08
Loading
Loading
Loading
Loading
+10 −17
Original line number Diff line number Diff line
@@ -58,7 +58,6 @@ import android.widget.ProgressBar;
import android.widget.TextView;

import com.android.internal.statusbar.StatusBarIcon;
import com.android.internal.telephony.ITelephony;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneConstants;
import com.android.internal.widget.LockPatternUtils;
@@ -605,8 +604,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
        }

        // Disable the Emergency call button if the device has no voice telephone capability
        final TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        if (!tm.isVoiceCapable()) {
        if (!getTelephonyManager().isVoiceCapable()) {
            final View emergencyCall = findViewById(R.id.emergencyCallButton);
            if (emergencyCall != null) {
                Log.d(TAG, "Removing the emergency Call button");
@@ -760,7 +758,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
     */
    private final void setAirplaneModeIfNecessary() {
        final boolean isLteDevice =
                TelephonyManager.getDefault().getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE;
                getTelephonyManager().getLteOnCdmaMode() == PhoneConstants.LTE_ON_CDMA_TRUE;
        if (!isLteDevice) {
            Log.d(TAG, "Going into airplane mode.");
            Settings.Global.putInt(getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
@@ -796,7 +794,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
            return;
        }

        final int newState = TelephonyManager.getDefault().getCallState();
        final int newState = getTelephonyManager().getCallState();
        int textId;
        if (newState == TelephonyManager.CALL_STATE_OFFHOOK) {
            // Show "return to call" text and show phone icon
@@ -816,23 +814,14 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
    }

    private void takeEmergencyCallAction() {
        if (TelephonyManager.getDefault().getCallState() == TelephonyManager.CALL_STATE_OFFHOOK) {
            resumeCall();
        TelephonyManager telephonyManager = getTelephonyManager();
        if (telephonyManager.getCallState() == TelephonyManager.CALL_STATE_OFFHOOK) {
            telephonyManager.showCallScreen();
        } else {
            launchEmergencyDialer();
        }
    }

    private void resumeCall() {
        final ITelephony phone = ITelephony.Stub.asInterface(ServiceManager.checkService("phone"));
        if (phone != null) {
            try {
                phone.showCallScreen();
            } catch (RemoteException e) {
                Log.e(TAG, "Error calling ITelephony service: " + e);
            }
        }
    }

    private void launchEmergencyDialer() {
        final Intent intent = new Intent(ACTION_EMERGENCY_DIAL);
@@ -841,6 +830,10 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
        startActivity(intent);
    }

    private TelephonyManager getTelephonyManager() {
        return (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
    }

    /**
     * Listen to key events so we can disable sounds when we get a keyinput in EditText.
     */