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

Commit 62f9cfd2 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Add Telecom Call Audio Test App.

It is sometimes useful to be able to have a device auto answer and play
back some audio.  This can be useful for edge of service call testing
where we need one endpoint to remain in a stable service area and another
to be mobile for testing purposes.

This app has one purpose only; it exposes an activity which allows the user
to enable auto answer.  When enabled, the first paragraph of
"A Tale of Two Cities" by Charles Dickens is read to the caller in a
continual loop.

Test: This is just a test app itself.
Bug: 163085177
Change-Id: I46094262f464d935f1d41aa9ac1fe5be65ca43d3
parent ae810381
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
//
// Copyright (C) 2021 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package {
    default_applicable_licenses: ["Android-Apache-2.0"],
}

android_test {
    name: "TelecomCallAudioTestApp",
    static_libs: [
        "androidx.legacy_legacy-support-v4",
        "guava",
    ],
    srcs: ["src/**/*.java"],
    platform_apis: true,
    certificate: "platform",
    privileged: true,
}
+58 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
     coreApp="true"
     package="com.android.server.telecom.callaudiotest">

    <uses-sdk android:minSdkVersion="28"
         android:targetSdkVersion="29"/>
    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.CALL_PHONE"/>
    <uses-permission android:name="android.permission.CONTROL_INCALL_EXPERIENCE"/>
    <uses-permission android:name="android.permission.READ_CALL_LOG"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
    <uses-permission android:name="android.permission.MODIFY_AUDIO_ROUTING"/>
    <uses-permission android:name="android.permission.MODIFY_PHONE_STATE"/>
    <uses-permission android:name="android.permission.WRITE_CALL_LOG"/>

    <application android:label="Telecom Call Audio Test">
        <uses-library android:name="android.test.runner"/>

        <service android:name="com.android.server.telecom.callaudiotest.CallAudioTestInCallService"
             android:permission="android.permission.BIND_INCALL_SERVICE"
             android:exported="true">
            <meta-data android:name="android.telecom.IN_CALL_SERVICE_CAR_MODE_UI"
                       android:value="false"/>
            <meta-data android:name="android.telecom.INCLUDE_SELF_MANAGED_CALLS"
                       android:value="false"/>
          <intent-filter>
              <action android:name="android.telecom.InCallService"/>
          </intent-filter>
        </service>

        <activity android:name="com.android.server.telecom.callaudiotest.CallAudioTestActivity"
             android:label="Call Audio Test"
             android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>
+41 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    <TextView
        android:id="@+id/appLabel"
        android:layout_gravity="left"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="25dp"
        android:text="Call Audio Testing" />
    <TextView
        android:id="@+id/appDescription"
        android:layout_gravity="left"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="12dp"
        android:text="You can enabled auto answer and calls will be answered and some awesome audio will be looped to the caller." />
    <CheckBox
        android:id="@+id/enableAutoAnswer"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Answer calls and loop audio" />
</LinearLayout>
+278 KiB

File added.

No diff preview for this file type.

+61 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server.telecom.callaudiotest;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;

/**
 * Activity to configure the auto answer behavior.
 */
public class CallAudioTestActivity extends Activity {
    private static final int RESULT_PICK_FILE = 1;
    public static final String AUDIO_TEST_PREFS = "audio_test_prefs";
    public static final String AUTO_ANSWER_ENABLED = "auto_answer_enabled";
    private CheckBox mEnable;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.call_audio_test_activity);
        mEnable = findViewById(R.id.enableAutoAnswer);
        mEnable.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                SharedPreferences prefs = getSharedPreferences(AUDIO_TEST_PREFS, MODE_PRIVATE);
                SharedPreferences.Editor edit = prefs.edit();
                edit.putBoolean(AUTO_ANSWER_ENABLED, isChecked);
                edit.apply();
            }
        });
        loadPreferences();
    }

    private void loadPreferences() {
        SharedPreferences prefs = getSharedPreferences(AUDIO_TEST_PREFS, MODE_PRIVATE);
        mEnable.setChecked(prefs.getBoolean(AUTO_ANSWER_ENABLED, false));
    }
}
Loading