Merge "Snap for 4455664 from cfc366534c0bc31a50172142d0ef75242b2e5c13 to oreo-vts-release" into oreo-vts-release
diff --git a/support/java/src/android/support/v8/renderscript/RenderScript.java b/support/java/src/android/support/v8/renderscript/RenderScript.java
index 13c5dc2..19a33d7 100644
--- a/support/java/src/android/support/v8/renderscript/RenderScript.java
+++ b/support/java/src/android/support/v8/renderscript/RenderScript.java
@@ -131,22 +131,10 @@
         return useNative;
     }
     /*
-     * Detect the bitness of the VM to allow FieldPacker and generated code to do the right thing.
+     * Detect the bitness of the VM to allow FieldPacker to do the right thing.
      */
     static native int rsnSystemGetPointerSize();
     static int sPointerSize;
-    static public int getPointerSize() {
-        // We provide an accessor rather than making the data item public for two reasons.
-        // 1) Prevents anyone outside this class from writing the data item.
-        // 2) Prevents anyone outside this class from reading the data item unless a class
-        //    instance has been created (ensuring the data item has been initialized).
-        // DISCLAIMER: Reflection can circumvent these preventive measures.
-        synchronized(lock) {
-            if (!sInitialized)
-                throw new RSInvalidStateException("Calling getPointerSize() before any RenderScript instantiated");
-        }
-        return sPointerSize;
-    }
 
     /**
      * Determines whether or not we should be thunking into the native
diff --git a/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/RSTestCore.java b/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/RSTestCore.java
index 72f941d..7ee559e 100644
--- a/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/RSTestCore.java
+++ b/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/RSTestCore.java
@@ -103,7 +103,6 @@
         unitTests.add(new UT_fp_mad(this, mRes, mCtx));
         unitTests.add(new UT_reduce(this, mRes, mCtx));
         unitTests.add(new UT_reduce_backward(this, mRes, mCtx));
-        unitTests.add(new UT_reflection3264(this, mCtx));
 
         /*
         unitTests.add(new UnitTest(null, "<Pass>", 1));
diff --git a/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/UT_reflection3264.java b/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/UT_reflection3264.java
deleted file mode 100644
index fa82b07..0000000
--- a/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/UT_reflection3264.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * 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 com.android.rs.test_compat;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.support.v8.renderscript.Allocation;
-import android.support.v8.renderscript.Element;
-import android.support.v8.renderscript.RenderScript;
-import android.support.v8.renderscript.Short4;
-import android.support.v8.renderscript.Type;
-import android.util.Log;
-import java.util.Random;
-
-import static junit.framework.Assert.assertEquals;
-
-public class UT_reflection3264 extends UnitTest {
-  private static final String TAG = "reflection3264";
-
-  protected UT_reflection3264(RSTestCore rstc, Context ctx) {
-    super(rstc, "reflection3264", ctx);
-  }
-
-  private final int xSize = 17, ySize = 23;  // arbitrary values
-
-  private final long seed = 20170609;  // arbitrary value
-
-  private static long unsigned(int v) {
-    if (v >= 0)
-      return (long)v;
-    else
-      return (long)v + ((long)1 << 32);
-  }
-
-  private static short unsigned(byte v) {
-    if (v >= 0)
-      return (short)v;
-    else
-      return (short)((short)v + (short)(1 << 8));
-  }
-
-  public void run() {
-    Random r = new Random(seed);
-
-    RenderScript pRS = RenderScript.create(mCtx);
-    ScriptC_reflection3264 s = new ScriptC_reflection3264(pRS);
-    pRS.setMessageHandler(mRsMessage);
-
-    Type.Builder typeBuilder = new Type.Builder(pRS, Element.U8_4(pRS));
-    typeBuilder.setX(xSize).setY(ySize);
-    Allocation inputAllocation = Allocation.createTyped(pRS, typeBuilder.create());
-    byte[] inputArray = new byte[xSize * ySize * 4];
-    r.nextBytes(inputArray);
-    inputAllocation.copyFrom(inputArray);
-
-    ScriptField_user_t.Item usrData = new ScriptField_user_t.Item();
-    usrData.ans = new Short4(
-        unsigned((byte)r.nextInt()),
-        unsigned((byte)r.nextInt()),
-        unsigned((byte)r.nextInt()),
-        unsigned((byte)r.nextInt()));
-    s.set_expect_ans(usrData.ans);
-    usrData.x = unsigned(r.nextInt());
-    s.set_expect_x(usrData.x);
-    usrData.y = unsigned(r.nextInt());
-    s.set_expect_y(usrData.y);
-
-    usrData.alloc = inputAllocation;
-
-    Allocation outputAllocation = Allocation.createTyped(pRS, typeBuilder.create());
-
-    s.set_expect_dAlloc_GetDimX(xSize);
-    s.set_expect_sAlloc_GetDimX(xSize);
-    final int dXOff = r.nextInt();
-    s.set_expect_dXOff(dXOff);
-    final int dMip = r.nextInt();
-    s.set_expect_dMip(dMip);
-    final int count = r.nextInt();
-    s.set_expect_count(count);
-    final int sXOff = r.nextInt();
-    s.set_expect_sXOff(sXOff);
-    final int sMip = r.nextInt();
-    s.set_expect_sMip(sMip);
-    s.invoke_args(outputAllocation, dXOff, dMip, count, inputAllocation, sXOff, sMip);
-
-    s.forEach_root(outputAllocation, usrData);
-    byte[] outputArray = new byte[xSize * ySize * 4];
-    outputAllocation.copyTo(outputArray);
-
-    for (int i = 0; i < xSize; ++i)
-      for (int j = 0; j < ySize; ++j) {
-        int idx = j * xSize + i;
-        assertEquals("[" + i + "][" + j + "]", inputArray[idx], outputArray[idx]);
-      }
-
-    s.invoke_check_asserts();
-    pRS.finish();
-    waitForMessage();
-    inputAllocation.destroy();
-    outputAllocation.destroy();
-    s.destroy();
-    pRS.destroy();
-  }
-}
diff --git a/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/apitest.rs b/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/apitest.rs
index 9dcd6b5..2576648 100644
--- a/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/apitest.rs
+++ b/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/apitest.rs
@@ -20,7 +20,7 @@
 
 volatile rs_sampler_value rsv;
 
-volatile static rs_time_t rst;
+volatile rs_time_t rst;
 volatile static rs_tm rstm;
 
 char *allocPtr;
diff --git a/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/reflection3264.rs b/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/reflection3264.rs
deleted file mode 100644
index 159b318..0000000
--- a/tests/java_api/RSTest_CompatLib/src/com/android/rs/test/reflection3264.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.
- */
-
-#include "shared.rsh"
-
-typedef struct user_t {
-  uchar4 ans;
-  uint x;
-  uint y;
-  rs_allocation alloc;
-} user;
-
-uchar4 expect_ans;
-uint expect_x;
-uint expect_y;
-
-uint32_t expect_dAlloc_GetDimX;
-int expect_dXOff;
-int expect_dMip;
-int expect_count;
-uint32_t expect_sAlloc_GetDimX;
-int expect_sXOff;
-int expect_sMip;
-
-static bool failed = false;
-
-// See http://b/21597073 "Broken structure layout for RenderScript on 32-bit/64-bit compiles"
-void root(uchar4 *output, const user * usr, uint x, uint y) {
-  if (!x && !y) {
-    // Only check one coordinate, so as to avoid contention on global variable "failed"
-    _RS_ASSERT(usr->ans.x == expect_ans.x);
-    _RS_ASSERT(usr->ans.y == expect_ans.y);
-    _RS_ASSERT(usr->ans.z == expect_ans.z);
-    _RS_ASSERT(usr->ans.w == expect_ans.w);
-    _RS_ASSERT(usr->x == expect_x);
-    _RS_ASSERT(usr->y == expect_y);
-  }
-
-  uchar4 * e_in = (uchar4*)rsGetElementAt(usr->alloc, x, y);
-  *output = *e_in;
-}
-
-// See http://b/32780232 "Corrupted rs_allocation instances when passed as arguments to invocables"
-void args(rs_allocation dAlloc, int dXOff, int dMip, int count,
-          rs_allocation sAlloc, int sXOff, int sMip) {
-  _RS_ASSERT(rsIsObject(dAlloc) &&
-             (rsAllocationGetDimX(dAlloc) == expect_dAlloc_GetDimX));
-  _RS_ASSERT(dXOff == expect_dXOff);
-  _RS_ASSERT(dMip == expect_dMip);
-  _RS_ASSERT(count == expect_count);
-  _RS_ASSERT(rsIsObject(sAlloc) &&
-             (rsAllocationGetDimX(sAlloc) == expect_sAlloc_GetDimX));
-  _RS_ASSERT(sXOff == expect_sXOff);
-  _RS_ASSERT(sMip == expect_sMip);
-}
-
-void check_asserts() {
-  if (failed) {
-    rsSendToClientBlocking(RS_MSG_TEST_FAILED);
-  }
-  else {
-    rsSendToClientBlocking(RS_MSG_TEST_PASSED);
-  }
-}
diff --git a/tests/java_api/RsTest/src/com/android/rs/test/RSTestCore.java b/tests/java_api/RsTest/src/com/android/rs/test/RSTestCore.java
index c6af078..133a48d 100644
--- a/tests/java_api/RsTest/src/com/android/rs/test/RSTestCore.java
+++ b/tests/java_api/RsTest/src/com/android/rs/test/RSTestCore.java
@@ -111,7 +111,6 @@
         unitTests.add(new UT_struct_field(this, mCtx));
         unitTests.add(new UT_struct_field_simple(this, mCtx));
         unitTests.add(new UT_bitfield(this, mCtx));
