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

Commit 808adcc2 authored by Tyler Gunn's avatar Tyler Gunn Committed by Gerrit Code Review
Browse files

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

parents 560f8f30 9895a287
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;
    }