Add onSurfaceTextureUpdated to the TextureView listener.

The app needs a way to throttle the producer side. Expose this to enable it.

Change-Id: I04b6a3fc444117a9fc2449fb87c3c834247c8ef1
diff --git a/api/current.txt b/api/current.txt
index 2f374bb..f170d78 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -21643,6 +21643,7 @@
     method public abstract void onSurfaceTextureAvailable(android.graphics.SurfaceTexture, int, int);
     method public abstract void onSurfaceTextureDestroyed(android.graphics.SurfaceTexture);
     method public abstract void onSurfaceTextureSizeChanged(android.graphics.SurfaceTexture, int, int);
+    method public abstract void onSurfaceTextureUpdated(android.graphics.SurfaceTexture);
   }
 
   public class TouchDelegate {
diff --git a/core/java/android/view/TextureView.java b/core/java/android/view/TextureView.java
index 4790289..de398eb 100644
--- a/core/java/android/view/TextureView.java
+++ b/core/java/android/view/TextureView.java
@@ -67,15 +67,19 @@
  *              // Something bad happened
  *          }
  *      }
- *      
+ *
  *      public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
  *          // Ignored, Camera does all the work for us
  *      }
- *      
+ *
  *      public void onSurfaceTextureDestroyed(SurfaceTexture surface) {
  *          mCamera.stopPreview();
  *          mCamera.release();
  *      }
+ *
+ *      public void onSurfaceTextureUpdated(SurfaceTexture surface) {
+ *          // Ignored
+ *      }
  *  }
  * </pre>
  * 
@@ -315,6 +319,10 @@
 
         mAttachInfo.mHardwareRenderer.updateTextureLayer(mLayer, getWidth(), getHeight(), mOpaque);
 
+        if (mListener != null) {
+            mListener.onSurfaceTextureUpdated(mSurface);
+        }
+
         invalidate();
     }
 
@@ -474,6 +482,14 @@
          * @param surface The surface about to be destroyed
          */
         public void onSurfaceTextureDestroyed(SurfaceTexture surface);
+
+        /**
+         * Invoked when the specified {@link SurfaceTexture} is updated through
+         * {@link SurfaceTexture#updateTexImage()}.
+         * 
+         * @param surface The surface just updated
+         */
+        public void onSurfaceTextureUpdated(SurfaceTexture surface);
     }
 
     private static native void nSetDefaultBufferSize(SurfaceTexture surfaceTexture,
diff --git a/graphics/java/android/renderscript/RSTextureView.java b/graphics/java/android/renderscript/RSTextureView.java
index f63ae8d..6046ee1 100644
--- a/graphics/java/android/renderscript/RSTextureView.java
+++ b/graphics/java/android/renderscript/RSTextureView.java
@@ -94,6 +94,12 @@
         }
     }
 
+    @Override
+    public void onSurfaceTextureUpdated(SurfaceTexture surface) {
+        //Log.e(RenderScript.LOG_TAG, "onSurfaceTextureUpdated");
+        mSurfaceTexture = surface;
+    }
+
    /**
      * Inform the view that the activity is paused. The owner of this view must
      * call this method when the activity is paused. Calling this method will
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
index 9bb5ba8..723f3e8 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GLTextureViewActivity.java
@@ -85,6 +85,10 @@
         }
     }
 
+    @Override
+    public void onSurfaceTextureUpdated(SurfaceTexture surface) {
+    }
+
     private static class RenderThread extends Thread {
         private static final String LOG_TAG = "GLTextureView";
 
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java
index 2e23aaa..f420fa0 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/GetBitmapActivity.java
@@ -100,4 +100,9 @@
         mCamera.stopPreview();
         mCamera.release();
     }
+
+    @Override
+    public void onSurfaceTextureUpdated(SurfaceTexture surface) {
+        // Ignored
+    }
 }
diff --git a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
index 9bc1fe0..01ee90a 100644
--- a/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
+++ b/tests/HwAccelerationTest/src/com/android/test/hwui/TextureViewActivity.java
@@ -109,4 +109,9 @@
         mCamera.stopPreview();
         mCamera.release();
     }
+
+    @Override
+    public void onSurfaceTextureUpdated(SurfaceTexture surface) {
+        // Ignored
+    }
 }