Loading core/java/android/view/contentcapture/MainContentCaptureSession.java +4 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import android.view.View; import android.view.ViewStructure; import android.view.autofill.AutofillId; import android.view.contentcapture.ViewNode.ViewStructureImpl; import android.view.contentcapture.flags.Flags; import android.view.contentprotection.ContentProtectionEventProcessor; import android.view.inputmethod.BaseInputConnection; Loading Loading @@ -1008,6 +1009,9 @@ public final class MainContentCaptureSession extends ContentCaptureSession { } } internalNotifyViewTreeEvent(sessionId, /* started= */ false); if (Flags.flushAfterEachFrame()) { internalNotifySessionFlushEvent(sessionId); } } } finally { Trace.traceEnd(Trace.TRACE_TAG_VIEW); Loading core/java/android/view/contentcapture/flags/content_capture_flags.aconfig +11 −0 Original line number Diff line number Diff line Loading @@ -15,3 +15,14 @@ flag { bug: "380381249" is_exported: true } flag { name: "flush_after_each_frame" namespace: "pixel_state_server" description: "Feature flag to send a flush event after each frame" bug: "380381249" is_fixed_read_only: true metadata { purpose: PURPOSE_BUGFIX } } core/tests/coretests/src/android/view/contentcapture/MainContentCaptureSessionTest.java +35 −0 Original line number Diff line number Diff line Loading @@ -36,11 +36,15 @@ import android.content.pm.ParceledListSlice; import android.graphics.Insets; import android.os.Handler; import android.os.RemoteException; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.util.SparseArray; import android.view.View; import android.view.autofill.AutofillId; import android.view.contentcapture.flags.Flags; import android.view.contentprotection.ContentProtectionEventProcessor; import androidx.test.core.app.ApplicationProvider; Loading Loading @@ -90,6 +94,8 @@ public class MainContentCaptureSessionTest { @Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule(); @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Mock private IContentCaptureManager mMockSystemServerInterface; @Mock private ContentProtectionEventProcessor mMockContentProtectionEventProcessor; Loading Loading @@ -407,6 +413,7 @@ public class MainContentCaptureSessionTest { } @Test @DisableFlags(Flags.FLAG_FLUSH_AFTER_EACH_FRAME) @SuppressWarnings("GuardedBy") public void notifyContentCaptureEvents_started_ContentCaptureEnabled_ProtectionEnabled() throws RemoteException { Loading @@ -433,6 +440,34 @@ public class MainContentCaptureSessionTest { assertThat(session.mEvents).isEmpty(); } @Test @EnableFlags(Flags.FLAG_FLUSH_AFTER_EACH_FRAME) @SuppressWarnings("GuardedBy") public void notifyContentCaptureEvents_started_ContentCaptureEnabled_ProtectionEnabled_Flush() throws RemoteException { ContentCaptureOptions options = createOptions( /* enableContentCaptureReceiver= */ true, /* enableContentProtectionReceiver= */ true); MainContentCaptureSession session = createSession(options); session.mDirectServiceInterface = mMockContentCaptureDirectManager; session.onSessionStarted(0x2, null); // Override the processor for interaction verification. session.mContentProtectionEventProcessor = mMockContentProtectionEventProcessor; notifyContentCaptureEvents(session); mTestableLooper.processAllMessages(); // Force flush will happen twice. verify(mMockContentCaptureDirectManager, times(1)) .sendEvents(any(), eq(FLUSH_REASON_VIEW_TREE_APPEARING), any()); verify(mMockContentCaptureDirectManager, times(1)) .sendEvents(any(), eq(FLUSH_REASON_VIEW_TREE_APPEARED), any()); // 5 view events + 2 view tree events + 1 flush event verify(mMockContentProtectionEventProcessor, times(8)).processEvent(any()); assertThat(session.mEvents).isEmpty(); } @Test public void notifyViewAppearedBelowMaximumBufferSize() throws RemoteException { ContentCaptureOptions options = Loading Loading
core/java/android/view/contentcapture/MainContentCaptureSession.java +4 −0 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import android.view.View; import android.view.ViewStructure; import android.view.autofill.AutofillId; import android.view.contentcapture.ViewNode.ViewStructureImpl; import android.view.contentcapture.flags.Flags; import android.view.contentprotection.ContentProtectionEventProcessor; import android.view.inputmethod.BaseInputConnection; Loading Loading @@ -1008,6 +1009,9 @@ public final class MainContentCaptureSession extends ContentCaptureSession { } } internalNotifyViewTreeEvent(sessionId, /* started= */ false); if (Flags.flushAfterEachFrame()) { internalNotifySessionFlushEvent(sessionId); } } } finally { Trace.traceEnd(Trace.TRACE_TAG_VIEW); Loading
core/java/android/view/contentcapture/flags/content_capture_flags.aconfig +11 −0 Original line number Diff line number Diff line Loading @@ -15,3 +15,14 @@ flag { bug: "380381249" is_exported: true } flag { name: "flush_after_each_frame" namespace: "pixel_state_server" description: "Feature flag to send a flush event after each frame" bug: "380381249" is_fixed_read_only: true metadata { purpose: PURPOSE_BUGFIX } }
core/tests/coretests/src/android/view/contentcapture/MainContentCaptureSessionTest.java +35 −0 Original line number Diff line number Diff line Loading @@ -36,11 +36,15 @@ import android.content.pm.ParceledListSlice; import android.graphics.Insets; import android.os.Handler; import android.os.RemoteException; import android.platform.test.annotations.DisableFlags; import android.platform.test.annotations.EnableFlags; import android.platform.test.flag.junit.SetFlagsRule; import android.testing.AndroidTestingRunner; import android.testing.TestableLooper; import android.util.SparseArray; import android.view.View; import android.view.autofill.AutofillId; import android.view.contentcapture.flags.Flags; import android.view.contentprotection.ContentProtectionEventProcessor; import androidx.test.core.app.ApplicationProvider; Loading Loading @@ -90,6 +94,8 @@ public class MainContentCaptureSessionTest { @Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule(); @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(); @Mock private IContentCaptureManager mMockSystemServerInterface; @Mock private ContentProtectionEventProcessor mMockContentProtectionEventProcessor; Loading Loading @@ -407,6 +413,7 @@ public class MainContentCaptureSessionTest { } @Test @DisableFlags(Flags.FLAG_FLUSH_AFTER_EACH_FRAME) @SuppressWarnings("GuardedBy") public void notifyContentCaptureEvents_started_ContentCaptureEnabled_ProtectionEnabled() throws RemoteException { Loading @@ -433,6 +440,34 @@ public class MainContentCaptureSessionTest { assertThat(session.mEvents).isEmpty(); } @Test @EnableFlags(Flags.FLAG_FLUSH_AFTER_EACH_FRAME) @SuppressWarnings("GuardedBy") public void notifyContentCaptureEvents_started_ContentCaptureEnabled_ProtectionEnabled_Flush() throws RemoteException { ContentCaptureOptions options = createOptions( /* enableContentCaptureReceiver= */ true, /* enableContentProtectionReceiver= */ true); MainContentCaptureSession session = createSession(options); session.mDirectServiceInterface = mMockContentCaptureDirectManager; session.onSessionStarted(0x2, null); // Override the processor for interaction verification. session.mContentProtectionEventProcessor = mMockContentProtectionEventProcessor; notifyContentCaptureEvents(session); mTestableLooper.processAllMessages(); // Force flush will happen twice. verify(mMockContentCaptureDirectManager, times(1)) .sendEvents(any(), eq(FLUSH_REASON_VIEW_TREE_APPEARING), any()); verify(mMockContentCaptureDirectManager, times(1)) .sendEvents(any(), eq(FLUSH_REASON_VIEW_TREE_APPEARED), any()); // 5 view events + 2 view tree events + 1 flush event verify(mMockContentProtectionEventProcessor, times(8)).processEvent(any()); assertThat(session.mEvents).isEmpty(); } @Test public void notifyViewAppearedBelowMaximumBufferSize() throws RemoteException { ContentCaptureOptions options = Loading