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

Commit 8ad2d8d8 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Preventing telecomm intent handling from executing on tablets.

Bug: 17000484
Change-Id: Iaea456f65670068515076d4c64bc1c65d0341d55
parent 9646ed98
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.telecomm.PhoneAccountHandle;
import android.telecomm.TelecommManager;
import android.telecomm.TelecommManager;
import android.telephony.PhoneNumberUtils;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

/**
@@ -47,6 +48,7 @@ import android.text.TextUtils;
 */
public class CallActivity extends Activity {
    private CallsManager mCallsManager = CallsManager.getInstance();
    private boolean mIsVoiceCapable;

    /**
     * {@inheritDoc}
@@ -58,6 +60,8 @@ public class CallActivity extends Activity {
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);

        mIsVoiceCapable = isVoiceCapable();

        // TODO: This activity will be displayed until the next screen which could be
        // the in-call UI and error dialog or potentially a call-type selection dialog.
        // Traditionally, this has been a black screen with a spinner. We need to reevaluate if this
@@ -88,6 +92,12 @@ public class CallActivity extends Activity {
     * @param intent The intent.
     */
    private void processIntent(Intent intent) {
        // Ensure call intents are not processed on devices that are not capable of calling.
        if (!mIsVoiceCapable) {
            setResult(RESULT_CANCELED);
            return;
        }

        String action = intent.getAction();

        // TODO: Check for non-voice capable devices before reading any intents.
@@ -107,6 +117,7 @@ public class CallActivity extends Activity {
     * @param intent Call intent containing data about the handle to call.
     */
    private void processOutgoingCallIntent(Intent intent) {

        String uriString = intent.getData().getSchemeSpecificPart();
        Uri handle = Uri.fromParts(
                PhoneNumberUtils.isUriNumber(uriString) ? "sip" : "tel", uriString, null);
@@ -165,4 +176,14 @@ public class CallActivity extends Activity {
        return (defaultPhoneApp != null
                && TextUtils.equals(defaultPhoneApp.getPackageName(), packageName));
    }

    /**
     * Returns whether the device is voice-capable (e.g. a phone vs a tablet).
     *
     * @return {@code True} if the device is voice-capable.
     */
    private boolean isVoiceCapable() {
        return getApplicationContext().getResources().getBoolean(
                com.android.internal.R.bool.config_voice_capable);
    }
}