Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7549d762 authored by Yi Jiang's avatar Yi Jiang
Browse files

Refactor ScreenCaptureListenerWrapper to guarantee callback delivery

The previous implementation of ScreenCaptureListenerWrapper used a weak
reference to hold the Java consumer object.

This created a race where the Java consumer could be garbage collected
before the native onScreenCaptureCompleted() callback was invoked. In
that case the screenshot result will be sliently dropped.

This change uses a strong global reference to the Java consumer object,
to ensure the consumer remains alive until the native callback is
invoked. The strong reference will be deleted immediately after the
callback is fired, as the listener is a one-shot mechanism.

Test: presubmit and locally tested screenshot functions.
Test: adding logs and see if the global reference deletion is called
after screenshot finishes.

Bug: 441019220
Flag: EXEMPT BUGFIX

Change-Id: I8e907384b915c30a7b9c1927b1cd517da26561e3
parent a9322002
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment