Merge "Moving include to static." into klp-dev
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 5c24131..ff79003 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -18,7 +18,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.android.cts.verifier"
       android:versionCode="1"
-      android:versionName="4.4_r0">
+      android:versionName="4.4_r1">
 
     <!-- Using 10+ for more complete NFC support... -->
     <uses-sdk android:minSdkVersion="12"></uses-sdk>
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 2aac38f..abe53f4 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -8,6 +8,15 @@
   bug: 8148617
 },
 {
+  name: "android.tests.sigtest.SimpleSignatureTest.testSignature",
+  bug: 11436500
+},
+{
+  name: "android.nativeopengl.EGLCleanupTest#TestCorrect",
+  name: "android.nativeopengl.EGLCreateContextTest#BadAttributeFails",
+  bug: 11652564
+},
+{
   name: "android.hardware.camera2.cts.ImageReaderTest",
   name: "android.hardware.camera2.cts.CameraCharacteristicsTest",
   name: "android.hardware.camera2.cts.CameraCaptureResultTest",
diff --git a/tests/tests/app/src/android/app/cts/WallpaperManagerTest.java b/tests/tests/app/src/android/app/cts/WallpaperManagerTest.java
index e27c83f..fdf3cac 100644
--- a/tests/tests/app/src/android/app/cts/WallpaperManagerTest.java
+++ b/tests/tests/app/src/android/app/cts/WallpaperManagerTest.java
@@ -18,6 +18,7 @@
 
 import android.app.WallpaperManager;
 import android.content.Context;
+import android.graphics.Point;
 import android.test.AndroidTestCase;
 import android.view.Display;
 import android.view.WindowManager;
@@ -33,30 +34,32 @@
     }
 
     public void testSuggestDesiredDimensions() {
-        int max = getMaximumSizeDimension();
-        int w = max * 3;
-        int h = max * 2;
+        Point min = getScreenSize();
+        int w = min.x * 3;
+        int h = min.y * 2;
 
-        mWallpaperManager.suggestDesiredDimensions(max / 2, max / 2);
-        assertEquals(max, mWallpaperManager.getDesiredMinimumWidth());
-        assertEquals(max, mWallpaperManager.getDesiredMinimumHeight());
+        mWallpaperManager.suggestDesiredDimensions(min.x / 2, min.y / 2);
+        assertEquals(min.x, mWallpaperManager.getDesiredMinimumWidth());
+        assertEquals(min.y, mWallpaperManager.getDesiredMinimumHeight());
 
         mWallpaperManager.suggestDesiredDimensions(w, h);
         assertEquals(w, mWallpaperManager.getDesiredMinimumWidth());
         assertEquals(h, mWallpaperManager.getDesiredMinimumHeight());
 
-        mWallpaperManager.suggestDesiredDimensions(max / 2, h);
-        assertEquals(max, mWallpaperManager.getDesiredMinimumWidth());
+        mWallpaperManager.suggestDesiredDimensions(min.x / 2, h);
+        assertEquals(min.x, mWallpaperManager.getDesiredMinimumWidth());
         assertEquals(h, mWallpaperManager.getDesiredMinimumHeight());
 
-        mWallpaperManager.suggestDesiredDimensions(w, max / 2);
+        mWallpaperManager.suggestDesiredDimensions(w, min.y / 2);
         assertEquals(w, mWallpaperManager.getDesiredMinimumWidth());
-        assertEquals(max, mWallpaperManager.getDesiredMinimumHeight());
+        assertEquals(min.y, mWallpaperManager.getDesiredMinimumHeight());
     }
 
-    private int getMaximumSizeDimension() {
+    private Point getScreenSize() {
         WindowManager wm = (WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE);
         Display d = wm.getDefaultDisplay();
-        return d.getMaximumSizeDimension();
+        Point p = new Point();
+        d.getRealSize(p);
+        return p;
     }
 }
