diff options
| author | 2024-05-02 22:10:42 +0000 | |
|---|---|---|
| committer | 2024-05-02 22:10:42 +0000 | |
| commit | 06b940fcf49f99ccd571882612d2b1916d30de01 (patch) | |
| tree | 8afbdd3a66af3fdecb190a9aa3cd80520cd30fe1 | |
| parent | e8a16c01e0b31061ee4a931f31170d7d9c4d0db2 (diff) | |
| parent | 36e7e62cdb7b482e897f112c031a7f0c37d35393 (diff) | |
Merge "Remove screen share protection on transaction commit" into main
| -rw-r--r-- | core/java/android/view/View.java | 7 | ||||
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 23 | ||||
| -rw-r--r-- | core/java/android/view/flags/view_flags.aconfig | 12 |
3 files changed, 41 insertions, 1 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index fe005d07622f..b87bb0822cdc 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -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; @@ -32237,7 +32238,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback, void decreaseSensitiveViewsCount() { mSensitiveViewsCount--; if (mSensitiveViewsCount == 0) { - mViewRootImpl.notifySensitiveContentAppProtection(false); + if (sensitiveContentPrematureProtectionRemovedFix()) { + mViewRootImpl.removeSensitiveContentProtectionOnTransactionCommit(); + } else { + mViewRootImpl.notifySensitiveContentAppProtection(false); + } } if (mSensitiveViewsCount < 0) { Log.wtf(VIEW_LOG_TAG, "mSensitiveViewsCount is negative" + mSensitiveViewsCount); diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 5ca79869cae9..1d843757489e 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -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; @@ -4336,6 +4337,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); @@ -4344,6 +4349,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) { diff --git a/core/java/android/view/flags/view_flags.aconfig b/core/java/android/view/flags/view_flags.aconfig index 16e141550fdc..12bd45af7ffb 100644 --- a/core/java/android/view/flags/view_flags.aconfig +++ b/core/java/android/view/flags/view_flags.aconfig @@ -46,6 +46,18 @@ flag { } 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" description: "Enable default arrow icon when hovering on buttons or clickable widgets." |