diff options
author | Elliott Hughes <enh@google.com> | 2014-04-23 17:53:37 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-04-24 16:47:32 -0700 |
commit | 5d930cadc8f62aee5f18e7921296fe66a54f18ab (patch) | |
tree | e4d8b5da53522515d28c601520c2cb6ef6e8b0cf /luni/src/main/java/android | |
parent | 4d402932d370f12f43045518dac4eeef542648c4 (diff) | |
download | libcore-5d930cadc8f62aee5f18e7921296fe66a54f18ab.zip libcore-5d930cadc8f62aee5f18e7921296fe66a54f18ab.tar.gz libcore-5d930cadc8f62aee5f18e7921296fe66a54f18ab.tar.bz2 |
Groundwork towards making the Libcore.os functionality public.
Change-Id: Ie700aa16d91fba53fc5eb2555829cb74d84b12ad
Diffstat (limited to 'luni/src/main/java/android')
24 files changed, 1031 insertions, 0 deletions
diff --git a/luni/src/main/java/android/system/ErrnoException.java b/luni/src/main/java/android/system/ErrnoException.java new file mode 100644 index 0000000..5114bec --- /dev/null +++ b/luni/src/main/java/android/system/ErrnoException.java @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * @hide + */ +public final class ErrnoException extends libcore.io.ErrnoException { + public ErrnoException(String functionName, int errno) { + super(functionName, errno); + } + + public ErrnoException(String functionName, int errno, Throwable cause) { + super(functionName, errno, cause); + } +} diff --git a/luni/src/main/java/android/system/GaiException.java b/luni/src/main/java/android/system/GaiException.java new file mode 100644 index 0000000..803fc29 --- /dev/null +++ b/luni/src/main/java/android/system/GaiException.java @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +import java.net.UnknownHostException; +import libcore.io.Libcore; + +/** + * An unchecked exception thrown when {@code getaddrinfo} or {@code getnameinfo} fails. + * This exception contains the native {@link #error} value, should sophisticated + * callers need to adjust their behavior based on the exact failure. + * + * @hide + */ +public final class GaiException extends RuntimeException { + private final String functionName; + + /** + * The native error value, for comparison with the {@code GAI_} constants in {@link OsConstants}. + */ + public final int error; + + public GaiException(String functionName, int error) { + this.functionName = functionName; + this.error = error; + } + + public GaiException(String functionName, int error, Throwable cause) { + super(cause); + this.functionName = functionName; + this.error = error; + } + + /** + * Converts the stashed function name and error value to a human-readable string. + * We do this here rather than in the constructor so that callers only pay for + * this if they need it. + */ + @Override public String getMessage() { + String gaiName = OsConstants.gaiName(error); + if (gaiName == null) { + gaiName = "GAI_ error " + error; + } + String description = Libcore.os.gai_strerror(error); + return functionName + " failed: " + gaiName + " (" + description + ")"; + } + + public UnknownHostException rethrowAsUnknownHostException(String detailMessage) throws UnknownHostException { + UnknownHostException newException = new UnknownHostException(detailMessage); + newException.initCause(this); + throw newException; + } + + public UnknownHostException rethrowAsUnknownHostException() throws UnknownHostException { + throw rethrowAsUnknownHostException(getMessage()); + } +} diff --git a/luni/src/main/java/android/system/Os.java b/luni/src/main/java/android/system/Os.java new file mode 100644 index 0000000..0ca22a9 --- /dev/null +++ b/luni/src/main/java/android/system/Os.java @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +import android.system.ErrnoException; +import android.system.GaiException; +import android.system.StructAddrinfo; +import android.system.StructFlock; +import android.system.StructGroupReq; +import android.system.StructGroupSourceReq; +import android.system.StructLinger; +import android.system.StructPasswd; +import android.system.StructPollfd; +import android.system.StructStat; +import android.system.StructStatVfs; +import android.system.StructTimeval; +import android.system.StructUcred; +import android.system.StructUtsname; +import android.util.MutableInt; +import android.util.MutableLong; +import java.io.FileDescriptor; +import java.io.InterruptedIOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.SocketAddress; +import java.net.SocketException; +import java.nio.ByteBuffer; +import libcore.io.Libcore; + +/** + * @hide + */ +public final class Os { + private Os() {} + + public static FileDescriptor accept(FileDescriptor fd, InetSocketAddress peerAddress) throws ErrnoException, SocketException { return Libcore.os.accept(fd, peerAddress); } + public static boolean access(String path, int mode) throws ErrnoException { return Libcore.os.access(path, mode); } + public static void bind(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { Libcore.os.bind(fd, address, port); } + public static void chmod(String path, int mode) throws ErrnoException { Libcore.os.chmod(path, mode); } + public static void chown(String path, int uid, int gid) throws ErrnoException { Libcore.os.chown(path, uid, gid); } + public static void close(FileDescriptor fd) throws ErrnoException { Libcore.os.close(fd); } + public static void connect(FileDescriptor fd, InetAddress address, int port) throws ErrnoException, SocketException { Libcore.os.connect(fd, address, port); } + public static FileDescriptor dup(FileDescriptor oldFd) throws ErrnoException { return Libcore.os.dup(oldFd); } + public static FileDescriptor dup2(FileDescriptor oldFd, int newFd) throws ErrnoException { return Libcore.os.dup2(oldFd, newFd); } + public static String[] environ() { return Libcore.os.environ(); } + public static void execv(String filename, String[] argv) throws ErrnoException { Libcore.os.execv(filename, argv); } + public static void execve(String filename, String[] argv, String[] envp) throws ErrnoException { Libcore.os.execve(filename, argv, envp); } + public static void fchmod(FileDescriptor fd, int mode) throws ErrnoException { Libcore.os.fchmod(fd, mode); } + public static void fchown(FileDescriptor fd, int uid, int gid) throws ErrnoException { Libcore.os.fchown(fd, uid, gid); } + public static int fcntlVoid(FileDescriptor fd, int cmd) throws ErrnoException { return Libcore.os.fcntlVoid(fd, cmd); } + public static int fcntlLong(FileDescriptor fd, int cmd, long arg) throws ErrnoException { return Libcore.os.fcntlLong(fd, cmd, arg); } + public static int fcntlFlock(FileDescriptor fd, int cmd, StructFlock arg) throws ErrnoException { return Libcore.os.fcntlFlock(fd, cmd, arg); } + public static void fdatasync(FileDescriptor fd) throws ErrnoException { Libcore.os.fdatasync(fd); } + public static StructStat fstat(FileDescriptor fd) throws ErrnoException { return Libcore.os.fstat(fd); } + public static StructStatVfs fstatvfs(FileDescriptor fd) throws ErrnoException { return Libcore.os.fstatvfs(fd); } + public static void fsync(FileDescriptor fd) throws ErrnoException { Libcore.os.fsync(fd); } + public static void ftruncate(FileDescriptor fd, long length) throws ErrnoException { Libcore.os.ftruncate(fd, length); } + public static String gai_strerror(int error) { return Libcore.os.gai_strerror(error); } + public static InetAddress[] getaddrinfo(String node, StructAddrinfo hints) throws GaiException { return Libcore.os.getaddrinfo(node, hints); } + public static int getegid() { return Libcore.os.getegid(); } + public static int geteuid() { return Libcore.os.geteuid(); } + public static int getgid() { return Libcore.os.getgid(); } + public static String getenv(String name) { return Libcore.os.getenv(name); } + public static String getnameinfo(InetAddress address, int flags) throws GaiException { return Libcore.os.getnameinfo(address, flags); } + public static SocketAddress getpeername(FileDescriptor fd) throws ErrnoException { return Libcore.os.getpeername(fd); } + public static int getpid() { return Libcore.os.getpid(); } + public static int getppid() { return Libcore.os.getppid(); } + public static StructPasswd getpwnam(String name) throws ErrnoException { return Libcore.os.getpwnam(name); } + public static StructPasswd getpwuid(int uid) throws ErrnoException { return Libcore.os.getpwuid(uid); } + public static SocketAddress getsockname(FileDescriptor fd) throws ErrnoException { return Libcore.os.getsockname(fd); } + public static int getsockoptByte(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptByte(fd, level, option); } + public static InetAddress getsockoptInAddr(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptInAddr(fd, level, option); } + public static int getsockoptInt(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptInt(fd, level, option); } + public static StructLinger getsockoptLinger(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptLinger(fd, level, option); } + public static StructTimeval getsockoptTimeval(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptTimeval(fd, level, option); } + public static StructUcred getsockoptUcred(FileDescriptor fd, int level, int option) throws ErrnoException { return Libcore.os.getsockoptUcred(fd, level, option); } + public static int gettid() { return Libcore.os.gettid(); } + public static int getuid() { return Libcore.os.getuid(); } + public static String if_indextoname(int index) { return Libcore.os.if_indextoname(index); } + public static InetAddress inet_pton(int family, String address) { return Libcore.os.inet_pton(family, address); } + public static InetAddress ioctlInetAddress(FileDescriptor fd, int cmd, String interfaceName) throws ErrnoException { return Libcore.os.ioctlInetAddress(fd, cmd, interfaceName); } + public static int ioctlInt(FileDescriptor fd, int cmd, MutableInt arg) throws ErrnoException { return Libcore.os.ioctlInt(fd, cmd, arg); } + public static boolean isatty(FileDescriptor fd) { return Libcore.os.isatty(fd); } + public static void kill(int pid, int signal) throws ErrnoException { Libcore.os.kill(pid, signal); } + public static void lchown(String path, int uid, int gid) throws ErrnoException { Libcore.os.lchown(path, uid, gid); } + public static void listen(FileDescriptor fd, int backlog) throws ErrnoException { Libcore.os.listen(fd, backlog); } + public static long lseek(FileDescriptor fd, long offset, int whence) throws ErrnoException { return Libcore.os.lseek(fd, offset, whence); } + public static StructStat lstat(String path) throws ErrnoException { return Libcore.os.lstat(path); } + public static void mincore(long address, long byteCount, byte[] vector) throws ErrnoException { Libcore.os.mincore(address, byteCount, vector); } + public static void mkdir(String path, int mode) throws ErrnoException { Libcore.os.mkdir(path, mode); } + public static void mkfifo(String path, int mode) throws ErrnoException { Libcore.os.mkfifo(path, mode); } + public static void mlock(long address, long byteCount) throws ErrnoException { Libcore.os.mlock(address, byteCount); } + 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); } + public static void msync(long address, long byteCount, int flags) throws ErrnoException { Libcore.os.msync(address, byteCount, flags); } + public static void munlock(long address, long byteCount) throws ErrnoException { Libcore.os.munlock(address, byteCount); } + public static void munmap(long address, long byteCount) throws ErrnoException { Libcore.os.munmap(address, byteCount); } + public static FileDescriptor open(String path, int flags, int mode) throws ErrnoException { return Libcore.os.open(path, flags, mode); } + public static FileDescriptor[] pipe() throws ErrnoException { return Libcore.os.pipe(); } + public static int poll(StructPollfd[] fds, int timeoutMs) throws ErrnoException { return Libcore.os.poll(fds, timeoutMs); } + public static void posix_fallocate(FileDescriptor fd, long offset, long length) throws ErrnoException { Libcore.os.posix_fallocate(fd, offset, length); } + public static int pread(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pread(fd, buffer, offset); } + 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); } + public static int pwrite(FileDescriptor fd, ByteBuffer buffer, long offset) throws ErrnoException, InterruptedIOException { return Libcore.os.pwrite(fd, buffer, offset); } + 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); } + public static int read(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException { return Libcore.os.read(fd, buffer); } + public static int read(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException { return Libcore.os.read(fd, bytes, byteOffset, byteCount); } + public static String readlink(String path) throws ErrnoException { return Libcore.os.readlink(path); } + public static int readv(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException { return Libcore.os.readv(fd, buffers, offsets, byteCounts); } + public static int recvfrom(FileDescriptor fd, ByteBuffer buffer, int flags, InetSocketAddress srcAddress) throws ErrnoException, SocketException { return Libcore.os.recvfrom(fd, buffer, flags, srcAddress); } + 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); } + public static void remove(String path) throws ErrnoException { Libcore.os.remove(path); } + public static void rename(String oldPath, String newPath) throws ErrnoException { Libcore.os.rename(oldPath, newPath); } + public static long sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount) throws ErrnoException { return Libcore.os.sendfile(outFd, inFd, inOffset, byteCount); } + 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); } + 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); } + public static void setegid(int egid) throws ErrnoException { Libcore.os.setegid(egid); } + public static void setenv(String name, String value, boolean overwrite) throws ErrnoException { Libcore.os.setenv(name, value, overwrite); } + public static void seteuid(int euid) throws ErrnoException { Libcore.os.seteuid(euid); } + public static void setgid(int gid) throws ErrnoException { Libcore.os.setgid(gid); } + public static int setsid() throws ErrnoException { return Libcore.os.setsid(); } + public static void setsockoptByte(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptByte(fd, level, option, value); } + public static void setsockoptIfreq(FileDescriptor fd, int level, int option, String value) throws ErrnoException { Libcore.os.setsockoptIfreq(fd, level, option, value); } + public static void setsockoptInt(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptInt(fd, level, option, value); } + public static void setsockoptIpMreqn(FileDescriptor fd, int level, int option, int value) throws ErrnoException { Libcore.os.setsockoptIpMreqn(fd, level, option, value); } + public static void setsockoptGroupReq(FileDescriptor fd, int level, int option, StructGroupReq value) throws ErrnoException { Libcore.os.setsockoptGroupReq(fd, level, option, value); } + public static void setsockoptGroupSourceReq(FileDescriptor fd, int level, int option, StructGroupSourceReq value) throws ErrnoException { Libcore.os.setsockoptGroupSourceReq(fd, level, option, value); } + public static void setsockoptLinger(FileDescriptor fd, int level, int option, StructLinger value) throws ErrnoException { Libcore.os.setsockoptLinger(fd, level, option, value); } + public static void setsockoptTimeval(FileDescriptor fd, int level, int option, StructTimeval value) throws ErrnoException { Libcore.os.setsockoptTimeval(fd, level, option, value); } + public static void setuid(int uid) throws ErrnoException { Libcore.os.setuid(uid); } + public static void shutdown(FileDescriptor fd, int how) throws ErrnoException { Libcore.os.shutdown(fd, how); } + public static FileDescriptor socket(int domain, int type, int protocol) throws ErrnoException { return Libcore.os.socket(domain, type, protocol); } + public static void socketpair(int domain, int type, int protocol, FileDescriptor fd1, FileDescriptor fd2) throws ErrnoException { Libcore.os.socketpair(domain, type, protocol, fd1, fd2); } + public static StructStat stat(String path) throws ErrnoException { return Libcore.os.stat(path); } + public static StructStatVfs statvfs(String path) throws ErrnoException { return Libcore.os.statvfs(path); } + public static String strerror(int errno) { return Libcore.os.strerror(errno); } + public static String strsignal(int signal) { return Libcore.os.strsignal(signal); } + public static void symlink(String oldPath, String newPath) throws ErrnoException { Libcore.os.symlink(oldPath, newPath); } + public static long sysconf(int name) { return Libcore.os.sysconf(name); } + public static void tcdrain(FileDescriptor fd) throws ErrnoException { Libcore.os.tcdrain(fd); } + public static void tcsendbreak(FileDescriptor fd, int duration) throws ErrnoException { Libcore.os.tcsendbreak(fd, duration); } + public static int umask(int mask) { return Libcore.os.umask(mask); } + public static StructUtsname uname() { return Libcore.os.uname(); } + public static void unsetenv(String name) throws ErrnoException { Libcore.os.unsetenv(name); } + public static int waitpid(int pid, MutableInt status, int options) throws ErrnoException { return Libcore.os.waitpid(pid, status, options); } + public static int write(FileDescriptor fd, ByteBuffer buffer) throws ErrnoException, InterruptedIOException { return Libcore.os.write(fd, buffer); } + public static int write(FileDescriptor fd, byte[] bytes, int byteOffset, int byteCount) throws ErrnoException, InterruptedIOException { return Libcore.os.write(fd, bytes, byteOffset, byteCount); } + public static int writev(FileDescriptor fd, Object[] buffers, int[] offsets, int[] byteCounts) throws ErrnoException, InterruptedIOException { return Libcore.os.writev(fd, buffers, offsets, byteCounts); } +} diff --git a/luni/src/main/java/android/system/OsConstants.java b/luni/src/main/java/android/system/OsConstants.java new file mode 100644 index 0000000..f7e02af --- /dev/null +++ b/luni/src/main/java/android/system/OsConstants.java @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * @hide + */ +public final class OsConstants extends libcore.io.OsConstants { + private OsConstants() {} +} diff --git a/luni/src/main/java/android/system/StructAddrinfo.java b/luni/src/main/java/android/system/StructAddrinfo.java new file mode 100644 index 0000000..9862190 --- /dev/null +++ b/luni/src/main/java/android/system/StructAddrinfo.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +import java.net.InetAddress; + +/** + * Information returned/taken by getaddrinfo(3). Corresponds to C's {@code struct addrinfo} from + * <a href="http://pubs.opengroup.org/onlinepubs/009695399/basedefs/netdb.h.html"><netdb.h></a> + * + * TODO: we currently only _take_ a StructAddrinfo; getaddrinfo returns an InetAddress[]. + * + * @hide + */ +public final class StructAddrinfo { + /** Flags describing the kind of lookup to be done. (Such as AI_ADDRCONFIG.) */ + public int ai_flags; + + /** Desired address family for results. (Such as AF_INET6 for IPv6. AF_UNSPEC means "any".) */ + public int ai_family; + + /** Socket type. (Such as SOCK_DGRAM. 0 means "any".) */ + public int ai_socktype; + + /** Protocol. (Such as IPPROTO_IPV6 IPv6. 0 means "any".) */ + public int ai_protocol; + + /** Address length. (Not useful in Java.) */ + // public int ai_addrlen; + + /** Address. */ + public InetAddress ai_addr; + + /** Canonical name of service location (if AI_CANONNAME provided in ai_flags). */ + // public String ai_canonname; + + /** Next element in linked list. */ + public StructAddrinfo ai_next; +} diff --git a/luni/src/main/java/android/system/StructFlock.java b/luni/src/main/java/android/system/StructFlock.java new file mode 100644 index 0000000..4908420 --- /dev/null +++ b/luni/src/main/java/android/system/StructFlock.java @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * Information returned/taken by fcntl(2) F_GETFL and F_SETFL. Corresponds to C's + * {@code struct flock} from + * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html"><fcntl.h></a> + * + * @hide + */ +public final class StructFlock { + /** The operation type, one of F_RDLCK, F_WRLCK, or F_UNLCK. */ + public short l_type; + + /** How to interpret l_start, one of SEEK_CUR, SEEK_END, SEEK_SET. */ + public short l_whence; + + /** Start offset. */ + public long l_start; /*off_t*/ + + /** Byte count to operate on. */ + public long l_len; /*off_t*/ + + /** Process blocking our lock (filled in by F_GETLK, otherwise unused). */ + public int l_pid; /*pid_t*/ +} diff --git a/luni/src/main/java/android/system/StructGroupReq.java b/luni/src/main/java/android/system/StructGroupReq.java new file mode 100644 index 0000000..f7e7d0f --- /dev/null +++ b/luni/src/main/java/android/system/StructGroupReq.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +import java.net.InetAddress; + +/** + * Corresponds to C's {@code struct group_req}. + * + * @hide + */ +public final class StructGroupReq { + public final int gr_interface; + public final InetAddress gr_group; + + public StructGroupReq(int gr_interface, InetAddress gr_group) { + this.gr_interface = gr_interface; + this.gr_group = gr_group; + } + + @Override public String toString() { + return "StructGroupReq[gr_interface=" + gr_interface + ",gr_group=" + gr_group + "]"; + } +} diff --git a/luni/src/main/java/android/system/StructGroupSourceReq.java b/luni/src/main/java/android/system/StructGroupSourceReq.java new file mode 100644 index 0000000..f3958ad --- /dev/null +++ b/luni/src/main/java/android/system/StructGroupSourceReq.java @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +import java.net.InetAddress; + +/** + * Corresponds to C's {@code struct group_source_req}. + * + * @hide + */ +public final class StructGroupSourceReq { + + public final int gsr_interface; + + public final InetAddress gsr_group; + + public final InetAddress gsr_source; + + public StructGroupSourceReq(int gsr_interface, InetAddress gsr_group, InetAddress gsr_source) { + this.gsr_interface = gsr_interface; + this.gsr_group = gsr_group; + this.gsr_source = gsr_source; + } + + @Override + public String toString() { + return "StructGroupSourceReq[gsr_interface=" + gsr_interface + ",gsr_group=" + gsr_group + + ",gsr_source=" + gsr_source + "]"; + } +} diff --git a/luni/src/main/java/android/system/StructLinger.java b/luni/src/main/java/android/system/StructLinger.java new file mode 100644 index 0000000..8c65336 --- /dev/null +++ b/luni/src/main/java/android/system/StructLinger.java @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * Corresponds to C's {@code struct linger} from + * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html"><sys/socket.h></a> + * + * @hide + */ +public final class StructLinger { + /** Whether or not linger is enabled. Non-zero is on. */ + public final int l_onoff; + + /** Linger time in seconds. */ + public final int l_linger; + + public StructLinger(int l_onoff, int l_linger) { + this.l_onoff = l_onoff; + this.l_linger = l_linger; + } + + public boolean isOn() { + return l_onoff != 0; + } + + @Override public String toString() { + return "StructLinger[l_onoff=" + l_onoff + ",l_linger=" + l_linger + "]"; + } +} diff --git a/luni/src/main/java/android/system/StructPasswd.java b/luni/src/main/java/android/system/StructPasswd.java new file mode 100644 index 0000000..9a94d3d --- /dev/null +++ b/luni/src/main/java/android/system/StructPasswd.java @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * Information returned by getpwnam(3) and getpwuid(3). Corresponds to C's + * {@code struct passwd} from + * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/pwd.h.html"><pwd.h></a> + * + * @hide + */ +public final class StructPasswd { + public String pw_name; + public int pw_uid; /* uid_t */ + public int pw_gid; /* gid_t */ + public String pw_dir; + public String pw_shell; + + public StructPasswd(String pw_name, int pw_uid, int pw_gid, String pw_dir, String pw_shell) { + this.pw_name = pw_name; + this.pw_uid = pw_uid; + this.pw_gid = pw_gid; + this.pw_dir = pw_dir; + this.pw_shell = pw_shell; + } +} diff --git a/luni/src/main/java/android/system/StructPollfd.java b/luni/src/main/java/android/system/StructPollfd.java new file mode 100644 index 0000000..9e65989 --- /dev/null +++ b/luni/src/main/java/android/system/StructPollfd.java @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +import java.io.FileDescriptor; + +/** + * Corresponds to C's {@code struct pollfd} from + * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/poll.h.html"><poll.h></a> + * + * @hide + */ +public final class StructPollfd { + /** The file descriptor to poll. */ + public FileDescriptor fd; + + /** + * The events we're interested in. POLLIN corresponds to being in select(2)'s read fd set, + * POLLOUT to the write fd set. + */ + public short events; + + /** The events that actually happened. */ + public short revents; + + /** + * A non-standard extension that lets callers conveniently map back to the object + * their fd belongs to. This is used by Selector, for example, to associate each + * FileDescriptor with the corresponding SelectionKey. + */ + public Object userData; + + @Override public String toString() { + return "StructPollfd[fd=" + fd + ",events=" + events + ",revents=" + revents + "]"; + } +} diff --git a/luni/src/main/java/android/system/StructStat.java b/luni/src/main/java/android/system/StructStat.java new file mode 100644 index 0000000..17221fd --- /dev/null +++ b/luni/src/main/java/android/system/StructStat.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * File information returned by fstat(2), lstat(2), and stat(2). Corresponds to C's + * {@code struct stat} from + * <a href="http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/stat.h.html"><stat.h></a> + * + * @hide + */ +public final class StructStat extends libcore.io.StructStat { + public StructStat(long st_dev, long st_ino, int st_mode, long st_nlink, int st_uid, int st_gid, + long st_rdev, long st_size, long st_atime, long st_mtime, long st_ctime, + long st_blksize, long st_blocks) { + super(st_dev, st_ino, st_mode, st_nlink, st_uid, st_gid, + st_rdev, st_size, st_atime, st_mtime, st_ctime, + st_blksize, st_blocks); + } +} diff --git a/luni/src/main/java/android/system/StructStatVfs.java b/luni/src/main/java/android/system/StructStatVfs.java new file mode 100644 index 0000000..b0eedb7 --- /dev/null +++ b/luni/src/main/java/android/system/StructStatVfs.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * File information returned by fstatvfs(2) and statvfs(2). + * + * @hide + */ +public final class StructStatVfs extends libcore.io.StructStatVfs { + public StructStatVfs(long f_bsize, long f_frsize, long f_blocks, long f_bfree, long f_bavail, + long f_files, long f_ffree, long f_favail, + long f_fsid, long f_flag, long f_namemax) { + super(f_bsize, f_frsize, f_blocks, f_bfree, f_bavail, + f_files, f_ffree, f_favail, + f_fsid, f_flag, f_namemax); + } +} diff --git a/luni/src/main/java/android/system/StructTimeval.java b/luni/src/main/java/android/system/StructTimeval.java new file mode 100644 index 0000000..c31ab3a --- /dev/null +++ b/luni/src/main/java/android/system/StructTimeval.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * Corresponds to C's {@code struct timeval} from + * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_time.h.html"><sys/time.h></a> + * + * @hide + */ +public final class StructTimeval { + /** Seconds. */ + public final long tv_sec; + + /** Microseconds. */ + public final long tv_usec; + + private StructTimeval(long tv_sec, long tv_usec) { + this.tv_sec = tv_sec; + this.tv_usec = tv_usec; + } + + + public static StructTimeval fromMillis(long millis) { + long tv_sec = millis / 1000; + long tv_usec = (millis - (tv_sec * 1000)) * 1000; + return new StructTimeval(tv_sec, tv_usec); + } + + public long toMillis() { + return (tv_sec * 1000) + (tv_usec / 1000); + } + + @Override public String toString() { + return "StructTimeval[tv_sec=" + tv_sec + ",tv_usec=" + tv_usec + "]"; + } +} diff --git a/luni/src/main/java/android/system/StructUcred.java b/luni/src/main/java/android/system/StructUcred.java new file mode 100644 index 0000000..563a904 --- /dev/null +++ b/luni/src/main/java/android/system/StructUcred.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2013 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * Corresponds to C's {@code struct ucred}. + * + * @hide + */ +public final class StructUcred { + /** The peer's process id. */ + public final int pid; + + /** The peer process' uid. */ + public final int uid; + + /** The peer process' gid. */ + public final int gid; + + public StructUcred(int pid, int uid, int gid) { + this.pid = pid; + this.uid = uid; + this.gid = gid; + } + + @Override public String toString() { + return "StructUcred[pid=" + pid + ",uid=" + uid + ",gid=" + gid + "]"; + } +} diff --git a/luni/src/main/java/android/system/StructUtsname.java b/luni/src/main/java/android/system/StructUtsname.java new file mode 100644 index 0000000..21e08bb --- /dev/null +++ b/luni/src/main/java/android/system/StructUtsname.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.system; + +/** + * Information returned by uname(2). Corresponds to C's + * {@code struct utsname} from + * <a href="http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_utsname.h.html"><sys/utsname.h></a> + * + * @hide + */ +public final class StructUtsname { + /** The OS name, such as "Linux". */ + public final String sysname; + + /** The machine's unqualified name on some implementation-defined network. */ + public final String nodename; + + /** The OS release, such as "2.6.35-27-generic". */ + public final String release; + + /** The OS version, such as "#48-Ubuntu SMP Tue Feb 22 20:25:29 UTC 2011". */ + public final String version; + + /** The machine architecture, such as "armv7l" or "x86_64". */ + public final String machine; + + public StructUtsname(String sysname, String nodename, String release, String version, String machine) { + this.sysname = sysname; + this.nodename = nodename; + this.release = release; + this.version = version; + this.machine = machine; + } +} diff --git a/luni/src/main/java/android/util/MutableBoolean.java b/luni/src/main/java/android/util/MutableBoolean.java new file mode 100644 index 0000000..90bf68c --- /dev/null +++ b/luni/src/main/java/android/util/MutableBoolean.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.util; + +/** + * @hide + */ +public final class MutableBoolean { + public boolean value; + + public MutableBoolean(boolean value) { + this.value = value; + } +} diff --git a/luni/src/main/java/android/util/MutableByte.java b/luni/src/main/java/android/util/MutableByte.java new file mode 100644 index 0000000..65738b9 --- /dev/null +++ b/luni/src/main/java/android/util/MutableByte.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.util; + +/** + * @hide + */ +public final class MutableByte { + public byte value; + + public MutableByte(byte value) { + this.value = value; + } +} diff --git a/luni/src/main/java/android/util/MutableChar.java b/luni/src/main/java/android/util/MutableChar.java new file mode 100644 index 0000000..b59bab3 --- /dev/null +++ b/luni/src/main/java/android/util/MutableChar.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.util; + +/** + * @hide + */ +public final class MutableChar { + public char value; + + public MutableChar(char value) { + this.value = value; + } +} diff --git a/luni/src/main/java/android/util/MutableDouble.java b/luni/src/main/java/android/util/MutableDouble.java new file mode 100644 index 0000000..3e2cc3a --- /dev/null +++ b/luni/src/main/java/android/util/MutableDouble.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.util; + +/** + * @hide + */ +public final class MutableDouble { + public double value; + + public MutableDouble(double value) { + this.value = value; + } +} diff --git a/luni/src/main/java/android/util/MutableFloat.java b/luni/src/main/java/android/util/MutableFloat.java new file mode 100644 index 0000000..6e30501 --- /dev/null +++ b/luni/src/main/java/android/util/MutableFloat.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.util; + +/** + * @hide + */ +public final class MutableFloat { + public float value; + + public MutableFloat(float value) { + this.value = value; + } +} diff --git a/luni/src/main/java/android/util/MutableInt.java b/luni/src/main/java/android/util/MutableInt.java new file mode 100644 index 0000000..8220c44 --- /dev/null +++ b/luni/src/main/java/android/util/MutableInt.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.util; + +/** + * @hide + */ +public final class MutableInt { + public int value; + + public MutableInt(int value) { + this.value = value; + } +} diff --git a/luni/src/main/java/android/util/MutableLong.java b/luni/src/main/java/android/util/MutableLong.java new file mode 100644 index 0000000..5df6a0d --- /dev/null +++ b/luni/src/main/java/android/util/MutableLong.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.util; + +/** + * @hide + */ +public final class MutableLong { + public long value; + + public MutableLong(long value) { + this.value = value; + } +} diff --git a/luni/src/main/java/android/util/MutableShort.java b/luni/src/main/java/android/util/MutableShort.java new file mode 100644 index 0000000..3880fef --- /dev/null +++ b/luni/src/main/java/android/util/MutableShort.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.util; + +/** + * @hide + */ +public final class MutableShort { + public short value; + + public MutableShort(short value) { + this.value = value; + } +} |