Fix getConfig on recycled bitmap

Test: android.graphics.cts.BitmapTest#testGetConfigOnRecycled
bug:33789983
Change-Id: Ic91c16cbd83acdd6002021b44da57636ee27742d
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index 8f74bf8..3c0b25c 100755
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -52,6 +52,7 @@
         mAllocationSize = mBitmap->getAllocationByteCount();
         mRowBytes = mBitmap->rowBytes();
         mGenerationId = mBitmap->getGenerationID();
+        mIsHardware = mBitmap->isHardware();
         mBitmap.reset();
     }
 
@@ -118,6 +119,13 @@
         return mGenerationId;
     }
 
+    bool isHardware() {
+        if (mBitmap) {
+            return mBitmap->isHardware();
+        }
+        return mIsHardware;
+    }
+
     ~BitmapWrapper() { }
 
 private:
@@ -127,6 +135,7 @@
     size_t mAllocationSize;
     size_t mRowBytes;
     uint32_t mGenerationId;
+    bool mIsHardware;
 };
 
 // Convenience class that does not take a global ref on the pixels, relying
@@ -775,7 +784,7 @@
 
 static jint Bitmap_config(JNIEnv* env, jobject, jlong bitmapHandle) {
     LocalScopedBitmap bitmap(bitmapHandle);
-    if (bitmap->bitmap().isHardware()) {
+    if (bitmap->isHardware()) {
         return GraphicsJNI::hardwareLegacyBitmapConfig();
     }
     return GraphicsJNI::colorTypeToLegacyBitmapConfig(bitmap->info().colorType());
@@ -1208,7 +1217,7 @@
     // Paying the price for making Hardware Bitmap as Config:
     // later check for colorType will pass successfully,
     // because Hardware Config internally may be RGBA8888 or smth like that.
-    if (bitmap0->bitmap().isHardware() != bitmap1->bitmap().isHardware()) {
+    if (bitmap0->isHardware() != bitmap1->isHardware()) {
         return JNI_FALSE;
     }