xref: /aosp_15_r20/hardware/interfaces/gnss/aidl/default/AGnssRil.cpp (revision 4d7e907c777eeecc4c5bd7cf640a754fac206ff7)
1 /*
2  * Copyright (C) 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 #define LOG_TAG "AGnssRilAidl"
18 
19 #include "AGnssRil.h"
20 #include <aidl/android/hardware/gnss/BnGnss.h>
21 #include <inttypes.h>
22 #include <log/log.h>
23 
24 namespace aidl::android::hardware::gnss {
25 
26 std::shared_ptr<IAGnssRilCallback> AGnssRil::sCallback = nullptr;
27 
setCallback(const std::shared_ptr<IAGnssRilCallback> & callback)28 ndk::ScopedAStatus AGnssRil::setCallback(const std::shared_ptr<IAGnssRilCallback>& callback) {
29     ALOGD("AGnssRil::setCallback");
30     std::unique_lock<std::mutex> lock(mMutex);
31     sCallback = callback;
32     return ndk::ScopedAStatus::ok();
33 }
34 
setRefLocation(const AGnssRefLocation & agnssReflocation)35 ndk::ScopedAStatus AGnssRil::setRefLocation(const AGnssRefLocation& agnssReflocation) {
36     const AGnssRefLocationCellID& cellInfo = agnssReflocation.cellID;
37     ALOGD("AGnssRil::setRefLocation: type: %s, mcc: %d, mnc: %d, lac: %d, cid: %" PRId64
38           ", tac: %d, pcid: "
39           "%d, arfcn: %d",
40           toString(agnssReflocation.type).c_str(), cellInfo.mcc, cellInfo.mnc, cellInfo.lac,
41           cellInfo.cid, cellInfo.tac, cellInfo.pcid, cellInfo.arfcn);
42     return ndk::ScopedAStatus::ok();
43 }
44 
setSetId(SetIdType type,const std::string & setid)45 ndk::ScopedAStatus AGnssRil::setSetId(SetIdType type, const std::string& setid) {
46     ALOGD("AGnssRil::setSetId: type:%s, setid: %s", toString(type).c_str(), setid.c_str());
47     return ndk::ScopedAStatus::ok();
48 }
49 
updateNetworkState(const NetworkAttributes & attributes)50 ndk::ScopedAStatus AGnssRil::updateNetworkState(const NetworkAttributes& attributes) {
51     ALOGD("AGnssRil::updateNetworkState: networkHandle:%" PRId64
52           ", isConnected: %d, capabilities: %d, "
53           "apn: %s",
54           attributes.networkHandle, attributes.isConnected, attributes.capabilities,
55           attributes.apn.c_str());
56     return ndk::ScopedAStatus::ok();
57 }
58 
injectNiSuplMessageData(const std::vector<uint8_t> & msgData,int slotIndex)59 ndk::ScopedAStatus AGnssRil::injectNiSuplMessageData(const std::vector<uint8_t>& msgData,
60                                                      int slotIndex) {
61     ALOGD("AGnssRil::injectNiSuplMessageData: msgData:%d bytes slotIndex:%d",
62           static_cast<int>(msgData.size()), slotIndex);
63     if (msgData.size() > 0) {
64         return ndk::ScopedAStatus::ok();
65     } else {
66         return ndk::ScopedAStatus::fromServiceSpecificError(IGnss::ERROR_INVALID_ARGUMENT);
67     }
68 }
69 
70 }  // namespace aidl::android::hardware::gnss
71