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

Commit c7310a80 authored by Leslie Watkins's avatar Leslie Watkins
Browse files

Add HfpClientConnectionServiceTest coverage and change

BluetoothtoothHeadsetClientProxy package name.

Test: atest BluetoothInstrumentationTests
Bug: 190404030
Tag: #stability
Change-Id: Iac18c4fee983bcb1b4ad0819b91d640107466ab3
parent b4d17e1c
Loading
Loading
Loading
Loading
+28 −2
Original line number Diff line number Diff line
@@ -14,13 +14,15 @@
 * limitations under the License.
 */

package android.bluetooth.hfpclient.connserv;
package com.android.bluetooth.hfpclient.connserv;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadsetClient;
import android.bluetooth.BluetoothHeadsetClientCall;
import android.os.Bundle;

import com.android.internal.annotations.VisibleForTesting;

import java.util.List;

/**
@@ -32,7 +34,7 @@ public class BluetoothHeadsetClientProxy {

    private final BluetoothHeadsetClient mBluetoothHeadsetClient;

    public BluetoothHeadsetClientProxy(BluetoothHeadsetClient bluetoothHeadsetClient) {
    private BluetoothHeadsetClientProxy(BluetoothHeadsetClient bluetoothHeadsetClient) {
        mBluetoothHeadsetClient = bluetoothHeadsetClient;
    }

@@ -99,4 +101,28 @@ public class BluetoothHeadsetClientProxy {
    public List<BluetoothHeadsetClientCall> getCurrentCalls(BluetoothDevice device) {
        return mBluetoothHeadsetClient.getCurrentCalls(device);
    }

    /**
     * Factory class for {@link BluetoothHeadsetClientProxy}
     */
    public static class Factory {
        private static Factory sInstance = new Factory();

        @VisibleForTesting
        static void setInstance(Factory instance) {
            sInstance = instance;
        }

        /**
         * Returns an instance of {@link BluetoothHeadsetClientProxy}
         */
        public static BluetoothHeadsetClientProxy build(BluetoothHeadsetClient proxy) {
            return sInstance.buildInternal(proxy);
        }

        protected BluetoothHeadsetClientProxy buildInternal(BluetoothHeadsetClient proxy) {
            return  new BluetoothHeadsetClientProxy(proxy);
        }

    }
}
+0 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package com.android.bluetooth.hfpclient.connserv;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadsetClient;
import android.bluetooth.hfpclient.connserv.BluetoothHeadsetClientProxy;
import android.telecom.Conference;
import android.telecom.Connection;
import android.telecom.PhoneAccountHandle;
+0 −1
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.bluetooth.hfpclient.connserv;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadsetClient;
import android.bluetooth.BluetoothHeadsetClientCall;
import android.bluetooth.hfpclient.connserv.BluetoothHeadsetClientProxy;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
+4 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadsetClient;
import android.bluetooth.BluetoothHeadsetClientCall;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.hfpclient.connserv.BluetoothHeadsetClientProxy;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -288,7 +287,8 @@ public class HfpClientConnectionService extends ConnectionService {
            if (DBG) {
                Log.d(TAG, "onServiceConnected");
            }
            mHeadsetProfile = new BluetoothHeadsetClientProxy((BluetoothHeadsetClient) proxy);
            mHeadsetProfile =
                    BluetoothHeadsetClientProxy.Factory.build((BluetoothHeadsetClient) proxy);

            List<BluetoothDevice> devices = mHeadsetProfile.getConnectedDevices();
            if (devices == null) {
@@ -324,7 +324,8 @@ public class HfpClientConnectionService extends ConnectionService {
            return null;
        }

        HfpClientDeviceBlock block = new HfpClientDeviceBlock(this, device, mHeadsetProfile);
        HfpClientDeviceBlock block =
                HfpClientDeviceBlock.Factory.build(this, device, mHeadsetProfile);
        mDeviceBlocks.put(device, block);
        return block;
    }
+27 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package com.android.bluetooth.hfpclient.connserv;

import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothHeadsetClientCall;
import android.bluetooth.hfpclient.connserv.BluetoothHeadsetClientProxy;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
@@ -28,6 +27,7 @@ import android.telecom.TelecomManager;
import android.util.Log;

import com.android.bluetooth.hfpclient.HeadsetClientService;
import com.android.internal.annotations.VisibleForTesting;

import java.util.HashMap;
import java.util.List;
@@ -361,4 +361,30 @@ public class HfpClientDeviceBlock {

        return bundle;
    }

    /**
     * Factory class for {@link HfpClientDeviceBlock}
     */
    public static class Factory {
        private static Factory sInstance = new Factory();

        @VisibleForTesting
        static void setInstance(Factory instance) {
            sInstance = instance;
        }

        /**
         * Returns an instance of {@link HfpClientDeviceBlock}
         */
        public static HfpClientDeviceBlock build(HfpClientConnectionService connServ,
                BluetoothDevice device, BluetoothHeadsetClientProxy profileProxy) {
            return sInstance.buildInternal(connServ, device, profileProxy);
        }

        protected HfpClientDeviceBlock buildInternal(HfpClientConnectionService connServ,
                BluetoothDevice device, BluetoothHeadsetClientProxy profileProxy) {
            return new HfpClientDeviceBlock(connServ, device, profileProxy);
        }

    }
}
Loading