diff options
author | Justin Klaassen <justinklaassen@google.com> | 2017-11-17 16:38:15 -0500 |
---|---|---|
committer | Justin Klaassen <justinklaassen@google.com> | 2017-11-17 16:38:15 -0500 |
commit | 6a65f2da209bff03cb0eb6da309710ac6ee5026d (patch) | |
tree | 48e2090e716d4178378cb0599fc5d9cffbcf3f63 /android/system | |
parent | 46c77c203439b3b37c99d09e326df4b1fe08c10b (diff) | |
download | android-28-6a65f2da209bff03cb0eb6da309710ac6ee5026d.tar.gz |
Import Android SDK Platform P [4456821]
/google/data/ro/projects/android/fetch_artifact \
--bid 4456821 \
--target sdk_phone_armv7-win_sdk \
sdk-repo-linux-sources-4456821.zip
AndroidVersion.ApiLevel has been modified to appear as 28
Change-Id: I2d206b200d7952f899a5d1647ab532638cc8dd43
Diffstat (limited to 'android/system')
-rw-r--r-- | android/system/Int32Ref.java | 28 | ||||
-rw-r--r-- | android/system/Int64Ref.java | 28 | ||||
-rw-r--r-- | android/system/Os.java | 101 | ||||
-rw-r--r-- | android/system/UnixSocketAddressTest.java | 51 |
4 files changed, 153 insertions, 55 deletions
diff --git a/android/system/Int32Ref.java b/android/system/Int32Ref.java new file mode 100644 index 00000000..25a818da --- /dev/null +++ b/android/system/Int32Ref.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2017 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; + +/** + * A signed 32bit integer reference suitable for passing to lower-level system calls. + */ +public class Int32Ref { + public int value; + + public Int32Ref(int value) { + this.value = value; + } +} diff --git a/android/system/Int64Ref.java b/android/system/Int64Ref.java new file mode 100644 index 00000000..f42450d8 --- /dev/null +++ b/android/system/Int64Ref.java @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2017 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; + +/** + * A signed 64bit integer reference suitable for passing to lower-level system calls. + */ +public class Int64Ref { + public long value; + + public Int64Ref(long value) { + this.value = value; + } +} diff --git a/android/system/Os.java b/android/system/Os.java index 2dabae2f..fe8f7d45 100644 --- a/android/system/Os.java +++ b/android/system/Os.java @@ -188,6 +188,17 @@ public final class Os { public static int getgid() { return Libcore.os.getgid(); } /** + * See <a href="http://man7.org/linux/man-pages/man2/getgroups.2.html">getgroups(2)</a>. + * + * <p>Should the number of groups change during the execution of this call, the call may + * return an arbitrary subset. This may be worth reconsidering should this be exposed + * as public API. + * + * @hide + */ + public static int[] getgroups() throws ErrnoException { return Libcore.os.getgroups(); } + + /** * See <a href="http://man7.org/linux/man-pages/man3/getenv.3.html">getenv(3)</a>. */ public static String getenv(String name) { return Libcore.os.getenv(name); } @@ -268,7 +279,16 @@ public final class Os { public static InetAddress inet_pton(int family, String address) { return Libcore.os.inet_pton(family, address); } /** @hide */ public static InetAddress ioctlInetAddress(FileDescriptor fd, int cmd, String interfaceName) throws ErrnoException { return Libcore.os.ioctlInetAddress(fd, cmd, interfaceName); } - /** @hide */ public static int ioctlInt(FileDescriptor fd, int cmd, MutableInt arg) throws ErrnoException { return Libcore.os.ioctlInt(fd, cmd, arg); } + + + /** @hide */ public static int ioctlInt(FileDescriptor fd, int cmd, Int32Ref arg) throws ErrnoException { + libcore.util.MutableInt internalArg = new libcore.util.MutableInt(arg.value); + try { + return Libcore.os.ioctlInt(fd, cmd, internalArg); + } finally { + arg.value = internalArg.value; + } + } /** * See <a href="http://man7.org/linux/man-pages/man3/isatty.3.html">isatty(3)</a>. @@ -453,8 +473,41 @@ public final class Os { /** * See <a href="http://man7.org/linux/man-pages/man2/sendfile.2.html">sendfile(2)</a>. + * + * @deprecated This method will be removed in a future version of Android. Use + * {@link #sendfile(FileDescriptor, FileDescriptor, Int64Ref, long)} instead. + */ + @Deprecated + public static long sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount) throws ErrnoException { + if (inOffset == null) { + return Libcore.os.sendfile(outFd, inFd, null, byteCount); + } else { + libcore.util.MutableLong internalInOffset = new libcore.util.MutableLong( + inOffset.value); + try { + return Libcore.os.sendfile(outFd, inFd, internalInOffset, byteCount); + } finally { + inOffset.value = internalInOffset.value; + } + } + } + + /** + * See <a href="http://man7.org/linux/man-pages/man2/sendfile.2.html">sendfile(2)</a>. */ - public static long sendfile(FileDescriptor outFd, FileDescriptor inFd, MutableLong inOffset, long byteCount) throws ErrnoException { return Libcore.os.sendfile(outFd, inFd, inOffset, byteCount); } + public static long sendfile(FileDescriptor outFd, FileDescriptor inFd, Int64Ref inOffset, long byteCount) throws ErrnoException { + if (inOffset == null) { + return Libcore.os.sendfile(outFd, inFd, null, byteCount); + } else { + libcore.util.MutableLong internalInOffset = new libcore.util.MutableLong( + inOffset.value); + try { + return Libcore.os.sendfile(outFd, inFd, internalInOffset, byteCount); + } finally { + inOffset.value = internalInOffset.value; + } + } + } /** * See <a href="http://man7.org/linux/man-pages/man2/sendto.2.html">sendto(2)</a>. @@ -492,6 +545,13 @@ public final class Os { public static void setgid(int gid) throws ErrnoException { Libcore.os.setgid(gid); } /** + * See <a href="http://man7.org/linux/man-pages/man2/setgroups.2.html">setgroups(2)</a>. + * + * @hide + */ + public static void setgroups(int[] gids) throws ErrnoException { Libcore.os.setgroups(gids); } + + /** * See <a href="http://man7.org/linux/man-pages/man2/setpgid.2.html">setpgid(2)</a>. */ /** @hide */ public static void setpgid(int pid, int pgid) throws ErrnoException { Libcore.os.setpgid(pid, pgid); } @@ -611,8 +671,41 @@ public final class Os { /** * See <a href="http://man7.org/linux/man-pages/man2/waitpid.2.html">waitpid(2)</a>. - */ - public static int waitpid(int pid, MutableInt status, int options) throws ErrnoException { return Libcore.os.waitpid(pid, status, options); } + * + * @deprecated This method will be removed in a future version of Android. Use + * {@link #waitpid(int, Int32Ref, int)} instead. + */ + @Deprecated + public static int waitpid(int pid, MutableInt status, int options) throws ErrnoException { + if (status == null) { + return Libcore.os.waitpid(pid, null, options); + } else { + libcore.util.MutableInt internalStatus = new libcore.util.MutableInt(status.value); + try { + return Libcore.os.waitpid(pid, internalStatus, options); + } finally { + status.value = internalStatus.value; + } + } + } + + /** + * See <a href="http://man7.org/linux/man-pages/man2/waitpid.2.html">waitpid(2)</a>. + * + * @throws IllegalArgumentException if {@code status != null && status.length != 1} + */ + public static int waitpid(int pid, Int32Ref status, int options) throws ErrnoException { + if (status == null) { + return Libcore.os.waitpid(pid, null, options); + } else { + libcore.util.MutableInt internalStatus = new libcore.util.MutableInt(status.value); + try { + return Libcore.os.waitpid(pid, internalStatus, options); + } finally { + status.value = internalStatus.value; + } + } + } /** * See <a href="http://man7.org/linux/man-pages/man2/write.2.html">write(2)</a>. diff --git a/android/system/UnixSocketAddressTest.java b/android/system/UnixSocketAddressTest.java deleted file mode 100644 index f1b7fc23..00000000 --- a/android/system/UnixSocketAddressTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2015 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 junit.framework.TestCase; - -import java.nio.charset.StandardCharsets; -import java.util.Arrays; - -public class UnixSocketAddressTest extends TestCase { - - public void testFilesystemSunPath() throws Exception { - String path = "/foo/bar"; - UnixSocketAddress sa = UnixSocketAddress.createFileSystem(path); - - byte[] abstractNameBytes = path.getBytes(StandardCharsets.UTF_8); - byte[] expected = new byte[abstractNameBytes.length + 1]; - // See unix(7) - System.arraycopy(abstractNameBytes, 0, expected, 0, abstractNameBytes.length); - assertTrue(Arrays.equals(expected, sa.getSunPath())); - } - - public void testUnnamedSunPath() throws Exception { - UnixSocketAddress sa = UnixSocketAddress.createUnnamed(); - assertEquals(0, sa.getSunPath().length); - } - - public void testAbstractSunPath() throws Exception { - String abstractName = "abstract"; - UnixSocketAddress sa = UnixSocketAddress.createAbstract(abstractName); - byte[] abstractNameBytes = abstractName.getBytes(StandardCharsets.UTF_8); - byte[] expected = new byte[abstractNameBytes.length + 1]; - // See unix(7) - System.arraycopy(abstractNameBytes, 0, expected, 1, abstractNameBytes.length); - assertTrue(Arrays.equals(expected, sa.getSunPath())); - } -} |