raw_os.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (C) 2016 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. #include <time.h>
  17. #include <unistd.h>
  18. #include "cutils/sockets.h"
  19. #include "wifilogd/raw_os.h"
  20. namespace android {
  21. namespace wifilogd {
  22. RawOs::RawOs() {}
  23. RawOs::~RawOs() {}
  24. // All methods in RawOs should be thin wrappers over library/system calls.
  25. // In particular, the methods in RawOs should not have any logic in them.
  26. // Instead, all logic should be placed in Os, so that said logic can be tested.
  27. int RawOs::ClockGettime(clockid_t clock_id, struct timespec* ts) const {
  28. return clock_gettime(clock_id, ts);
  29. }
  30. int RawOs::GetControlSocket(const char* socket_name) {
  31. return android_get_control_socket(socket_name);
  32. }
  33. int RawOs::Nanosleep(const struct timespec* req, struct timespec* rem) {
  34. return nanosleep(req, rem);
  35. }
  36. ssize_t RawOs::Recv(int sockfd, void* buf, size_t buflen, int flags) {
  37. return recv(sockfd, buf, buflen, flags);
  38. }
  39. ssize_t RawOs::Write(int fd, const void* buf, size_t buflen) {
  40. return write(fd, buf, buflen);
  41. }
  42. } // namespace wifilogd
  43. } // namespace android