GnssNi.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
  3. * Not a Contribution
  4. */
  5. /*
  6. * Copyright (C) 2016 The Android Open Source Project
  7. *
  8. * Licensed under the Apache License, Version 2.0 (the "License");
  9. * you may not use this file except in compliance with the License.
  10. * You may obtain a copy of the License at
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. *
  14. * Unless required by applicable law or agreed to in writing, software
  15. * distributed under the License is distributed on an "AS IS" BASIS,
  16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. * See the License for the specific language governing permissions and
  18. * limitations under the License.
  19. */
  20. #define LOG_TAG "LocSvc_GnssNiInterface"
  21. #include <log_util.h>
  22. #include "Gnss.h"
  23. #include "GnssNi.h"
  24. namespace android {
  25. namespace hardware {
  26. namespace gnss {
  27. namespace V1_0 {
  28. namespace implementation {
  29. GnssNi::GnssNi(Gnss* gnss) : mGnss(gnss) {
  30. }
  31. // Methods from ::android::hardware::gnss::V1_0::IGnssNi follow.
  32. Return<void> GnssNi::setCallback(const sp<IGnssNiCallback>& callback) {
  33. if (mGnss == nullptr) {
  34. LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
  35. return Void();
  36. }
  37. mGnss->setGnssNiCb(callback);
  38. mGnssNiCbIface = callback;
  39. return Void();
  40. }
  41. Return<void> GnssNi::respond(int32_t notifId, IGnssNiCallback::GnssUserResponseType userResponse) {
  42. if (mGnss == nullptr) {
  43. LOC_LOGE("%s]: mGnss is nullptr", __FUNCTION__);
  44. return Void();
  45. }
  46. GnssAPIClient* api = mGnss->getApi();
  47. if (api == nullptr) {
  48. LOC_LOGE("%s]: api is nullptr", __FUNCTION__);
  49. return Void();
  50. }
  51. api->gnssNiRespond(notifId, userResponse);
  52. return Void();
  53. }
  54. } // namespace implementation
  55. } // namespace V1_0
  56. } // namespace gnss
  57. } // namespace hardware
  58. } // namespace android