blob: 5c8ee1d62d946a781f3d3ff7e6276af06396dc8e [file] [log] [blame]
Shinru Hand9535a12024-11-09 08:10:18 +00001/*
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#define LOG_TAG "GnssAssistanceInterfaceAidl"
18
19#include "GnssAssistanceInterface.h"
20#include <aidl/android/hardware/gnss/BnGnss.h>
21#include <log/log.h>
22
23namespace aidl::android::hardware::gnss::gnss_assistance {
24
25std::shared_ptr<IGnssAssistanceCallback> GnssAssistanceInterface::sCallback = nullptr;
26
27ndk::ScopedAStatus GnssAssistanceInterface::setCallback(
28 const std::shared_ptr<IGnssAssistanceCallback>& callback) {
29 ALOGD("setCallback");
30 std::unique_lock<std::mutex> lock(mMutex);
31 sCallback = callback;
32 return ndk::ScopedAStatus::ok();
33}
34
35ndk::ScopedAStatus GnssAssistanceInterface::injectGnssAssistance(
36 const GnssAssistance& gnssAssistance) {
37 ALOGD("injectGnssAssistance. %s", gnssAssistance.toString().c_str());
Shinru Han0993f512025-03-28 09:09:25 -070038 if (!gnssAssistance.gpsAssistance) {
39 ALOGE("Empty GpsAssistance");
40 return ndk::ScopedAStatus::fromServiceSpecificError(IGnss::ERROR_INVALID_ARGUMENT);
41 }
42 if (gnssAssistance.gpsAssistance->satelliteEphemeris.size() == 0) {
43 ALOGE("Empty SatelliteEphemeris");
Shinru Hand9535a12024-11-09 08:10:18 +000044 return ndk::ScopedAStatus::fromServiceSpecificError(IGnss::ERROR_INVALID_ARGUMENT);
45 }
46 return ndk::ScopedAStatus::ok();
47}
48} // namespace aidl::android::hardware::gnss::gnss_assistance