summaryrefslogtreecommitdiff
path: root/framework-s/java
diff options
context:
space:
mode:
Diffstat (limited to 'framework-s/java')
-rw-r--r--framework-s/java/android/safetycenter/SafetySourceIssue.java5
-rw-r--r--framework-s/java/android/safetycenter/config/SafetySource.java56
-rw-r--r--framework-s/java/android/safetycenter/config/safety_center_config.xsd2
3 files changed, 58 insertions, 5 deletions
diff --git a/framework-s/java/android/safetycenter/SafetySourceIssue.java b/framework-s/java/android/safetycenter/SafetySourceIssue.java
index afc4f071f..f4a369a4b 100644
--- a/framework-s/java/android/safetycenter/SafetySourceIssue.java
+++ b/framework-s/java/android/safetycenter/SafetySourceIssue.java
@@ -380,7 +380,10 @@ public final class SafetySourceIssue implements Parcelable {
* deduplication identifiers.
*
* <p>Deduplication identifier will be used to identify duplicate issues. This identifier
- * applies globally across all safety sources sending data to SafetyCenter.
+ * applies across all safety sources which are part of the same deduplication group.
+ * Deduplication groups can be set, for each source, in the SafetyCenter config. Therefore, two
+ * issues are considered duplicate if their sources are part of the same deduplication group and
+ * they have the same deduplication identifier.
*
* <p>Out of all issues that are found to be duplicates, only one will be shown in the UI (the
* one with the highest severity, or in case of same severities, the one placed highest in the
diff --git a/framework-s/java/android/safetycenter/config/SafetySource.java b/framework-s/java/android/safetycenter/config/SafetySource.java
index 9c8c279c3..d3d9cb9f7 100644
--- a/framework-s/java/android/safetycenter/config/SafetySource.java
+++ b/framework-s/java/android/safetycenter/config/SafetySource.java
@@ -171,6 +171,7 @@ public final class SafetySource implements Parcelable {
.setRefreshOnPageOpenAllowed(in.readBoolean());
if (SdkLevel.isAtLeastU()) {
builder.setNotificationsAllowed(in.readBoolean());
+ builder.setDeduplicationGroup(in.readString());
}
return builder.build();
}
@@ -195,6 +196,7 @@ public final class SafetySource implements Parcelable {
private final boolean mLoggingAllowed;
private final boolean mRefreshOnPageOpenAllowed;
private final boolean mNotificationsAllowed;
+ @Nullable final String mDeduplicationGroup;
private SafetySource(
@SafetySourceType int type,
@@ -210,7 +212,8 @@ public final class SafetySource implements Parcelable {
@StringRes int searchTermsResId,
boolean loggingAllowed,
boolean refreshOnPageOpenAllowed,
- boolean notificationsAllowed) {
+ boolean notificationsAllowed,
+ @Nullable String deduplicationGroup) {
mType = type;
mId = id;
mPackageName = packageName;
@@ -225,6 +228,7 @@ public final class SafetySource implements Parcelable {
mLoggingAllowed = loggingAllowed;
mRefreshOnPageOpenAllowed = refreshOnPageOpenAllowed;
mNotificationsAllowed = notificationsAllowed;
+ mDeduplicationGroup = deduplicationGroup;
}
/** Returns the type of this safety source. */
@@ -442,6 +446,21 @@ public final class SafetySource implements Parcelable {
return mNotificationsAllowed;
}
+ /**
+ * Returns the deduplication group this source belongs to.
+ *
+ * <p>Sources which are part of the same deduplication group can coordinate to deduplicate their
+ * issues.
+ */
+ @Nullable
+ @RequiresApi(UPSIDE_DOWN_CAKE)
+ public String getDeduplicationGroup() {
+ if (!SdkLevel.isAtLeastU()) {
+ throw new UnsupportedOperationException();
+ }
+ return mDeduplicationGroup;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
@@ -460,7 +479,8 @@ public final class SafetySource implements Parcelable {
&& mSearchTermsResId == that.mSearchTermsResId
&& mLoggingAllowed == that.mLoggingAllowed
&& mRefreshOnPageOpenAllowed == that.mRefreshOnPageOpenAllowed
- && mNotificationsAllowed == that.mNotificationsAllowed;
+ && mNotificationsAllowed == that.mNotificationsAllowed
+ && Objects.equals(mDeduplicationGroup, that.mDeduplicationGroup);
}
@Override
@@ -479,7 +499,8 @@ public final class SafetySource implements Parcelable {
mSearchTermsResId,
mLoggingAllowed,
mRefreshOnPageOpenAllowed,
- mNotificationsAllowed);
+ mNotificationsAllowed,
+ mDeduplicationGroup);
}
@Override
@@ -513,6 +534,8 @@ public final class SafetySource implements Parcelable {
+ mRefreshOnPageOpenAllowed
+ ", mNotificationsAllowed="
+ mNotificationsAllowed
+ + ", mDeduplicationGroup="
+ + mDeduplicationGroup
+ '}';
}
@@ -538,6 +561,7 @@ public final class SafetySource implements Parcelable {
dest.writeBoolean(mRefreshOnPageOpenAllowed);
if (SdkLevel.isAtLeastU()) {
dest.writeBoolean(mNotificationsAllowed);
+ dest.writeString(mDeduplicationGroup);
}
}
@@ -558,6 +582,7 @@ public final class SafetySource implements Parcelable {
@Nullable private Boolean mLoggingAllowed;
@Nullable private Boolean mRefreshOnPageOpenAllowed;
@Nullable private Boolean mNotificationsAllowed;
+ @Nullable private String mDeduplicationGroup;
/** Creates a {@link Builder} for a {@link SafetySource}. */
public Builder(@SafetySourceType int type) {
@@ -766,6 +791,25 @@ public final class SafetySource implements Parcelable {
}
/**
+ * Sets the deduplication group for this source.
+ *
+ * <p>Sources which are part of the same deduplication group can coordinate to deduplicate
+ * issues that they're sending to SafetyCenter by providing the same deduplication
+ * identifier with those issues.
+ *
+ * <p>The deduplication group property is prohibited for sources of type static.
+ */
+ @NonNull
+ @RequiresApi(UPSIDE_DOWN_CAKE)
+ public Builder setDeduplicationGroup(@Nullable String deduplicationGroup) {
+ if (!SdkLevel.isAtLeastU()) {
+ throw new UnsupportedOperationException();
+ }
+ mDeduplicationGroup = deduplicationGroup;
+ return this;
+ }
+
+ /**
* Creates the {@link SafetySource} defined by this {@link Builder}.
*
* <p>Throws an {@link IllegalStateException} if any constraint on the safety source is
@@ -868,6 +912,9 @@ public final class SafetySource implements Parcelable {
false,
isStatic,
false);
+
+ BuilderUtils.validateAttribute(
+ mDeduplicationGroup, "deduplicationGroup", false, isStatic);
}
return new SafetySource(
@@ -884,7 +931,8 @@ public final class SafetySource implements Parcelable {
searchTermsResId,
loggingAllowed,
refreshOnPageOpenAllowed,
- notificationsAllowed);
+ notificationsAllowed,
+ mDeduplicationGroup);
}
}
}
diff --git a/framework-s/java/android/safetycenter/config/safety_center_config.xsd b/framework-s/java/android/safetycenter/config/safety_center_config.xsd
index 8d9903e16..75b31c166 100644
--- a/framework-s/java/android/safetycenter/config/safety_center_config.xsd
+++ b/framework-s/java/android/safetycenter/config/safety_center_config.xsd
@@ -72,6 +72,7 @@
default="false"/>
<xsd:attribute name="notificationsAllowed" type="booleanOrStringResourceName"
default="false"/>
+ <xsd:attribute name="deduplicationGroup" type="stringOrStringResourceName"/>
</xsd:complexType>
<xsd:complexType name="issue-only-safety-source">
@@ -85,6 +86,7 @@
default="false"/>
<xsd:attribute name="notificationsAllowed" type="booleanOrStringResourceName"
default="false"/>
+ <xsd:attribute name="deduplicationGroup" type="stringOrStringResourceName"/>
</xsd:complexType>
<xsd:complexType name="static-safety-source">