Merge "Drop the hardware buffer" into rvc-dev
This commit is contained in:
@@ -2400,6 +2400,10 @@ public abstract class AccessibilityService extends Service {
|
||||
|
||||
/**
|
||||
* Gets the {@link HardwareBuffer} representing a memory buffer of the screenshot.
|
||||
* <p>
|
||||
* <strong>Note:</strong> The application should call {@link HardwareBuffer#close()} when
|
||||
* the buffer is no longer needed to free the underlying resources.
|
||||
* </p>
|
||||
*
|
||||
* @return the hardware buffer
|
||||
*/
|
||||
|
||||
@@ -1023,18 +1023,21 @@ abstract class AbstractAccessibilityServiceConnection extends IAccessibilityServ
|
||||
displaySize.x, displaySize.y, false,
|
||||
rotation);
|
||||
final GraphicBuffer graphicBuffer = screenshotBuffer.getGraphicBuffer();
|
||||
final HardwareBuffer hardwareBuffer =
|
||||
HardwareBuffer.createFromGraphicBuffer(graphicBuffer);
|
||||
final ParcelableColorSpace colorSpace =
|
||||
new ParcelableColorSpace(screenshotBuffer.getColorSpace());
|
||||
try (HardwareBuffer hardwareBuffer =
|
||||
HardwareBuffer.createFromGraphicBuffer(graphicBuffer)) {
|
||||
final ParcelableColorSpace colorSpace =
|
||||
new ParcelableColorSpace(screenshotBuffer.getColorSpace());
|
||||
|
||||
// Send back the result.
|
||||
final Bundle payload = new Bundle();
|
||||
payload.putParcelable(KEY_ACCESSIBILITY_SCREENSHOT_HARDWAREBUFFER,
|
||||
hardwareBuffer);
|
||||
payload.putParcelable(KEY_ACCESSIBILITY_SCREENSHOT_COLORSPACE, colorSpace);
|
||||
payload.putLong(KEY_ACCESSIBILITY_SCREENSHOT_TIMESTAMP, SystemClock.uptimeMillis());
|
||||
callback.sendResult(payload);
|
||||
// Send back the result.
|
||||
final Bundle payload = new Bundle();
|
||||
payload.putParcelable(KEY_ACCESSIBILITY_SCREENSHOT_HARDWAREBUFFER,
|
||||
hardwareBuffer);
|
||||
payload.putParcelable(KEY_ACCESSIBILITY_SCREENSHOT_COLORSPACE, colorSpace);
|
||||
payload.putLong(KEY_ACCESSIBILITY_SCREENSHOT_TIMESTAMP,
|
||||
SystemClock.uptimeMillis());
|
||||
callback.sendResult(payload);
|
||||
hardwareBuffer.close();
|
||||
}
|
||||
}, null).recycleOnUse());
|
||||
} finally {
|
||||
Binder.restoreCallingIdentity(identity);
|
||||
|
||||
Reference in New Issue
Block a user