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

Commit a18189cb authored by Charlie Boutier's avatar Charlie Boutier
Browse files

Pandora: Update a2dp from experimental to stable

* Android.bp python: remove a2dp from pandora_experimental
* PandoraServer: update A2dp.kt and A2dpSink.kt
* mmi2grpc: change pandora_experimental to pandora for a2dp

Test: m PandoraServer
Bug: 290416189

Change-Id: Id406a55ffc4aee01dcac467e8ccc2a2588a98a45
parent 12f447b2
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -22,8 +22,8 @@ from mmi2grpc._audio import AudioSignal
from mmi2grpc._helpers import assert_description, match_description
from mmi2grpc._proxy import ProfileProxy
from mmi2grpc._rootcanal import RootCanal
from pandora_experimental.a2dp_grpc import A2DP
from pandora_experimental.a2dp_pb2 import Sink, Source, PlaybackAudioRequest
from pandora.a2dp_grpc import A2DP
from pandora.a2dp_pb2 import Sink, Source, PlaybackAudioRequest
from pandora.host_grpc import Host
from pandora.host_pb2 import Connection

+5 −6
Original line number Diff line number Diff line
@@ -21,8 +21,8 @@ from grpc import RpcError
from mmi2grpc._audio import AudioSignal
from mmi2grpc._helpers import assert_description
from mmi2grpc._proxy import ProfileProxy
from pandora_experimental.a2dp_grpc import A2DP
from pandora_experimental.a2dp_pb2 import Sink, Source
from pandora.a2dp_grpc import A2DP
from pandora.a2dp_pb2 import Sink, Source
from pandora_experimental.avrcp_grpc import AVRCP
from pandora.host_grpc import Host
from pandora.host_pb2 import Connection
@@ -470,10 +470,9 @@ class AVRCPProxy(ProfileProxy):
        passthrough command, if the current streaming state is not relevant to
        this IUT, please press 'OK to continue.
        """
        if not self.a2dp.IsSuspended(source=self.source).is_suspended:
            return "Yes"
        else:
            return "No"

        suspended = self.a2dp.IsSuspended(source=self.source).value
        return "Yes" if not suspended else "No"

    @assert_description
    def TSC_AVRCP_mmi_iut_reject_invalid_get_capabilities(self, **kwargs):
+16 −11
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ import android.content.Intent
import android.content.IntentFilter
import android.media.*
import android.util.Log
import com.google.protobuf.BoolValue
import com.google.protobuf.ByteString
import io.grpc.Status
import io.grpc.stub.StreamObserver
import java.io.Closeable
@@ -41,7 +43,7 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.shareIn
import pandora.A2DPGrpc.A2DPImplBase
import pandora.A2dpProto.*
import pandora.A2DPProto.*

@kotlinx.coroutines.ExperimentalCoroutinesApi
class A2dp(val context: Context) : A2DPImplBase(), Closeable {
@@ -104,7 +106,8 @@ class A2dp(val context: Context) : A2DPImplBase(), Closeable {
            // early.
            delay(2000L)

            val source = Source.newBuilder().setConnection(request.connection).build()
            val source =
                Source.newBuilder().setCookie(ByteString.copyFrom(device.getAddress(), "UTF-8"))
            OpenSourceResponse.newBuilder().setSource(source).build()
        }
    }
@@ -140,7 +143,8 @@ class A2dp(val context: Context) : A2DPImplBase(), Closeable {
            // early.
            delay(2000L)

            val source = Source.newBuilder().setConnection(request.connection).build()
            val source =
                Source.newBuilder().setCookie(ByteString.copyFrom(device.getAddress(), "UTF-8"))
            WaitSourceResponse.newBuilder().setSource(source).build()
        }
    }
@@ -150,7 +154,7 @@ class A2dp(val context: Context) : A2DPImplBase(), Closeable {
            if (audioTrack == null) {
                audioTrack = buildAudioTrack()
            }
            val device = request.source.connection.toBluetoothDevice(bluetoothAdapter)
            val device = bluetoothAdapter.getRemoteDevice(request.source.cookie.toString("UTF-8"))
            Log.i(TAG, "start: device=$device")

            if (bluetoothA2dp.getConnectionState(device) != BluetoothA2dp.STATE_CONNECTED) {
@@ -177,7 +181,7 @@ class A2dp(val context: Context) : A2DPImplBase(), Closeable {
        responseObserver: StreamObserver<SuspendResponse>
    ) {
        grpcUnary<SuspendResponse>(scope, responseObserver) {
            val device = request.source.connection.toBluetoothDevice(bluetoothAdapter)
            val device = bluetoothAdapter.getRemoteDevice(request.source.cookie.toString("UTF-8"))
            Log.i(TAG, "suspend: device=$device")

            if (bluetoothA2dp.getConnectionState(device) != BluetoothA2dp.STATE_CONNECTED) {
@@ -202,10 +206,10 @@ class A2dp(val context: Context) : A2DPImplBase(), Closeable {

    override fun isSuspended(
        request: IsSuspendedRequest,
        responseObserver: StreamObserver<IsSuspendedResponse>
        responseObserver: StreamObserver<BoolValue>
    ) {
        grpcUnary<IsSuspendedResponse>(scope, responseObserver) {
            val device = request.source.connection.toBluetoothDevice(bluetoothAdapter)
        grpcUnary(scope, responseObserver) {
            val device = bluetoothAdapter.getRemoteDevice(request.source.cookie.toString("UTF-8"))
            Log.i(TAG, "isSuspended: device=$device")

            if (bluetoothA2dp.getConnectionState(device) != BluetoothA2dp.STATE_CONNECTED) {
@@ -213,13 +217,14 @@ class A2dp(val context: Context) : A2DPImplBase(), Closeable {
            }

            val isSuspended = bluetoothA2dp.isA2dpPlaying(device)
            IsSuspendedResponse.newBuilder().setIsSuspended(isSuspended).build()

            BoolValue.newBuilder().setValue(isSuspended).build()
        }
    }

    override fun close(request: CloseRequest, responseObserver: StreamObserver<CloseResponse>) {
        grpcUnary<CloseResponse>(scope, responseObserver) {
            val device = request.source.connection.toBluetoothDevice(bluetoothAdapter)
            val device = bluetoothAdapter.getRemoteDevice(request.source.cookie.toString("UTF-8"))
            Log.i(TAG, "close: device=$device")

            if (bluetoothA2dp.getConnectionState(device) != BluetoothA2dp.STATE_CONNECTED) {
@@ -296,7 +301,7 @@ class A2dp(val context: Context) : A2DPImplBase(), Closeable {
        responseObserver: StreamObserver<GetAudioEncodingResponse>
    ) {
        grpcUnary<GetAudioEncodingResponse>(scope, responseObserver) {
            val device = request.source.connection.toBluetoothDevice(bluetoothAdapter)
            val device = bluetoothAdapter.getRemoteDevice(request.source.cookie.toString("UTF-8"))
            Log.i(TAG, "getAudioEncoding: device=$device")

            if (bluetoothA2dp.getConnectionState(device) != BluetoothA2dp.STATE_CONNECTED) {
+5 −3
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.Intent
import android.content.IntentFilter
import android.media.*
import android.util.Log
import com.google.protobuf.ByteString
import io.grpc.stub.StreamObserver
import java.io.Closeable
import kotlinx.coroutines.CoroutineScope
@@ -37,7 +38,7 @@ import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.shareIn
import pandora.A2DPGrpc.A2DPImplBase
import pandora.A2dpProto.*
import pandora.A2DPProto.*

@kotlinx.coroutines.ExperimentalCoroutinesApi
class A2dpSink(val context: Context) : A2DPImplBase(), Closeable {
@@ -93,14 +94,15 @@ class A2dpSink(val context: Context) : A2DPImplBase(), Closeable {
                }
            }

            val sink = Sink.newBuilder().setConnection(request.connection).build()
            val sink =
                Sink.newBuilder().setCookie(ByteString.copyFrom(device.getAddress(), "UTF-8"))
            WaitSinkResponse.newBuilder().setSink(sink).build()
        }
    }

    override fun close(request: CloseRequest, responseObserver: StreamObserver<CloseResponse>) {
        grpcUnary<CloseResponse>(scope, responseObserver) {
            val device = request.sink.connection.toBluetoothDevice(bluetoothAdapter)
            val device = bluetoothAdapter.getRemoteDevice(request.sink.cookie.toString("UTF-8"))
            Log.i(TAG, "close: device=$device")
            if (bluetoothA2dpSink.getConnectionState(device) != BluetoothProfile.STATE_CONNECTED) {
                throw RuntimeException("Device is not connected, cannot close")
+0 −5
Original line number Diff line number Diff line
@@ -30,10 +30,6 @@ genrule {
        "pandora_experimental/_android_pb2.py",
        "pandora_experimental/_android_pb2.pyi",
        "pandora_experimental/_utils.py",
        "pandora_experimental/a2dp_grpc.py",
        "pandora_experimental/a2dp_grpc_aio.py",
        "pandora_experimental/a2dp_pb2.py",
        "pandora_experimental/a2dp_pb2.pyi",
        "pandora_experimental/asha_grpc.py",
        "pandora_experimental/asha_grpc_aio.py",
        "pandora_experimental/asha_pb2.py",
@@ -92,7 +88,6 @@ filegroup {
    name: "pandora_experimental-python-stubs",
    srcs: [
        ":pandora_experimental-python-gen-src{pandora_experimental/_android_pb2.pyi}",
        ":pandora_experimental-python-gen-src{pandora_experimental/a2dp_pb2.pyi}",
        ":pandora_experimental-python-gen-src{pandora_experimental/asha_pb2.pyi}",
        ":pandora_experimental-python-gen-src{pandora_experimental/avrcp_pb2.pyi}",
        ":pandora_experimental-python-gen-src{pandora_experimental/gatt_pb2.pyi}",