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

Commit bdf02058 authored by mrulhania's avatar mrulhania Committed by Manjeet Rulhania
Browse files

Fix comments for sensitive protection removal fix

addressing comments from ag/27183164
- move flag logic to ViewRootImpl
- fix indentation in aconfig flag

Bug: 336626172
Test: atest ViewSensitiveContentTest
Test: manual test
Change-Id: I9cbec659cf49f034f011e3c7148efd58d33a157a
parent 7e5027f0
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ 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;
@@ -32230,7 +32229,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        void increaseSensitiveViewsCount() {
            if (mSensitiveViewsCount == 0) {
                mViewRootImpl.notifySensitiveContentAppProtection(true);
                mViewRootImpl.addSensitiveContentAppProtection();
            }
            mSensitiveViewsCount++;
        }
@@ -32238,11 +32237,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        void decreaseSensitiveViewsCount() {
            mSensitiveViewsCount--;
            if (mSensitiveViewsCount == 0) {
                if (sensitiveContentPrematureProtectionRemovedFix()) {
                    mViewRootImpl.removeSensitiveContentProtectionOnTransactionCommit();
                } else {
                    mViewRootImpl.notifySensitiveContentAppProtection(false);
                }
                mViewRootImpl.removeSensitiveContentAppProtection();
            }
            if (mSensitiveViewsCount < 0) {
                Log.wtf(VIEW_LOG_TAG, "mSensitiveViewsCount is negative" + mSensitiveViewsCount);
+21 −7
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static android.os.Trace.TRACE_TAG_VIEW;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.DragEvent.ACTION_DRAG_LOCATION;
import static android.view.flags.Flags.sensitiveContentPrematureProtectionRemovedFix;
import static android.view.InputDevice.SOURCE_CLASS_NONE;
import static android.view.InsetsSource.ID_IME;
import static android.view.Surface.FRAME_RATE_CATEGORY_DEFAULT;
@@ -4331,29 +4332,42 @@ public final class ViewRootImpl implements ViewParent,
     *   <li>It should only notify service to unblock projection when all sensitive view are
     *   removed from the window.
     * </ol>
     *
     * @param enableProtection if true, the protection is enabled for this window.
     *                         if false, the protection is removed for this window.
     */
    void notifySensitiveContentAppProtection(boolean showSensitiveContent) {
    private void applySensitiveContentAppProtection(boolean enableProtection) {
        try {
            if (mSensitiveContentProtectionService == null) {
                return;
            }
            if (DEBUG_SENSITIVE_CONTENT) {
                Log.d(TAG, "Notify sensitive content, package=" + mContext.getPackageName()
                        + ", token=" + getWindowToken() + ", flag=" + showSensitiveContent);
                        + ", token=" + getWindowToken() + ", flag=" + enableProtection);
            }
            // The window would be blocked during screen share if it shows sensitive content.
            mSensitiveContentProtectionService.setSensitiveContentProtection(
                    getWindowToken(), mContext.getPackageName(), showSensitiveContent);
                    getWindowToken(), mContext.getPackageName(), enableProtection);
        } catch (RemoteException ex) {
            Log.e(TAG, "Unable to protect sensitive content during screen share", ex);
        }
    }
    /**
     * Sensitive protection is removed on transaction commit to avoid prematurely removing
     * the protection.
     * Add sensitive content protection, when there are one or more visible sensitive views.
     */
    void removeSensitiveContentProtectionOnTransactionCommit() {
    void addSensitiveContentAppProtection() {
        applySensitiveContentAppProtection(true);
    }
    /**
     * Remove sensitive content protection, when there is no visible sensitive view.
     */
    void removeSensitiveContentAppProtection() {
        if (!sensitiveContentPrematureProtectionRemovedFix()) {
            applySensitiveContentAppProtection(false);
            return;
        }
        if (DEBUG_SENSITIVE_CONTENT) {
            Log.d(TAG, "Add transaction to remove sensitive content protection, package="
                    + mContext.getPackageName() + ", token=" + getWindowToken());
@@ -4361,7 +4375,7 @@ public final class ViewRootImpl implements ViewParent,
        Transaction t = new Transaction();
        t.addTransactionCommittedListener(mExecutor, () -> {
            if (mAttachInfo.mSensitiveViewsCount == 0) {
                notifySensitiveContentAppProtection(false);
                applySensitiveContentAppProtection(false);
            }
        });
        applyTransactionOnDraw(t);
+1 −1

File changed.

Contains only whitespace changes.