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

Commit c797e856 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 9354090 from 616d44b4 to tm-qpr2-release

Change-Id: If1d52acd566162f6dcee6f39a05a628d4004a635
parents 2d208046 616d44b4
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -100,14 +100,14 @@ public class LeAudioService extends ProfileService {
    private static final int AUDIO_DIRECTION_NONE = 0x00;

    /**
     * Indicates group audio support for input direction
     * Indicates group audio support for output direction
     */
    private static final int AUDIO_DIRECTION_INPUT_BIT = 0x01;
    private static final int AUDIO_DIRECTION_OUTPUT_BIT = 0x01;

    /**
     * Indicates group audio support for output direction
     * Indicates group audio support for input direction
     */
    private static final int AUDIO_DIRECTION_OUTPUT_BIT = 0x02;
    private static final int AUDIO_DIRECTION_INPUT_BIT = 0x02;

    private AdapterService mAdapterService;
    private DatabaseManager mDatabaseManager;
+8 −4
Original line number Diff line number Diff line
@@ -1045,7 +1045,8 @@ public class LeAudioServiceTest {
    @Test
    public void testGetActiveDevices() {
        int groupId = 1;
        int direction = 2;
        /* AUDIO_DIRECTION_OUTPUT_BIT = 0x01 */
        int direction = 1;
        int snkAudioLocation = 3;
        int srcAudioLocation = 4;
        int availableContexts = 5;
@@ -1295,7 +1296,8 @@ public class LeAudioServiceTest {
    @Test
    public void testLeadGroupDeviceDisconnects() {
        int groupId = 1;
        int direction = 2;
        /* AUDIO_DIRECTION_OUTPUT_BIT = 0x01 */
        int direction = 1;
        int snkAudioLocation = 3;
        int srcAudioLocation = 4;
        int availableContexts = 5;
@@ -1359,7 +1361,8 @@ public class LeAudioServiceTest {
    @Test
    public void testLeadGroupDeviceReconnects() {
        int groupId = 1;
        int direction = 2;
        /* AUDIO_DIRECTION_OUTPUT_BIT = 0x01 */
        int direction = 1;
        int snkAudioLocation = 3;
        int srcAudioLocation = 4;
        int availableContexts = 5;
@@ -1426,7 +1429,8 @@ public class LeAudioServiceTest {
    public void testVolumeCache() {
        int groupId = 1;
        int volume = 100;
        int direction = 2;
        /* AUDIO_DIRECTION_OUTPUT_BIT = 0x01 */
        int direction = 1;
        int availableContexts = 4;

        doReturn(true).when(mNativeInterface).connectLeAudio(any(BluetoothDevice.class));
+42 −168

File changed.

Preview size limit exceeded, changes collapsed.

+12 −130

File changed.

Preview size limit exceeded, changes collapsed.

+43 −23
Original line number Diff line number Diff line
@@ -22,12 +22,14 @@ import android.annotation.SuppressLint;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.UserHandle;
import android.util.CloseGuard;
@@ -54,6 +56,9 @@ public abstract class BluetoothProfileConnector<T> {
    // -3 match with UserHandle.USER_CURRENT_OR_SELF
    private static final UserHandle USER_HANDLE_CURRENT_OR_SELF = UserHandle.of(-3);

    private static final int MESSAGE_SERVICE_CONNECTED = 100;
    private static final int MESSAGE_SERVICE_DISCONNECTED = 101;

    private final IBluetoothStateChangeCallback mBluetoothStateChangeCallback =
            new IBluetoothStateChangeCallback.Stub() {
        public void onBluetoothStateChange(boolean up) {
@@ -89,22 +94,22 @@ public abstract class BluetoothProfileConnector<T> {
        return comp;
    }

    private final ServiceConnection mConnection = new ServiceConnection() {
    private final IBluetoothProfileServiceConnection mConnection =
            new IBluetoothProfileServiceConnection.Stub() {
        @Override
        public void onServiceConnected(ComponentName className, IBinder service) {
            logDebug("Proxy object connected");
            mService = getServiceInterface(service);

            if (mServiceListener != null) {
                mServiceListener.onServiceConnected(mProfileId, mProfileProxy);
            }
            mHandler.sendMessage(mHandler.obtainMessage(
                    MESSAGE_SERVICE_CONNECTED));
        }

        @Override
        public void onServiceDisconnected(ComponentName className) {
            logDebug("Proxy object disconnected");
            doUnbind();
            if (mServiceListener != null) {
                mServiceListener.onServiceDisconnected(mProfileId);
            }
            mHandler.sendMessage(mHandler.obtainMessage(
                    MESSAGE_SERVICE_DISCONNECTED));
        }
    };

@@ -123,23 +128,16 @@ public abstract class BluetoothProfileConnector<T> {
        doUnbind();
    }

    @SuppressLint("AndroidFrameworkRequiresPermission")
    private boolean doBind() {
        synchronized (mConnection) {
            if (mService == null) {
                logDebug("Binding service...");
                mCloseGuard.open("doUnbind");
                try {
                    Intent intent = new Intent(mServiceName);
                    ComponentName comp = resolveSystemService(intent, mContext.getPackageManager());
                    intent.setComponent(comp);
                    if (comp == null || !mContext.bindServiceAsUser(intent, mConnection, 0,
                            USER_HANDLE_CURRENT_OR_SELF)) {
                        logError("Could not bind to Bluetooth Service with " + intent);
                        return false;
                    }
                } catch (SecurityException se) {
                    logError("Failed to bind service. " + se);
                    return BluetoothAdapter.getDefaultAdapter().getBluetoothManager()
                            .bindBluetoothProfileService(mProfileId, mServiceName, mConnection);
                } catch (RemoteException re) {
                    logError("Failed to bind service. " + re);
                    return false;
                }
            }
@@ -153,9 +151,10 @@ public abstract class BluetoothProfileConnector<T> {
                logDebug("Unbinding service...");
                mCloseGuard.close();
                try {
                    mContext.unbindService(mConnection);
                } catch (IllegalArgumentException ie) {
                    logError("Unable to unbind service: " + ie);
                    BluetoothAdapter.getDefaultAdapter().getBluetoothManager()
                            .unbindBluetoothProfileService(mProfileId, mConnection);
                } catch (RemoteException re) {
                    logError("Unable to unbind service: " + re);
                } finally {
                    mService = null;
                }
@@ -224,4 +223,25 @@ public abstract class BluetoothProfileConnector<T> {
    private void logError(String log) {
        Log.e(mProfileName, log);
    }

    @SuppressLint("AndroidFrameworkBluetoothPermission")
    private final Handler mHandler = new Handler(Looper.getMainLooper()) {
        @Override
        public void handleMessage(Message msg) {
            switch (msg.what) {
                case MESSAGE_SERVICE_CONNECTED: {
                    if (mServiceListener != null) {
                        mServiceListener.onServiceConnected(mProfileId, mProfileProxy);
                    }
                    break;
                }
                case MESSAGE_SERVICE_DISCONNECTED: {
                    if (mServiceListener != null) {
                        mServiceListener.onServiceDisconnected(mProfileId);
                    }
                    break;
                }
            }
        }
    };
}
Loading