Support loading image and paused image for inline video

bug:4142131

Change-Id: I28d82a8e30a2146a3380c63dcdcbd51228f23f56
diff --git a/core/java/android/webkit/HTML5VideoViewProxy.java b/core/java/android/webkit/HTML5VideoViewProxy.java
index d3fcfa5..d12b965 100644
--- a/core/java/android/webkit/HTML5VideoViewProxy.java
+++ b/core/java/android/webkit/HTML5VideoViewProxy.java
@@ -105,12 +105,12 @@
 
                 int currentVideoLayerId = mHTML5VideoView.getVideoLayerId();
                 if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) {
-                    boolean readyToUseSurfTex =
-                        mHTML5VideoView.getReadyToUseSurfTex();
+                    int playerState = mHTML5VideoView.getCurrentState();
                     boolean foundInTree = nativeSendSurfaceTexture(surfTexture,
                             layer, currentVideoLayerId, textureName,
-                            readyToUseSurfTex);
-                    if (readyToUseSurfTex && !foundInTree) {
+                            playerState);
+                    if (playerState == HTML5VideoView.STATE_PREPARED
+                            && !foundInTree) {
                         mHTML5VideoView.pauseAndDispatch(mCurrentProxy);
                         mHTML5VideoView.deleteSurfaceTexture();
                     }
@@ -228,6 +228,9 @@
                     mHTML5VideoView.isFullScreenMode() &&
                     mHTML5VideoView.getAutostart() )
                 mHTML5VideoView.start();
+            if (mBaseLayer != 0) {
+                setBaseLayer(mBaseLayer);
+            }
         }
 
         public static void end() {
@@ -668,5 +671,5 @@
     private native void nativeOnTimeupdate(int position, int nativePointer);
     private native static boolean nativeSendSurfaceTexture(SurfaceTexture texture,
             int baseLayer, int videoLayerId, int textureName,
-            boolean updateTexture);
+            int playerState);
 }