mukesh agrawal | ec533e0 | 2016-09-30 19:04:33 -0700 | [diff] [blame] | 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 | |
| 17 | #include <time.h> |
mukesh agrawal | b8f8f6a | 2016-10-06 15:11:59 -0700 | [diff] [blame] | 18 | #include <unistd.h> |
mukesh agrawal | ec533e0 | 2016-09-30 19:04:33 -0700 | [diff] [blame] | 19 | |
mukesh agrawal | a5bb08c | 2016-10-26 14:38:52 -0700 | [diff] [blame] | 20 | #include "cutils/sockets.h" |
| 21 | |
mukesh agrawal | ec533e0 | 2016-09-30 19:04:33 -0700 | [diff] [blame] | 22 | #include "wifilogd/raw_os.h" |
| 23 | |
| 24 | namespace android { |
| 25 | namespace wifilogd { |
| 26 | |
| 27 | RawOs::RawOs() {} |
| 28 | RawOs::~RawOs() {} |
| 29 | |
| 30 | // All methods in RawOs should be thin wrappers over library/system calls. |
| 31 | // In particular, the methods in RawOs should not have any logic in them. |
| 32 | // Instead, all logic should be placed in Os, so that said logic can be tested. |
| 33 | |
| 34 | int RawOs::ClockGettime(clockid_t clock_id, struct timespec* ts) const { |
| 35 | return clock_gettime(clock_id, ts); |
| 36 | } |
| 37 | |
mukesh agrawal | a5bb08c | 2016-10-26 14:38:52 -0700 | [diff] [blame] | 38 | int RawOs::GetControlSocket(const char* socket_name) { |
| 39 | return android_get_control_socket(socket_name); |
| 40 | } |
| 41 | |
mukesh agrawal | 960c8a8 | 2016-10-27 17:39:18 -0700 | [diff] [blame] | 42 | int RawOs::Nanosleep(const struct timespec* req, struct timespec* rem) { |
| 43 | return nanosleep(req, rem); |
| 44 | } |
| 45 | |
mukesh agrawal | d75fd9e | 2016-10-26 16:34:04 -0700 | [diff] [blame] | 46 | ssize_t RawOs::Recv(int sockfd, void* buf, size_t buflen, int flags) { |
| 47 | return recv(sockfd, buf, buflen, flags); |
| 48 | } |
| 49 | |
mukesh agrawal | b8f8f6a | 2016-10-06 15:11:59 -0700 | [diff] [blame] | 50 | ssize_t RawOs::Write(int fd, const void* buf, size_t buflen) { |
| 51 | return write(fd, buf, buflen); |
| 52 | } |
| 53 | |
mukesh agrawal | ec533e0 | 2016-09-30 19:04:33 -0700 | [diff] [blame] | 54 | } // namespace wifilogd |
| 55 | } // namespace android |