Convert IScreenCaptureListener to AIDL

Test: Screen capture works
Fixes: 166271443
Change-Id: I62aeb0376fa56c32669b99b515c70c180c2ce2b8
This commit is contained in:
chaviw
2021-01-05 12:23:06 -08:00
parent 31d0862eca
commit 329fb64150

View File

@@ -26,11 +26,11 @@
#include <android-base/chrono_utils.h>
#include <android/graphics/region.h>
#include <android/gui/BnScreenCaptureListener.h>
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/android_hardware_HardwareBuffer.h>
#include <android_runtime/android_view_Surface.h>
#include <android_runtime/android_view_SurfaceSession.h>
#include <gui/IScreenCaptureListener.h>
#include <gui/ISurfaceComposer.h>
#include <gui/Surface.h>
#include <gui/SurfaceComposerClient.h>
@@ -51,8 +51,8 @@
#include <ui/HdrCapabilities.h>
#include <ui/Rect.h>
#include <ui/Region.h>
#include <utils/Log.h>
#include <utils/LightRefBase.h>
#include <utils/Log.h>
// ----------------------------------------------------------------------------
@@ -247,7 +247,7 @@ constexpr ui::Dataspace pickDataspaceFromColorMode(const ui::ColorMode colorMode
}
}
class ScreenCaptureListenerWrapper : public BnScreenCaptureListener {
class ScreenCaptureListenerWrapper : public gui::BnScreenCaptureListener {
public:
explicit ScreenCaptureListenerWrapper(JNIEnv* env, jobject jobject) {
env->GetJavaVM(&mVm);
@@ -262,12 +262,13 @@ public:
}
}
status_t onScreenCaptureComplete(const ScreenCaptureResults& captureResults) override {
binder::Status onScreenCaptureComplete(
const gui::ScreenCaptureResults& captureResults) override {
JNIEnv* env = getenv();
if (captureResults.result != NO_ERROR || captureResults.buffer == nullptr) {
env->CallVoidMethod(screenCaptureListenerObject,
gScreenCaptureListenerClassInfo.onScreenCaptureComplete, nullptr);
return NO_ERROR;
return binder::Status::ok();
}
jobject jhardwareBuffer = android_hardware_HardwareBuffer_createFromAHardwareBuffer(
env, captureResults.buffer->toAHardwareBuffer());
@@ -283,7 +284,7 @@ public:
screenshotHardwareBuffer);
env->DeleteLocalRef(jhardwareBuffer);
env->DeleteLocalRef(screenshotHardwareBuffer);
return NO_ERROR;
return binder::Status::ok();
}
private: