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

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

Pandora: Add device name as parameter in SendFile

Bug: 281616480
Test: atest pts-bot:OPP/CL/GOEP/BC/BV-02-I -v
Change-Id: I7c0198800ebde975dbd9958975d4bd93cf685c64
parent 6cb3766c
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -122,7 +122,7 @@ class OPPProxy(ProfileProxy):
        Take action to create an rfcomm channel for an OBEX connection.
        Take action to create an rfcomm channel for an OBEX connection.
        """
        """


        self._android.SendFile()
        self._android.SendFile('PTS')


        return "OK"
        return "OK"


@@ -132,7 +132,7 @@ class OPPProxy(ProfileProxy):
        Take action to create an l2cap channel for an OBEX connection.
        Take action to create an l2cap channel for an OBEX connection.
        """
        """


        self._android.SendFile()
        self._android.SendFile('PTS')


        return "OK"
        return "OK"


+5 −10
Original line number Original line Diff line number Diff line
@@ -144,18 +144,15 @@ class AndroidInternal(val context: Context) : AndroidImplBase(), Closeable {
    }
    }
  }
  }


  override fun sendFile(request: Empty, responseObserver: StreamObserver<Empty>) {
  override fun sendFile(request: SendFileRequest, responseObserver: StreamObserver<Empty>) {
    grpcUnary<Empty>(scope, responseObserver) {
    grpcUnary<Empty>(scope, responseObserver) {
      initiateSendFile(getImageId(IMAGE_FILE_NAME), "image/bmp")
      initiateSendFile(getImageId(IMAGE_FILE_NAME), "image/bmp")
      waitAndSelectBluetoothDevice()
      waitAndSelectBluetoothDevice(request.name)
      Empty.getDefaultInstance()
      Empty.getDefaultInstance()
    }
    }
  }
  }


  override fun sendPing(
  override fun sendPing(request: SendPingRequest, responseObserver: StreamObserver<Empty>) {
    request: SendPingRequest,
    responseObserver: StreamObserver<Empty>
  ) {
    grpcUnary<Empty>(scope, responseObserver) {
    grpcUnary<Empty>(scope, responseObserver) {
      val pingStatus =
      val pingStatus =
        Runtime.getRuntime().exec("ping -I bt-pan -c 1 ${request.ipAddress}").waitFor()
        Runtime.getRuntime().exec("ping -I bt-pan -c 1 ${request.ipAddress}").waitFor()
@@ -163,12 +160,10 @@ class AndroidInternal(val context: Context) : AndroidImplBase(), Closeable {
    }
    }
  }
  }


  suspend private fun waitAndSelectBluetoothDevice() {
  suspend private fun waitAndSelectBluetoothDevice(name: String) {
    var selectJob =
    var selectJob =
      scope.async {
      scope.async {
        device
        device.wait(Until.findObject(By.textContains(name)), BT_DEVICE_SELECT_WAIT_TIMEOUT).click()
          .wait(Until.findObject(By.textContains("PTS")), BT_DEVICE_SELECT_WAIT_TIMEOUT)
          .click()
      }
      }
    selectJob.await()
    selectJob.await()
  }
  }
+8 −2
Original line number Original line Diff line number Diff line
@@ -21,7 +21,8 @@ service Android {
  // Accept incoming file
  // Accept incoming file
  rpc AcceptIncomingFile(google.protobuf.Empty) returns (google.protobuf.Empty);
  rpc AcceptIncomingFile(google.protobuf.Empty) returns (google.protobuf.Empty);
  // Send file
  // Send file
  rpc SendFile(google.protobuf.Empty) returns (google.protobuf.Empty);
  rpc SendFile(SendFileRequest) returns (google.protobuf.Empty);

  // Send ping
  // Send ping
  rpc SendPing(SendPingRequest) returns (google.protobuf.Empty);
  rpc SendPing(SendPingRequest) returns (google.protobuf.Empty);
}
}
@@ -45,6 +46,11 @@ message SetAccessPermissionRequest {
  AccessType access_type = 2;
  AccessType access_type = 2;
}
}


message SendFileRequest {
  // Peer Bluetooth Device name.
  string name = 1;
}

// Internal representation of a Connection - not exposed to clients, included here
// Internal representation of a Connection - not exposed to clients, included here
// just for code-generation convenience. This is what we put in the Connection.cookie.
// just for code-generation convenience. This is what we put in the Connection.cookie.
message InternalConnectionRef {
message InternalConnectionRef {