• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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>
18 #include <unistd.h>
19 
20 #include "cutils/sockets.h"
21 
22 #include "wifilogd/raw_os.h"
23 
24 namespace android {
25 namespace wifilogd {
26 
RawOs()27 RawOs::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 
ClockGettime(clockid_t clock_id,struct timespec * ts) const34 int RawOs::ClockGettime(clockid_t clock_id, struct timespec* ts) const {
35   return clock_gettime(clock_id, ts);
36 }
37 
GetControlSocket(const char * socket_name)38 int RawOs::GetControlSocket(const char* socket_name) {
39   return android_get_control_socket(socket_name);
40 }
41 
Nanosleep(const struct timespec * req,struct timespec * rem)42 int RawOs::Nanosleep(const struct timespec* req, struct timespec* rem) {
43   return nanosleep(req, rem);
44 }
45 
Recv(int sockfd,void * buf,size_t buflen,int flags)46 ssize_t RawOs::Recv(int sockfd, void* buf, size_t buflen, int flags) {
47   return recv(sockfd, buf, buflen, flags);
48 }
49 
Write(int fd,const void * buf,size_t buflen)50 ssize_t RawOs::Write(int fd, const void* buf, size_t buflen) {
51   return write(fd, buf, buflen);
52 }
53 
54 }  // namespace wifilogd
55 }  // namespace android
56