Merge "[ATF integration] #2 Add validation to render path" into rvc-dev am: 51b1770542 am: d3850f6663 am: 90e2fb968c am: d6efd3f8eb

Change-Id: I884b00dda559d4b6d2007455db58c703f75273fc
diff --git a/bridge/src/android/graphics/BitmapFactory_Delegate.java b/bridge/src/android/graphics/BitmapFactory_Delegate.java
index b344451..7a12d38 100644
--- a/bridge/src/android/graphics/BitmapFactory_Delegate.java
+++ b/bridge/src/android/graphics/BitmapFactory_Delegate.java
@@ -73,12 +73,9 @@
                         npis, true /*is9Patch*/, false /*convert*/);
 
                 // get the bitmap and chunk objects.
-                bm = Bitmap_Delegate.createBitmap(ninePatch.getImage(), bitmapCreateFlags,
-                        density);
                 NinePatchChunk chunk = ninePatch.getChunk();
-
-                // put the chunk in the bitmap
-                bm.setNinePatchChunk(NinePatch_Delegate.serialize(chunk));
+                bm = Bitmap_Delegate.createBitmap(ninePatch.getImage(),
+                        NinePatch_Delegate.serialize(chunk), bitmapCreateFlags, density);
 
                 if (padding != null) {
                     // read the padding
diff --git a/bridge/src/android/graphics/Bitmap_Delegate.java b/bridge/src/android/graphics/Bitmap_Delegate.java
index 7fc952d..4ea8f37 100644
--- a/bridge/src/android/graphics/Bitmap_Delegate.java
+++ b/bridge/src/android/graphics/Bitmap_Delegate.java
@@ -143,7 +143,7 @@
         Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.ARGB_8888);
         delegate.mIsMutable = createFlags.contains(BitmapCreateFlags.MUTABLE);
 
-        return createBitmap(delegate, createFlags, density.getDpiValue());
+        return createBitmap(delegate, createFlags, density.getDpiValue(), null);
     }
 
     /**
@@ -172,11 +172,27 @@
      */
     public static Bitmap createBitmap(BufferedImage image, Set<BitmapCreateFlags> createFlags,
             Density density) {
+        return createBitmap(image, null, createFlags, density);
+    }
+
+    /**
+     * Creates and returns a {@link Bitmap} initialized with the given {@link BufferedImage}
+     *
+     * @param image the bitmap content
+     * @param ninePatchChunk serialized ninepatch data
+     * @param density the density associated with the bitmap
+     *
+     * @see Bitmap#isPremultiplied()
+     * @see Bitmap#isMutable()
+     * @see Bitmap#getDensity()
+     */
+    public static Bitmap createBitmap(BufferedImage image, byte[] ninePatchChunk,
+            Set<BitmapCreateFlags> createFlags, Density density) {
         // create a delegate with the given image.
         Bitmap_Delegate delegate = new Bitmap_Delegate(image, Config.ARGB_8888);
         delegate.mIsMutable = createFlags.contains(BitmapCreateFlags.MUTABLE);
 
-        return createBitmap(delegate, createFlags, density.getDpiValue());
+        return createBitmap(delegate, createFlags, density.getDpiValue(), ninePatchChunk);
     }
 
     private static int getBufferedImageType() {
@@ -234,7 +250,7 @@
         delegate.mIsMutable = isMutable;
 
         return createBitmap(delegate, getPremultipliedBitmapCreateFlags(isMutable),
-                            Bitmap.getDefaultDensity());
+                            Bitmap.getDefaultDensity(), null);
     }
 
     @LayoutlibDelegate
@@ -264,7 +280,7 @@
         delegate.mIsMutable = isMutable;
 
         return createBitmap(delegate, getPremultipliedBitmapCreateFlags(isMutable),
-                Bitmap.getDefaultDensity());
+                Bitmap.getDefaultDensity(), null);
     }
 
     @LayoutlibDelegate
@@ -493,7 +509,7 @@
 
         // the density doesn't matter, it's set by the Java method.
         return createBitmap(delegate, EnumSet.of(BitmapCreateFlags.MUTABLE),
-                Density.DEFAULT_DENSITY /*density*/);
+                Density.DEFAULT_DENSITY /*density*/, null);
     }
 
     @LayoutlibDelegate
@@ -617,7 +633,7 @@
         delegate.mIsMutable = srcBmpDelegate.mIsMutable;
 
         return createBitmap(delegate, EnumSet.of(BitmapCreateFlags.NONE),
-                Bitmap.getDefaultDensity());
+                Bitmap.getDefaultDensity(), null);
     }
 
     @LayoutlibDelegate
@@ -629,13 +645,6 @@
     }
 
     @LayoutlibDelegate
-    /*package*/ static GraphicBuffer nativeCreateGraphicBufferHandle(long nativeBitmap) {
-        Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
-                "Bitmap.nativeCreateGraphicBufferHandle() is not supported", null /*data*/);
-        return null;
-    }
-
-    @LayoutlibDelegate
     /*package*/ static boolean nativeIsSRGB(long nativeBitmap) {
         Bridge.getLog().error(LayoutLog.TAG_UNSUPPORTED,
                 "Color spaces are not supported", null, null /*data*/);
@@ -695,7 +704,7 @@
     }
 
     private static Bitmap createBitmap(Bitmap_Delegate delegate,
-            Set<BitmapCreateFlags> createFlags, int density) {
+            Set<BitmapCreateFlags> createFlags, int density, byte[] ninePatchChunk) {
         // get its native_int
         long nativeInt = sManager.addNewDelegate(delegate);
 
@@ -705,7 +714,7 @@
 
         // and create/return a new Bitmap with it
         return new Bitmap(nativeInt, width, height, density, isPremultiplied,
-                null /*ninePatchChunk*/, null /* layoutBounds */, true /* fromMalloc */);
+                ninePatchChunk, null /* layoutBounds */, true /* fromMalloc */);
     }
 
     private static Set<BitmapCreateFlags> getPremultipliedBitmapCreateFlags(boolean isMutable) {
diff --git a/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java b/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
index 584e8c2..0e78ef9 100644
--- a/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
+++ b/bridge/src/com/android/layoutlib/bridge/android/BridgePowerManager.java
@@ -84,13 +84,14 @@
     }
 
     @Override
-    public void acquireWakeLockWithUid(IBinder arg0, int arg1, String arg2, String arg2_5, int arg3)
-            throws RemoteException {
+    public void acquireWakeLockAsync(IBinder arg0, int arg1, String arg2, String arg2_5,
+            WorkSource arg3, String arg4) throws RemoteException {
         // pass for now.
     }
 
     @Override
-    public void powerHint(int hintId, int data) {
+    public void acquireWakeLockWithUid(IBinder arg0, int arg1, String arg2, String arg2_5, int arg3)
+            throws RemoteException {
         // pass for now.
     }
 
@@ -150,11 +151,21 @@
     }
 
     @Override
+    public void releaseWakeLockAsync(IBinder arg0, int arg1) throws RemoteException {
+        // pass for now.
+    }
+
+    @Override
     public void updateWakeLockUids(IBinder arg0, int[] arg1) throws RemoteException {
         // pass for now.
     }
 
     @Override
+    public void updateWakeLockUidsAsync(IBinder arg0, int[] arg1) throws RemoteException {
+        // pass for now.
+    }
+
+    @Override
     public void setAttentionLight(boolean arg0, int arg1) throws RemoteException {
         // pass for now.
     }