Os
class Os
kotlin.Any | |
↳ | android.system.Os |
Access to low-level system functionality. Most of these are system calls. Most users will want to use higher-level APIs where available, but this class provides access to the underlying primitives used to implement the higher-level APIs.
The corresponding constants can be found in OsConstants
.
Summary
Public methods
accept
static fun accept(
fd: FileDescriptor!,
peerAddress: InetSocketAddress!
): FileDescriptor!
See accept(2).
bind
static fun bind(
fd: FileDescriptor!,
address: InetAddress!,
port: Int
): Unit
See bind(2).
bind
static fun bind(
fd: FileDescriptor,
address: SocketAddress
): Unit
See bind(2).
Parameters | |
---|---|
fd |
FileDescriptor: This value cannot be null . |
address |
SocketAddress: This value cannot be null . |
chown
static fun chown(
path: String!,
uid: Int,
gid: Int
): Unit
See chown(2).
connect
static fun connect(
fd: FileDescriptor!,
address: InetAddress!,
port: Int
): Unit
See connect(2).
connect
static fun connect(
fd: FileDescriptor,
address: SocketAddress
): Unit
See connect(2).
Parameters | |
---|---|
fd |
FileDescriptor: This value cannot be null . |
address |
SocketAddress: This value cannot be null . |
dup2
static fun dup2(
oldFd: FileDescriptor!,
newFd: Int
): FileDescriptor!
See dup2(2).
execv
static fun execv(
filename: String!,
argv: Array<String!>!
): Unit
See exec(3).
execve
static fun execve(
filename: String!,
argv: Array<String!>!,
envp: Array<String!>!
): Unit
See execve(2).
fchmod
static fun fchmod(
fd: FileDescriptor!,
mode: Int
): Unit
See fchmod(2).
fchown
static fun fchown(
fd: FileDescriptor!,
uid: Int,
gid: Int
): Unit
See fchown(2).
fcntlInt
static fun fcntlInt(
fd: FileDescriptor,
cmd: Int,
arg: Int
): Int
See fcntl(2).
Parameters | |
---|---|
fd |
FileDescriptor: This value cannot be null . |
fstatvfs
static fun fstatvfs(fd: FileDescriptor!): StructStatVfs!
See fstatvfs(2).
ftruncate
static fun ftruncate(
fd: FileDescriptor!,
length: Long
): Unit
See ftruncate(2).
gai_strerror
static fun gai_strerror(error: Int): String!
See gai_strerror(3).
getpeername
static fun getpeername(fd: FileDescriptor!): SocketAddress!
See getpeername(2).
getsockname
static fun getsockname(fd: FileDescriptor!): SocketAddress!
See getsockname(2).
getsockoptTimeval
static fun getsockoptTimeval(
fd: FileDescriptor,
level: Int,
option: Int
): StructTimeval
See getsockopt(2).
Only for use with option
values that return a struct timeval
such as OsConstants#SO_RCVTIMEO
and OsConstants#SO_SNDTIMEO
. Use with other options may throw an IllegalArgumentException
or return junk values.
Parameters | |
---|---|
fd |
FileDescriptor: This value cannot be null . |
Return | |
---|---|
StructTimeval |
This value cannot be null . |
getxattr
static fun getxattr(
path: String!,
name: String!
): ByteArray!
See getxattr(2)
if_indextoname
static fun if_indextoname(index: Int): String!
See if_indextoname(3).
if_nametoindex
static fun if_nametoindex(name: String!): Int
See if_nametoindex(3).
inet_pton
static fun inet_pton(
family: Int,
address: String!
): InetAddress!
See inet_pton(3).
lchown
static fun lchown(
path: String!,
uid: Int,
gid: Int
): Unit
See lchown(2).
listen
static fun listen(
fd: FileDescriptor!,
backlog: Int
): Unit
See listen(2).
listxattr
static fun listxattr(path: String!): Array<String!>!
See listxattr(2)
lseek
static fun lseek(
fd: FileDescriptor!,
offset: Long,
whence: Int
): Long
See lseek(2).
memfd_create
static fun memfd_create(
name: String,
flags: Int
): FileDescriptor
See memfd_create(2).
Parameters | |
---|---|
name |
String: This value cannot be null . |
Return | |
---|---|
FileDescriptor |
This value cannot be null . |
mincore
static fun mincore(
address: Long,
byteCount: Long,
vector: ByteArray!
): Unit
See mincore(2).
mmap
static fun mmap(
address: Long,
byteCount: Long,
prot: Int,
flags: Int,
fd: FileDescriptor!,
offset: Long
): Long
See mmap(2).
msync
static fun msync(
address: Long,
byteCount: Long,
flags: Int
): Unit
See msync(2).
munlock
static fun munlock(
address: Long,
byteCount: Long
): Unit
See munlock(2).
munmap
static fun munmap(
address: Long,
byteCount: Long
): Unit
See munmap(2).
open
static fun open(
path: String!,
flags: Int,
mode: Int
): FileDescriptor!
See open(2).
poll
static fun poll(
fds: Array<StructPollfd!>!,
timeoutMs: Int
): Int
See poll(2).
Note that in Lollipop this could throw an ErrnoException
with EINTR
. In later releases, the implementation will automatically just restart the system call with an appropriately reduced timeout.
posix_fallocate
static fun posix_fallocate(
fd: FileDescriptor!,
offset: Long,
length: Long
): Unit
See posix_fallocate(3).
prctl
static fun prctl(
option: Int,
arg2: Long,
arg3: Long,
arg4: Long,
arg5: Long
): Int
See prctl(2).
pread
static fun pread(
fd: FileDescriptor!,
buffer: ByteBuffer!,
offset: Long
): Int
See pread(2).
pread
static fun pread(
fd: FileDescriptor!,
bytes: ByteArray!,
byteOffset: Int,
byteCount: Int,
offset: Long
): Int
See pread(2).
pwrite
static fun pwrite(
fd: FileDescriptor!,
buffer: ByteBuffer!,
offset: Long
): Int
See pwrite(2).
pwrite
static fun pwrite(
fd: FileDescriptor!,
bytes: ByteArray!,
byteOffset: Int,
byteCount: Int,
offset: Long
): Int
See pwrite(2).
read
static fun read(
fd: FileDescriptor!,
buffer: ByteBuffer!
): Int
See read(2).
read
static fun read(
fd: FileDescriptor!,
bytes: ByteArray!,
byteOffset: Int,
byteCount: Int
): Int
See read(2).
readv
static fun readv(
fd: FileDescriptor!,
buffers: Array<Any!>!,
offsets: IntArray!,
byteCounts: IntArray!
): Int
See readv(2).
recvfrom
static fun recvfrom(
fd: FileDescriptor!,
buffer: ByteBuffer!,
flags: Int,
srcAddress: InetSocketAddress!
): Int
See recvfrom(2).
recvfrom
static fun recvfrom(
fd: FileDescriptor!,
bytes: ByteArray!,
byteOffset: Int,
byteCount: Int,
flags: Int,
srcAddress: InetSocketAddress!
): Int
See recvfrom(2).
recvmsg
static fun recvmsg(
fd: FileDescriptor,
msg: StructMsghdr,
flags: Int
): Int
See recvmsg(2).
Parameters | |
---|---|
fd |
FileDescriptor: This value cannot be null . |
msg |
StructMsghdr: This value cannot be null . |
removexattr
static fun removexattr(
path: String!,
name: String!
): Unit
See removexattr(2).
rename
static fun rename(
oldPath: String!,
newPath: String!
): Unit
See rename(2).
sendfile
static fun sendfile(
outFd: FileDescriptor!,
inFd: FileDescriptor!,
offset: Int64Ref!,
byteCount: Long
): Long
See sendfile(2).
sendmsg
static fun sendmsg(
fd: FileDescriptor,
msg: StructMsghdr,
flags: Int
): Int
See sendmsg(2).
Parameters | |
---|---|
fd |
FileDescriptor: This value cannot be null . |
msg |
StructMsghdr: This value cannot be null . |
sendto
static fun sendto(
fd: FileDescriptor!,
buffer: ByteBuffer!,
flags: Int,
inetAddress: InetAddress!,
port: Int
): Int
See sendto(2).
sendto
static fun sendto(
fd: FileDescriptor!,
bytes: ByteArray!,
byteOffset: Int,
byteCount: Int,
flags: Int,
inetAddress: InetAddress!,
port: Int
): Int
See sendto(2).
sendto
static fun sendto(
fd: FileDescriptor,
bytes: ByteArray,
byteOffset: Int,
byteCount: Int,
flags: Int,
address: SocketAddress?
): Int
See sendto(2).
Parameters | |
---|---|
fd |
FileDescriptor: This value cannot be null . |
bytes |
ByteArray: This value cannot be null . |
address |
SocketAddress?: This value may be null . |
setegid
static funsetegid(egid: Int): Unit
Deprecated: Android Applications do not have sufficient privileges to call this method.
See setegid(2).
setenv
static fun setenv(
name: String!,
value: String!,
overwrite: Boolean
): Unit
See setenv(3).
seteuid
static funseteuid(euid: Int): Unit
Deprecated: Android Applications do not have sufficient privileges to call this method.
See seteuid(2).
setgid
static funsetgid(gid: Int): Unit
Deprecated: Android Applications do not have sufficient privileges to call this method.
See setgid(2).
setsockoptInt
static fun setsockoptInt(
fd: FileDescriptor!,
level: Int,
option: Int,
value: Int
): Unit
See setsockopt(2).
setsockoptTimeval
static fun setsockoptTimeval(
fd: FileDescriptor,
level: Int,
option: Int,
value: StructTimeval
): Unit
See setsockopt(2).
Only for use with option
values that take a struct timeval
such as OsConstants#SO_RCVTIMEO
and OsConstants#SO_SNDTIMEO
. Use with other options is likely to cause incorrect behavior.
Parameters | |
---|---|
fd |
FileDescriptor: This value cannot be null . |
value |
StructTimeval: This value cannot be null . |
setuid
static funsetuid(uid: Int): Unit
Deprecated: Android Applications do not have sufficient privileges to call this method.
See setuid(2).
setxattr
static fun setxattr(
path: String!,
name: String!,
value: ByteArray!,
flags: Int
): Unit
See setxattr(2)
shutdown
static fun shutdown(
fd: FileDescriptor!,
how: Int
): Unit
See shutdown(2).
socket
static fun socket(
domain: Int,
type: Int,
protocol: Int
): FileDescriptor!
See socket(2).
socketpair
static fun socketpair(
domain: Int,
type: Int,
protocol: Int,
fd1: FileDescriptor!,
fd2: FileDescriptor!
): Unit
See socketpair(2).
symlink
static fun symlink(
oldPath: String!,
newPath: String!
): Unit
See symlink(2).
tcsendbreak
static fun tcsendbreak(
fd: FileDescriptor!,
duration: Int
): Unit
See tcsendbreak(3).
write
static fun write(
fd: FileDescriptor!,
buffer: ByteBuffer!
): Int
See write(2).
write
static fun write(
fd: FileDescriptor!,
bytes: ByteArray!,
byteOffset: Int,
byteCount: Int
): Int
See write(2).
writev
static fun writev(
fd: FileDescriptor!,
buffers: Array<Any!>!,
offsets: IntArray!,
byteCounts: IntArray!
): Int
See writev(2).