summaryrefslogtreecommitdiff
path: root/core/java/android
diff options
context:
space:
mode:
authorPete Gillin <peteg@google.com>2018-05-16 08:27:27 -0700
committerandroid-build-merger <android-build-merger@google.com>2018-05-16 08:27:27 -0700
commit306481a63bed2962eee6c6d79b28cc3d5c6fceb6 (patch)
tree9c845bb32576d4942ed85b04d4f9a24264130568 /core/java/android
parent9473edd1da28e088947ab753f72d52c3a8b5189e (diff)
parent72629d9999e2b04a3c14eab8e6feb952a7bd5710 (diff)
Merge "Stop using Arrays.checkOffsetAndCount. am: 60f55a255f" into stage-aosp-master
am: 72629d9999 Change-Id: Ia8f5ce41c654cb6522c6ea5f2863d97f282ce268
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/content/pm/LimitedLengthInputStream.java5
-rw-r--r--core/java/android/os/FileBridge.java4
-rw-r--r--core/java/android/os/Parcel.java6
3 files changed, 8 insertions, 7 deletions
diff --git a/core/java/android/content/pm/LimitedLengthInputStream.java b/core/java/android/content/pm/LimitedLengthInputStream.java
index e78727718cbd..19b681e4373a 100644
--- a/core/java/android/content/pm/LimitedLengthInputStream.java
+++ b/core/java/android/content/pm/LimitedLengthInputStream.java
@@ -1,9 +1,10 @@
package android.content.pm;
+import libcore.util.ArrayUtils;
+
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Arrays;
/**
* A class that limits the amount of data that is read from an InputStream. When
@@ -71,7 +72,7 @@ public class LimitedLengthInputStream extends FilterInputStream {
}
final int arrayLength = buffer.length;
- Arrays.checkOffsetAndCount(arrayLength, offset, byteCount);
+ ArrayUtils.throwsIfOutOfBounds(arrayLength, offset, byteCount);
if (mOffset > Long.MAX_VALUE - byteCount) {
throw new IOException("offset out of bounds: " + mOffset + " + " + byteCount);
diff --git a/core/java/android/os/FileBridge.java b/core/java/android/os/FileBridge.java
index 3ac88c564f41..21fd819f3d94 100644
--- a/core/java/android/os/FileBridge.java
+++ b/core/java/android/os/FileBridge.java
@@ -27,12 +27,12 @@ import libcore.io.IoBridge;
import libcore.io.IoUtils;
import libcore.io.Memory;
import libcore.io.Streams;
+import libcore.util.ArrayUtils;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteOrder;
-import java.util.Arrays;
/**
* Simple bridge that allows file access across process boundaries without
@@ -178,7 +178,7 @@ public class FileBridge extends Thread {
@Override
public void write(byte[] buffer, int byteOffset, int byteCount) throws IOException {
- Arrays.checkOffsetAndCount(buffer.length, byteOffset, byteCount);
+ ArrayUtils.throwsIfOutOfBounds(buffer.length, byteOffset, byteCount);
Memory.pokeInt(mTemp, 0, CMD_WRITE, ByteOrder.BIG_ENDIAN);
Memory.pokeInt(mTemp, 4, byteCount, ByteOrder.BIG_ENDIAN);
IoBridge.write(mClient, mTemp, 0, MSG_LENGTH);
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 514292872e90..3bf170980e29 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -32,6 +32,7 @@ import dalvik.annotation.optimization.CriticalNative;
import dalvik.annotation.optimization.FastNative;
import dalvik.system.VMRuntime;
+import libcore.util.ArrayUtils;
import libcore.util.SneakyThrow;
import java.io.ByteArrayInputStream;
@@ -47,7 +48,6 @@ import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -631,7 +631,7 @@ public final class Parcel {
writeInt(-1);
return;
}
- Arrays.checkOffsetAndCount(b.length, offset, len);
+ ArrayUtils.throwsIfOutOfBounds(b.length, offset, len);
nativeWriteByteArray(mNativePtr, b, offset, len);
}
@@ -660,7 +660,7 @@ public final class Parcel {
writeInt(-1);
return;
}
- Arrays.checkOffsetAndCount(b.length, offset, len);
+ ArrayUtils.throwsIfOutOfBounds(b.length, offset, len);
nativeWriteBlob(mNativePtr, b, offset, len);
}