Update TestCallService app to include a dummy selector.
Also some sprinkled fixes to get outgoing calls working.
Change-Id: I0fe34dfd42cbf75cc05f2a4ca4582a2052682143
diff --git a/tests/Android.mk b/tests/Android.mk
index 23b6950..592d408 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -17,6 +17,9 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ guava \
+
LOCAL_SRC_FILES := $(call all-java-files-under, src)
LOCAL_JAVA_LIBRARIES := android.test.runner
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 5ad1cae..567863e 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -27,6 +27,12 @@
</intent-filter>
</service>
+ <service android:name="com.android.telecomm.testcallservice.DummyCallServiceSelector">
+ <intent-filter>
+ <action android:name="android.telecomm.ICallServiceSelector" />
+ </intent-filter>
+ </service>
+
<activity android:name="com.android.telecomm.testcallservice.TestCallActivity"
android:label="@string/testCallActivityLabel">
<intent-filter>
diff --git a/tests/src/com/android/telecomm/testcallservice/DummyCallServiceSelector.java b/tests/src/com/android/telecomm/testcallservice/DummyCallServiceSelector.java
new file mode 100644
index 0000000..da28ee9
--- /dev/null
+++ b/tests/src/com/android/telecomm/testcallservice/DummyCallServiceSelector.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2014 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.telecomm.testcallservice;
+
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.telecomm.CallInfo;
+import android.telecomm.ICallServiceSelector;
+import android.telecomm.ICallServiceSelectionResponse;
+import android.telecomm.ICallSwitchabilityResponse;
+
+import java.util.List;
+
+/**
+ * Dummy call-service selector which returns the list of call services in the same order in which it
+ * was given. Also returns false for every request on switchability.
+ */
+public class DummyCallServiceSelector extends Service {
+
+ /**
+ * Actual Binder implementation of ICallServiceSelector.
+ */
+ private final IBinder mBinder = new ICallServiceSelector.Stub() {
+ /**
+ * Returns the unaltered list of call services.
+ *
+ * {@inheritDoc}
+ */
+ @Override public void select(
+ CallInfo callInfo,
+ List<String> callServiceIds,
+ ICallServiceSelectionResponse response) throws RemoteException {
+
+ response.setSelectedCallServiceIds(callServiceIds);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void isSwitchable(CallInfo callInfo, ICallSwitchabilityResponse response)
+ throws RemoteException {
+
+ response.setIsSwitchable(false);
+ }
+ };
+
+ /** {@inheritDoc} */
+ @Override
+ public IBinder onBind(Intent intent) {
+ return mBinder;
+ }
+}
diff --git a/tests/src/com/android/telecomm/testcallservice/TestCallService.java b/tests/src/com/android/telecomm/testcallservice/TestCallService.java
index 5685b6f..db768ba 100644
--- a/tests/src/com/android/telecomm/testcallservice/TestCallService.java
+++ b/tests/src/com/android/telecomm/testcallservice/TestCallService.java
@@ -25,6 +25,7 @@
import java.util.Date;
import java.util.Set;
+import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.media.MediaPlayer;
@@ -37,6 +38,7 @@
/**
* Service which provides fake calls to test the ICallService interface.
+ * TODO(santoscordon): Rename all classes in the directory to Dummy* (e.g., DummyCallService).
*/
public class TestCallService extends CallService {
private static final String TAG = TestCallService.class.getSimpleName();
@@ -57,6 +59,17 @@
*/
private MediaPlayer mMediaPlayer;
+ /**
+ * The application context.
+ */
+ private final Context mContext;
+
+
+ /** Persists the specified parameters. */
+ public TestCallService(Context context) {
+ mContext = context;
+ }
+
/** {@inheritDoc} */
@Override
public void setCallServiceAdapter(ICallServiceAdapter callServiceAdapter) {
@@ -66,9 +79,11 @@
mLiveCallIds = Sets.newHashSet();
// Prepare the media player to play a tone when there is a call.
- mMediaPlayer = MediaPlayer.create(null, R.raw.beep_boop);
+ mMediaPlayer = MediaPlayer.create(mContext, R.raw.beep_boop);
mMediaPlayer.setLooping(true);
- mMediaPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
+
+ // TODO(santoscordon): Re-enable audio through voice-call stream.
+ //mMediaPlayer.setAudioStreamType(AudioManager.STREAM_VOICE_CALL);
}
/**
@@ -148,12 +163,7 @@
// Starts audio if not already started.
if (!mMediaPlayer.isPlaying()) {
- try {
- mMediaPlayer.prepare();
- mMediaPlayer.start();
- } catch (IOException e) {
- Log.e(TAG, "Error playing audio", e);
- }
+ mMediaPlayer.start();
}
}
diff --git a/tests/src/com/android/telecomm/testcallservice/TestCallServiceProvider.java b/tests/src/com/android/telecomm/testcallservice/TestCallServiceProvider.java
index 6e420f6..81f95c4 100644
--- a/tests/src/com/android/telecomm/testcallservice/TestCallServiceProvider.java
+++ b/tests/src/com/android/telecomm/testcallservice/TestCallServiceProvider.java
@@ -38,7 +38,7 @@
Log.i(TAG, "lookupCallServices()");
try {
- TestCallService callService = new TestCallService();
+ TestCallService callService = new TestCallService(this);
List<IBinder> callServiceList = Lists.newArrayList(callService.getBinder());
response.setCallServices(callServiceList);
} catch (RemoteException e) {