summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/view/View.java9
-rw-r--r--core/java/android/view/ViewRootImpl.java28
-rw-r--r--core/java/android/view/flags/view_flags.aconfig2
3 files changed, 24 insertions, 15 deletions
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 9579614ac379..60ad926f2be1 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -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);
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 64b3ef1e9f29..fa579611a3a1 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -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;
@@ -4338,29 +4339,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());
@@ -4368,7 +4382,7 @@ public final class ViewRootImpl implements ViewParent,
Transaction t = new Transaction();
t.addTransactionCommittedListener(mExecutor, () -> {
if (mAttachInfo.mSensitiveViewsCount == 0) {
- notifySensitiveContentAppProtection(false);
+ applySensitiveContentAppProtection(false);
}
});
applyTransactionOnDraw(t);
diff --git a/core/java/android/view/flags/view_flags.aconfig b/core/java/android/view/flags/view_flags.aconfig
index 12bd45af7ffb..c0d31fae4b8f 100644
--- a/core/java/android/view/flags/view_flags.aconfig
+++ b/core/java/android/view/flags/view_flags.aconfig
@@ -54,7 +54,7 @@ flag {
is_fixed_read_only: true
metadata {
purpose: PURPOSE_BUGFIX
- }
+ }
}
flag {