Merge remote-tracking branch 'aosp/upstream-main' into main

Change-Id: Ic9dc3820623ba9b13fe52c6702fa9039026af74b
diff --git a/pandora/host.proto b/pandora/host.proto
index fbdc1cc..cd776a3 100644
--- a/pandora/host.proto
+++ b/pandora/host.proto
@@ -59,6 +59,13 @@
   // Unlike BR/EDR `Connect`, this must not trigger or wait any
   // pairing/encryption and return as soon as the connection is complete.
   rpc ConnectLE(ConnectLERequest) returns (ConnectLEResponse);
+  // Waits for an ACL LE connection update and returns the new values of the
+  // connection parameters. Subsequent calls will wait for new connection
+  // updates before returning. Servers should cache connection updates so that
+  // none are lost before and in between calls.
+  rpc WaitConnectionUpdate(WaitConnectionUpdateRequest) returns (WaitConnectionUpdateResponse);
+  // Returns the current ACL LE connection parameters.
+  rpc GetConnectionParameters(GetConnectionParametersRequest) returns (GetConnectionParametersResponse);
   // Disconnect an ACL connection.
   // The related Connection must not be reused afterwards.
   rpc Disconnect(DisconnectRequest) returns (google.protobuf.Empty);
@@ -258,6 +265,58 @@
   }
 }
 
+// Request of the `WaitConnectionUpdate` method.
+message WaitConnectionUpdateRequest {
+  // Connection on which to wait for connection updates.
+  Connection connection = 1;
+}
+
+// Response of the `WaitConnectionUpdate` method.
+message WaitConnectionUpdateResponse {
+  // Response result.
+  oneof result {
+    // The new connection parameters on success.
+    ConnectionParameters connection_parameters = 1;
+    // No LE connection matching the Connection in the request was found.
+    google.protobuf.Empty connection_not_found = 2;
+  }
+}
+
+// Request of the `GetConnectionParameters` method.
+message GetConnectionParametersRequest {
+  // Connection whose parameters will be returned.
+  Connection connection = 1;
+}
+
+// Response of the `GetConnectionParameters` method.
+message GetConnectionParametersResponse {
+  // Response result.
+  oneof result {
+    // The current connection parameters on success.
+    ConnectionParameters connection_parameters = 1;
+    // No LE connection matching the Connection in the request was found.
+    google.protobuf.Empty connection_not_found = 2;
+  }
+}
+
+// Response of the `WaitConnectionUpdate` method.
+message ConnectionParameters {
+  // Connection interval used on this connection.
+  // Range: 0x0006 to 0x0C80
+  // Time = N × 1.25 ms
+  // Time Range: 7.5 ms to 4000 ms.
+  uint32 connection_interval = 1;
+  // Peripheral latency for the connection in number of subrated connection
+  // events.
+  // Range: 0x0000 to 0x01F3
+  uint32 peripheral_latency = 2;
+  // Supervision timeout for this connection.
+  // Range: 0x000A to 0x0C80
+  // Time = N × 10 ms
+  // Time Range: 100 ms to 32000 ms
+  uint32 supervision_timeout = 3;
+}
+
 // Request of the `Disconnect` method.
 message DisconnectRequest {
   // Connection that should be disconnected.
diff --git a/pandora/l2cap.proto b/pandora/l2cap.proto
index 055f893..7c9d40a 100644
--- a/pandora/l2cap.proto
+++ b/pandora/l2cap.proto
@@ -28,17 +28,16 @@
 service L2CAP {
   // Establish an L2CAP channel on an ACL connection.
   rpc Connect(ConnectRequest) returns (ConnectResponse);
-  // Await and accept incoming L2CAP channels on an existing ACL connection.
-  // Returns a stream of channel, this accept and yield channels until the stream
-  // is closed. Every incoming L2CAP channel connection request not handled by this
+  // Await and accept an incoming L2CAP channel on an existing ACL connection.
+  // Every incoming L2CAP channel connection request not handled by this
   // method should be rejected.
-  rpc OnConnection(OnConnectionRequest) returns (stream OnConnectionResponse);
+  rpc WaitConnection(WaitConnectionRequest) returns (WaitConnectionResponse);
   // Disconnect an established L2CAP channel.
   rpc Disconnect(DisconnectRequest) returns (DisconnectResponse);
   // Await an established L2CAP channel's termination.
   rpc WaitDisconnection(WaitDisconnectionRequest) returns (WaitDisconnectionResponse);
   // Fetch data received from an active L2CAP channel.
-  // Packets are yielded until the stream is closed, packets are droped otherwise. 
+  // Packets are yielded until the stream is closed, packets are dropped otherwise.
   rpc Receive(ReceiveRequest) returns (stream ReceiveResponse);
   // Send data over an L2CAP channel to a connected device.
   rpc Send(SendRequest) returns (SendResponse);
@@ -60,6 +59,23 @@
   google.protobuf.Any cookie = 1;
 }
 
+// Fixed channel, represented by a `Connection` and a Fixed Channel Identifier (CID).
+message FixedChannel {
+  // Specifies the underlying ACL connection, either BR/EDR (Basic Rate/Enhanced Data Rate) or BLE.
+  Connection connection = 1;
+  // Fixed Channel Identifier (CID). Represents the unique identifier for the fixed channel.
+  // Available CIDs are:
+  // - 0x0001: L2CAP Signaling Channel
+  // - 0x0002: Connectionless Channel
+  // - 0x0003: AMP Manager Protocol
+  // - 0x0004: Attribute Protocol (ATT) for BLE
+  // - 0x0005: L2CAP Signaling Channel for BLE
+  // - 0x0006: Security Manager Protocol for BLE
+  // - 0x0007: Security Manager Protocol for BR/EDR
+  // - CIDs in the range of 0x0007 to 0x003F are reserved for standardization purposes.
+  uint32 cid = 2;
+}
+
 // Request for establishing an L2CAP connection-oriented channel, 
 // where data is transmitted with acknowledgment.
 message ConnectionOrientedChannelRequest {
@@ -82,35 +98,18 @@
   uint32 initial_credit = 4;
 }
 
-// Request for establishing a fixed L2CAP channel, often pre-defined for specific purposes.
-message FixedChannelRequest {
-  // Fixed Channel Identifier (CID). Represents the unique identifier for the fixed channel.
-  // Available CIDs are:
-  // - 0x0001: L2CAP Signaling Channel
-  // - 0x0002: Connectionless Channel
-  // - 0x0003: AMP Manager Protocol
-  // - 0x0004: Attribute Protocol (ATT) for BLE
-  // - 0x0005: L2CAP Signaling Channel for BLE
-  // - 0x0006: Security Manager Protocol for BLE
-  // - 0x0007: Security Manager Protocol for BR/EDR
-  // - CIDs in the range of 0x0007 to 0x003F are reserved for standardization purposes.
-  uint32 cid = 1;
-}
-
 // Request of the `Connect` method.
 message ConnectRequest {
   // Specifies the underlying ACL connection, either BR/EDR (Basic Rate/Enhanced Data Rate) or BLE.
   Connection connection = 1;
   // Defines the type and specifics of the channel to establish.
   oneof type {
-    // Request a fixed channel.
-    FixedChannelRequest fixed = 2;
     // Request a connection-oriented channel.
-    ConnectionOrientedChannelRequest basic = 3;
+    ConnectionOrientedChannelRequest basic = 2;
     // Request a BLE credit-based channel.
-    CreditBasedChannelRequest le_credit_based = 4;
+    CreditBasedChannelRequest le_credit_based = 3;
     // Request an enhanced credit-based channel.
-    CreditBasedChannelRequest enhanced_credit_based = 5;
+    CreditBasedChannelRequest enhanced_credit_based = 4;
   }
 }
 
@@ -124,25 +123,23 @@
   }
 }
 
