Consolidate NDK and APEX implementations

the NDK APIs are implemented in terms of the APEX APIs to
reduce the number of different implementations serving the
same fundamental purpose.

Bug: 137655431
Test: CtsGraphicsTestCases
Change-Id: Idc7b85403a7e546843b9c1d822acc0a1e740059a
diff --git a/native/graphics/jni/bitmap.cpp b/native/graphics/jni/bitmap.cpp
index ff14832..1aebeaf 100644
--- a/native/graphics/jni/bitmap.cpp
+++ b/native/graphics/jni/bitmap.cpp
@@ -15,7 +15,7 @@
  */
 
 #include <android/bitmap.h>
-#include <android/graphics/Bitmap.h>
+#include <android/graphics/bitmap.h>
 
 int AndroidBitmap_getInfo(JNIEnv* env, jobject jbitmap,
                           AndroidBitmapInfo* info) {
@@ -24,7 +24,7 @@
     }
 
     if (info) {
-        android::bitmap::imageInfo(env, jbitmap, info);
+        *info = ABitmap_getInfoFromJava(env, jbitmap);
     }
     return ANDROID_BITMAP_RESULT_SUCCESS;
 }
@@ -34,11 +34,15 @@
         return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
     }
 
-    void* addr = android::bitmap::lockPixels(env, jbitmap);
+    android::graphics::Bitmap bitmap(env, jbitmap);
+    void* addr = bitmap.isValid() ? bitmap.getPixels() : nullptr;
+
     if (!addr) {
         return ANDROID_BITMAP_RESULT_JNI_EXCEPTION;
     }
 
+    ABitmap_acquireRef(bitmap.get());
+
     if (addrPtr) {
         *addrPtr = addr;
     }
@@ -50,9 +54,13 @@
         return ANDROID_BITMAP_RESULT_BAD_PARAMETER;
     }
 
-    bool unlocked = android::bitmap::unlockPixels(env, jbitmap);
-    if (!unlocked) {
+    android::graphics::Bitmap bitmap(env, jbitmap);
+
+    if (!bitmap.isValid()) {
         return ANDROID_BITMAP_RESULT_JNI_EXCEPTION;
     }
+
+    bitmap.notifyPixelsChanged();
+    ABitmap_releaseRef(bitmap.get());
     return ANDROID_BITMAP_RESULT_SUCCESS;
 }