一、前言
在上一篇安卓10源码开发定制(34)系统截屏流程之Java层分析已经分析了系统截屏中Java层的流程。本篇将接着上篇分析系统截屏在JNI层的流程。
二、截屏JNI层流程分析
1.SurfaceControl.java类中的jni接口
SurfaceControl.java中定义了native方法来提供屏幕截图操作。如下所示:
private static native ScreenshotGraphicBuffer nativeScreenshot(IBinder displayToken,
Rect sourceCrop, int width, int height, boolean useIdentityTransform, int rotation,
boolean captureSecureLayers);
在源码中通过搜索定位到jni的实现文件为"android_view_SurfaceControl.cpp"。