-// Request of the `OnConnection` method.
-message OnConnectionRequest {
+// Request of the `WaitConnection` method.
+message WaitConnectionRequest {
   // Specifies the underlying ACL connection, either BR/EDR or BLE.
   Connection connection = 1;
   // Defines the type and specifics of the channel to wait and accept.
   oneof type {
-    // Accept fixed channels.
-    FixedChannelRequest fixed = 2;
     // Accept connection-oriented channels.
-    ConnectionOrientedChannelRequest basic = 3;
+    ConnectionOrientedChannelRequest basic = 2;
     // Accept BLE credit-based channels.
-    CreditBasedChannelRequest le_credit_based = 4;
+    CreditBasedChannelRequest le_credit_based = 3;
     // Accept enhanced credit-based channels.
-    CreditBasedChannelRequest enhanced_credit_based = 5;
+    CreditBasedChannelRequest enhanced_credit_based = 4;
   }
 }
 
-// Response of the `OnConnection` method.
-message OnConnectionResponse {
+// Response of the `WaitConnection` method.
+message WaitConnectionResponse {
   oneof result {
     CommandRejectReason error = 1;
     Channel channel = 2;
@@ -180,7 +177,12 @@
 // Request of the `Receive` method.
 message ReceiveRequest {
   // Specifies the channel to fetch data from.
-  Channel channel = 1;
+  oneof source {
+    // Fetch data from a dynamic channel.
+    Channel channel = 1;
+    // Fetch data from a fixed channel.
+    FixedChannel fixed_channel = 2;
+  }
 }
 
 // Response of the `Receive` method.
@@ -192,9 +194,14 @@
 // Request of the `Send` method.
 message SendRequest {
   // Specifies the channel to send data over.
-  Channel channel = 1;
+  oneof sink {
+    // Send data over a dynamic channel.
+    Channel channel = 1;
+    // Send data over a fixed channel.
+    FixedChannel fixed_channel = 2;
+  }
   // Data to be sent over the specified channel.
-  bytes data = 2;
+  bytes data = 3;
 }
 
 // Response of the `Send` method.
diff --git a/python/_build/protoc-gen-custom_grpc b/python/_build/protoc-gen-custom_grpc
index 2071a65..287b95b 100755
--- a/python/_build/protoc-gen-custom_grpc
+++ b/python/_build/protoc-gen-custom_grpc
@@ -210,7 +210,7 @@
             type = 'Optional[' + types.pop() + ']'
         else:
             types.add('None')
-            type = 'Union[' + ', '.join(types) + ']'
+            type = 'Union[' + ', '.join(sorted(types)) + ']'
 
         nested_message_lines.extend([
             f'class {message.name}_{oneof_name}_dict(TypedDict, total=False):',
@@ -453,12 +453,12 @@
 # limitations under the License.
 
 """Generated python gRPC interfaces."""
+
+from __future__ import annotations
 '''
 
 _UTILS_PY = f'''{_HEADER}
 
-from __future__ import annotations
-
 import asyncio
 import queue
 import grpc
@@ -467,7 +467,7 @@
 from typing import Any, AsyncIterable, AsyncIterator, Generic, Iterator, TypeVar
 
 
-_T_co = TypeVar('_T_co', covariant=True)
+_T_co = TypeVar('_T_co', covariant=True)  # pytype: disable=not-supported-yet
 _T = TypeVar('_T')
 
 
diff --git a/python/pandora/__init__.py b/python/pandora/__init__.py
index 7f180dd..6a16141 100644
--- a/python/pandora/__init__.py
+++ b/python/pandora/__init__.py
@@ -14,4 +14,4 @@
 
 """Pandora gRPC Bluetooth test interfaces."""
 
-__version__ = "0.0.4"
+__version__ = "0.0.5"