summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2022-04-01 14:57:33 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2022-04-01 14:57:33 +0000
commit7d68e05afd912800a9a74f9c41311f84fa7eb78d (patch)
treed73555bcc8b928276195303b155fe8f4c19a5f20
parentd6454ce9be4f363973a92b2a380a468f985bf537 (diff)
parent9e13edc14b24119ca4a7a050bcb95a4f5a606f5a (diff)
Merge "Apply some comments from ag/17523010." into tm-dev
-rw-r--r--framework-s/java/android/safetycenter/SafetySourceData.java1
-rw-r--r--framework-s/java/android/safetycenter/SafetySourceIssue.java1
-rw-r--r--framework-s/java/android/safetycenter/config/SafetyCenterConfig.java1
-rw-r--r--framework-s/java/android/safetycenter/config/SafetyCenterConfigParser.java56
-rw-r--r--framework-s/java/android/safetycenter/config/SafetySourcesGroup.java1
5 files changed, 24 insertions, 36 deletions
diff --git a/framework-s/java/android/safetycenter/SafetySourceData.java b/framework-s/java/android/safetycenter/SafetySourceData.java
index 7da987dd2..bbec63db5 100644
--- a/framework-s/java/android/safetycenter/SafetySourceData.java
+++ b/framework-s/java/android/safetycenter/SafetySourceData.java
@@ -158,7 +158,6 @@ public final class SafetySourceData implements Parcelable {
List<SafetySourceIssue> issues =
requireNonNull(in.createTypedArrayList(SafetySourceIssue.CREATOR));
Builder builder = new Builder().setStatus(status);
- // TODO(b/224513050): Consider simplifying by adding a new API to the builder.
for (int i = 0; i < issues.size(); i++) {
builder.addIssue(issues.get(i));
}
diff --git a/framework-s/java/android/safetycenter/SafetySourceIssue.java b/framework-s/java/android/safetycenter/SafetySourceIssue.java
index 6f2c6f124..fa3cefc7f 100644
--- a/framework-s/java/android/safetycenter/SafetySourceIssue.java
+++ b/framework-s/java/android/safetycenter/SafetySourceIssue.java
@@ -107,7 +107,6 @@ public final class SafetySourceIssue implements Parcelable {
.setSubtitle(subtitle)
.setIssueCategory(issueCategory)
.setOnDismissPendingIntent(onDismissPendingIntent);
- // TODO(b/224513050): Consider simplifying by adding a new API to the builder.
for (int i = 0; i < actions.size(); i++) {
builder.addAction(actions.get(i));
}
diff --git a/framework-s/java/android/safetycenter/config/SafetyCenterConfig.java b/framework-s/java/android/safetycenter/config/SafetyCenterConfig.java
index 5fa01308a..99544e600 100644
--- a/framework-s/java/android/safetycenter/config/SafetyCenterConfig.java
+++ b/framework-s/java/android/safetycenter/config/SafetyCenterConfig.java
@@ -52,7 +52,6 @@ public final class SafetyCenterConfig implements Parcelable {
List<SafetySourcesGroup> safetySourcesGroups =
requireNonNull(in.createTypedArrayList(SafetySourcesGroup.CREATOR));
Builder builder = new Builder();
- // TODO(b/224513050): Consider simplifying by adding a new API to the builder.
for (int i = 0; i < safetySourcesGroups.size(); i++) {
builder.addSafetySourcesGroup(safetySourcesGroups.get(i));
}
diff --git a/framework-s/java/android/safetycenter/config/SafetyCenterConfigParser.java b/framework-s/java/android/safetycenter/config/SafetyCenterConfigParser.java
index 562d42267..45d5c9f2f 100644
--- a/framework-s/java/android/safetycenter/config/SafetyCenterConfigParser.java
+++ b/framework-s/java/android/safetycenter/config/SafetyCenterConfigParser.java
@@ -123,9 +123,8 @@ final class SafetyCenterConfigParser {
try {
return builder.build();
} catch (IllegalStateException e) {
- throwElementInvalid(TAG_SAFETY_SOURCES_CONFIG, e);
+ throw elementInvalid(TAG_SAFETY_SOURCES_CONFIG, e);
}
- throw new AssertionError("unreachable");
}
@NonNull
@@ -150,7 +149,7 @@ final class SafetyCenterConfigParser {
parser.getAttributeValue(i), name, parser.getAttributeName(i)));
break;
default:
- throwAttributeUnexpected(name, parser.getAttributeName(i));
+ throw attributeUnexpected(name, parser.getAttributeName(i));
}
}
parser.nextTag();
@@ -177,9 +176,8 @@ final class SafetyCenterConfigParser {
try {
return builder.build();
} catch (IllegalStateException e) {
- throwElementInvalid(name, e);
+ throw elementInvalid(name, e);
}
- throw new AssertionError("unreachable");
}
@NonNull
@@ -236,7 +234,7 @@ final class SafetyCenterConfigParser {
parser.getAttributeName(i)));
break;
default:
- throwAttributeUnexpected(name, parser.getAttributeName(i));
+ throw attributeUnexpected(name, parser.getAttributeName(i));
}
}
parser.nextTag();
@@ -245,58 +243,55 @@ final class SafetyCenterConfigParser {
try {
return builder.build();
} catch (IllegalStateException e) {
- throwElementInvalid(name, e);
+ throw elementInvalid(name, e);
}
- throw new AssertionError("unreachable");
}
private static void validateElementStart(@NonNull XmlResourceParser parser,
@NonNull String name)
throws XmlPullParserException, ParseException {
if (parser.getEventType() != START_TAG || !parser.getName().equals(name)) {
- throwElementMissing(name);
+ throw elementMissing(name);
}
}
private static void validateElementEnd(@NonNull XmlResourceParser parser, @NonNull String name)
throws XmlPullParserException, ParseException {
if (parser.getEventType() != END_TAG || !parser.getName().equals(name)) {
- throwElementNotClosed(name);
+ throw elementNotClosed(name);
}
}
private static void validateElementHasNoAttribute(
@NonNull XmlResourceParser parser, @NonNull String name) throws ParseException {
if (parser.getAttributeCount() != 0) {
- throwElementInvalid(name);
+ throw elementInvalid(name);
}
}
- private static void throwElementMissing(@NonNull String name) throws ParseException {
- throw new ParseException(String.format("Element %s missing", name));
+ private static ParseException elementMissing(@NonNull String name) {
+ return new ParseException(String.format("Element %s missing", name));
}
- private static void throwElementNotClosed(@NonNull String name) throws ParseException {
- throw new ParseException(String.format("Element %s not closed", name));
+ private static ParseException elementNotClosed(@NonNull String name) {
+ return new ParseException(String.format("Element %s not closed", name));
}
- private static void throwElementInvalid(@NonNull String name) throws ParseException {
- throw new ParseException(String.format("Element %s invalid", name));
+ private static ParseException elementInvalid(@NonNull String name) {
+ return new ParseException(String.format("Element %s invalid", name));
}
- private static void throwElementInvalid(@NonNull String name, @NonNull Throwable e)
- throws ParseException {
- throw new ParseException(String.format("Element %s invalid", name), e);
+ private static ParseException elementInvalid(@NonNull String name, @NonNull Throwable e) {
+ return new ParseException(String.format("Element %s invalid", name), e);
}
- private static void throwAttributeUnexpected(@NonNull String parent, @NonNull String name)
- throws ParseException {
- throw new ParseException(String.format("Unexpected attribute %s.%s", parent, name));
+ private static ParseException attributeUnexpected(@NonNull String parent,
+ @NonNull String name) {
+ return new ParseException(String.format("Unexpected attribute %s.%s", parent, name));
}
- private static void throwAttributeInvalid(@NonNull String parent, @NonNull String name)
- throws ParseException {
- throw new ParseException(String.format("Attribute %s.%s invalid", parent, name));
+ private static ParseException attributeInvalid(@NonNull String parent, @NonNull String name) {
+ return new ParseException(String.format("Attribute %s.%s invalid", parent, name));
}
private static int parseInteger(
@@ -346,9 +341,8 @@ final class SafetyCenterConfigParser {
case ENUM_STATELESS_ICON_TYPE_PRIVACY:
return SafetySourcesGroup.STATELESS_ICON_TYPE_PRIVACY;
default:
- throwAttributeInvalid(parent, name);
+ throw attributeInvalid(parent, name);
}
- throw new AssertionError("unreachable");
}
@Profile
@@ -361,9 +355,8 @@ final class SafetyCenterConfigParser {
case ENUM_PROFILE_ALL:
return SafetySource.PROFILE_ALL;
default:
- throwAttributeInvalid(parent, name);
+ throw attributeInvalid(parent, name);
}
- throw new AssertionError("unreachable");
}
@InitialDisplayState
@@ -378,8 +371,7 @@ final class SafetyCenterConfigParser {
case ENUM_INITIAL_DISPLAY_STATE_HIDDEN:
return SafetySource.INITIAL_DISPLAY_STATE_HIDDEN;
default:
- throwAttributeInvalid(parent, name);
+ throw attributeInvalid(parent, name);
}
- throw new AssertionError("unreachable");
}
}
diff --git a/framework-s/java/android/safetycenter/config/SafetySourcesGroup.java b/framework-s/java/android/safetycenter/config/SafetySourcesGroup.java
index 1df1af6e9..886d1071b 100644
--- a/framework-s/java/android/safetycenter/config/SafetySourcesGroup.java
+++ b/framework-s/java/android/safetycenter/config/SafetySourcesGroup.java
@@ -115,7 +115,6 @@ public final class SafetySourcesGroup implements Parcelable {
.setStatelessIconType(in.readInt());
List<SafetySource> safetySources =
requireNonNull(in.createTypedArrayList(SafetySource.CREATOR));
- // TODO(b/224513050): Consider simplifying by adding a new API to the builder.
for (int i = 0; i < safetySources.size(); i++) {
builder.addSafetySource(safetySources.get(i));
}