-        unitTests.add(new UT_reflection3264(this, mCtx));
 
         /*
         unitTests.add(new UnitTest(null, "<Pass>", 1));
diff --git a/tests/java_api/RsTest/src/com/android/rs/test/UT_reflection3264.java b/tests/java_api/RsTest/src/com/android/rs/test/UT_reflection3264.java
deleted file mode 100644
index 2ced238..0000000
--- a/tests/java_api/RsTest/src/com/android/rs/test/UT_reflection3264.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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 com.android.rs.test;
-
-import android.content.Context;
-import android.renderscript.Allocation;
-import android.renderscript.Element;
-import android.renderscript.RenderScript;
-import android.renderscript.Short4;
-import android.renderscript.Type;
-import android.util.Log;
-import java.util.Random;
-
-import static junit.framework.Assert.assertEquals;
-
-public class UT_reflection3264 extends UnitTest {
-  private static final String TAG = "reflection3264";
-
-  protected UT_reflection3264(RSTestCore rstc, Context ctx) {
-    super(rstc, "reflection3264", ctx);
-  }
-
-  private final int xSize = 17, ySize = 23;  // arbitrary values
-
-  private final long seed = 20170609;  // arbitrary value
-
-  private static long unsigned(int v) {
-    if (v >= 0)
-      return (long)v;
-    else
-      return (long)v + ((long)1 << 32);
-  }
-
-  private static short unsigned(byte v) {
-    if (v >= 0)
-      return (short)v;
-    else
-      return (short)((short)v + (short)(1 << 8));
-  }
-
-  public void run() {
-    Random r = new Random(seed);
-
-    RenderScript pRS = RenderScript.create(mCtx);
-    ScriptC_reflection3264 s = new ScriptC_reflection3264(pRS);
-    pRS.setMessageHandler(mRsMessage);
-
-    Type.Builder typeBuilder = new Type.Builder(pRS, Element.U8_4(pRS));
-    typeBuilder.setX(xSize).setY(ySize);
-    Allocation inputAllocation = Allocation.createTyped(pRS, typeBuilder.create());
-    byte[] inputArray = new byte[xSize * ySize * 4];
-    r.nextBytes(inputArray);
-    inputAllocation.copyFrom(inputArray);
-
-    ScriptField_user_t.Item usrData = new ScriptField_user_t.Item();
-    usrData.ans = new Short4(
-        unsigned((byte)r.nextInt()),
-        unsigned((byte)r.nextInt()),
-        unsigned((byte)r.nextInt()),
-        unsigned((byte)r.nextInt()));
-    s.set_expect_ans(usrData.ans);
-    usrData.x = unsigned(r.nextInt());
-    s.set_expect_x(usrData.x);
-    usrData.y = unsigned(r.nextInt());
-    s.set_expect_y(usrData.y);
-
-    usrData.alloc = inputAllocation;
-
-    Allocation outputAllocation = Allocation.createTyped(pRS, typeBuilder.create());
-
-    s.set_expect_dAlloc_GetDimX(xSize);
-    s.set_expect_sAlloc_GetDimX(xSize);
-    final int dXOff = r.nextInt();
-    s.set_expect_dXOff(dXOff);
-    final int dMip = r.nextInt();
-    s.set_expect_dMip(dMip);
-    final int count = r.nextInt();
-    s.set_expect_count(count);
-    final int sXOff = r.nextInt();
-    s.set_expect_sXOff(sXOff);
-    final int sMip = r.nextInt();
-    s.set_expect_sMip(sMip);
-    s.invoke_args(outputAllocation, dXOff, dMip, count, inputAllocation, sXOff, sMip);
-
-    s.forEach_root(outputAllocation, usrData);
-    byte[] outputArray = new byte[xSize * ySize * 4];
-    outputAllocation.copyTo(outputArray);
-
-    for (int i = 0; i < xSize; ++i)
-      for (int j = 0; j < ySize; ++j) {
-        int idx = j * xSize + i;
-        assertEquals("[" + i + "][" + j + "]", inputArray[idx], outputArray[idx]);
-      }
-
-    s.invoke_check_asserts();
-    pRS.finish();
-    waitForMessage();
-    inputAllocation.destroy();
-    outputAllocation.destroy();
-    s.destroy();
-    pRS.destroy();
-  }
-}
diff --git a/tests/java_api/RsTest/src/com/android/rs/test/reflection3264.rs b/tests/java_api/RsTest/src/com/android/rs/test/reflection3264.rs
deleted file mode 100644
index 159b318..0000000
--- a/tests/java_api/RsTest/src/com/android/rs/test/reflection3264.rs
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * 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.
- */
-
-#include "shared.rsh"
-
-typedef struct user_t {
-  uchar4 ans;
-  uint x;
-  uint y;
-  rs_allocation alloc;
-} user;
-
-uchar4 expect_ans;
-uint expect_x;
-uint expect_y;
-
-uint32_t expect_dAlloc_GetDimX;
-int expect_dXOff;
-int expect_dMip;
-int expect_count;
-uint32_t expect_sAlloc_GetDimX;
-int expect_sXOff;
-int expect_sMip;
-
-static bool failed = false;
-
-// See http://b/21597073 "Broken structure layout for RenderScript on 32-bit/64-bit compiles"
-void root(uchar4 *output, const user * usr, uint x, uint y) {
-  if (!x && !y) {
-    // Only check one coordinate, so as to avoid contention on global variable "failed"
-    _RS_ASSERT(usr->ans.x == expect_ans.x);
-    _RS_ASSERT(usr->ans.y == expect_ans.y);
-    _RS_ASSERT(usr->ans.z == expect_ans.z);
-    _RS_ASSERT(usr->ans.w == expect_ans.w);
-    _RS_ASSERT(usr->x == expect_x);
-    _RS_ASSERT(usr->y == expect_y);
-  }
-
-  uchar4 * e_in = (uchar4*)rsGetElementAt(usr->alloc, x, y);
-  *output = *e_in;
-}
-
-// See http://b/32780232 "Corrupted rs_allocation instances when passed as arguments to invocables"
-void args(rs_allocation dAlloc, int dXOff, int dMip, int count,
-          rs_allocation sAlloc, int sXOff, int sMip) {
-  _RS_ASSERT(rsIsObject(dAlloc) &&
-             (rsAllocationGetDimX(dAlloc) == expect_dAlloc_GetDimX));
-  _RS_ASSERT(dXOff == expect_dXOff);
-  _RS_ASSERT(dMip == expect_dMip);
-  _RS_ASSERT(count == expect_count);
-  _RS_ASSERT(rsIsObject(sAlloc) &&
-             (rsAllocationGetDimX(sAlloc) == expect_sAlloc_GetDimX));
-  _RS_ASSERT(sXOff == expect_sXOff);
-  _RS_ASSERT(sMip == expect_sMip);
-}
-
-void check_asserts() {
-  if (failed) {
-    rsSendToClientBlocking(RS_MSG_TEST_FAILED);
-  }
-  else {
-    rsSendToClientBlocking(RS_MSG_TEST_PASSED);
-  }
-}