diff --git a/tests/tests/nativeopengl/standalone/jni/tests/EGLCleanup_test.cpp b/tests/tests/nativeopengl/standalone/jni/tests/EGLCleanup_test.cpp
index 1227d42..db39798 100644
--- a/tests/tests/nativeopengl/standalone/jni/tests/EGLCleanup_test.cpp
+++ b/tests/tests/nativeopengl/standalone/jni/tests/EGLCleanup_test.cpp
@@ -328,9 +328,8 @@
     ASSERT_TRUE(result);
 }
 
-#if 0
-/* try it without un-currenting the surfaces and context */
-TEST_F(EGLCleanupTest, TestNoReleaseCurrent) {
+/* try it without un-currenting the surfaces and context
+TEST _F(EGLCleanupTest, TestNoReleaseCurrent) {
     ALOGI("Starting TEST_NO_RELEASE_CURRENT");
     ChainedThread cht(ChainedThread::TEST_NO_RELEASE_CURRENT);
 
@@ -342,6 +341,6 @@
     bool result = cht.getResult();
     ASSERT_TRUE(result);
 }
-#endif
+*/
 
 } // namespace android
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicHistogram.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicHistogram.java
new file mode 100644
index 0000000..e970291
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicHistogram.java
@@ -0,0 +1,176 @@
+/*
+ * 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.renderscript.cts;
+
+import android.renderscript.*;
+import android.util.Log;
+
+public class IntrinsicHistogram extends IntrinsicBase {
+    private Allocation mAin;
+    private Allocation mAout;
+
+    private void createAllocations(int inVSize, int outVSize, int w, int h) {
+        Element e1;
+        Element e2;
+
+        switch (inVSize) {
+        case 4: e1 = Element.U8_4(mRS); break;
+        case 3: e1 = Element.U8_3(mRS); break;
+        case 2: e1 = Element.U8_2(mRS); break;
+        default: e1 = Element.U8(mRS); break;
+        }
+
+        switch (outVSize) {
+        case 4: e2 = Element.I32_4(mRS); break;
+        case 3: e2 = Element.I32_3(mRS); break;
+        case 2: e2 = Element.I32_2(mRS); break;
+        default: e2 = Element.I32(mRS); break;
+        }
+
+        Type.Builder tb = new Type.Builder(mRS, e1);
+        tb.setX(w).setY(h);
+
+        mAin = Allocation.createTyped(mRS, tb.create());
+        mAout = Allocation.createSized(mRS, e2, 256);
+    }
+
+    private void testNorm(int inVSize, int outVSize, int w, int h) {
+        createAllocations(inVSize, outVSize, w, h);
+
+        int invs2 = (inVSize != 3) ? inVSize : 4;
+        int outvs2 = (outVSize != 3) ? outVSize : 4;
+
+        byte i[] = new byte[w * h * invs2];
+        int res[] = new int[256 * outvs2];
+        int ref[] = new int[256 * outvs2];
+
+        java.util.Random r = new java.util.Random();
+        r.nextBytes(i);
+
+        for (int ct=0; ct < i.length; ct++) {
+            int t = i[ct];
+            if (t < 0) t = 256 + t;
+            if ((ct % invs2) < outVSize) {
+                ref[(t * outvs2) + (ct % invs2)] ++;
+            }
+        }
+
+        mAin.copyFrom(i);
+        ScriptIntrinsicHistogram hist =
+                ScriptIntrinsicHistogram.create(mRS, mAin.getType().getElement());
+        hist.setOutput(mAout);
+        hist.forEach(mAin);
+
+        mAin.copyFrom(i);
+        mAout.copyTo(res);
+        for (int ct=0; ct < res.length; ct++) {
+            assertTrue(res[ct] == ref[ct]);
+        }
+    }
+
+    public void test_norm_4_4() {
+        testNorm(4, 4, 101, 101);
+    }
+    public void test_norm_4_3() {
+        testNorm(4, 3, 101, 101);
+    }
+    public void test_norm_4_2() {
+        testNorm(4, 2, 101, 101);
+    }
+    public void test_norm_4_1() {
+        testNorm(4, 1, 101, 101);
+    }
+
+    public void test_norm_3_3() {
+        testNorm(3, 3, 101, 101);
+    }
+    public void test_norm_3_2() {
+        testNorm(3, 2, 101, 101);
+    }
+    public void test_norm_3_1() {
+        testNorm(3, 1, 101, 101);
+    }
+
+    public void test_norm_2_2() {
+        testNorm(2, 2, 101, 101);
+    }
+    public void test_norm_2_1() {
+        testNorm(2, 1, 101, 101);
+    }
+
+    public void test_norm_1_1() {
+        testNorm(1, 1, 101, 101);
+    }
+
+
+
+    private void testDot(int inVSize, int w, int h) {
+        createAllocations(inVSize, 1, w, h);
+
+        int invs2 = (inVSize != 3) ? inVSize : 4;
+
+        byte i[] = new byte[w * h * invs2];
+        int res[] = new int[256];
+        int ref[] = new int[256];
+
+        java.util.Random r = new java.util.Random();
+        r.nextBytes(i);
+
+        float dotVals[] = {0.2501f, 0.1251f, 0.06251f, 0.1251f};
+        int doti[] = new int[4];
+        for (int ct=0; ct < 4; ct++) {
+            doti[ct] = (int)((dotVals[ct] * 256.f) + 0.5f);
+        }
+
+        for (int ct=0; ct < i.length; ct+=invs2) {
+            int v = 0;
+            for (int c = 0; c < inVSize; c++) {
+                int t = i[ct + c];
+                if (t < 0) t = 256 + t;
+                v += doti[c] * t;
+            }
+            ref[(v + 0x7f) >> 8] ++;
+        }
+
+        mAin.copyFrom(i);
+        ScriptIntrinsicHistogram hist =
+                ScriptIntrinsicHistogram.create(mRS, mAin.getType().getElement());
+        hist.setOutput(mAout);
+        hist.setDotCoefficients(dotVals[0], dotVals[1], dotVals[2], dotVals[3]);
+        hist.forEach_Dot(mAin);
+
+        mAin.copyFrom(i);
+        mAout.copyTo(res);
+        for (int ct=0; ct < res.length; ct++) {
+            assertTrue(res[ct] == ref[ct]);
+        }
+    }
+
+    public void test_dot_1() {
+        testDot(1, 101, 101);
+    }
+    public void test_dot_2() {
+        testDot(2, 101, 101);
+    }
+    public void test_dot_3() {
+        testDot(3, 101, 101);
+    }
+    public void test_dot_4() {
+        testDot(4, 101, 101);
+    }
+
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/LeakTest.java b/tests/tests/renderscript/src/android/renderscript/cts/LeakTest.java
index ce9153b..b8c133a 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/LeakTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/LeakTest.java
@@ -16,10 +16,12 @@
 
 package android.renderscript.cts;
 
+import android.app.ActivityManager;
 import android.renderscript.Allocation;
 import android.renderscript.Element;
 import android.renderscript.Type;
 import android.util.Log;
+import android.content.Context;
 
 /*
 // -target-api 11
@@ -44,10 +46,16 @@
  * bug, since it may have been compiled without .rs.dtor() support.
  */
 public class LeakTest extends RSBaseCompute {
-    private final static int x = 16 * 1024 * 1024;
     private static final String TAG = "LeakTest";
 
     public void testForLeaks() {
+        ActivityManager am = (ActivityManager) getContext().getSystemService("activity");
+        int mc = am.getLargeMemoryClass() / 32;
+        if (mc < 1) {
+            mc = 1;
+        }
+        int x = mc * 1024 * 1024;
+
         for (int i = 0; i < 100; i++) {
             Log.w(TAG, "Leak test iteration " + i);
             ScriptC_leak leak = new ScriptC_leak(mRS);
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
index 59b9d3c..59d966e 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
@@ -31,7 +31,7 @@
     @Option(name="cts-install-path", description="the path to the cts installation to use")
     private String mCtsRootDirPath = System.getProperty("CTS_ROOT");
 
-    public static final String CTS_BUILD_VERSION = "4.4_r0";
+    public static final String CTS_BUILD_VERSION = "4.4_r1";
 
     /**
      * {@inheritDoc}