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

Commit a14d1236 authored by Hall Liu's avatar Hall Liu
Browse files

Add call composer support to telecom testapp

Bug: 181045366
Test: manual
Change-Id: I0a8e503ee3c85a34de07b8e87e54ee7cfbac6a83
parent 67f64a66
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -131,6 +131,11 @@
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"/>
    </LinearLayout>
    <TextView
        android:id="@+id/incoming_composer_attachments"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"/>
    <Button
        android:id="@+id/disable_incallservice"
        android:layout_width="wrap_content"
+5 −0
Original line number Diff line number Diff line
@@ -59,6 +59,11 @@
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/startCallWithRtt"/>
    <CheckBox
        android:id="@+id/add_composer_attachments_checkbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/addComposerAttachments"/>
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
+2 −0
Original line number Diff line number Diff line
@@ -44,6 +44,8 @@

    <string name="startCallWithRtt">Start call with RTT</string>

    <string name="addComposerAttachments">Add call composer attachments</string>

    <string name="rttIfaceButton">RTT</string>

    <string name="endRttButton">End RTT</string>
+17 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
import android.os.PersistableBundle;
@@ -32,8 +33,18 @@ public class TestDialerActivity extends Activity {

    private EditText mNumberView;
    private CheckBox mRttCheckbox;
    private CheckBox mComposerCheckbox;
    private EditText mPriorityView;

    private static final String COMPOSER_SUBJECT = "Sample call composer subject";
    private static final Location COMPOSER_LOCATION;
    static {
        // Area 51
        COMPOSER_LOCATION = new Location("");
        COMPOSER_LOCATION.setLongitude(-115.806407);
        COMPOSER_LOCATION.setLatitude(37.236214);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
@@ -68,6 +79,7 @@ public class TestDialerActivity extends Activity {

        mNumberView = (EditText) findViewById(R.id.number);
        mRttCheckbox = (CheckBox) findViewById(R.id.call_with_rtt_checkbox);
        mComposerCheckbox = (CheckBox) findViewById(R.id.add_composer_attachments_checkbox);
        findViewById(R.id.enable_car_mode).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
@@ -169,6 +181,11 @@ public class TestDialerActivity extends Activity {
        if (mRttCheckbox.isChecked()) {
            extras.putBoolean(TelecomManager.EXTRA_START_CALL_WITH_RTT, true);
        }
        if (mComposerCheckbox.isChecked()) {
            extras.putInt(TelecomManager.EXTRA_PRIORITY, TelecomManager.PRIORITY_URGENT);
            extras.putParcelable(TelecomManager.EXTRA_LOCATION, COMPOSER_LOCATION);
            extras.putString(TelecomManager.EXTRA_CALL_SUBJECT, COMPOSER_SUBJECT);
        }

        Bundle intentExtras = new Bundle();
        intentExtras.putBundle(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS, extras);
+39 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.bluetooth.BluetoothDevice;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Bundle;
import android.telecom.Call;
import android.telecom.CallAudioState;
@@ -248,6 +249,44 @@ public class TestInCallUI extends Activity {
                enableInCallService();
            }
        });

        // Find the ringing call and populate the composer extras
        for (int i = 0; i < TestCallList.getInstance().size(); i++) {
            Call call = TestCallList.getInstance().getCall(i);
            if (call.getState() == Call.STATE_RINGING) {
                int priority = call.getDetails()
                        .getIntentExtras().getInt(TelecomManager.EXTRA_PRIORITY, -1);
                Location location = call.getDetails()
                        .getIntentExtras().getParcelable(TelecomManager.EXTRA_LOCATION);
                String subject = call.getDetails()
                        .getIntentExtras().getString(TelecomManager.EXTRA_CALL_SUBJECT);

                StringBuilder display = new StringBuilder();
                display.append("priority=");
                switch (priority) {
                    case TelecomManager.PRIORITY_NORMAL:
                        display.append("normal");
                        break;
                    case TelecomManager.PRIORITY_URGENT:
                        display.append("urgent");
                        break;
                    default:
                        display.append("unset");
                }
                display.append(";");
                if (location != null) {
                    display.append("lat=" + location.getLatitude());
                    display.append("lon=" + location.getLongitude());
                } else {
                    display.append("loc=null");
                }

                display.append(" subject=" + subject);
                TextView attachmentsTextView = findViewById(R.id.incoming_composer_attachments);
                attachmentsTextView.setText(display.toString());
                break;
            }
        }
    }

    public void updateCallAudioState(CallAudioState cas) {