xref: /aosp_15_r20/hardware/interfaces/bluetooth/socket/aidl/default/BluetoothSocket.cpp (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "BluetoothSocket.h"
18 
19 using aidl::android::hardware::bluetooth::socket::Status;
20 
21 namespace aidl::android::hardware::bluetooth::socket::impl {
22 
BluetoothSocket()23 BluetoothSocket::BluetoothSocket() {}
~BluetoothSocket()24 BluetoothSocket::~BluetoothSocket() {}
25 
registerCallback(const std::shared_ptr<::aidl::android::hardware::bluetooth::socket::IBluetoothSocketCallback> & in_callback)26 ::ndk::ScopedAStatus BluetoothSocket::registerCallback(
27     const std::shared_ptr<
28         ::aidl::android::hardware::bluetooth::socket::IBluetoothSocketCallback>&
29         in_callback) {
30   if (in_callback == nullptr) {
31     return ndk::ScopedAStatus::fromServiceSpecificError(STATUS_BAD_VALUE);
32   }
33   callback_ = in_callback;
34   return ::ndk::ScopedAStatus::ok();
35 }
getSocketCapabilities(::aidl::android::hardware::bluetooth::socket::SocketCapabilities * _aidl_return)36 ::ndk::ScopedAStatus BluetoothSocket::getSocketCapabilities(
37     ::aidl::android::hardware::bluetooth::socket::SocketCapabilities*
38         _aidl_return) {
39   _aidl_return->leCocCapabilities.numberOfSupportedSockets = 0;
40   _aidl_return->leCocCapabilities.mtu = 0;
41   _aidl_return->rfcommCapabilities.numberOfSupportedSockets = 0;
42   _aidl_return->rfcommCapabilities.maxFrameSize = 0;
43   return ::ndk::ScopedAStatus::ok();
44 }
opened(const::aidl::android::hardware::bluetooth::socket::SocketContext &)45 ::ndk::ScopedAStatus BluetoothSocket::opened(
46     const ::aidl::android::hardware::bluetooth::socket::SocketContext&
47     /* in_context */) {
48   return ::ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
49 }
closed(int64_t)50 ::ndk::ScopedAStatus BluetoothSocket::closed(int64_t /*in_socketId*/) {
51   return ::ndk::ScopedAStatus::ok();
52 }
53 
54 }  // namespace aidl::android::hardware::bluetooth::socket::impl
55