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

Commit 9895a287 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Update Telecom test app to support bluetooth for self-managed calls.

Add support for bluetooth route in the telecom test app.
Also, update the test connectionservice to set mediaplayer properties so
that its speech uses the correct audio attributes to more accurately
emulate how a real voip app would do things.

And yes, the buttons are now emojis in the test UI. :)

Bug: 78770358
Test: Manually tested.
Change-Id: I69c595fef852717caad38719abf33911dec3dd86
parent 9c71effd
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -65,13 +65,18 @@
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Speaker"
            android:text="🔊"
            android:id="@+id/speakerButton" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Earpiece"
            android:text="👂"
            android:id="@+id/earpieceButton" />
        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="🎧"
            android:id="@+id/bluetoothButton" />
        <CheckBox
            android:id="@+id/holdable"
            android:layout_width="wrap_content"
+12 −0
Original line number Diff line number Diff line
@@ -104,6 +104,16 @@ public class SelfManagedCallListAdapter extends BaseAdapter {
        }
    };

    private View.OnClickListener mBluetoothListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            View parent = (View) v.getParent().getParent();
            SelfManagedConnection connection = (SelfManagedConnection) parent.getTag();
            connection.setAudioRoute(CallAudioState.ROUTE_BLUETOOTH);
            notifyDataSetChanged();
        }
    };

    private View.OnClickListener mHoldableListener = new View.OnClickListener() {
        @Override
        public void onClick (View v) {
@@ -221,6 +231,8 @@ public class SelfManagedCallListAdapter extends BaseAdapter {
        speakerButton.setOnClickListener(mSpeakerListener);
        View earpieceButton = view.findViewById(R.id.earpieceButton);
        earpieceButton.setOnClickListener(mEarpieceListener);
        View bluetoothButton = view.findViewById(R.id.bluetoothButton);
        bluetoothButton.setOnClickListener(mBluetoothListener);
        View missedButton = view.findViewById(R.id.missedButton);
        missedButton.setOnClickListener(mMissedListener);
        missedButton.setVisibility(isRinging ? View.VISIBLE : View.GONE);
+14 −1
Original line number Diff line number Diff line
@@ -16,11 +16,16 @@

package com.android.server.telecom.testapps;

import static android.media.AudioAttributes.CONTENT_TYPE_SPEECH;
import static android.media.AudioAttributes.USAGE_VOICE_COMMUNICATION;

import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.media.AudioAttributes;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
@@ -582,8 +587,16 @@ public class TestConnectionService extends ConnectionService {
    }

    private MediaPlayer createMediaPlayer() {
        AudioAttributes attributes = new AudioAttributes.Builder()
                .setUsage(USAGE_VOICE_COMMUNICATION)
                .setContentType(CONTENT_TYPE_SPEECH)
                .build();

        final int audioSessionId = ((AudioManager) getSystemService(
                Context.AUDIO_SERVICE)).generateAudioSessionId();
        // Prepare the media player to play a tone when there is a call.
        MediaPlayer mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.beep_boop);
        MediaPlayer mediaPlayer = MediaPlayer.create(getApplicationContext(), R.raw.beep_boop, attributes,
                audioSessionId);
        mediaPlayer.setLooping(true);
        return mediaPlayer;
    }