Fix Telecomm tests

Change-Id: I6aacffbd26a2e9446d1e161e39981c85505608e7
diff --git a/src/com/android/telecomm/TelephonyUtil.java b/src/com/android/telecomm/TelephonyUtil.java
index a8cfb3e..83303c7 100644
--- a/src/com/android/telecomm/TelephonyUtil.java
+++ b/src/com/android/telecomm/TelephonyUtil.java
@@ -28,8 +28,7 @@
 public final class TelephonyUtil {
     private static final String TAG = TelephonyUtil.class.getSimpleName();
 
-    private static final String TELEPHONY_PACKAGE_NAME =
-            "com.android.phone";
+    private static final String TELEPHONY_PACKAGE_NAME = "com.android.phone";
 
     private static final String PSTN_CALL_SERVICE_CLASS_NAME =
             "com.android.services.telephony.PstnConnectionService";
@@ -37,13 +36,9 @@
     private TelephonyUtil() {}
 
     static boolean isPstnCallService(CallServiceDescriptor descriptor) {
-        ComponentName componentName = descriptor.getServiceComponent();
-        if (TELEPHONY_PACKAGE_NAME.equals(componentName.getPackageName())) {
-            String className = componentName.getClassName();
-            return PSTN_CALL_SERVICE_CLASS_NAME.equals(className);
-        }
-
-        return false;
+        final ComponentName pstnComponentName = new ComponentName(
+                TELEPHONY_PACKAGE_NAME, PSTN_CALL_SERVICE_CLASS_NAME);
+        return pstnComponentName.equals(descriptor.getServiceComponent());
     }
 
     /**
diff --git a/tests/src/com/android/telecomm/testapps/TestConnectionService.java b/tests/src/com/android/telecomm/testapps/TestConnectionService.java
index c6f9fe3..6315e9a 100644
--- a/tests/src/com/android/telecomm/testapps/TestConnectionService.java
+++ b/tests/src/com/android/telecomm/testapps/TestConnectionService.java
@@ -62,11 +62,6 @@
             }
 
             @Override
-            public void onAudioStateChanged(RemoteConnection connection, CallAudioState state) {
-                setAudioState(state);
-            }
-
-            @Override
             public void onDisconnected(RemoteConnection connection, int cause, String message) {
                 setDisconnected(cause, message);
                 destroyCall(TestConnection.this);
@@ -180,6 +175,13 @@
             }
         }
 
+        @Override
+        protected void onSetAudioState(CallAudioState state) {
+            if (mRemoteConnection != null) {
+                mRemoteConnection.setAudioState(state);
+            }
+        }
+
         private void setState(int state) {
             switch (state) {
                 case Connection.State.ACTIVE:
@@ -257,14 +259,6 @@
 
     /** {@inheritDoc} */
     @Override
-    public void onAdapterAttached(CallServiceAdapter callServiceAdapter) {
-        log("onAdapterAttached");
-        mMediaPlayer = createMediaPlayer();
-        super.onAdapterAttached(callServiceAdapter);
-    }
-
-    /** {@inheritDoc} */
-    @Override
     public boolean onUnbind(Intent intent) {
         log("onUnbind");
         mMediaPlayer = null;
@@ -273,7 +267,10 @@
 
     private void activateCall(TestConnection connection) {
         if (!connection.isProxy()) {
-            if (mMediaPlayer != null && !mMediaPlayer.isPlaying()) {
+            if (mMediaPlayer == null) {
+                mMediaPlayer = createMediaPlayer();
+            }
+            if (!mMediaPlayer.isPlaying()) {
                 mMediaPlayer.start();
             }
         }