1 /*
2 * Copyright 2021, 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 "uwb.h"
18
19 namespace {
20 constexpr static int32_t kAndroidUciVersion = 1;
21 }
22
23 namespace android {
24 namespace hardware {
25 namespace uwb {
26 namespace impl {
27 using namespace ::aidl::android::hardware::uwb;
28
UwbChip(const std::string & name)29 UwbChip::UwbChip(const std::string& name) : name_(name), mClientCallback(nullptr) {}
~UwbChip()30 UwbChip::~UwbChip() {}
31
getName(std::string * name)32 ::ndk::ScopedAStatus UwbChip::getName(std::string* name) {
33 *name = name_;
34 return ndk::ScopedAStatus::ok();
35 }
36
open(const std::shared_ptr<IUwbClientCallback> & clientCallback)37 ::ndk::ScopedAStatus UwbChip::open(const std::shared_ptr<IUwbClientCallback>& clientCallback) {
38 mClientCallback = clientCallback;
39 mClientCallback->onHalEvent(UwbEvent::OPEN_CPLT, UwbStatus::OK);
40 return ndk::ScopedAStatus::ok();
41 }
42
close()43 ::ndk::ScopedAStatus UwbChip::close() {
44 mClientCallback->onHalEvent(UwbEvent::CLOSE_CPLT, UwbStatus::OK);
45 mClientCallback = nullptr;
46 return ndk::ScopedAStatus::ok();
47 }
48
coreInit()49 ::ndk::ScopedAStatus UwbChip::coreInit() {
50 return ndk::ScopedAStatus::ok();
51 }
52
sessionInit(int)53 ::ndk::ScopedAStatus UwbChip::sessionInit(int /* sessionId */) {
54 return ndk::ScopedAStatus::ok();
55 }
56
getSupportedAndroidUciVersion(int32_t * version)57 ::ndk::ScopedAStatus UwbChip::getSupportedAndroidUciVersion(int32_t* version) {
58 *version = kAndroidUciVersion;
59 return ndk::ScopedAStatus::ok();
60 }
61
sendUciMessage(const std::vector<uint8_t> &,int32_t *)62 ::ndk::ScopedAStatus UwbChip::sendUciMessage(const std::vector<uint8_t>& /* data */,
63 int32_t* /* bytes_written */) {
64 // TODO(b/195992658): Need emulator support for UCI stack.
65 return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
66 }
67 } // namespace impl
68 } // namespace uwb
69 } // namespace hardware
70 } // namespace android
71