Os.java revision 5d930cadc8f62aee5f18e7921296fe66a54f18ab
1/* 2 * Copyright (C) 2011 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 17package android.system; 18 19import android.system.ErrnoException; 20import android.system.GaiException; 21import android.system.StructAddrinfo; 22import android.system.StructFlock; 23import android.system.StructGroupReq; 24import android.system.StructGroupSourceReq; 25import android.system.StructLinger; 26import android.system.StructPasswd; 27import android.system.StructPollfd; 28import android.system.StructStat; 29import android.system.StructStatVfs; 30import android.system.StructTimeval; 31import android.system.StructUcred; 32import android.system.StructUtsname; 33import android.util.MutableInt; 34import android.util.MutableLong; 35import java.io.FileDescriptor; 36import java.io.InterruptedIOException; 37import java.net.InetAddress; 38import java.net.InetSocketAddress; 39import java.net.SocketAddress; 40import java.net.SocketException; 41import java.nio.ByteBuffer; 42import libcore.io.Libcore; 43 44/** 45 * @hide 46 */ 47public final class Os { 48 private Os() {} 49 50 public static FileDescriptor accept(FileDescriptor fd, InetSocketAddress peerAddress) throws ErrnoException, SocketException { return Libcore.os.accept(fd, peerAddress); } 51 public static boolean access(String path, int mode) throws ErrnoException { return Libcore.os.access(path, mode); } 52 public static void bind(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { Libcore.os.bind(fd, address, port); } 53 public static void chmod(String path, int mode) throws ErrnoException { Libcore.os.chmod(path, mode); } 54 public static void chown(String path, int uid, int gid) throws ErrnoException { Libcore.os.chown(path, uid, gid); } 55 public static void close(FileDescriptor fd) throws ErrnoException { Libcore.os.close(fd); } 56 public static void connect(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { Libcore.os.connect(fd, address, port); } 57 public static FileDescriptor dup(FileDescriptor oldFd) throws ErrnoException { return Libcore.os.dup(oldFd); } 58 public static FileDescriptor dup2(FileDescriptor oldFd, int newFd) throws ErrnoException { return Libcore.os.dup2(oldFd, newFd); } 59 public static String[] environ() { return Libcore.os.environ(); } 60 public static void execv(String filename, String[] argv) throws ErrnoException { Libcore.os.execv(filename, argv); } 61 public static void execve(String filename, String[] argv, String[] envp) throws ErrnoException { Libcore.os.execve(filename, argv, envp); } 62 public static void fchmod(FileDescriptor fd, int mode) throws ErrnoException { Libcore.os.fchmod(fd, mode); } 63 public static void fchown(FileDescriptor fd, int uid, int gid) throws ErrnoException { Libcore.os.fchown(fd, uid, gid); } 64 public static int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException { return Libcore.os.fcntlVoid(fd, cmd); } 65 public static int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException { return Libcore.os.fcntlLong(fd, cmd, arg); } 66 public static int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException { return Libcore.os.fcntlFlock(fd, cmd, arg); } 67 public static void fdatasync(FileDescriptor fd) throws ErrnoException { Libcore.os.fdatasync(fd); } 68 public static StructStat fstat(FileDescriptor fd) throws ErrnoException { return Libcore.os.fstat(fd); } 69 public static StructStatVfs fstatvfs(FileDescriptor fd) throws ErrnoException { return Libcore.os.fstatvfs(fd); } 70 public static void fsync(FileDescriptor fd) throws ErrnoException { Libcore.os.fsync(fd); } 71 public static void ftruncate(FileDescriptor fd, long length) throws ErrnoException { Libcore.os.ftruncate(fd, length); } 72 public static String gai_strerror(int error) { return Libcore.os.gai_strerror(error); } 73 public static InetAddress[] getaddrinfo(String node, StructAddrinfo hints) throws GaiException { return Libcore.os.getaddrinfo(node, hints); } 74 public static int getegid() { return Libcore.os.getegid(); } 75 public static int geteuid() { return Libcore.os.geteuid(); } 76 public static int getgid() { return Libcore.os.getgid(); } 77 public static String getenv(String name) { return Libcore.os.getenv(name); } 78 public static String getnameinfo(InetAddress address, int flags) throws GaiException { return Libcore.os.getnameinfo(address, flags); } 79 public static SocketAddress getpeername(FileDescriptor fd) throws ErrnoException { return Libcore.os.getpeername(fd); } 80 public static int getpid() { return Libcore.os.getpid(); } 81 public static int getppid() { return Libcore.os.getppid(); } 82 public static StructPasswd getpwnam(String name) throws ErrnoException { return Libcore.os.getpwnam(name); } 83 public static StructPasswd getpwuid(int uid) throws ErrnoException { return Libcore.os.getpwuid(uid); } 84 public static SocketAddress getsockname(FileDescriptor fd) throws ErrnoException { return Libcore.os.getsockname(fd); } 85 public static int getsockoptByte(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptByte(fd, level, option); } 86 public static InetAddress getsockoptInAddr(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptInAddr(fd, level, option); } 87 public static int getsockoptInt(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptInt(fd, level, option); } 88 public static StructLinger getsockoptLinger(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptLinger(fd, level, option); } 89 public static StructTimeval getsockoptTimeval(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptTimeval(fd, level, option); } 90 public static StructUcred getsockoptUcred(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptUcred(fd, level, option); } 91 public static int gettid() { return Libcore.os.gettid(); } 92 public static int getuid() { return Libcore.os.getuid(); } 93 public static String if_indextoname(int index) { return Libcore.os.if_indextoname(index); } 94 public static InetAddress inet_pton(int family, String address) { return Libcore.os.inet_pton(family, address); } 95 public static InetAddress ioctlInetAddress(FileDescriptor fd, int cmd, String interfaceName) throws ErrnoException { return Libcore.os.ioctlInetAddress(fd, cmd, interfaceName); } 96 public static int ioctlInt(FileDescriptor fd, int cmd, MutableInt arg) throws ErrnoException { return Libcore.os.ioctlInt(fd, cmd, arg); } 97 public static boolean isatty(FileDescriptor fd) { return Libcore.os.isatty(fd); } 98 public static void kill(int pid, int signal) throws ErrnoException { Libcore.os.kill(pid, signal); } 99 public static void lchown(String path, int uid, int gid) throws ErrnoException { Libcore.os.lchown(path, uid, gid); } 100 public static void listen(FileDescriptor fd, int backlog) throws ErrnoException { Libcore.os.listen(fd, backlog); } 101 public static long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException { return Libcore.os.lseek(fd, offset, whence); } 102 public static StructStat lstat(String path) throws ErrnoException { return Libcore.os.lstat(path); } 103 public static void mincore(long address, long byteCount, byte[] vector) throws ErrnoException { Libcore.os.mincore(address, byteCount, vector); } 104 public static void mkdir(String path, int mode) throws ErrnoException { Libcore.os.mkdir(path, mode); } 105 public static void mkfifo(String path, int mode) throws ErrnoException { Libcore.os.mkfifo(path, mode); } 106 public static void mlock(long address, long byteCount) throws ErrnoException { Libcore.os.mlock(address, byteCount); } 107 public static long mmap(long address, long byteCount, int prot, int flags, FileDescriptor fd, long offset) throws ErrnoException { return Libcore.os.mmap(address, byteCount, prot, flags, fd, offset); } 108 public static void msync(long address, long byteCount, int flags) throws ErrnoException { Libcore.os.msync(address, byteCount, flags); } 109 public static void munlock(long address, long byteCount) throws ErrnoException { Libcore.os.munlock(address, byteCount); } 110 public static void munmap(long address, long byteCount) throws ErrnoException { Libcore.os.munmap(address, byteCount); } 111 public static FileDescriptor open(String path, int flags, int mode) throws ErrnoException { return Libcore.os.open(path, flags, mode); } 112 public static FileDescriptor[] pipe() throws ErrnoException { return Libcore.os.pipe(); } 113 public static int poll(StructPollfd[] fds, int timeoutMs) throws ErrnoException { return Libcore.os.poll(fds, timeoutMs); } 114 public static void posix_fallocate(FileDescriptor fd, long offset, long length) throws ErrnoException { Libcore.os.posix_fallocate(fd, offset, length); } 115 public static int pread(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pread(fd, buffer, offset); } 116 public static int pread(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pread(fd, bytes, byteOffset, byteCount, offset); } 117 public static int pwrite(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pwrite(fd, buffer, offset); } 118 public static int pwrite(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pwrite(fd, bytes, byteOffset, byteCount, offset); } 119 public static int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException { return Libcore.os.read(fd, buffer); } 120 public static int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException { return Libcore.os.read(fd, bytes, byteOffset, byteCount); } 121 public static String readlink(String path) throws ErrnoException { return Libcore.os.readlink(path); } 122 public static int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException { return Libcore.os.readv(fd, buffers, offsets, byteCounts); } 123 public static int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException { return Libcore.os.recvfrom(fd, buffer, flags, srcAddress); } 124 public static int recvfrom(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException { return Libcore.os.recvfrom(fd, bytes, byteOffset, byteCount, flags, srcAddress); } 125 public static void remove(String path) throws ErrnoException { Libcore.os.remove(path); } 126 public static void rename(String oldPath, String newPath) throws ErrnoException { Libcore.os.rename(oldPath, newPath); } 127 public static long sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount) throws ErrnoException { return Libcore.os.sendfile(outFd, inFd, inOffset, byteCount); } 128 public static int sendto(FileDescriptor fd, ByteBuffer buffer, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { return Libcore.os.sendto(fd, buffer, flags, inetAddress, port); } 129 public static int sendto(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount, int flags, InetAddress inetAddress, int port) throws ErrnoException, SocketException { return Libcore.os.sendto(fd, bytes, byteOffset, byteCount, flags, inetAddress, port); } 130 public static void setegid(int egid) throws ErrnoException { Libcore.os.setegid(egid); } 131 public static void setenv(String name, String value, boolean overwrite) throws ErrnoException { Libcore.os.setenv(name, value, overwrite); } 132 public static void seteuid(int euid) throws ErrnoException { Libcore.os.seteuid(euid); } 133 public static void setgid(int gid) throws ErrnoException { Libcore.os.setgid(gid); } 134 public static int setsid() throws ErrnoException { return Libcore.os.setsid(); } 135 public static void setsockoptByte(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptByte(fd, level, option, value); } 136 public static void setsockoptIfreq(FileDescriptor fd, int level, int option, String value) throws ErrnoException { Libcore.os.setsockoptIfreq(fd, level, option, value); } 137 public static void setsockoptInt(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptInt(fd, level, option, value); } 138 public static void setsockoptIpMreqn(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptIpMreqn(fd, level, option, value); } 139 public static void setsockoptGroupReq(FileDescriptor fd, int level, int option, StructGroupReq value) throws ErrnoException { Libcore.os.setsockoptGroupReq(fd, level, option, value); } 140 public static void setsockoptGroupSourceReq(FileDescriptor fd, int level, int option, StructGroupSourceReq value) throws ErrnoException { Libcore.os.setsockoptGroupSourceReq(fd, level, option, value); } 141 public static void setsockoptLinger(FileDescriptor fd, int level, int option, StructLinger value) throws ErrnoException { Libcore.os.setsockoptLinger(fd, level, option, value); } 142 public static void setsockoptTimeval(FileDescriptor fd, int level, int option, StructTimeval value) throws ErrnoException { Libcore.os.setsockoptTimeval(fd, level, option, value); } 143 public static void setuid(int uid) throws ErrnoException { Libcore.os.setuid(uid); } 144 public static void shutdown(FileDescriptor fd, int how) throws ErrnoException { Libcore.os.shutdown(fd, how); } 145 public static FileDescriptor socket(int domain, int type, int protocol) throws ErrnoException { return Libcore.os.socket(domain, type, protocol); } 146 public static void socketpair(int domain, int type, int protocol, FileDescriptor fd1, FileDescriptor fd2) throws ErrnoException { Libcore.os.socketpair(domain, type, protocol, fd1, fd2); } 147 public static StructStat stat(String path) throws ErrnoException { return Libcore.os.stat(path); } 148 public static StructStatVfs statvfs(String path) throws ErrnoException { return Libcore.os.statvfs(path); } 149 public static String strerror(int errno) { return Libcore.os.strerror(errno); } 150 public static String strsignal(int signal) { return Libcore.os.strsignal(signal); } 151 public static void symlink(String oldPath, String newPath) throws ErrnoException { Libcore.os.symlink(oldPath, newPath); } 152 public static long sysconf(int name) { return Libcore.os.sysconf(name); } 153 public static void tcdrain(FileDescriptor fd) throws ErrnoException { Libcore.os.tcdrain(fd); } 154 public static void tcsendbreak(FileDescriptor fd, int duration) throws ErrnoException { Libcore.os.tcsendbreak(fd, duration); } 155 public static int umask(int mask) { return Libcore.os.umask(mask); } 156 public static StructUtsname uname() { return Libcore.os.uname(); } 157 public static void unsetenv(String name) throws ErrnoException { Libcore.os.unsetenv(name); } 158 public static int waitpid(int pid, MutableInt status, int options) throws ErrnoException { return Libcore.os.waitpid(pid, status, options); } 159 public static int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException { return Libcore.os.write(fd, buffer); } 160 public static int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException { return Libcore.os.write(fd, bytes, byteOffset, byteCount); } 161 public static int writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException { return Libcore.os.writev(fd, buffers, offsets, byteCounts); } 162} 163