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

Commit f5362cff authored by Manjeet Rulhania's avatar Manjeet Rulhania Committed by Android (Google) Code Review
Browse files

Merge "Fix comments for sensitive protection removal fix" into main

parents 822f8837 bdf02058
Loading
Loading
Loading
Loading
+2 −7
Original line number Original line 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.FLAG_VIEW_VELOCITY_API;
import static android.view.flags.Flags.enableUseMeasureCacheDuringForceLayout;
import static android.view.flags.Flags.enableUseMeasureCacheDuringForceLayout;
import static android.view.flags.Flags.sensitiveContentAppProtection;
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.toolkitFrameRateBySizeReadOnly;
import static android.view.flags.Flags.toolkitFrameRateDefaultNormalReadOnly;
import static android.view.flags.Flags.toolkitFrameRateDefaultNormalReadOnly;
import static android.view.flags.Flags.toolkitFrameRateSmallUsesPercentReadOnly;
import static android.view.flags.Flags.toolkitFrameRateSmallUsesPercentReadOnly;
@@ -32230,7 +32229,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        void increaseSensitiveViewsCount() {
        void increaseSensitiveViewsCount() {
            if (mSensitiveViewsCount == 0) {
            if (mSensitiveViewsCount == 0) {
                mViewRootImpl.notifySensitiveContentAppProtection(true);
                mViewRootImpl.addSensitiveContentAppProtection();
            }
            }
            mSensitiveViewsCount++;
            mSensitiveViewsCount++;
        }
        }
@@ -32238,11 +32237,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
        void decreaseSensitiveViewsCount() {
        void decreaseSensitiveViewsCount() {
            mSensitiveViewsCount--;
            mSensitiveViewsCount--;
            if (mSensitiveViewsCount == 0) {
            if (mSensitiveViewsCount == 0) {
                if (sensitiveContentPrematureProtectionRemovedFix()) {
                mViewRootImpl.removeSensitiveContentAppProtection();
                    mViewRootImpl.removeSensitiveContentProtectionOnTransactionCommit();
                } else {
                    mViewRootImpl.notifySensitiveContentAppProtection(false);
                }
            }
            }
            if (mSensitiveViewsCount < 0) {
            if (mSensitiveViewsCount < 0) {
                Log.wtf(VIEW_LOG_TAG, "mSensitiveViewsCount is negative" + mSensitiveViewsCount);
                Log.wtf(VIEW_LOG_TAG, "mSensitiveViewsCount is negative" + mSensitiveViewsCount);
+21 −7
Original line number Original line 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.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.DragEvent.ACTION_DRAG_LOCATION;
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.InputDevice.SOURCE_CLASS_NONE;
import static android.view.InsetsSource.ID_IME;
import static android.view.InsetsSource.ID_IME;
import static android.view.Surface.FRAME_RATE_CATEGORY_DEFAULT;
import static android.view.Surface.FRAME_RATE_CATEGORY_DEFAULT;
@@ -4338,29 +4339,42 @@ public final class ViewRootImpl implements ViewParent,
     *   <li>It should only notify service to unblock projection when all sensitive view are
     *   <li>It should only notify service to unblock projection when all sensitive view are
     *   removed from the window.
     *   removed from the window.
     * </ol>
     * </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 {
        try {
            if (mSensitiveContentProtectionService == null) {
            if (mSensitiveContentProtectionService == null) {
                return;
                return;
            }
            }
            if (DEBUG_SENSITIVE_CONTENT) {
            if (DEBUG_SENSITIVE_CONTENT) {
                Log.d(TAG, "Notify sensitive content, package=" + mContext.getPackageName()
                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.
            // The window would be blocked during screen share if it shows sensitive content.
            mSensitiveContentProtectionService.setSensitiveContentProtection(
            mSensitiveContentProtectionService.setSensitiveContentProtection(
                    getWindowToken(), mContext.getPackageName(), showSensitiveContent);
                    getWindowToken(), mContext.getPackageName(), enableProtection);
        } catch (RemoteException ex) {
        } catch (RemoteException ex) {
            Log.e(TAG, "Unable to protect sensitive content during screen share", ex);
            Log.e(TAG, "Unable to protect sensitive content during screen share", ex);
        }
        }
    }
    }
    /**
    /**
     * Sensitive protection is removed on transaction commit to avoid prematurely removing
     * Add sensitive content protection, when there are one or more visible sensitive views.
     * the protection.
     */
     */
    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) {
        if (DEBUG_SENSITIVE_CONTENT) {
            Log.d(TAG, "Add transaction to remove sensitive content protection, package="
            Log.d(TAG, "Add transaction to remove sensitive content protection, package="
                    + mContext.getPackageName() + ", token=" + getWindowToken());
                    + mContext.getPackageName() + ", token=" + getWindowToken());
@@ -4368,7 +4382,7 @@ public final class ViewRootImpl implements ViewParent,
        Transaction t = new Transaction();
        Transaction t = new Transaction();
        t.addTransactionCommittedListener(mExecutor, () -> {
        t.addTransactionCommittedListener(mExecutor, () -> {
            if (mAttachInfo.mSensitiveViewsCount == 0) {
            if (mAttachInfo.mSensitiveViewsCount == 0) {
                notifySensitiveContentAppProtection(false);
                applySensitiveContentAppProtection(false);
            }
            }
        });
        });
        applyTransactionOnDraw(t);
        applyTransactionOnDraw(t);
+1 −1

File changed.

Contains only whitespace changes.