Expose several useful Bitmap APIs.
Bug #3408073

Bitmap.setHasAlpha() in particular is very useful for applications that use
ARGB_8888 bitmaps but want/need to benefit from an extra speed boost.

Change-Id: I73d081b7e43bd725baffd1a9892c72d8729816f7
diff --git a/api/current.xml b/api/current.xml
index bd86302..ea86e3b 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -76419,6 +76419,17 @@
  visibility="public"
 >
 </method>
+<method name="getGenerationId"
+ return="int"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
 <method name="getHeight"
  return="int"
  abstract="false"
@@ -76636,6 +76647,19 @@
  visibility="public"
 >
 </method>
+<method name="sameAs"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="other" type="android.graphics.Bitmap">
+</parameter>
+</method>
 <method name="setDensity"
  return="void"
  abstract="false"
@@ -76649,6 +76673,19 @@
 <parameter name="density" type="int">
 </parameter>
 </method>
+<method name="setHasAlpha"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="false"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="hasAlpha" type="boolean">
+</parameter>
+</method>
 <method name="setPixel"
  return="void"
  abstract="false"
diff --git a/graphics/java/android/graphics/Bitmap.java b/graphics/java/android/graphics/Bitmap.java
index c7ae2cf..bd903da 100644
--- a/graphics/java/android/graphics/Bitmap.java
+++ b/graphics/java/android/graphics/Bitmap.java
@@ -200,8 +200,6 @@
      * check if a bitmap has changed.
      * 
      * @return The current generation ID for this bitmap.
-     * 
-     * @hide
      */
     public int getGenerationId() {
         return nativeGenerationId(mNativeBitmap);
@@ -752,7 +750,7 @@
         }
         
         // Scale by tdensity / sdensity, rounding up.
-        return ( (size * tdensity) + (sdensity >> 1) ) / sdensity;
+        return ((size * tdensity) + (sdensity >> 1)) / sdensity;
     }
     
     /**
@@ -790,14 +788,12 @@
     /**
      * Tell the bitmap if all of the pixels are known to be opaque (false)
      * or if some of the pixels may contain non-opaque alpha values (true).
-     * Note, for some configs (e.g. RGB_565) this call is ignore, since it does
-     * not support per-pixel alpha values.
+     * Note, for some configs (e.g. RGB_565) this call is ignored, since it
+     * does not support per-pixel alpha values.
      *
      * This is meant as a drawing hint, as in some cases a bitmap that is known
      * to be opaque can take a faster drawing case than one that may have
      * non-opaque per-pixel alpha values.
-     *
-     * @hide
      */
     public void setHasAlpha(boolean hasAlpha) {
         nativeSetHasAlpha(mNativeBitmap, hasAlpha);
@@ -1066,13 +1062,9 @@
      *  Given another bitmap, return true if it has the same dimensions, config,
      *  and pixel data as this bitmap. If any of those differ, return false.
      *  If other is null, return false.
-     *
-     * @hide (just needed internally right now)
      */
     public boolean sameAs(Bitmap other) {
-        return this == other ||
-              (other != null &&
-               nativeSameAs(mNativeBitmap, other.mNativeBitmap));
+        return this == other || (other != null && nativeSameAs(mNativeBitmap, other.mNativeBitmap));
     }
 
     /**
@@ -1099,7 +1091,13 @@
 
         @Override
         public void finalize() {
-            nativeDestructor(mNativeBitmap);
+            try {
+                super.finalize();
+            } catch (Throwable t) {
+                // Ignore
+            } finally {
+                nativeDestructor(mNativeBitmap);
+            }
         }
     }