Add "contentSensitivity" xml attribute for View
Bug: 322886920
Test: atest CtsSensitiveContentProtectionTestCases
Change-Id: I8545806f2c50e244a82a79c164d036474c073d35
diff --git a/core/api/current.txt b/core/api/current.txt
index 0e42f80..66dbfdc 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -653,6 +653,7 @@
field public static final int contentInsetRight = 16843862; // 0x1010456
field public static final int contentInsetStart = 16843859; // 0x1010453
field public static final int contentInsetStartWithNavigation = 16844066; // 0x1010522
+ field @FlaggedApi("android.view.flags.sensitive_content_app_protection_api") public static final int contentSensitivity;
field public static final int contextClickable = 16844007; // 0x10104e7
field public static final int contextDescription = 16844078; // 0x101052e
field public static final int contextPopupMenuStyle = 16844033; // 0x1010501
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index c22986b..a0121ed 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -6364,6 +6364,9 @@
case R.styleable.View_handwritingBoundsOffsetBottom:
mHandwritingBoundsOffsetBottom = a.getDimension(attr, 0);
break;
+ case R.styleable.View_contentSensitivity:
+ setContentSensitivity(a.getInt(attr, CONTENT_SENSITIVITY_AUTO));
+ break;
}
}
diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml
index 41bc825..3cd1893 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -3641,6 +3641,18 @@
<p> The default value is 40dp for {@link android.widget.TextView} and
{@link android.widget.EditText}, and 0dp for all other views. -->
<attr name="handwritingBoundsOffsetBottom" format="dimension" />
+
+ <!-- Sets whether this view renders sensitive content. -->
+ <!-- @FlaggedApi("android.view.flags.sensitive_content_app_protection_api") -->
+ <attr name="contentSensitivity">
+ <!-- Let the Android System use its heuristics to determine if the view renders
+ sensitive content. -->
+ <enum name="auto" value="0" />
+ <!-- This view renders sensitive content. -->
+ <enum name="sensitive" value="0x1" />
+ <!-- This view doesn't render sensitive content. -->
+ <enum name="notSensitive" value="0x2" />
+ </attr>
</declare-styleable>
<!-- Attributes that can be assigned to a tag for a particular View. -->
diff --git a/core/res/res/values/public-staging.xml b/core/res/res/values/public-staging.xml
index 5ee5555..5674390 100644
--- a/core/res/res/values/public-staging.xml
+++ b/core/res/res/values/public-staging.xml
@@ -155,6 +155,8 @@
<public name="languageSettingsActivity"/>
<!-- @FlaggedApi("com.android.text.flags.fix_line_height_for_locale") -->
<public name="useLocalePreferredLineHeightForMinimum"/>
+ <!-- @FlaggedApi("android.view.flags.sensitive_content_app_protection_api") -->
+ <public name="contentSensitivity" />
</staging-public-group>
<staging-public-group type="id" first-id="0x01bc0000">