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

Commit 77266134 authored by David Duarte's avatar David Duarte
Browse files

Make BluetoothProfileConnector final

Remove the need for each profile to inherit the
BluetoothProfileConnector class.

Bug: 305741984
Test: atest BluetoothProfileConnectorTest
Change-Id: I7e580b42cb01ca8ed7a832720dfd168c83026239
parent 075842e4
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.content.AttributionSource;
import android.content.Context;
import android.os.Build;
import android.os.IBinder;
import android.os.ParcelUuid;
import android.os.RemoteException;
import android.util.Log;
@@ -271,14 +270,9 @@ public final class BluetoothA2dp implements BluetoothProfile {

    private final BluetoothAdapter mAdapter;
    private final AttributionSource mAttributionSource;
    private final BluetoothProfileConnector<IBluetoothA2dp> mProfileConnector =
            new BluetoothProfileConnector(this, BluetoothProfile.A2DP, "BluetoothA2dp",
                    IBluetoothA2dp.class.getName()) {
                @Override
                public IBluetoothA2dp getServiceInterface(IBinder service) {
                    return IBluetoothA2dp.Stub.asInterface(service);
                }
    };
    private final BluetoothProfileConnector mProfileConnector =
            new BluetoothProfileConnector(
                    this, BluetoothProfile.A2DP, "BluetoothA2dp", IBluetoothA2dp.class.getName());

    /**
     * Create a BluetoothA2dp proxy object for interacting with the local
@@ -301,7 +295,7 @@ public final class BluetoothA2dp implements BluetoothProfile {
    }

    private IBluetoothA2dp getService() {
        return mProfileConnector.getService();
        return IBluetoothA2dp.Stub.asInterface(mProfileConnector.getService());
    }

    @Override
+7 −10
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@ import android.compat.annotation.UnsupportedAppUsage;
import android.content.AttributionSource;
import android.content.Context;
import android.os.Build;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

@@ -85,14 +84,12 @@ public final class BluetoothA2dpSink implements BluetoothProfile {

    private final BluetoothAdapter mAdapter;
    private final AttributionSource mAttributionSource;
    private final BluetoothProfileConnector<IBluetoothA2dpSink> mProfileConnector =
            new BluetoothProfileConnector(this, BluetoothProfile.A2DP_SINK,
                    "BluetoothA2dpSink", IBluetoothA2dpSink.class.getName()) {
                @Override
                public IBluetoothA2dpSink getServiceInterface(IBinder service) {
                    return IBluetoothA2dpSink.Stub.asInterface(service);
                }
    };
    private final BluetoothProfileConnector mProfileConnector =
            new BluetoothProfileConnector(
                    this,
                    BluetoothProfile.A2DP_SINK,
                    "BluetoothA2dpSink",
                    IBluetoothA2dpSink.class.getName());

    /**
     * Create a BluetoothA2dp proxy object for interacting with the local
@@ -112,7 +109,7 @@ public final class BluetoothA2dpSink implements BluetoothProfile {
    }

    private IBluetoothA2dpSink getService() {
        return mProfileConnector.getService();
        return IBluetoothA2dpSink.Stub.asInterface(mProfileConnector.getService());
    }

    @Override
+7 −10
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.bluetooth.annotations.RequiresBluetoothConnectPermission;
import android.bluetooth.annotations.RequiresLegacyBluetoothPermission;
import android.content.AttributionSource;
import android.content.Context;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;

@@ -92,14 +91,12 @@ public final class BluetoothAvrcpController implements BluetoothProfile {

    private final BluetoothAdapter mAdapter;
    private final AttributionSource mAttributionSource;
    private final BluetoothProfileConnector<IBluetoothAvrcpController> mProfileConnector =
            new BluetoothProfileConnector(this, BluetoothProfile.AVRCP_CONTROLLER,
                    "BluetoothAvrcpController", IBluetoothAvrcpController.class.getName()) {
                @Override
                public IBluetoothAvrcpController getServiceInterface(IBinder service) {
                    return IBluetoothAvrcpController.Stub.asInterface(service);
                }
    };
    private final BluetoothProfileConnector mProfileConnector =
            new BluetoothProfileConnector(
                    this,
                    BluetoothProfile.AVRCP_CONTROLLER,
                    "BluetoothAvrcpController",
                    IBluetoothAvrcpController.class.getName());

    /**
     * Create a BluetoothAvrcpController proxy object for interacting with the local
@@ -119,7 +116,7 @@ public final class BluetoothAvrcpController implements BluetoothProfile {
    }

    private IBluetoothAvrcpController getService() {
        return mProfileConnector.getService();
        return IBluetoothAvrcpController.Stub.asInterface(mProfileConnector.getService());
    }

    @Override
+7 −10
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import android.annotation.SdkConstant.SdkConstantType;
import android.annotation.SystemApi;
import android.content.AttributionSource;
import android.content.Context;
import android.os.IBinder;
import android.os.ParcelUuid;
import android.os.RemoteException;
import android.util.CloseGuard;
@@ -207,14 +206,12 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto

    private final BluetoothAdapter mAdapter;
    private final AttributionSource mAttributionSource;
    private final BluetoothProfileConnector<IBluetoothCsipSetCoordinator> mProfileConnector =
            new BluetoothProfileConnector(this, BluetoothProfile.CSIP_SET_COORDINATOR, TAG,
                    IBluetoothCsipSetCoordinator.class.getName()) {
                @Override
                public IBluetoothCsipSetCoordinator getServiceInterface(IBinder service) {
                    return IBluetoothCsipSetCoordinator.Stub.asInterface(service);
                }
            };
    private final BluetoothProfileConnector mProfileConnector =
            new BluetoothProfileConnector(
                    this,
                    BluetoothProfile.CSIP_SET_COORDINATOR,
                    TAG,
                    IBluetoothCsipSetCoordinator.class.getName());

    /**
     * Create a BluetoothCsipSetCoordinator proxy object for interacting with the local
@@ -246,7 +243,7 @@ public final class BluetoothCsipSetCoordinator implements BluetoothProfile, Auto
    }

    private IBluetoothCsipSetCoordinator getService() {
        return mProfileConnector.getService();
        return IBluetoothCsipSetCoordinator.Stub.asInterface(mProfileConnector.getService());
    }

    /**
+7 −11
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.annotation.SystemApi;
import android.bluetooth.annotations.RequiresBluetoothConnectPermission;
import android.content.AttributionSource;
import android.content.Context;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.CloseGuard;
import android.util.Log;
@@ -506,15 +505,12 @@ public final class BluetoothHapClient implements BluetoothProfile, AutoCloseable

    private final BluetoothAdapter mAdapter;
    private final AttributionSource mAttributionSource;
    private final BluetoothProfileConnector<IBluetoothHapClient> mProfileConnector =
            new BluetoothProfileConnector(this, BluetoothProfile.HAP_CLIENT, "BluetoothHapClient",
                    IBluetoothHapClient.class.getName()) {
                @Override
                public IBluetoothHapClient getServiceInterface(IBinder service) {
                    return IBluetoothHapClient.Stub.asInterface(service);
                }
            };

    private final BluetoothProfileConnector mProfileConnector =
            new BluetoothProfileConnector(
                    this,
                    BluetoothProfile.HAP_CLIENT,
                    "BluetoothHapClient",
                    IBluetoothHapClient.class.getName());

    /**
     * Create a BluetoothHapClient proxy object for interacting with the local
@@ -548,7 +544,7 @@ public final class BluetoothHapClient implements BluetoothProfile, AutoCloseable
    }

    private IBluetoothHapClient getService() {
        return mProfileConnector.getService();
        return IBluetoothHapClient.Stub.asInterface(mProfileConnector.getService());
    }

    /**
Loading