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

Commit 05dd7236 authored by Rahul Arya's avatar Rahul Arya
Browse files

[Pandora] Move pairing interface into a separate interface

As per offline discussion, all pairing/bonding related interfaces for
both classic + LE will be moved out of Host (since Host is getting huge)
and put in a separate interface. We can't call it SM since we have
classic stuff in here too.

Test: existing PTS
Bug: 242326310
Tag: #refactor
Change-Id: I2704098edd72e50d53366b210a2bf425f11d3388
parent 3e23b5f8
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@
from mmi2grpc._helpers import assert_description
from mmi2grpc._proxy import ProfileProxy

from pandora.sm_grpc import SM
from pandora.security_grpc import Security
from pandora.host_grpc import Host

# The tests needs the MMI to accept pairing confirmation request.
@@ -42,7 +42,7 @@ class SMProxy(ProfileProxy):

    def __init__(self, channel):
        super().__init__()
        self.sm = SM(channel)
        self.security = Security(channel)
        self.host = Host(channel)
        self.connection = None

@@ -53,7 +53,7 @@ class SMProxy(ProfileProxy):
        """
        self.connection = self.host.ConnectLE(address=pts_addr).connection
        if self.connection and test in ACCEPTS_REMOTE_PAIRING_CONFIRMATION:
            self.sm.ProvidePairingConfirmation(connection=self.connection, pairing_confirmation_value=True)
            self.security.ProvidePairingConfirmation(connection=self.connection, pairing_confirmation_value=True)
        return "OK"

    @assert_description
@@ -62,9 +62,9 @@ class SMProxy(ProfileProxy):
        Please start pairing process.
        """
        if self.connection:
            self.sm.Pair(connection=self.connection)
            self.security.Pair(connection=self.connection)
            if test in NEEDS_PAIRING_CONFIRMATION:
                self.sm.ProvidePairingConfirmation(connection=self.connection, pairing_confirmation_value=True)
                self.security.ProvidePairingConfirmation(connection=self.connection, pairing_confirmation_value=True)

        return "OK"

+3 −3
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ genrule {
        "proto/pandora/gatt.proto",
        "proto/pandora/hfp.proto",
        "proto/pandora/host.proto",
        "proto/pandora/sm.proto",
        "proto/pandora/security.proto",
    ],
    out: [
        "pandora/a2dp_grpc.py",
@@ -151,7 +151,7 @@ genrule {
        "pandora/hfp_pb2.py",
        "pandora/host_grpc.py",
        "pandora/host_pb2.py",
        "pandora/sm_grpc.py",
        "pandora/sm_pb2.py",
        "pandora/security_grpc.py",
        "pandora/security_pb2.py",
    ]
}
+0 −59
Original line number Diff line number Diff line
@@ -39,15 +39,6 @@ service Host {
  rpc ConnectLE(ConnectLERequest) returns (ConnectLEResponse);
  // Disconnect ongoing LE connection.
  rpc DisconnectLE(DisconnectLERequest) returns (google.protobuf.Empty);
  // Listen to pairing events.
  // This is handled independently from connections for several reasons:
  // - Pairing can be triggered at any time and multiple times during the
  //   lifetime of a connection (this also explains why this is a stream).
  // - In BR/EDR, the specification allows for a device to authenticate before
  //   connecting when in security mode 3 (link level enforced security).
  rpc OnPairing(stream PairingEventAnswer) returns (stream PairingEvent);
  // Remove pairing.
  rpc DeletePairing(DeletePairingRequest) returns (DeletePairingResponse);
}

