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 "GnssVisibilityControl"
18 
19 #include "GnssVisibilityControl.h"
20 #include <log/log.h>
21 
22 namespace aidl::android::hardware::gnss::visibility_control {
23 
24 std::shared_ptr<IGnssVisibilityControlCallback> GnssVisibilityControl::sCallback = nullptr;
25 
enableNfwLocationAccess(const std::vector<std::string> & proxyApps)26 ndk::ScopedAStatus GnssVisibilityControl::enableNfwLocationAccess(
27         const std::vector<std::string>& proxyApps) {
28     std::string os;
29     bool first = true;
30     for (const auto& proxyApp : proxyApps) {
31         if (first) {
32             first = false;
33         } else {
34             os += " ";
35         }
36         os += proxyApp;
37     }
38 
39     ALOGD("GnssVisibilityControl::enableNfwLocationAccess proxyApps: %s", os.c_str());
40     return ndk::ScopedAStatus::ok();
41 }
42 
setCallback(const std::shared_ptr<IGnssVisibilityControlCallback> & callback)43 ndk::ScopedAStatus GnssVisibilityControl::setCallback(
44         const std::shared_ptr<IGnssVisibilityControlCallback>& callback) {
45     ALOGD("GnssVisibilityControl::setCallback");
46     std::unique_lock<std::mutex> lock(mMutex);
47     sCallback = callback;
48     return ndk::ScopedAStatus::ok();
49 }
50 
51 }  // namespace aidl::android::hardware::gnss::visibility_control
52