Loading android/pandora/mmi2grpc/mmi2grpc/gap.py +12 −8 Original line number Diff line number Diff line Loading @@ -7,7 +7,8 @@ from pandora_experimental.gatt_grpc import GATT from pandora_experimental.gatt_pb2 import GattServiceParams, GattCharacteristicParams from pandora_experimental.host_grpc import Host from pandora_experimental.host_pb2 import ConnectabilityMode, DataTypes, DiscoverabilityMode, OwnAddressType from pandora_experimental.security_grpc import Security from pandora_experimental.security_grpc import Security, SecurityStorage from pandora_experimental.security_pb2 import LESecurityLevel class GAPProxy(ProfileProxy): Loading @@ -17,6 +18,7 @@ class GAPProxy(ProfileProxy): self.gatt = GATT(channel) self.host = Host(channel) self.security = Security(channel) self.security_storage = SecurityStorage(channel) self.connection = None self.pairing_events = None Loading Loading @@ -132,9 +134,9 @@ class GAPProxy(ProfileProxy): # we also begin pairing here if we are not already paired on LE if self.counter == 0: self.counter += 1 self.security.DeletePairing(address=pts_addr) self.security_storage.DeleteBond(public=pts_addr) self.connection = self.host.ConnectLE(public=pts_addr).connection self.security.Pair(connection=self.host.GetLEConnection(address=pts_addr).connection) self.security.Secure(connection=self.connection, le=LESecurityLevel.LE_LEVEL3) return "OK" if test == "GAP/SEC/AUT/BV-21-C" and self.connection is not None: Loading @@ -158,7 +160,7 @@ class GAPProxy(ProfileProxy): self.connection = self.host.ConnectLE(public=address).connection if test in {"GAP/BOND/BON/BV-04-C"}: self.security.Pair(connection=self.connection) self.security.Secure(connection=self.connection, le=LESecurityLevel.LE_LEVEL3) return "OK" Loading Loading @@ -559,9 +561,10 @@ class GAPProxy(ProfileProxy): return "OK" if test not in {"GAP/SEC/AUT/BV-21-C"}: self.security.DeletePairing(address=pts_addr) self.security_storage.DeleteBond(public=pts_addr) self.security.Pair(connection=self.host.GetLEConnection(address=pts_addr).connection) connection = self.host.GetLEConnection(address=pts_addr).connection self.security.Secure(connection=connection, le=LESecurityLevel.LE_LEVEL3) return "OK" Loading Loading @@ -704,7 +707,8 @@ class GAPProxy(ProfileProxy): """ # No idea how we can bond in non-bondable mode, but this passes the tests... self.security.Pair(connection=self.host.GetLEConnection(address=pts_addr).connection,) connection = self.host.GetLEConnection(address=pts_addr).connection self.security.Secure(connection=connection, le=LESecurityLevel.LE_LEVEL3) return "OK" Loading Loading @@ -887,7 +891,7 @@ class GAPProxy(ProfileProxy): if test != "GAP/SEC/SEM/BV-08-C": # we already started in the Connect MMI self.pairing_events = self.security.OnPairing() self.security.Pair(connection=connection) self.security.Secure(connection=connection, le=LESecurityLevel.LE_LEVEL3) connection = self.host.GetConnection(address=pts_addr).connection Loading android/pandora/mmi2grpc/mmi2grpc/hfp.py +3 −2 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ from mmi2grpc._proxy import ProfileProxy from pandora_experimental.hfp_grpc import HFP from pandora_experimental.host_grpc import Host from pandora_experimental.host_pb2 import ConnectabilityMode from pandora_experimental.security_grpc import Security from pandora_experimental.security_grpc import Security, SecurityStorage from pandora_experimental.hfp_pb2 import AudioPath import sys Loading @@ -43,6 +43,7 @@ class HFPProxy(ProfileProxy): self.hfp = HFP(channel) self.host = Host(channel) self.security = Security(channel) self.security_storage = SecurityStorage(channel) self.rootcanal = rootcanal self.modem = modem Loading Loading @@ -75,7 +76,7 @@ class HFPProxy(ProfileProxy): (IUT), then click Ok. """ self.security.DeletePairing(address=pts_addr) self.security_storage.DeleteBond(public=pts_addr) return "OK" @assert_description Loading android/pandora/mmi2grpc/mmi2grpc/hogp.py +5 −1 Original line number Diff line number Diff line import threading import textwrap import uuid import re Loading @@ -7,6 +8,7 @@ from mmi2grpc._proxy import ProfileProxy from pandora_experimental.host_grpc import Host from pandora_experimental.security_grpc import Security from pandora_experimental.security_pb2 import LESecurityLevel from pandora_experimental.gatt_grpc import GATT BASE_UUID = uuid.UUID("00000000-0000-1000-8000-00805F9B34FB") Loading Loading @@ -39,7 +41,9 @@ class HOGPProxy(ProfileProxy): self.connection = self.host.ConnectLE(public=pts_addr).connection self.pairing_stream = self.security.OnPairing() self.security.Pair(connection=self.connection) def secure(): self.security.Secure(connection=self.connection, le=LESecurityLevel.LE_LEVEL3) threading.Thread(target=secure).start() return "OK" Loading android/pandora/mmi2grpc/mmi2grpc/sm.py +6 −3 Original line number Diff line number Diff line Loading @@ -15,13 +15,14 @@ from queue import Empty, Queue from threading import Thread import sys import time import asyncio from mmi2grpc._helpers import assert_description, match_description from mmi2grpc._proxy import ProfileProxy from mmi2grpc._streaming import StreamWrapper from pandora_experimental.security_grpc import Security from pandora_experimental.security_pb2 import LESecurityLevel from pandora_experimental.host_grpc import Host from pandora_experimental.host_pb2 import ConnectabilityMode, OwnAddressType Loading Loading @@ -54,8 +55,10 @@ class SMProxy(ProfileProxy): """ Please start pairing process. """ def secure(): if self.connection: self.security.Pair(connection=self.connection) self.security.Secure(connection=self.connection, le=LESecurityLevel.LE_LEVEL3) Thread(target=secure).start() return "OK" @assert_description Loading android/pandora/server/src/com/android/pandora/Host.kt +16 −23 Original line number Diff line number Diff line Loading @@ -43,7 +43,6 @@ import com.google.protobuf.ByteString import com.google.protobuf.Empty import io.grpc.Status import io.grpc.stub.StreamObserver import java.io.IOException import java.time.Duration import java.util.UUID import kotlinx.coroutines.CoroutineScope Loading @@ -62,12 +61,15 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.shareIn import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withTimeout import pandora.HostGrpc.HostImplBase import pandora.HostProto.* @kotlinx.coroutines.ExperimentalCoroutinesApi class Host(private val context: Context, private val server: Server) : HostImplBase() { class Host( private val context: Context, private val security: Security, private val server: Server ) : HostImplBase() { private val TAG = "PandoraHost" private val scope: CoroutineScope Loading Loading @@ -194,7 +196,7 @@ class Host(private val context: Context, private val server: Server) : HostImplB .first() } private suspend fun waitBondIntent(bluetoothDevice: BluetoothDevice) { suspend fun waitBondIntent(bluetoothDevice: BluetoothDevice) { // We only wait for bonding to be completed since we only need the ACL connection to be // established with the peer device (on Android state connected is sent when all profiles // have been connected). Loading Loading @@ -229,7 +231,7 @@ class Host(private val context: Context, private val server: Server) : HostImplB throw Status.UNKNOWN.asException() } if (request.manuallyConfirm) { if (security.manuallyConfirm) { waitBondIntent(bluetoothDevice) } else { acceptPairingAndAwaitBonded(bluetoothDevice) Loading @@ -250,14 +252,6 @@ class Host(private val context: Context, private val server: Server) : HostImplB bluetoothAdapter.cancelDiscovery() if (!bluetoothDevice.isConnected()) { if (request.skipPairing) { // do an SDP request to trigger a temporary BREDR connection try { withTimeout(1500) { bluetoothDevice.createRfcommSocket(3).connect() } } catch (e: IOException) { // ignore } } else { if (bluetoothDevice.bondState == BOND_BONDED) { // already bonded, just reconnect bluetoothDevice.connect() Loading @@ -265,12 +259,11 @@ class Host(private val context: Context, private val server: Server) : HostImplB } else { // need to bond bluetoothDevice.createBond() if (!request.manuallyConfirm) { if (!security.manuallyConfirm) { acceptPairingAndAwaitBonded(bluetoothDevice) } } } } ConnectResponse.newBuilder() .setConnection(bluetoothDevice.toConnection(TRANSPORT_BREDR)) Loading Loading
android/pandora/mmi2grpc/mmi2grpc/gap.py +12 −8 Original line number Diff line number Diff line Loading @@ -7,7 +7,8 @@ from pandora_experimental.gatt_grpc import GATT from pandora_experimental.gatt_pb2 import GattServiceParams, GattCharacteristicParams from pandora_experimental.host_grpc import Host from pandora_experimental.host_pb2 import ConnectabilityMode, DataTypes, DiscoverabilityMode, OwnAddressType from pandora_experimental.security_grpc import Security from pandora_experimental.security_grpc import Security, SecurityStorage from pandora_experimental.security_pb2 import LESecurityLevel class GAPProxy(ProfileProxy): Loading @@ -17,6 +18,7 @@ class GAPProxy(ProfileProxy): self.gatt = GATT(channel) self.host = Host(channel) self.security = Security(channel) self.security_storage = SecurityStorage(channel) self.connection = None self.pairing_events = None Loading Loading @@ -132,9 +134,9 @@ class GAPProxy(ProfileProxy): # we also begin pairing here if we are not already paired on LE if self.counter == 0: self.counter += 1 self.security.DeletePairing(address=pts_addr) self.security_storage.DeleteBond(public=pts_addr) self.connection = self.host.ConnectLE(public=pts_addr).connection self.security.Pair(connection=self.host.GetLEConnection(address=pts_addr).connection) self.security.Secure(connection=self.connection, le=LESecurityLevel.LE_LEVEL3) return "OK" if test == "GAP/SEC/AUT/BV-21-C" and self.connection is not None: Loading @@ -158,7 +160,7 @@ class GAPProxy(ProfileProxy): self.connection = self.host.ConnectLE(public=address).connection if test in {"GAP/BOND/BON/BV-04-C"}: self.security.Pair(connection=self.connection) self.security.Secure(connection=self.connection, le=LESecurityLevel.LE_LEVEL3) return "OK" Loading Loading @@ -559,9 +561,10 @@ class GAPProxy(ProfileProxy): return "OK" if test not in {"GAP/SEC/AUT/BV-21-C"}: self.security.DeletePairing(address=pts_addr) self.security_storage.DeleteBond(public=pts_addr) self.security.Pair(connection=self.host.GetLEConnection(address=pts_addr).connection) connection = self.host.GetLEConnection(address=pts_addr).connection self.security.Secure(connection=connection, le=LESecurityLevel.LE_LEVEL3) return "OK" Loading Loading @@ -704,7 +707,8 @@ class GAPProxy(ProfileProxy): """ # No idea how we can bond in non-bondable mode, but this passes the tests... self.security.Pair(connection=self.host.GetLEConnection(address=pts_addr).connection,) connection = self.host.GetLEConnection(address=pts_addr).connection self.security.Secure(connection=connection, le=LESecurityLevel.LE_LEVEL3) return "OK" Loading Loading @@ -887,7 +891,7 @@ class GAPProxy(ProfileProxy): if test != "GAP/SEC/SEM/BV-08-C": # we already started in the Connect MMI self.pairing_events = self.security.OnPairing() self.security.Pair(connection=connection) self.security.Secure(connection=connection, le=LESecurityLevel.LE_LEVEL3) connection = self.host.GetConnection(address=pts_addr).connection Loading
android/pandora/mmi2grpc/mmi2grpc/hfp.py +3 −2 Original line number Diff line number Diff line Loading @@ -19,7 +19,7 @@ from mmi2grpc._proxy import ProfileProxy from pandora_experimental.hfp_grpc import HFP from pandora_experimental.host_grpc import Host from pandora_experimental.host_pb2 import ConnectabilityMode from pandora_experimental.security_grpc import Security from pandora_experimental.security_grpc import Security, SecurityStorage from pandora_experimental.hfp_pb2 import AudioPath import sys Loading @@ -43,6 +43,7 @@ class HFPProxy(ProfileProxy): self.hfp = HFP(channel) self.host = Host(channel) self.security = Security(channel) self.security_storage = SecurityStorage(channel) self.rootcanal = rootcanal self.modem = modem Loading Loading @@ -75,7 +76,7 @@ class HFPProxy(ProfileProxy): (IUT), then click Ok. """ self.security.DeletePairing(address=pts_addr) self.security_storage.DeleteBond(public=pts_addr) return "OK" @assert_description Loading
android/pandora/mmi2grpc/mmi2grpc/hogp.py +5 −1 Original line number Diff line number Diff line import threading import textwrap import uuid import re Loading @@ -7,6 +8,7 @@ from mmi2grpc._proxy import ProfileProxy from pandora_experimental.host_grpc import Host from pandora_experimental.security_grpc import Security from pandora_experimental.security_pb2 import LESecurityLevel from pandora_experimental.gatt_grpc import GATT BASE_UUID = uuid.UUID("00000000-0000-1000-8000-00805F9B34FB") Loading Loading @@ -39,7 +41,9 @@ class HOGPProxy(ProfileProxy): self.connection = self.host.ConnectLE(public=pts_addr).connection self.pairing_stream = self.security.OnPairing() self.security.Pair(connection=self.connection) def secure(): self.security.Secure(connection=self.connection, le=LESecurityLevel.LE_LEVEL3) threading.Thread(target=secure).start() return "OK" Loading
android/pandora/mmi2grpc/mmi2grpc/sm.py +6 −3 Original line number Diff line number Diff line Loading @@ -15,13 +15,14 @@ from queue import Empty, Queue from threading import Thread import sys import time import asyncio from mmi2grpc._helpers import assert_description, match_description from mmi2grpc._proxy import ProfileProxy from mmi2grpc._streaming import StreamWrapper from pandora_experimental.security_grpc import Security from pandora_experimental.security_pb2 import LESecurityLevel from pandora_experimental.host_grpc import Host from pandora_experimental.host_pb2 import ConnectabilityMode, OwnAddressType Loading Loading @@ -54,8 +55,10 @@ class SMProxy(ProfileProxy): """ Please start pairing process. """ def secure(): if self.connection: self.security.Pair(connection=self.connection) self.security.Secure(connection=self.connection, le=LESecurityLevel.LE_LEVEL3) Thread(target=secure).start() return "OK" @assert_description Loading
android/pandora/server/src/com/android/pandora/Host.kt +16 −23 Original line number Diff line number Diff line Loading @@ -43,7 +43,6 @@ import com.google.protobuf.ByteString import com.google.protobuf.Empty import io.grpc.Status import io.grpc.stub.StreamObserver import java.io.IOException import java.time.Duration import java.util.UUID import kotlinx.coroutines.CoroutineScope Loading @@ -62,12 +61,15 @@ import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.shareIn import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withTimeout import pandora.HostGrpc.HostImplBase import pandora.HostProto.* @kotlinx.coroutines.ExperimentalCoroutinesApi class Host(private val context: Context, private val server: Server) : HostImplBase() { class Host( private val context: Context, private val security: Security, private val server: Server ) : HostImplBase() { private val TAG = "PandoraHost" private val scope: CoroutineScope Loading Loading @@ -194,7 +196,7 @@ class Host(private val context: Context, private val server: Server) : HostImplB .first() } private suspend fun waitBondIntent(bluetoothDevice: BluetoothDevice) { suspend fun waitBondIntent(bluetoothDevice: BluetoothDevice) { // We only wait for bonding to be completed since we only need the ACL connection to be // established with the peer device (on Android state connected is sent when all profiles // have been connected). Loading Loading @@ -229,7 +231,7 @@ class Host(private val context: Context, private val server: Server) : HostImplB throw Status.UNKNOWN.asException() } if (request.manuallyConfirm) { if (security.manuallyConfirm) { waitBondIntent(bluetoothDevice) } else { acceptPairingAndAwaitBonded(bluetoothDevice) Loading @@ -250,14 +252,6 @@ class Host(private val context: Context, private val server: Server) : HostImplB bluetoothAdapter.cancelDiscovery() if (!bluetoothDevice.isConnected()) { if (request.skipPairing) { // do an SDP request to trigger a temporary BREDR connection try { withTimeout(1500) { bluetoothDevice.createRfcommSocket(3).connect() } } catch (e: IOException) { // ignore } } else { if (bluetoothDevice.bondState == BOND_BONDED) { // already bonded, just reconnect bluetoothDevice.connect() Loading @@ -265,12 +259,11 @@ class Host(private val context: Context, private val server: Server) : HostImplB } else { // need to bond bluetoothDevice.createBond() if (!request.manuallyConfirm) { if (!security.manuallyConfirm) { acceptPairingAndAwaitBonded(bluetoothDevice) } } } } ConnectResponse.newBuilder() .setConnection(bluetoothDevice.toConnection(TRANSPORT_BREDR)) Loading