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

Commit 7eacb90e authored by Robin Lee's avatar Robin Lee
Browse files

SurfaceView reports setSecure in AssistStructure

Allows Assistant, Contextual Search, Autofill services to identify
regions of the screen where the screenshot will be blank.

Test: atest ContextualSearchManagerTest
Flag: android.app.contextualsearch.flags.report_secure_surfaces_in_assist_structure
Bug: 390504528
Change-Id: Ic8616b6cf7a650a820250a3324abb16f11a53a99
parent ba2ddbe8
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -23,6 +23,18 @@ flag {
    bug: "371065456"
}


flag {
  name: "report_secure_surfaces_in_assist_structure"
  namespace: "windowing_frontend"
  description: "SurfaceView reports when the surface is using a SECURE flag."
  bug: "390504528"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}


flag {
    name: "contextual_search_window_layer"
    namespace: "sysui_integrations"
+21 −0
Original line number Diff line number Diff line
@@ -2232,6 +2232,27 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall
        t.reparent(sc, mBlastSurfaceControl).show(sc);
    }

    /**
     * Populates a {@link ViewStructure} for content capture.
     *
     * <p>If {@link #setSecure(boolean)} has been enabled, will add a property to the
     * {@link android.app.assist.AssistStructure.ViewNode} to indicate that content will not
     * be available for this part of the screen.
     *
     * @hide
     */
    @Override
    protected void onProvideStructure(@NonNull ViewStructure structure,
            @ViewStructureType int viewFor, int flags) {
        super.onProvideStructure(structure, viewFor, flags);
        if (android.app.contextualsearch.flags.Flags.reportSecureSurfacesInAssistStructure()) {
            if ((mSurfaceFlags & SurfaceControl.SECURE) != 0) {
                structure.getExtras().putBoolean(
                        ViewStructure.EXTRA_CONTAINS_SECURE_LAYERS, true);
            }
        }
    }

    /** @hide */
    @Override
    public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
+13 −0
Original line number Diff line number Diff line
@@ -76,6 +76,19 @@ public abstract class ViewStructure {
    public static final String EXTRA_FIRST_ACTIVE_POSITION =
            "android.view.ViewStructure.extra.FIRST_ACTIVE_POSITION";

    /**
     * Key used for confirming whether the view draws graphics containing secure layers.
     *
     * <p>Secure layers cannot be read back into main memory and will show up as blank regions
     * in assist screenshots.
     *
     * @see android.view.SurfaceControl#SECURE
     *
     * @hide
     */
    public static final String EXTRA_CONTAINS_SECURE_LAYERS =
            "android.view.ViewStructure.extra.CONTAINS_SECURE_LAYERS";

    /**
     * Key used for writing the type of the view that generated the virtual structure of its
     * children.