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

Commit 36e7e62c authored by mrulhania's avatar mrulhania
Browse files

Remove screen share protection on transaction commit

When screen share protection is removed on view's visibility
change, it may leak the sensitive content becuase the content
might still be visible on the screen.

This change delay the protection removal until the sensitive
content is removed from the screen.

Fix: 336626172
Test: atest ViewSensitiveContentTest
Test: manual test
Change-Id: Iba399b4e65c7346fc891c355fa653bb9abfd7869
parent a01d784a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@ import static android.view.flags.Flags.FLAG_TOOLKIT_SET_FRAME_RATE_READ_ONLY;
import static android.view.flags.Flags.FLAG_VIEW_VELOCITY_API;
import static android.view.flags.Flags.enableUseMeasureCacheDuringForceLayout;
import static android.view.flags.Flags.sensitiveContentAppProtection;
import static android.view.flags.Flags.sensitiveContentPrematureProtectionRemovedFix;
import static android.view.flags.Flags.toolkitFrameRateBySizeReadOnly;
import static android.view.flags.Flags.toolkitFrameRateDefaultNormalReadOnly;
import static android.view.flags.Flags.toolkitFrameRateSmallUsesPercentReadOnly;
@@ -32235,8 +32236,12 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        void decreaseSensitiveViewsCount() {
            mSensitiveViewsCount--;
            if (mSensitiveViewsCount == 0) {
                if (sensitiveContentPrematureProtectionRemovedFix()) {
                    mViewRootImpl.removeSensitiveContentProtectionOnTransactionCommit();
                } else {
                    mViewRootImpl.notifySensitiveContentAppProtection(false);
                }
            }
            if (mSensitiveViewsCount < 0) {
                Log.wtf(VIEW_LOG_TAG, "mSensitiveViewsCount is negative" + mSensitiveViewsCount);
                mSensitiveViewsCount = 0;
+23 −0
Original line number Diff line number Diff line
@@ -317,6 +317,7 @@ public final class ViewRootImpl implements ViewParent,
    private static final boolean DEBUG_SCROLL_CAPTURE = false || LOCAL_LOGV;
    private static final boolean DEBUG_TOUCH_NAVIGATION = false || LOCAL_LOGV;
    private static final boolean DEBUG_BLAST = false || LOCAL_LOGV;
    private static final boolean DEBUG_SENSITIVE_CONTENT = false || LOCAL_LOGV;
    private static final int LOGTAG_INPUT_FOCUS = 62001;
    private static final int LOGTAG_VIEWROOT_DRAW_EVENT = 60004;
@@ -4334,6 +4335,10 @@ public final class ViewRootImpl implements ViewParent,
            if (mSensitiveContentProtectionService == null) {
                return;
            }
            if (DEBUG_SENSITIVE_CONTENT) {
                Log.d(TAG, "Notify sensitive content, package=" + mContext.getPackageName()
                        + ", token=" + getWindowToken() + ", flag=" + showSensitiveContent);
            }
            // The window would be blocked during screen share if it shows sensitive content.
            mSensitiveContentProtectionService.setSensitiveContentProtection(
                    getWindowToken(), mContext.getPackageName(), showSensitiveContent);
@@ -4342,6 +4347,24 @@ public final class ViewRootImpl implements ViewParent,
        }
    }
    /**
     * Sensitive protection is removed on transaction commit to avoid prematurely removing
     * the protection.
     */
    void removeSensitiveContentProtectionOnTransactionCommit() {
        if (DEBUG_SENSITIVE_CONTENT) {
            Log.d(TAG, "Add transaction to remove sensitive content protection, package="
                    + mContext.getPackageName() + ", token=" + getWindowToken());
        }
        Transaction t = new Transaction();
        t.addTransactionCommittedListener(mExecutor, () -> {
            if (mAttachInfo.mSensitiveViewsCount == 0) {
                notifySensitiveContentAppProtection(false);
            }
        });
        applyTransactionOnDraw(t);
    }
    private void notifyContentCaptureEvents() {
        if (!isContentCaptureEnabled()) {
            if (DEBUG_CONTENT_CAPTURE) {
+12 −0
Original line number Diff line number Diff line
@@ -45,6 +45,18 @@ flag {
  is_fixed_read_only: true
}

flag {
  name: "sensitive_content_premature_protection_removed_fix"
  namespace: "permissions"
  description: "Bug fix where sensitive content protection is prematurely removed."
  bug: "336626172"
  # Referenced in WM where WM starts before DeviceConfig
  is_fixed_read_only: true
  metadata {
      purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "enable_arrow_icon_on_hover_when_clickable"
    namespace: "toolkit"