// Response of the `ReadLocalAddress` method.
@@ -134,53 +125,3 @@ message ConnectLEResponse {
message DisconnectLERequest {
  Connection connection = 1;
}

message PairingEvent {
  // Peer Bluetooth Device Address as array of 6 bytes.
  bytes address = 1;
  // Authentication method used for this pairing event
  oneof method {
    // "Just Works" Secure Simple Pairing association
    // model. Confirmation is automatic.
    google.protobuf.Empty just_works = 2;
    // Numeric Comparison Secure Simple Pairing association
    // model. Confirmation is required.
    uint32 numeric_comparison = 3;
    // Passkey Entry Secure Simple Pairing association model.
    // Passkey is shown to the user.
    // The peer device receives a Passkey Entry request.
    bytes passkey_entry_notification = 4;
    // Passkey Entry Secure Simple Pairing association model.
    // Passkey is typed by the user.
    google.protobuf.Empty passkey_entry_request = 5;
    // Legacy PIN Pairing.
    // A PIN Code is typed by the user.
    google.protobuf.Empty pin_code = 6;
  }
}

message PairingEventAnswer {
  // Received pairing event.
  PairingEvent event = 1;
  // Answer when needed to the pairing event method.
  oneof answer {
    // Numeric Comparison confirmation.
    // Used when pairing event method is `numeric_comparison`.
    bool confirm = 2;
    // Passkey typed by the user.
    // Used when pairing event method is `passkey_entry_request`.
    bytes passkey = 3;
    // Pin typed by the user.
    // Used when pairing event method is `pin_code`.
    uint32 pin = 4;
  };
}

// Request of the `DeletePairing` method.
message DeletePairingRequest {
  // Local Bluetooth Device Address as array of 6 bytes.
  bytes address = 1;
}

// Response of the `DeletePairing` method.
message DeletePairingResponse {}
+86 −0
Original line number Diff line number Diff line
syntax = "proto3";

option java_outer_classname = "SecurityProto";

import "pandora/host.proto";
import "google/protobuf/empty.proto";

package pandora;

service Security {
  // Begin pairing asynchronously with a device. Responses will be streamed
  // using the OnPairing rpc.
  rpc Pair(PairRequest) returns (google.protobuf.Empty);
  // Acknowledge a pairing request and continue pairing
  // TODO(240276298) remove, since PairingEventAnswers supersede these
  rpc ProvidePairingConfirmation(PairingConfirmationRequest)
      returns (google.protobuf.Empty);
  // Listen to pairing events.
  // This is handled independently from connections for several reasons:
  // - Pairing can be triggered at any time and multiple times during the
  //   lifetime of a connection (this also explains why this is a stream).
  // - In BR/EDR, the specification allows for a device to authenticate before
  //   connecting when in security mode 3 (link level enforced security).
  rpc OnPairing(stream PairingEventAnswer) returns (stream PairingEvent);
  // Remove pairing.
  rpc DeletePairing(DeletePairingRequest) returns (DeletePairingResponse);
}

message PairRequest {
    Connection connection = 1;
}

message PairingConfirmationRequest {
    Connection connection = 1;
    bool pairing_confirmation_value = 2;
}

message PairingEvent {
    // Peer Bluetooth Device Address as array of 6 bytes.
    bytes address = 1;
    // Authentication method used for this pairing event
    oneof method {
      // "Just Works" Secure Simple Pairing association
      // model. Confirmation is automatic.
      google.protobuf.Empty just_works = 2;
      // Numeric Comparison Secure Simple Pairing association
      // model. Confirmation is required.
      uint32 numeric_comparison = 3;
      // Passkey Entry Secure Simple Pairing association model.
      // Passkey is shown to the user.
      // The peer device receives a Passkey Entry request.
      bytes passkey_entry_notification = 4;
      // Passkey Entry Secure Simple Pairing association model.
      // Passkey is typed by the user.
      google.protobuf.Empty passkey_entry_request = 5;
      // Legacy PIN Pairing.
      // A PIN Code is typed by the user.
      google.protobuf.Empty pin_code = 6;
    }
}

message PairingEventAnswer {
    // Received pairing event.
    PairingEvent event = 1;
    // Answer when needed to the pairing event method.
    oneof answer {
      // Numeric Comparison confirmation.
      // Used when pairing event method is `numeric_comparison`.
      bool confirm = 2;
      // Passkey typed by the user.
      // Used when pairing event method is `passkey_entry_request`.
      bytes passkey = 3;
      // Pin typed by the user.
      // Used when pairing event method is `pin_code`.
      uint32 pin = 4;
    };
}

// Request of the `DeletePairing` method.
message DeletePairingRequest {
    // Local Bluetooth Device Address as array of 6 bytes.
    bytes address = 1;
}

// Response of the `DeletePairing` method.
message DeletePairingResponse {}
+0 −22
Original line number Diff line number Diff line
syntax = "proto3";

option java_outer_classname = "SmProto";

import "pandora/host.proto";
import "google/protobuf/empty.proto";

package pandora;

service SM {
    rpc Pair(PairRequest) returns (google.protobuf.Empty);
    rpc ProvidePairingConfirmation(PairingConfirmationRequest) returns (google.protobuf.Empty);
}

message PairRequest {
    Connection connection = 1;
}

message PairingConfirmationRequest {
    Connection connection = 1;
    bool pairing_confirmation_value = 2;
}
Loading