blob: 8ea60f360a6e9c1ed9ab460deae96dd340648228 [file] [log] [blame]
Yu-Han Yang24753612020-10-27 14:42:14 -07001/*
2 * Copyright (C) 2020 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 "GnssPowerIndicationAidl"
18
19#include "GnssPowerIndication.h"
20#include <aidl/android/hardware/gnss/BnGnss.h>
21#include <log/log.h>
22
23namespace aidl::android::hardware::gnss {
24
25std::shared_ptr<IGnssPowerIndicationCallback> GnssPowerIndication::sCallback = nullptr;
26
27ndk::ScopedAStatus GnssPowerIndication::setCallback(
28 const std::shared_ptr<IGnssPowerIndicationCallback>& callback) {
29 ALOGD("setCallback");
30 std::unique_lock<std::mutex> lock(mMutex);
31 sCallback = callback;
32 sCallback->setCapabilitiesCb(IGnssPowerIndicationCallback::CAPABILITY_TOTAL |
33 IGnssPowerIndicationCallback::CAPABILITY_SINGLEBAND_TRACKING |
34 IGnssPowerIndicationCallback::CAPABILITY_MULTIBAND_TRACKING |
35 IGnssPowerIndicationCallback::CAPABILITY_SINGLEBAND_ACQUISITION |
36 IGnssPowerIndicationCallback::CAPABILITY_MULTIBAND_ACQUISITION |
37 IGnssPowerIndicationCallback::CAPABILITY_OTHER_MODES);
38 return ndk::ScopedAStatus::ok();
39}
40
41ndk::ScopedAStatus GnssPowerIndication::requestGnssPowerStats() {
42 ALOGD("requestGnssPowerStats");
43 std::unique_lock<std::mutex> lock(mMutex);
44
45 ElapsedRealtime elapsedRealtime = {
46 .flags = IGnss::ELAPSED_REALTIME_HAS_TIMESTAMP_NS |
47 IGnss::ELAPSED_REALTIME_HAS_TIME_UNCERTAINTY_NS,
48 .timestampNs = (long)1323542,
49 .timeUncertaintyNs = (long)1000,
50 };
51 GnssPowerStats gnssPowerStats = {
52 .elapsedRealtime = elapsedRealtime,
53 .totalEnergyMilliJoule = 1.59975e+3,
54 .singlebandTrackingModeEnergyMilliJoule = 1.2342e+3,
55 .multibandTrackingModeEnergyMilliJoule = 3.653e+2,
56 .otherModesEnergyMilliJoule = {1.232e+2, 3.234e+3},
57 };
58 sCallback->gnssPowerStatsCb(gnssPowerStats);
59 return ndk::ScopedAStatus::ok();
60}
61
62} // namespace aidl::android::hardware::gnss