diff options
9 files changed, 739 insertions, 344 deletions
diff --git a/PermissionController/src/com/android/permissioncontroller/permission/ui/television/GrantPermissionsViewHandlerImpl.java b/PermissionController/src/com/android/permissioncontroller/permission/ui/television/GrantPermissionsViewHandlerImpl.java index fa7f8120b..3c7a90b5b 100644 --- a/PermissionController/src/com/android/permissioncontroller/permission/ui/television/GrantPermissionsViewHandlerImpl.java +++ b/PermissionController/src/com/android/permissioncontroller/permission/ui/television/GrantPermissionsViewHandlerImpl.java @@ -100,10 +100,12 @@ public final class GrantPermissionsViewHandlerImpl implements GrantPermissionsVi mSoftDenyButton.setOnClickListener(this); mHardDenyButton.setOnClickListener(this); - mRootView.addOnLayoutChangeListener((view, l, t, r, b, oldL, oldT, oldR, oldB) -> { - mRootView.setUnrestrictedPreferKeepClearRects( - Collections.singletonList(new Rect(0, 0, r - l, b - t))); - }); + if (SdkLevel.isAtLeastT()) { + mRootView.addOnLayoutChangeListener((view, l, t, r, b, oldL, oldT, oldR, oldB) -> { + mRootView.setUnrestrictedPreferKeepClearRects( + Collections.singletonList(new Rect(0, 0, r - l, b - t))); + }); + } return mRootView; } diff --git a/SafetyCenter/Resources/shared_res/values/strings.xml b/SafetyCenter/Resources/shared_res/values/strings.xml index 250ea27e7..c5b02b3f8 100644 --- a/SafetyCenter/Resources/shared_res/values/strings.xml +++ b/SafetyCenter/Resources/shared_res/values/strings.xml @@ -35,15 +35,15 @@ <string name="overall_severity_level_ok_review_summary">Check settings list</string> <!-- Title for the overall Safety Center status when the user security and privacy signals could potentially put them at risk [CHAR LIMIT=35] --> - <string name="overall_severity_level_recommendation_title">Device may be at risk</string> + <string name="overall_severity_level_device_recommendation_title">Device may be at risk</string> <!-- Title for the overall Safety Center status when the user security and privacy signals are putting them at risk [CHAR LIMIT=35] --> - <string name="overall_severity_level_critical_warning_title">Device is at risk</string> + <string name="overall_severity_level_critical_device_warning_title">Device is at risk</string> - <!-- Title for the overall Safety Center status when the user security and privacy signals could potentially put their personal safety at risk [CHAR LIMIT=35] --> + <!-- Title for the overall Safety Center status when the user security and privacy signals could potentially put their general safety at risk [CHAR LIMIT=35] --> <string name="overall_severity_level_safety_recommendation_title">You may be at risk</string> - <!-- Title for the overall Safety Center status when the user security and privacy signals are putting their personal safety at risk [CHAR LIMIT=35] --> + <!-- Title for the overall Safety Center status when the user security and privacy signals are putting their general safety at risk [CHAR LIMIT=35] --> <string name="overall_severity_level_critical_safety_warning_title">You are at risk</string> <!-- Summary for the overall Safety Center status when the user security and privacy signals contain alerts that could range from minor suggestions to warnings or critical issues. The number of alerts is given as a parameter [CHAR LIMIT=60] --> diff --git a/service/java/com/android/safetycenter/SafetyCenterDataTracker.java b/service/java/com/android/safetycenter/SafetyCenterDataTracker.java index ac1d44f12..4681b4799 100644 --- a/service/java/com/android/safetycenter/SafetyCenterDataTracker.java +++ b/service/java/com/android/safetycenter/SafetyCenterDataTracker.java @@ -69,6 +69,7 @@ import com.android.safetycenter.persistence.PersistedSafetyCenterIssue; import com.android.safetycenter.resources.SafetyCenterResourcesContext; import java.io.PrintWriter; +import java.time.Duration; import java.time.Instant; import java.util.ArrayList; import java.util.Comparator; @@ -358,11 +359,13 @@ final class SafetyCenterDataTracker { */ void dismissSafetyCenterIssue(@NonNull SafetyCenterIssueKey safetyCenterIssueKey) { IssueData issueData = mSafetyCenterIssueCache.get(safetyCenterIssueKey); - if (issueData != null) { - issueData.setDismissedAt(Instant.now()); - issueData.setDismissCount(issueData.getDismissCount() + 1); - mSafetyCenterIssueCacheDirty = true; + if (issueData == null) { + Log.w(TAG, "Issue missing when writing to cache for key: " + safetyCenterIssueKey); + return; } + issueData.setDismissedAt(Instant.now()); + issueData.setDismissCount(issueData.getDismissCount() + 1); + mSafetyCenterIssueCacheDirty = true; } /** @@ -373,10 +376,6 @@ final class SafetyCenterDataTracker { */ @Nullable SafetySourceIssue getSafetySourceIssue(@NonNull SafetyCenterIssueKey safetyCenterIssueKey) { - if (isDismissed(safetyCenterIssueKey)) { - return null; - } - SafetySourceKey key = SafetySourceKey.of( safetyCenterIssueKey.getSafetySourceId(), safetyCenterIssueKey.getUserId()); @@ -386,15 +385,24 @@ final class SafetyCenterDataTracker { } List<SafetySourceIssue> safetySourceIssues = safetySourceData.getIssues(); + SafetySourceIssue targetIssue = null; for (int i = 0; i < safetySourceIssues.size(); i++) { SafetySourceIssue safetySourceIssue = safetySourceIssues.get(i); if (safetyCenterIssueKey.getSafetySourceIssueId().equals(safetySourceIssue.getId())) { - return safetySourceIssue; + targetIssue = safetySourceIssue; + break; } } + if (targetIssue == null) { + return null; + } - return null; + if (isDismissed(safetyCenterIssueKey, targetIssue.getSeverityLevel())) { + return null; + } + + return targetIssue; } /** @@ -443,8 +451,8 @@ final class SafetyCenterDataTracker { new SafetyCenterStatus.Builder( getSafetyCenterStatusTitle( SafetyCenterStatus.OVERALL_SEVERITY_LEVEL_UNKNOWN, + new ArrayList<>(), SafetyCenterStatus.REFRESH_STATUS_NONE, - new ArraySet<>(), false), getSafetyCenterStatusSummary( SafetyCenterStatus.OVERALL_SEVERITY_LEVEL_UNKNOWN, @@ -560,12 +568,37 @@ final class SafetyCenterDataTracker { } } - private boolean isDismissed(@NonNull SafetyCenterIssueKey safetyCenterIssueKey) { + private boolean isDismissed( + @NonNull SafetyCenterIssueKey safetyCenterIssueKey, + @SafetySourceData.SeverityLevel int safetySourceIssueSeverityLevel) { IssueData issueData = mSafetyCenterIssueCache.get(safetyCenterIssueKey); if (issueData == null) { + Log.w(TAG, "Issue missing when reading from cache for key: " + safetyCenterIssueKey); + return false; + } + + Instant dismissedAt = issueData.getDismissedAt(); + boolean hasNeverBeenDismissed = dismissedAt == null; + if (hasNeverBeenDismissed) { + return false; + } + + long maxCount = SafetyCenterFlags.getResurfaceIssueMaxCount(safetySourceIssueSeverityLevel); + Duration delay = SafetyCenterFlags.getResurfaceIssueDelay(safetySourceIssueSeverityLevel); + + boolean hasAlreadyResurfacedTheMaxAllowedNumberOfTimes = + issueData.getDismissCount() > maxCount; + if (hasAlreadyResurfacedTheMaxAllowedNumberOfTimes) { + return true; + } + + Duration timeSinceLastDismissal = Duration.between(dismissedAt, Instant.now()); + boolean isTimeToResurface = timeSinceLastDismissal.compareTo(delay) >= 0; + if (isTimeToResurface) { return false; } - return issueData.getDismissedAt() != null; + + return true; } private boolean isInFlight(@NonNull SafetyCenterIssueActionId safetyCenterIssueActionId) { @@ -770,8 +803,7 @@ final class SafetyCenterDataTracker { @NonNull UserProfileGroup userProfileGroup) { int safetyCenterOverallSeverityLevel = SafetyCenterStatus.OVERALL_SEVERITY_LEVEL_OK; int safetyCenterEntriesSeverityLevel = SafetyCenterStatus.OVERALL_SEVERITY_LEVEL_OK; - List<SafetyCenterIssue> safetyCenterIssues = new ArrayList<>(); - ArraySet<Integer> allCurrentIssueCategories = new ArraySet<>(); + List<SafetyCenterIssueWithCategory> safetyCenterIssuesWithCategories = new ArrayList<>(); List<SafetyCenterEntryOrGroup> safetyCenterEntryOrGroups = new ArrayList<>(); List<SafetyCenterStaticEntryGroup> safetyCenterStaticEntryGroups = new ArrayList<>(); SafetyCenterOverallStatusErrorState safetyCenterOverallStatusErrorState = @@ -784,8 +816,7 @@ final class SafetyCenterDataTracker { Math.max( safetyCenterOverallSeverityLevel, addSafetyCenterIssues( - safetyCenterIssues, - allCurrentIssueCategories, + safetyCenterIssuesWithCategories, safetySourcesGroup, userProfileGroup)); int safetySourcesGroupType = safetySourcesGroup.getType(); @@ -820,14 +851,21 @@ final class SafetyCenterDataTracker { boolean hasSettingsToReview = safetyCenterEntriesSeverityLevel > safetyCenterOverallSeverityLevel || safetyCenterOverallStatusErrorState.mHasAtLeastOneUserVisibleError; - safetyCenterIssues.sort(SAFETY_CENTER_ISSUES_BY_SEVERITY_DESCENDING); + safetyCenterIssuesWithCategories.sort(SAFETY_CENTER_ISSUES_BY_SEVERITY_DESCENDING); + + List<SafetyCenterIssue> safetyCenterIssues = + new ArrayList<>(safetyCenterIssuesWithCategories.size()); + for (int i = 0; i < safetyCenterIssuesWithCategories.size(); i++) { + safetyCenterIssues.add(safetyCenterIssuesWithCategories.get(i).getSafetyCenterIssue()); + } + int refreshStatus = mSafetyCenterRefreshTracker.getRefreshStatus(); return new SafetyCenterData( new SafetyCenterStatus.Builder( getSafetyCenterStatusTitle( safetyCenterOverallSeverityLevel, + safetyCenterIssuesWithCategories, refreshStatus, - allCurrentIssueCategories, hasSettingsToReview), getSafetyCenterStatusSummary( safetyCenterOverallSeverityLevel, @@ -844,8 +882,7 @@ final class SafetyCenterDataTracker { @SafetyCenterStatus.OverallSeverityLevel private int addSafetyCenterIssues( - @NonNull List<SafetyCenterIssue> safetyCenterIssues, - @NonNull ArraySet<Integer> allCurrentIssueCategories, + @NonNull List<SafetyCenterIssueWithCategory> safetyCenterIssuesWithCategories, @NonNull SafetySourcesGroup safetySourcesGroup, @NonNull UserProfileGroup userProfileGroup) { int safetyCenterIssuesOverallSeverityLevel = SafetyCenterStatus.OVERALL_SEVERITY_LEVEL_OK; @@ -861,8 +898,7 @@ final class SafetyCenterDataTracker { Math.max( safetyCenterIssuesOverallSeverityLevel, addSafetyCenterIssues( - safetyCenterIssues, - allCurrentIssueCategories, + safetyCenterIssuesWithCategories, safetySource, userProfileGroup.getProfileParentUserId())); @@ -879,8 +915,7 @@ final class SafetyCenterDataTracker { Math.max( safetyCenterIssuesOverallSeverityLevel, addSafetyCenterIssues( - safetyCenterIssues, - allCurrentIssueCategories, + safetyCenterIssuesWithCategories, safetySource, managedRunningProfileUserId)); } @@ -891,8 +926,7 @@ final class SafetyCenterDataTracker { @SafetyCenterStatus.OverallSeverityLevel private int addSafetyCenterIssues( - @NonNull List<SafetyCenterIssue> safetyCenterIssues, - @NonNull ArraySet<Integer> allCurrentIssueCategories, + @NonNull List<SafetyCenterIssueWithCategory> safetyCenterIssuesWithCategories, @NonNull SafetySource safetySource, @UserIdInt int userId) { SafetySourceKey key = SafetySourceKey.of(safetySource.getId(), userId); @@ -917,9 +951,9 @@ final class SafetyCenterDataTracker { safetyCenterIssuesOverallSeverityLevel, toSafetyCenterStatusOverallSeverityLevel( safetySourceIssue.getSeverityLevel())); - safetyCenterIssues.add(safetyCenterIssue); - - allCurrentIssueCategories.add(safetySourceIssue.getIssueCategory()); + safetyCenterIssuesWithCategories.add( + SafetyCenterIssueWithCategory.create( + safetyCenterIssue, safetySourceIssue.getIssueCategory())); } return safetyCenterIssuesOverallSeverityLevel; @@ -941,7 +975,9 @@ final class SafetyCenterDataTracker { .setIssueTypeId(safetySourceIssue.getIssueTypeId()) .build(); - if (isDismissed(safetyCenterIssueId.getSafetyCenterIssueKey())) { + if (isDismissed( + safetyCenterIssueId.getSafetyCenterIssueKey(), + safetySourceIssue.getSeverityLevel())) { return null; } @@ -1047,10 +1083,9 @@ final class SafetyCenterDataTracker { SafetyCenterEntryGroupId.newBuilder() .setSafetySourcesGroupId(safetySourcesGroup.getId()) .build(); - CharSequence groupSummary = getSafetyCenterEntryGroupSummary( - safetySourcesGroup, - groupSafetyCenterEntryLevel, - entries); + CharSequence groupSummary = + getSafetyCenterEntryGroupSummary( + safetySourcesGroup, groupSafetyCenterEntryLevel, entries); safetyCenterEntryOrGroups.add( new SafetyCenterEntryOrGroup( new SafetyCenterEntryGroup.Builder( @@ -1688,17 +1723,13 @@ final class SafetyCenterDataTracker { private String getSafetyCenterStatusTitle( @SafetyCenterStatus.OverallSeverityLevel int overallSeverityLevel, + @NonNull List<SafetyCenterIssueWithCategory> safetyCenterIssuesWithCategories, @SafetyCenterStatus.RefreshStatus int refreshStatus, - @NonNull ArraySet<Integer> allCurrentIssueCategories, boolean hasSettingsToReview) { String refreshStatusTitle = getSafetyCenterRefreshStatusTitle(refreshStatus); if (refreshStatusTitle != null) { return refreshStatusTitle; } - boolean onlyAccountIssuesPresent = - allCurrentIssueCategories.size() == 1 - && allCurrentIssueCategories.contains( - SafetySourceIssue.ISSUE_CATEGORY_ACCOUNT); switch (overallSeverityLevel) { case SafetyCenterStatus.OVERALL_SEVERITY_LEVEL_UNKNOWN: case SafetyCenterStatus.OVERALL_SEVERITY_LEVEL_OK: @@ -1709,25 +1740,48 @@ final class SafetyCenterDataTracker { return mSafetyCenterResourcesContext.getStringByName( "overall_severity_level_ok_title"); case SafetyCenterStatus.OVERALL_SEVERITY_LEVEL_RECOMMENDATION: - if (onlyAccountIssuesPresent) { - return mSafetyCenterResourcesContext.getStringByName( - "overall_severity_level_account_recommendation_title"); - } - return mSafetyCenterResourcesContext.getStringByName( - "overall_severity_level_recommendation_title"); + return getStatusTitleFromIssueCategories( + safetyCenterIssuesWithCategories, + "overall_severity_level_device_recommendation_title", + "overall_severity_level_account_recommendation_title", + "overall_severity_level_safety_recommendation_title"); case SafetyCenterStatus.OVERALL_SEVERITY_LEVEL_CRITICAL_WARNING: - if (onlyAccountIssuesPresent) { - return mSafetyCenterResourcesContext.getStringByName( - "overall_severity_level_critical_account_warning_title"); - } - return mSafetyCenterResourcesContext.getStringByName( - "overall_severity_level_critical_warning_title"); + return getStatusTitleFromIssueCategories( + safetyCenterIssuesWithCategories, + "overall_severity_level_critical_device_warning_title", + "overall_severity_level_critical_account_warning_title", + "overall_severity_level_critical_safety_warning_title"); } Log.w(TAG, "Unexpected SafetyCenterStatus.OverallSeverityLevel: " + overallSeverityLevel); return ""; } + @NonNull + private String getStatusTitleFromIssueCategories( + @NonNull List<SafetyCenterIssueWithCategory> safetyCenterIssuesWithCategories, + @NonNull String deviceResourceName, + @NonNull String accountResourceName, + @NonNull String generalResourceName) { + String generalString = mSafetyCenterResourcesContext.getStringByName(generalResourceName); + if (safetyCenterIssuesWithCategories.isEmpty()) { + Log.w(TAG, "No safety center issues found in a non-green status"); + return generalString; + } + int issueCategory = safetyCenterIssuesWithCategories.get(0).getSafetyCenterIssueCategory(); + switch (issueCategory) { + case SafetySourceIssue.ISSUE_CATEGORY_DEVICE: + return mSafetyCenterResourcesContext.getStringByName(deviceResourceName); + case SafetySourceIssue.ISSUE_CATEGORY_ACCOUNT: + return mSafetyCenterResourcesContext.getStringByName(accountResourceName); + case SafetySourceIssue.ISSUE_CATEGORY_GENERAL: + return generalString; + } + + Log.w(TAG, "Unexpected issueCategory found: " + issueCategory); + return generalString; + } + private String getSafetyCenterStatusSummary( @SafetyCenterStatus.OverallSeverityLevel int overallSeverityLevel, @SafetyCenterStatus.RefreshStatus int refreshStatus, @@ -1834,15 +1888,48 @@ final class SafetyCenterDataTracker { return SafetySourceKey.of(id.getSafetySourceId(), id.getUserId()); } - /** A comparator to order {@link SafetyCenterIssue}s by severity level descending. */ + /** Wrapper that encapsulates both {@link SafetyCenterIssue} and its category. */ + private static final class SafetyCenterIssueWithCategory { + @NonNull private final SafetyCenterIssue mSafetyCenterIssue; + @SafetySourceIssue.IssueCategory private final int mSafetyCenterIssueCategory; + + private SafetyCenterIssueWithCategory( + @NonNull SafetyCenterIssue safetyCenterIssue, + @SafetySourceIssue.IssueCategory int safetyCenterIssueCategory) { + this.mSafetyCenterIssue = safetyCenterIssue; + this.mSafetyCenterIssueCategory = safetyCenterIssueCategory; + } + + @NonNull + public SafetyCenterIssue getSafetyCenterIssue() { + return mSafetyCenterIssue; + } + + @SafetySourceIssue.IssueCategory + public int getSafetyCenterIssueCategory() { + return mSafetyCenterIssueCategory; + } + + public static SafetyCenterIssueWithCategory create( + @NonNull SafetyCenterIssue safetyCenterIssue, + @SafetySourceIssue.IssueCategory int safetyCenterIssueCategory) { + return new SafetyCenterIssueWithCategory(safetyCenterIssue, safetyCenterIssueCategory); + } + } + + /** A comparator to order {@link SafetyCenterIssueWithCategory} by severity level descending. */ private static final class SafetyCenterIssuesBySeverityDescending - implements Comparator<SafetyCenterIssue> { + implements Comparator<SafetyCenterIssueWithCategory> { SafetyCenterIssuesBySeverityDescending() {} @Override - public int compare(@NonNull SafetyCenterIssue left, @NonNull SafetyCenterIssue right) { - return Integer.compare(right.getSeverityLevel(), left.getSeverityLevel()); + public int compare( + @NonNull SafetyCenterIssueWithCategory left, + @NonNull SafetyCenterIssueWithCategory right) { + return Integer.compare( + right.getSafetyCenterIssue().getSeverityLevel(), + left.getSafetyCenterIssue().getSeverityLevel()); } } diff --git a/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterActivityTest.kt b/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterActivityTest.kt index 5c4177db7..56bcd0591 100644 --- a/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterActivityTest.kt +++ b/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterActivityTest.kt @@ -132,7 +132,7 @@ class SafetyCenterActivityTest { @Test fun launchActivity_displaysSafetyData() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) - val dataToDisplay = safetySourceCtsData.criticalWithResolvingIssue + val dataToDisplay = safetySourceCtsData.criticalWithResolvingGeneralIssue safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, dataToDisplay) context.launchSafetyCenterActivity { assertSourceDataDisplayed(dataToDisplay) } @@ -144,7 +144,7 @@ class SafetyCenterActivityTest { safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, safetySourceCtsData.information) context.launchSafetyCenterActivity { - val dataToDisplay = safetySourceCtsData.recommendationWithIssue + val dataToDisplay = safetySourceCtsData.recommendationWithGeneralIssue safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, dataToDisplay) assertSourceDataDisplayed(dataToDisplay) @@ -207,7 +207,7 @@ class SafetyCenterActivityTest { fun issueCard_criticalIssue_hasContentDescriptions() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) context.launchSafetyCenterActivity { waitFindObject(By.desc("Alert. Critical issue title. Critical issue summary")) @@ -248,14 +248,14 @@ class SafetyCenterActivityTest { fun issueCard_confirmsDismissal_dismisses() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) context.launchSafetyCenterActivity { waitFindObject(By.desc("Dismiss")).click() waitFindObject(By.text("Dismiss this alert?")) findButton("Dismiss").click() - assertSourceIssueNotDisplayed(safetySourceCtsData.criticalResolvingIssue) + assertSourceIssueNotDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) findButton("Scan device") } } @@ -264,7 +264,7 @@ class SafetyCenterActivityTest { fun issueCard_confirmsDismissal_afterRotation_dismisses() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) context.launchSafetyCenterActivity { waitFindObject(By.desc("Dismiss")).click() @@ -283,7 +283,7 @@ class SafetyCenterActivityTest { "Review your security and privacy settings any time to add more protection")) findButton("Dismiss").click() - assertSourceIssueNotDisplayed(safetySourceCtsData.criticalResolvingIssue) + assertSourceIssueNotDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) findButton("Scan device") } } @@ -292,14 +292,14 @@ class SafetyCenterActivityTest { fun issueCard_confirmsDismissal_cancels() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) context.launchSafetyCenterActivity { waitFindObject(By.desc("Dismiss")).click() waitFindObject(By.text("Dismiss this alert?")) findButton("Cancel").click() - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) } } @@ -307,7 +307,7 @@ class SafetyCenterActivityTest { fun issueCard_confirmsDismissal_afterRotation_cancels() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) context.launchSafetyCenterActivity { waitFindObject(By.desc("Dismiss")).click() @@ -320,7 +320,7 @@ class SafetyCenterActivityTest { waitFindObject(By.text("Dismiss this alert?")) findButton("Cancel").click() - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) } } @@ -361,7 +361,7 @@ class SafetyCenterActivityTest { // Set the initial data for the source safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) // Clear the data when action is triggered to simulate resolution. SafetySourceReceiver.safetySourceData[ @@ -378,7 +378,7 @@ class SafetyCenterActivityTest { // Wait for success message to go away, verify issue no longer displayed waitTextNotDisplayed("Complete") - assertSourceIssueNotDisplayed(safetySourceCtsData.criticalResolvingIssue) + assertSourceIssueNotDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) }, SEND_SAFETY_CENTER_UPDATE) } @@ -389,7 +389,7 @@ class SafetyCenterActivityTest { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) // Set the initial data for the source - val data = safetySourceCtsData.criticalWithResolvingIssue + val data = safetySourceCtsData.criticalWithResolvingGeneralIssue safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, data) // Respond with an error when the action is triggered @@ -405,7 +405,7 @@ class SafetyCenterActivityTest { // criticalResolvingAction does not define a success message, check for default waitTextNotDisplayed("Complete") - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) }, SEND_SAFETY_CENTER_UPDATE) } @@ -416,7 +416,7 @@ class SafetyCenterActivityTest { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) // Set the initial data for the source - val data = safetySourceCtsData.criticalWithResolvingIssue + val data = safetySourceCtsData.criticalWithResolvingGeneralIssue safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, data) SafetyCenterFlags.resolveActionTimeout = TIMEOUT_SHORT @@ -431,7 +431,7 @@ class SafetyCenterActivityTest { // criticalResolvingAction does not define a success message, check for default waitTextNotDisplayed("Complete") - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) }, SEND_SAFETY_CENTER_UPDATE) } @@ -456,8 +456,10 @@ class SafetyCenterActivityTest { @Test fun launchActivity_fromQuickSettings_issuesExpanded() { safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) - safetyCenterCtsHelper.setData(SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingIssue) - safetyCenterCtsHelper.setData(SOURCE_ID_2, safetySourceCtsData.recommendationWithIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingGeneralIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_2, safetySourceCtsData.recommendationWithGeneralIssue) safetyCenterCtsHelper.setData(SOURCE_ID_3, safetySourceCtsData.informationWithIssue) val bundle = Bundle() @@ -465,8 +467,8 @@ class SafetyCenterActivityTest { context.launchSafetyCenterActivity(bundle) { // Verify cards expanded waitTextNotDisplayed("See all alerts") - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) - assertSourceIssueDisplayed(safetySourceCtsData.recommendationIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) + assertSourceIssueDisplayed(safetySourceCtsData.recommendationGeneralIssue) assertSourceIssueDisplayed(safetySourceCtsData.informationIssue) } } @@ -474,17 +476,19 @@ class SafetyCenterActivityTest { @Test fun launchActivity_fromNotification_targetIssueAlreadyFirstIssue() { safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) - safetyCenterCtsHelper.setData(SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingIssue) - safetyCenterCtsHelper.setData(SOURCE_ID_2, safetySourceCtsData.recommendationWithIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingGeneralIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_2, safetySourceCtsData.recommendationWithGeneralIssue) safetyCenterCtsHelper.setData(SOURCE_ID_3, safetySourceCtsData.informationWithIssue) val bundle = Bundle() bundle.putString(EXTRA_SAFETY_SOURCE_ID, SOURCE_ID_1) bundle.putString(EXTRA_SAFETY_SOURCE_ISSUE_ID, CRITICAL_ISSUE_ID) context.launchSafetyCenterActivity(bundle) { - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) waitFindObject(By.text("See all alerts")) - assertSourceIssueNotDisplayed(safetySourceCtsData.recommendationIssue) + assertSourceIssueNotDisplayed(safetySourceCtsData.recommendationGeneralIssue) assertSourceIssueNotDisplayed(safetySourceCtsData.informationIssue) } } @@ -492,7 +496,8 @@ class SafetyCenterActivityTest { @Test fun launchActivity_fromNotification_targetIssueSamePriorityAsFirstIssue_reorderedFirstIssue() { safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) - safetyCenterCtsHelper.setData(SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingGeneralIssue) safetyCenterCtsHelper.setData(SOURCE_ID_2, safetySourceCtsData.criticalWithRedirectingIssue) safetyCenterCtsHelper.setData(SOURCE_ID_3, safetySourceCtsData.informationWithIssue) @@ -502,7 +507,7 @@ class SafetyCenterActivityTest { context.launchSafetyCenterActivity(bundle) { assertSourceIssueDisplayed(safetySourceCtsData.criticalRedirectingIssue) waitFindObject(By.text("See all alerts")) - assertSourceIssueNotDisplayed(safetySourceCtsData.criticalResolvingIssue) + assertSourceIssueNotDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) assertSourceIssueNotDisplayed(safetySourceCtsData.informationIssue) } } @@ -510,16 +515,18 @@ class SafetyCenterActivityTest { @Test fun launchActivity_fromNotification_targetLowerPriorityAsFirstIssue_reorderedSecondIssue() { safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) - safetyCenterCtsHelper.setData(SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingIssue) - safetyCenterCtsHelper.setData(SOURCE_ID_2, safetySourceCtsData.recommendationWithIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingGeneralIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_2, safetySourceCtsData.recommendationWithGeneralIssue) safetyCenterCtsHelper.setData(SOURCE_ID_3, safetySourceCtsData.informationWithIssue) val bundle = Bundle() bundle.putString(EXTRA_SAFETY_SOURCE_ID, SOURCE_ID_2) bundle.putString(EXTRA_SAFETY_SOURCE_ISSUE_ID, RECOMMENDATION_ISSUE_ID) context.launchSafetyCenterActivity(bundle) { - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) - assertSourceIssueDisplayed(safetySourceCtsData.recommendationIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) + assertSourceIssueDisplayed(safetySourceCtsData.recommendationGeneralIssue) waitFindObject(By.text("See all alerts")) assertSourceIssueNotDisplayed(safetySourceCtsData.informationIssue) } @@ -528,17 +535,19 @@ class SafetyCenterActivityTest { @Test fun launchActivity_fromNotification_targetIssueNotFound() { safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) - safetyCenterCtsHelper.setData(SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingIssue) - safetyCenterCtsHelper.setData(SOURCE_ID_2, safetySourceCtsData.recommendationWithIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingGeneralIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_2, safetySourceCtsData.recommendationWithGeneralIssue) safetyCenterCtsHelper.setData(SOURCE_ID_3, safetySourceCtsData.informationWithIssue) val bundle = Bundle() bundle.putString(EXTRA_SAFETY_SOURCE_ID, SOURCE_ID_2) bundle.putString(EXTRA_SAFETY_SOURCE_ISSUE_ID, CRITICAL_ISSUE_ID) context.launchSafetyCenterActivity(bundle) { - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) waitFindObject(By.text("See all alerts")) - assertSourceIssueNotDisplayed(safetySourceCtsData.recommendationIssue) + assertSourceIssueNotDisplayed(safetySourceCtsData.recommendationGeneralIssue) assertSourceIssueNotDisplayed(safetySourceCtsData.informationIssue) } } @@ -547,10 +556,10 @@ class SafetyCenterActivityTest { fun moreIssuesCard_underMaxShownIssues_noMoreIssuesCard() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) context.launchSafetyCenterActivity { - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) waitTextNotDisplayed("See all alerts") } } @@ -558,14 +567,16 @@ class SafetyCenterActivityTest { @Test fun moreIssuesCard_moreIssuesCardShown_additionalIssueCardsCollapsed() { safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) - safetyCenterCtsHelper.setData(SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingIssue) - safetyCenterCtsHelper.setData(SOURCE_ID_2, safetySourceCtsData.recommendationWithIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingGeneralIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_2, safetySourceCtsData.recommendationWithGeneralIssue) safetyCenterCtsHelper.setData(SOURCE_ID_3, safetySourceCtsData.informationWithIssue) context.launchSafetyCenterActivity { - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) waitFindObject(By.text("See all alerts")) - assertSourceIssueNotDisplayed(safetySourceCtsData.recommendationIssue) + assertSourceIssueNotDisplayed(safetySourceCtsData.recommendationGeneralIssue) assertSourceIssueNotDisplayed(safetySourceCtsData.informationIssue) } } @@ -573,19 +584,21 @@ class SafetyCenterActivityTest { @Test fun moreIssuesCard_expandAdditionalIssueCards() { safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) - safetyCenterCtsHelper.setData(SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingIssue) - safetyCenterCtsHelper.setData(SOURCE_ID_2, safetySourceCtsData.recommendationWithIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingGeneralIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_2, safetySourceCtsData.recommendationWithGeneralIssue) safetyCenterCtsHelper.setData(SOURCE_ID_3, safetySourceCtsData.informationWithIssue) context.launchSafetyCenterActivity { - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) expandMoreIssuesCard() // Verify cards expanded waitTextNotDisplayed("See all alerts") - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) - assertSourceIssueDisplayed(safetySourceCtsData.recommendationIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) + assertSourceIssueDisplayed(safetySourceCtsData.recommendationGeneralIssue) assertSourceIssueDisplayed(safetySourceCtsData.informationIssue) } } @@ -593,8 +606,10 @@ class SafetyCenterActivityTest { @Test fun moreIssuesCard_rotation_cardsStillExpanded() { safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) - safetyCenterCtsHelper.setData(SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingIssue) - safetyCenterCtsHelper.setData(SOURCE_ID_2, safetySourceCtsData.recommendationWithIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingGeneralIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_2, safetySourceCtsData.recommendationWithGeneralIssue) safetyCenterCtsHelper.setData(SOURCE_ID_3, safetySourceCtsData.informationWithIssue) context.launchSafetyCenterActivity { @@ -605,8 +620,8 @@ class SafetyCenterActivityTest { // Verify cards initially expanded waitTextNotDisplayed("See all alerts") - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) - assertSourceIssueDisplayed(safetySourceCtsData.recommendationIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) + assertSourceIssueDisplayed(safetySourceCtsData.recommendationGeneralIssue) assertSourceIssueDisplayed(safetySourceCtsData.informationIssue) // Device rotation to trigger usage of savedinstancestate via config update @@ -614,8 +629,8 @@ class SafetyCenterActivityTest { // Verify cards remain expanded waitTextNotDisplayed("See all alerts") - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) - assertSourceIssueDisplayed(safetySourceCtsData.recommendationIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) + assertSourceIssueDisplayed(safetySourceCtsData.recommendationGeneralIssue) assertSourceIssueDisplayed(safetySourceCtsData.informationIssue) } } @@ -623,16 +638,18 @@ class SafetyCenterActivityTest { @Test fun moreIssuesCard_twoIssuesAlreadyShown_expandAdditionalIssueCards() { safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) - safetyCenterCtsHelper.setData(SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingIssue) - safetyCenterCtsHelper.setData(SOURCE_ID_2, safetySourceCtsData.recommendationWithIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingGeneralIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_2, safetySourceCtsData.recommendationWithGeneralIssue) safetyCenterCtsHelper.setData(SOURCE_ID_3, safetySourceCtsData.informationWithIssue) val bundle = Bundle() bundle.putString(EXTRA_SAFETY_SOURCE_ID, SOURCE_ID_2) bundle.putString(EXTRA_SAFETY_SOURCE_ISSUE_ID, RECOMMENDATION_ISSUE_ID) context.launchSafetyCenterActivity(bundle) { - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) - assertSourceIssueDisplayed(safetySourceCtsData.recommendationIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) + assertSourceIssueDisplayed(safetySourceCtsData.recommendationGeneralIssue) waitFindObject(By.text("See all alerts")) assertSourceIssueNotDisplayed(safetySourceCtsData.informationIssue) @@ -640,8 +657,8 @@ class SafetyCenterActivityTest { // Verify cards expanded waitTextNotDisplayed("See all alerts") - assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingIssue) - assertSourceIssueDisplayed(safetySourceCtsData.recommendationIssue) + assertSourceIssueDisplayed(safetySourceCtsData.criticalResolvingGeneralIssue) + assertSourceIssueDisplayed(safetySourceCtsData.recommendationGeneralIssue) assertSourceIssueDisplayed(safetySourceCtsData.informationIssue) } } diff --git a/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterManagedDeviceTest.kt b/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterManagedDeviceTest.kt index 42872bf56..56cb44b43 100644 --- a/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterManagedDeviceTest.kt +++ b/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterManagedDeviceTest.kt @@ -252,9 +252,10 @@ class SafetyCenterManagedDeviceTest { @EnsureHasWorkProfile(installInstrumentedApp = TRUE) fun setSafetySourceData_issuesOnlySourceWithWorkProfile_shouldBeAbleToSetData() { val managedSafetyCenterManager = getManagedSafetyCenterManager() - val dataToSet = SafetySourceCtsData.issuesOnly(safetySourceCtsData.recommendationIssue) + val dataToSet = + SafetySourceCtsData.issuesOnly(safetySourceCtsData.recommendationGeneralIssue) val dataToSetForWork = - SafetySourceCtsData.issuesOnly(safetySourceCtsData.criticalResolvingIssue) + SafetySourceCtsData.issuesOnly(safetySourceCtsData.criticalResolvingGeneralIssue) safetyCenterCtsHelper.setConfig(ISSUE_ONLY_SOURCE_ALL_PROFILE_CONFIG) safetyCenterCtsHelper.setData(ISSUE_ONLY_ALL_PROFILE_SOURCE_ID, dataToSet) managedSafetyCenterManager.setSafetySourceDataWithPermissionForManagedUser( diff --git a/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterManagerTest.kt b/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterManagerTest.kt index 175e9b9bf..2a44bd1d1 100644 --- a/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterManagerTest.kt +++ b/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterManagerTest.kt @@ -57,8 +57,10 @@ import android.safetycenter.SafetySourceData.SEVERITY_LEVEL_INFORMATION import android.safetycenter.SafetySourceData.SEVERITY_LEVEL_RECOMMENDATION import android.safetycenter.SafetySourceData.SEVERITY_LEVEL_UNSPECIFIED import android.safetycenter.SafetySourceErrorDetails +import android.safetycenter.SafetySourceIssue import android.safetycenter.cts.testing.Coroutines.TIMEOUT_LONG import android.safetycenter.cts.testing.Coroutines.TIMEOUT_SHORT +import android.safetycenter.cts.testing.Coroutines.waitForWithTimeout import android.safetycenter.cts.testing.FakeExecutor import android.safetycenter.cts.testing.SafetyCenterApisWithShellPermissions.addOnSafetyCenterDataChangedListenerWithPermission import android.safetycenter.cts.testing.SafetyCenterApisWithShellPermissions.clearAllSafetySourceDataForTestsWithPermission @@ -137,8 +139,10 @@ import androidx.test.core.app.ApplicationProvider.getApplicationContext import androidx.test.ext.junit.runners.AndroidJUnit4 import com.android.compatibility.common.preconditions.ScreenLockHelper import com.android.safetycenter.resources.SafetyCenterResourcesContext +import com.google.common.base.Preconditions.checkState import com.google.common.truth.Truth.assertThat import com.google.common.util.concurrent.MoreExecutors.directExecutor +import java.time.Duration import java.util.Locale import kotlin.test.assertFailsWith import kotlinx.coroutines.TimeoutCancellationException @@ -196,10 +200,10 @@ class SafetyCenterManagerTest { .setSeverityLevel(OVERALL_SEVERITY_LEVEL_OK) .build() - private val safetyCenterStatusRecommendationOneAlert = + private val safetyCenterStatusGeneralRecommendationOneAlert = SafetyCenterStatus.Builder( safetyCenterResourcesContext.getStringByName( - "overall_severity_level_recommendation_title"), + "overall_severity_level_safety_recommendation_title"), getAlertString(1)) .setSeverityLevel(OVERALL_SEVERITY_LEVEL_RECOMMENDATION) .build() @@ -212,18 +216,26 @@ class SafetyCenterManagerTest { .setSeverityLevel(OVERALL_SEVERITY_LEVEL_RECOMMENDATION) .build() - private val safetyCenterStatusCriticalOneAlert = + private val safetyCenterStatusDeviceRecommendationOneAlert = SafetyCenterStatus.Builder( safetyCenterResourcesContext.getStringByName( - "overall_severity_level_critical_warning_title"), + "overall_severity_level_device_recommendation_title"), + getAlertString(1)) + .setSeverityLevel(OVERALL_SEVERITY_LEVEL_RECOMMENDATION) + .build() + + private val safetyCenterStatusGeneralCriticalOneAlert = + SafetyCenterStatus.Builder( + safetyCenterResourcesContext.getStringByName( + "overall_severity_level_critical_safety_warning_title"), getAlertString(1)) .setSeverityLevel(OVERALL_SEVERITY_LEVEL_CRITICAL_WARNING) .build() - private val safetyCenterStatusCriticalTwoAlerts = + private val safetyCenterStatusGeneralCriticalTwoAlerts = SafetyCenterStatus.Builder( safetyCenterResourcesContext.getStringByName( - "overall_severity_level_critical_warning_title"), + "overall_severity_level_critical_safety_warning_title"), getAlertString(2)) .setSeverityLevel(OVERALL_SEVERITY_LEVEL_CRITICAL_WARNING) .build() @@ -236,10 +248,34 @@ class SafetyCenterManagerTest { .setSeverityLevel(OVERALL_SEVERITY_LEVEL_CRITICAL_WARNING) .build() + private val safetyCenterStatusAccountCriticalTwoAlerts = + SafetyCenterStatus.Builder( + safetyCenterResourcesContext.getStringByName( + "overall_severity_level_critical_account_warning_title"), + getAlertString(2)) + .setSeverityLevel(OVERALL_SEVERITY_LEVEL_CRITICAL_WARNING) + .build() + + private val safetyCenterStatusDeviceCriticalOneAlert = + SafetyCenterStatus.Builder( + safetyCenterResourcesContext.getStringByName( + "overall_severity_level_critical_device_warning_title"), + getAlertString(1)) + .setSeverityLevel(OVERALL_SEVERITY_LEVEL_CRITICAL_WARNING) + .build() + + private val safetyCenterStatusDeviceCriticalTwoAlerts = + SafetyCenterStatus.Builder( + safetyCenterResourcesContext.getStringByName( + "overall_severity_level_critical_device_warning_title"), + getAlertString(2)) + .setSeverityLevel(OVERALL_SEVERITY_LEVEL_CRITICAL_WARNING) + .build() + private val safetyCenterStatusCriticalSixAlerts = SafetyCenterStatus.Builder( safetyCenterResourcesContext.getStringByName( - "overall_severity_level_critical_warning_title"), + "overall_severity_level_critical_safety_warning_title"), getAlertString(6)) .setSeverityLevel(OVERALL_SEVERITY_LEVEL_CRITICAL_WARNING) .build() @@ -385,9 +421,9 @@ class SafetyCenterManagerTest { listOf(safetyCenterEntryOrGroupCritical), emptyList()) - private val safetyCenterDataRecommendationOneAlert = + private val safetyCenterDataGeneralRecommendationOneAlert = SafetyCenterData( - safetyCenterStatusRecommendationOneAlert, + safetyCenterStatusGeneralRecommendationOneAlert, listOf(safetyCenterIssueRecommendation(SINGLE_SOURCE_ID)), listOf(SafetyCenterEntryOrGroup(safetyCenterEntryRecommendation(SINGLE_SOURCE_ID))), emptyList()) @@ -399,9 +435,16 @@ class SafetyCenterManagerTest { listOf(SafetyCenterEntryOrGroup(safetyCenterEntryRecommendation(SINGLE_SOURCE_ID))), emptyList()) - private val safetyCenterDataCriticalOneAlert = + private val safetyCenterDataDeviceRecommendationOneAlert = SafetyCenterData( - safetyCenterStatusCriticalOneAlert, + safetyCenterStatusDeviceRecommendationOneAlert, + listOf(safetyCenterIssueRecommendation(SINGLE_SOURCE_ID)), + listOf(SafetyCenterEntryOrGroup(safetyCenterEntryRecommendation(SINGLE_SOURCE_ID))), + emptyList()) + + private val safetyCenterDataGeneralCriticalOneAlert = + SafetyCenterData( + safetyCenterStatusGeneralCriticalOneAlert, listOf(safetyCenterIssueCritical(SINGLE_SOURCE_ID)), listOf(safetyCenterEntryOrGroupCritical), emptyList()) @@ -413,18 +456,16 @@ class SafetyCenterManagerTest { listOf(safetyCenterEntryOrGroupCritical), emptyList()) - private val safetyCenterDataCriticalTwoAlerts = + private val safetyCenterDataDeviceCriticalOneAlert = SafetyCenterData( - safetyCenterStatusCriticalTwoAlerts, - listOf( - safetyCenterIssueCritical(SINGLE_SOURCE_ID), - safetyCenterIssueRecommendation(SINGLE_SOURCE_ID)), + safetyCenterStatusDeviceCriticalOneAlert, + listOf(safetyCenterIssueCritical(SINGLE_SOURCE_ID)), listOf(safetyCenterEntryOrGroupCritical), emptyList()) private val safetyCenterDataCriticalOneAlertInFlight = SafetyCenterData( - safetyCenterStatusCriticalOneAlert, + safetyCenterStatusGeneralCriticalOneAlert, listOf(safetyCenterIssueCritical(SINGLE_SOURCE_ID, isActionInFlight = true)), listOf(safetyCenterEntryOrGroupCritical), emptyList()) @@ -561,7 +602,7 @@ class SafetyCenterManagerTest { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, safetySourceCtsData.unspecified) - val dataToSet = safetySourceCtsData.criticalWithResolvingIssue + val dataToSet = safetySourceCtsData.criticalWithResolvingGeneralIssue safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, dataToSet) val apiSafetySourceData = @@ -770,7 +811,7 @@ class SafetyCenterManagerTest { val thrown = assertFailsWith(IllegalArgumentException::class) { safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) } assertThat(thrown) @@ -785,7 +826,7 @@ class SafetyCenterManagerTest { fun setSafetySourceData_withMaxSevRecommendation_met() { safetyCenterCtsHelper.setConfig(COMPLEX_CONFIG) - val dataToSet = safetySourceCtsData.recommendationWithIssue + val dataToSet = safetySourceCtsData.recommendationWithGeneralIssue safetyCenterCtsHelper.setData(DYNAMIC_ALL_OPTIONAL_ID, dataToSet) val apiSafetySourceData = @@ -800,7 +841,7 @@ class SafetyCenterManagerTest { val thrown = assertFailsWith(IllegalArgumentException::class) { safetyCenterCtsHelper.setData( - DYNAMIC_ALL_OPTIONAL_ID, safetySourceCtsData.criticalWithResolvingIssue) + DYNAMIC_ALL_OPTIONAL_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) } assertThat(thrown) @@ -815,7 +856,8 @@ class SafetyCenterManagerTest { fun setSafetySourceData_issueOnlyWithMaxSevRecommendation_met() { safetyCenterCtsHelper.setConfig(COMPLEX_CONFIG) - val dataToSet = SafetySourceCtsData.issuesOnly(safetySourceCtsData.recommendationIssue) + val dataToSet = + SafetySourceCtsData.issuesOnly(safetySourceCtsData.recommendationGeneralIssue) safetyCenterCtsHelper.setData(ISSUE_ONLY_ALL_OPTIONAL_ID, dataToSet) val apiSafetySourceData = @@ -831,7 +873,8 @@ class SafetyCenterManagerTest { assertFailsWith(IllegalArgumentException::class) { safetyCenterCtsHelper.setData( ISSUE_ONLY_ALL_OPTIONAL_ID, - SafetySourceCtsData.issuesOnly(safetySourceCtsData.criticalResolvingIssue)) + SafetySourceCtsData.issuesOnly( + safetySourceCtsData.criticalResolvingGeneralIssue)) } assertThat(thrown) @@ -1087,22 +1130,22 @@ class SafetyCenterManagerTest { fun refreshSafetySources_withRefreshReasonRescanButtonClick_sourceSendsRescanData() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = - safetySourceCtsData.criticalWithResolvingIssue - + SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = + safetySourceCtsData.criticalWithResolvingGeneralIssue safetyCenterManager.refreshSafetySourcesWithReceiverPermissionAndWait( REFRESH_REASON_RESCAN_BUTTON_CLICK) val apiSafetySourceData = safetyCenterManager.getSafetySourceDataWithPermission(SINGLE_SOURCE_ID) - assertThat(apiSafetySourceData).isEqualTo(safetySourceCtsData.criticalWithResolvingIssue) + assertThat(apiSafetySourceData) + .isEqualTo(safetySourceCtsData.criticalWithResolvingGeneralIssue) } @Test fun refreshSafetySources_withRefreshReasonPageOpen_sourceSendsPageOpenData() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = + SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = safetySourceCtsData.information safetyCenterManager.refreshSafetySourcesWithReceiverPermissionAndWait( @@ -1117,7 +1160,7 @@ class SafetyCenterManagerTest { fun refreshSafetySources_withRefreshReasonPageOpen_notCalledIfSourceDoesntSupportPageOpen() { safetyCenterCtsHelper.setConfig(NO_PAGE_OPEN_CONFIG) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = + SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = safetySourceCtsData.information assertFailsWith(TimeoutCancellationException::class) { @@ -1135,7 +1178,7 @@ class SafetyCenterManagerTest { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, safetySourceCtsData.information) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = null + SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = null safetyCenterManager.refreshSafetySourcesWithReceiverPermissionAndWait( REFRESH_REASON_RESCAN_BUTTON_CLICK) @@ -1149,10 +1192,10 @@ class SafetyCenterManagerTest { fun refreshSafetySources_withMultipleSourcesInConfig_multipleSourcesSendData() { safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SOURCE_ID_1)] = - safetySourceCtsData.criticalWithResolvingIssue + SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SOURCE_ID_1)] = + safetySourceCtsData.criticalWithResolvingGeneralIssue SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SOURCE_ID_3)] = + SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SOURCE_ID_3)] = safetySourceCtsData.information safetyCenterManager.refreshSafetySourcesWithReceiverPermissionAndWait( @@ -1160,7 +1203,8 @@ class SafetyCenterManagerTest { val apiSafetySourceData1 = safetyCenterManager.getSafetySourceDataWithPermission(SOURCE_ID_1) - assertThat(apiSafetySourceData1).isEqualTo(safetySourceCtsData.criticalWithResolvingIssue) + assertThat(apiSafetySourceData1) + .isEqualTo(safetySourceCtsData.criticalWithResolvingGeneralIssue) val apiSafetySourceData2 = safetyCenterManager.getSafetySourceDataWithPermission(SOURCE_ID_2) assertThat(apiSafetySourceData2).isNull() @@ -1173,7 +1217,7 @@ class SafetyCenterManagerTest { fun refreshSafetySources_withMultipleSourcesOnPageOpen_onlyUpdatesAllowedSources() { safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) SafetySourceReceiver.safetySourceData[SafetySourceDataKey(REFRESH_GET_DATA, SOURCE_ID_1)] = - safetySourceCtsData.criticalWithResolvingIssue + safetySourceCtsData.criticalWithResolvingGeneralIssue SafetySourceReceiver.safetySourceData[SafetySourceDataKey(REFRESH_GET_DATA, SOURCE_ID_3)] = safetySourceCtsData.information @@ -1182,7 +1226,8 @@ class SafetyCenterManagerTest { val apiSafetySourceData1 = safetyCenterManager.getSafetySourceDataWithPermission(SOURCE_ID_1) - assertThat(apiSafetySourceData1).isEqualTo(safetySourceCtsData.criticalWithResolvingIssue) + assertThat(apiSafetySourceData1) + .isEqualTo(safetySourceCtsData.criticalWithResolvingGeneralIssue) val apiSafetySourceData2 = safetyCenterManager.getSafetySourceDataWithPermission(SOURCE_ID_2) assertThat(apiSafetySourceData2).isNull() @@ -1196,8 +1241,8 @@ class SafetyCenterManagerTest { fun refreshSafetySources_whenReceiverDoesntHavePermission_sourceDoesntSendData() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = - safetySourceCtsData.criticalWithResolvingIssue + SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = + safetySourceCtsData.criticalWithResolvingGeneralIssue assertFailsWith(TimeoutCancellationException::class) { safetyCenterManager.refreshSafetySourcesWithoutReceiverPermissionAndWait( @@ -1211,7 +1256,7 @@ class SafetyCenterManagerTest { @Test fun refreshSafetySources_whenSourceNotInConfig_sourceDoesntSendData() { SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = + SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = safetySourceCtsData.information assertFailsWith(TimeoutCancellationException::class) { @@ -1235,7 +1280,7 @@ class SafetyCenterManagerTest { fun refreshSafetySources_sendsDifferentBroadcastIdsOnEachMethodCall() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = + SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = safetySourceCtsData.information val broadcastId1 = @@ -1253,7 +1298,7 @@ class SafetyCenterManagerTest { SafetyCenterFlags.refreshTimeout = TIMEOUT_SHORT safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = + SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = safetySourceCtsData.information SafetySourceReceiver.overrideBroadcastId = "invalid" val listener = safetyCenterCtsHelper.addListener() @@ -1277,27 +1322,28 @@ class SafetyCenterManagerTest { fun refreshSafetySources_refreshAfterSuccessfulRefresh_completesSuccessfully() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = + SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = safetySourceCtsData.information safetyCenterManager.refreshSafetySourcesWithReceiverPermissionAndWait( REFRESH_REASON_PAGE_OPEN) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = - safetySourceCtsData.criticalWithResolvingIssue + SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = + safetySourceCtsData.criticalWithResolvingGeneralIssue safetyCenterManager.refreshSafetySourcesWithReceiverPermissionAndWait( REFRESH_REASON_PAGE_OPEN) val apiSafetySourceData = safetyCenterManager.getSafetySourceDataWithPermission(SINGLE_SOURCE_ID) - assertThat(apiSafetySourceData).isEqualTo(safetySourceCtsData.criticalWithResolvingIssue) + assertThat(apiSafetySourceData) + .isEqualTo(safetySourceCtsData.criticalWithResolvingGeneralIssue) } @Test fun refreshSafetySources_refreshAfterFailedRefresh_completesSuccessfully() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = + SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = safetySourceCtsData.information SafetySourceReceiver.shouldReportSafetySourceError = true safetyCenterManager.refreshSafetySourcesWithReceiverPermissionAndWait( @@ -1327,7 +1373,7 @@ class SafetyCenterManagerTest { listener.receiveSafetyCenterErrorDetails() SafetyCenterFlags.refreshTimeout = TIMEOUT_LONG SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = + SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = safetySourceCtsData.information safetyCenterManager.refreshSafetySourcesWithReceiverPermissionAndWait( @@ -1343,7 +1389,7 @@ class SafetyCenterManagerTest { safetyCenterManager.refreshSafetySourcesWithReceiverPermissionAndWait( REFRESH_REASON_PAGE_OPEN) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = + SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = safetySourceCtsData.information safetyCenterManager.refreshSafetySourcesWithReceiverPermissionAndWait( @@ -1361,7 +1407,7 @@ class SafetyCenterManagerTest { // SOURCE_ID_1 will timeout for (sourceId in listOf(SOURCE_ID_2, SOURCE_ID_3)) { SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, sourceId)] = + SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, sourceId)] = safetySourceCtsData.information } val listener = safetyCenterCtsHelper.addListener() @@ -1384,7 +1430,7 @@ class SafetyCenterManagerTest { // SOURCE_ID_1 will timeout for (sourceId in listOf(SOURCE_ID_2, SOURCE_ID_3)) { SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, sourceId)] = + SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, sourceId)] = safetySourceCtsData.information } val listener = safetyCenterCtsHelper.addListener() @@ -1404,7 +1450,7 @@ class SafetyCenterManagerTest { safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) // SOURCE_ID_1 and SOURCE_ID_2 will timeout SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SOURCE_ID_3)] = + SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SOURCE_ID_3)] = safetySourceCtsData.information val listener = safetyCenterCtsHelper.addListener() @@ -1478,7 +1524,7 @@ class SafetyCenterManagerTest { SafetyCenterFlags.refreshTimeout = TIMEOUT_LONG SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = + SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = safetySourceCtsData.information safetyCenterManager.refreshSafetySourcesWithReceiverPermissionAndWait( REFRESH_REASON_RESCAN_BUTTON_CLICK) @@ -1493,7 +1539,7 @@ class SafetyCenterManagerTest { fun refreshSafetySources_withRefreshReasonRescanButtonClick_notifiesUiDuringRescan() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = + SafetySourceDataKey(REFRESH_FETCH_FRESH_DATA, SINGLE_SOURCE_ID)] = safetySourceCtsData.information val listener = safetyCenterCtsHelper.addListener() @@ -1515,7 +1561,7 @@ class SafetyCenterManagerTest { fun refreshSafetySources_withRefreshReasonPageOpen_notifiesUiWithFetch() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = + SafetySourceDataKey(REFRESH_GET_DATA, SINGLE_SOURCE_ID)] = safetySourceCtsData.information val listener = safetyCenterCtsHelper.addListener() @@ -1627,12 +1673,12 @@ class SafetyCenterManagerTest { val previousApiSafetyCenterData = safetyCenterManager.getSafetySourceDataWithPermission(SINGLE_SOURCE_ID) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val apiSafetyCenterData = safetyCenterManager.getSafetyCenterDataWithPermission() assertThat(apiSafetyCenterData).isNotEqualTo(previousApiSafetyCenterData) - assertThat(apiSafetyCenterData).isEqualTo(safetyCenterDataCriticalOneAlert) + assertThat(apiSafetyCenterData).isEqualTo(safetyCenterDataGeneralCriticalOneAlert) } @Test @@ -1657,17 +1703,18 @@ class SafetyCenterManagerTest { } @Test - fun getSafetyCenterData_withRecommendationIssue_returnsOverallStatusRecommendationOneAlert() { + fun getSafetyCenterData_withRecommendationGeneralIssue_returnsGeneralRecommendationOneAlert() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) - safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, safetySourceCtsData.recommendationWithIssue) + safetyCenterCtsHelper.setData( + SINGLE_SOURCE_ID, safetySourceCtsData.recommendationWithGeneralIssue) val apiSafetyCenterData = safetyCenterManager.getSafetyCenterDataWithPermission() - assertThat(apiSafetyCenterData).isEqualTo(safetyCenterDataRecommendationOneAlert) + assertThat(apiSafetyCenterData).isEqualTo(safetyCenterDataGeneralRecommendationOneAlert) } @Test - fun getSafetyCenterData_withAccountIssue_returnsOverallStatusAccountRecommendationOneAlert() { + fun getSafetyCenterData_withRecommendationAccountIssue_returnsAccountRecommendationOneAlert() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( SINGLE_SOURCE_ID, safetySourceCtsData.recommendationWithAccountIssue) @@ -1678,7 +1725,29 @@ class SafetyCenterManagerTest { } @Test - fun getSafetyCenterData_withAccountIssue_returnsOverallStatusAccountCriticalOneAlert() { + fun getSafetyCenterData_withRecommendationDeviceIssue_returnsDeviceRecommendationOneAlert() { + safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) + safetyCenterCtsHelper.setData( + SINGLE_SOURCE_ID, safetySourceCtsData.recommendationWithDeviceIssue) + + val apiSafetyCenterData = safetyCenterManager.getSafetyCenterDataWithPermission() + + assertThat(apiSafetyCenterData).isEqualTo(safetyCenterDataDeviceRecommendationOneAlert) + } + + @Test + fun getSafetyCenterData_withCriticalGeneralIssue_returnsOverallStatusGeneralCriticalOneAlert() { + safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) + safetyCenterCtsHelper.setData( + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) + + val apiSafetyCenterData = safetyCenterManager.getSafetyCenterDataWithPermission() + + assertThat(apiSafetyCenterData).isEqualTo(safetyCenterDataGeneralCriticalOneAlert) + } + + @Test + fun getSafetyCenterData_withCriticalAccountIssue_returnsOverallStatusAccountCriticalOneAlert() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingAccountIssue) @@ -1689,31 +1758,94 @@ class SafetyCenterManagerTest { } @Test - fun getSafetyCenterData_withAccountAndOtherIssue_returnsOverallStatusCriticalTwoAlerts() { + fun getSafetyCenterData_withCriticalDeviceIssue_returnsOverallStatusDeviceCriticalOneAlert() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) - safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithTwoIssues) + safetyCenterCtsHelper.setData( + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingDeviceIssue) val apiSafetyCenterData = safetyCenterManager.getSafetyCenterDataWithPermission() - assertThat(apiSafetyCenterData).isEqualTo(safetyCenterDataCriticalTwoAlerts) + assertThat(apiSafetyCenterData).isEqualTo(safetyCenterDataDeviceCriticalOneAlert) + } + + @Test + fun getSafetyCenterData_singleSourceIssues_returnsOverallStatusBasedOnHigherSeverityIssue() { + safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) + safetyCenterCtsHelper.setData( + SINGLE_SOURCE_ID, + safetySourceCtsData.criticalWithResolvingDeviceIssueAndRecommendationIssue) + + val apiSafetyCenterStatus = safetyCenterManager.getSafetyCenterDataWithPermission().status + + assertThat(apiSafetyCenterStatus).isEqualTo(safetyCenterStatusDeviceCriticalTwoAlerts) + } + + @Test + fun getSafetyCenterData_multipleSourcesIssues_returnsOverallStatusBasedOnHigherSeverityIssue() { + safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) + safetyCenterCtsHelper.setData( + SOURCE_ID_1, safetySourceCtsData.recommendationWithAccountIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_3, safetySourceCtsData.criticalWithResolvingDeviceIssue) + + val apiSafetyCenterStatus = safetyCenterManager.getSafetyCenterDataWithPermission().status + + assertThat(apiSafetyCenterStatus).isEqualTo(safetyCenterStatusDeviceCriticalTwoAlerts) + } + + @Test + fun getSafetyCenterData_multipleIssues_returnsOverallStatusBasedOnConfigOrdering() { + safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) + safetyCenterCtsHelper.setData( + SOURCE_ID_1, safetySourceCtsData.criticalWithResolvingGeneralIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_3, safetySourceCtsData.criticalWithResolvingDeviceIssue) + + val apiSafetyCenterStatus = safetyCenterManager.getSafetyCenterDataWithPermission().status + + assertThat(apiSafetyCenterStatus).isEqualTo(safetyCenterStatusGeneralCriticalTwoAlerts) + } + + @Test + fun getSafetyCenterData_criticalDeviceIssues_returnsOverallStatusBasedOnAddIssueCallOrder() { + safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) + safetyCenterCtsHelper.setData( + SINGLE_SOURCE_ID, + safetySourceCtsData + .defaultCriticalDataBuilder() + .addIssue( + safetySourceCtsData + .defaultCriticalResolvingIssueBuilder("critical issue num 1") + .setIssueCategory(SafetySourceIssue.ISSUE_CATEGORY_ACCOUNT) + .build()) + .addIssue( + safetySourceCtsData + .defaultCriticalResolvingIssueBuilder("critical issue num 2") + .setIssueCategory(SafetySourceIssue.ISSUE_CATEGORY_DEVICE) + .build()) + .build()) + + val apiSafetyCenterStatus = safetyCenterManager.getSafetyCenterDataWithPermission().status + + assertThat(apiSafetyCenterStatus).isEqualTo(safetyCenterStatusAccountCriticalTwoAlerts) } @Test fun getSafetyCenterData_withComplexConfigWithSomeDataProvided_returnsDataProvided() { safetyCenterCtsHelper.setConfig(COMPLEX_CONFIG) safetyCenterCtsHelper.setData( - DYNAMIC_BAREBONE_ID, safetySourceCtsData.criticalWithResolvingIssue) + DYNAMIC_BAREBONE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) safetyCenterCtsHelper.setData( - DYNAMIC_DISABLED_ID, safetySourceCtsData.recommendationWithIssue) + DYNAMIC_DISABLED_ID, safetySourceCtsData.recommendationWithGeneralIssue) safetyCenterCtsHelper.setData(DYNAMIC_HIDDEN_ID, safetySourceCtsData.unspecified) safetyCenterCtsHelper.setData( DYNAMIC_HIDDEN_WITH_SEARCH_ID, safetySourceCtsData.information) safetyCenterCtsHelper.setData( ISSUE_ONLY_BAREBONE_ID, - SafetySourceCtsData.issuesOnly(safetySourceCtsData.criticalResolvingIssue)) + SafetySourceCtsData.issuesOnly(safetySourceCtsData.criticalResolvingGeneralIssue)) safetyCenterCtsHelper.setData( ISSUE_ONLY_ALL_OPTIONAL_ID, - SafetySourceCtsData.issuesOnly(safetySourceCtsData.recommendationIssue)) + SafetySourceCtsData.issuesOnly(safetySourceCtsData.recommendationGeneralIssue)) safetyCenterCtsHelper.setData(DYNAMIC_IN_RIGID_ID, safetySourceCtsData.unspecifiedWithIssue) safetyCenterCtsHelper.setData( ISSUE_ONLY_IN_RIGID_ID, @@ -2069,10 +2201,10 @@ class SafetyCenterManagerTest { listener.receiveSafetyCenterData() safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val safetyCenterDataFromListener = listener.receiveSafetyCenterData() - assertThat(safetyCenterDataFromListener).isEqualTo(safetyCenterDataCriticalOneAlert) + assertThat(safetyCenterDataFromListener).isEqualTo(safetyCenterDataGeneralCriticalOneAlert) } @Test @@ -2226,7 +2358,7 @@ class SafetyCenterManagerTest { fun dismissSafetyCenterIssue_existing_callsListenerAndDismisses() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val listener = safetyCenterCtsHelper.addListener() safetyCenterManager.dismissSafetyCenterIssueWithPermission( @@ -2240,7 +2372,7 @@ class SafetyCenterManagerTest { fun dismissSafetyCenterIssue_issueShowsUpAgainIfSourceStopsSendingItAtLeastOnce() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) safetyCenterManager.dismissSafetyCenterIssueWithPermission( SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, CRITICAL_ISSUE_ID)) val listener = safetyCenterCtsHelper.addListener() @@ -2253,19 +2385,19 @@ class SafetyCenterManagerTest { .isEqualTo(safetyCenterDataOk) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val safetyCenterDataAfterSourcePushesDismissedIssueAgain = listener.receiveSafetyCenterData() assertThat(safetyCenterDataAfterSourcePushesDismissedIssueAgain) - .isEqualTo(safetyCenterDataCriticalOneAlert) + .isEqualTo(safetyCenterDataGeneralCriticalOneAlert) } @Test fun dismissSafetyCenterIssue_existingWithDifferentIssueType_callsListenerAndDismisses() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val listener = safetyCenterCtsHelper.addListener() safetyCenterManager.dismissSafetyCenterIssueWithPermission( @@ -2282,7 +2414,8 @@ class SafetyCenterManagerTest { safetyCenterCtsHelper.setData( SINGLE_SOURCE_ID, safetySourceCtsData.recommendationDismissPendingIntentIssue) SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(DISMISS_ISSUE, SINGLE_SOURCE_ID)] = safetySourceCtsData.information + SafetySourceDataKey(DISMISS_ISSUE, SINGLE_SOURCE_ID)] = + safetySourceCtsData.information val listener = safetyCenterCtsHelper.addListener() safetyCenterManager.dismissSafetyCenterIssueWithPermissionAndWait( @@ -2319,7 +2452,7 @@ class SafetyCenterManagerTest { fun dismissSafetyCenterIssue_nonExisting_doesntCallListenerOrDismiss() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val listener = safetyCenterCtsHelper.addListener() safetyCenterManager.dismissSafetyCenterIssueWithPermission( @@ -2334,7 +2467,7 @@ class SafetyCenterManagerTest { fun dismissSafetyCenterIssue_alreadyDismissed_doesntCallListenerOrDismiss() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) safetyCenterManager.dismissSafetyCenterIssueWithPermission( SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, CRITICAL_ISSUE_ID)) val listener = safetyCenterCtsHelper.addListener() @@ -2351,7 +2484,7 @@ class SafetyCenterManagerTest { fun dismissSafetyCenterIssue_dismissedWithDifferentIssueType_doesntCallListenerOrDismiss() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) safetyCenterManager.dismissSafetyCenterIssueWithPermission( SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, CRITICAL_ISSUE_ID)) val listener = safetyCenterCtsHelper.addListener() @@ -2366,10 +2499,136 @@ class SafetyCenterManagerTest { } @Test - fun dismissSafetyCenterIssue_withFlagDisabled_doesntCallListenerOrDismiss() { + fun dismissSafetyCenterIssue_withEmptyMaxCountMap_doesNotResurface() { + SafetyCenterFlags.resurfaceIssueMaxCounts = emptyMap() + SafetyCenterFlags.resurfaceIssueDelays = mapOf(SEVERITY_LEVEL_INFORMATION to Duration.ZERO) + safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) + safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, safetySourceCtsData.informationWithIssue) + val apiSafetyCenterData = safetyCenterManager.getSafetyCenterDataWithPermission() + checkState(apiSafetyCenterData == safetyCenterDataOkOneAlert) + + safetyCenterManager.dismissSafetyCenterIssueWithPermission( + SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, INFORMATION_ISSUE_ID)) + + assertFailsWith(TimeoutCancellationException::class) { + waitForWithTimeout(timeout = TIMEOUT_SHORT) { + val hasResurfaced = + safetyCenterManager.getSafetyCenterDataWithPermission() != safetyCenterDataOk + hasResurfaced + } + } + } + + @Test + fun dismissSafetyCenterIssue_withZeroMaxCount_doesNotResurface() { + SafetyCenterFlags.resurfaceIssueMaxCounts = + mapOf( + SEVERITY_LEVEL_INFORMATION to 0L, + SEVERITY_LEVEL_RECOMMENDATION to 99L, + SEVERITY_LEVEL_CRITICAL_WARNING to 99L) + SafetyCenterFlags.resurfaceIssueDelays = + mapOf( + SEVERITY_LEVEL_INFORMATION to Duration.ZERO, + SEVERITY_LEVEL_RECOMMENDATION to Duration.ZERO, + SEVERITY_LEVEL_CRITICAL_WARNING to Duration.ZERO) + safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) + safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, safetySourceCtsData.informationWithIssue) + val apiSafetyCenterData = safetyCenterManager.getSafetyCenterDataWithPermission() + checkState(apiSafetyCenterData == safetyCenterDataOkOneAlert) + + safetyCenterManager.dismissSafetyCenterIssueWithPermission( + SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, INFORMATION_ISSUE_ID)) + + assertFailsWith(TimeoutCancellationException::class) { + waitForWithTimeout(timeout = TIMEOUT_SHORT) { + val hasResurfaced = + safetyCenterManager.getSafetyCenterDataWithPermission() != safetyCenterDataOk + hasResurfaced + } + } + } + + @Test + fun dismissSafetyCenterIssue_withTwoMaxCount_resurfacesTwice() { + SafetyCenterFlags.resurfaceIssueMaxCounts = + mapOf( + SEVERITY_LEVEL_INFORMATION to 0L, + SEVERITY_LEVEL_RECOMMENDATION to 0L, + SEVERITY_LEVEL_CRITICAL_WARNING to 2L) + SafetyCenterFlags.resurfaceIssueDelays = + mapOf( + SEVERITY_LEVEL_INFORMATION to RESURFACE_DELAY, + SEVERITY_LEVEL_RECOMMENDATION to RESURFACE_DELAY, + SEVERITY_LEVEL_CRITICAL_WARNING to Duration.ZERO) safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + val apiSafetyCenterData = safetyCenterManager.getSafetyCenterDataWithPermission() + checkState(apiSafetyCenterData == safetyCenterDataCriticalOneAlert) + + safetyCenterManager.dismissSafetyCenterIssueWithPermission( + SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, CRITICAL_ISSUE_ID)) + val apiSafetyCenterDataResurface = safetyCenterManager.getSafetyCenterDataWithPermission() + checkState(apiSafetyCenterDataResurface == safetyCenterDataCriticalOneAlert) + safetyCenterManager.dismissSafetyCenterIssueWithPermission( + SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, CRITICAL_ISSUE_ID)) + val apiSafetyCenterDataResurfaceAgain = + safetyCenterManager.getSafetyCenterDataWithPermission() + checkState(apiSafetyCenterDataResurfaceAgain == safetyCenterDataCriticalOneAlert) + safetyCenterManager.dismissSafetyCenterIssueWithPermission( + SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, CRITICAL_ISSUE_ID)) + + assertFailsWith(TimeoutCancellationException::class) { + waitForWithTimeout(timeout = TIMEOUT_SHORT) { + val hasResurfaced = + safetyCenterManager.getSafetyCenterDataWithPermission() != + safetyCenterDataOkReviewCriticalEntry + hasResurfaced + } + } + } + + @Test + fun dismissSafetyCenterIssue_withNonZeroMaxCountAndNonZeroDelay_resurfacesAfterDelay() { + // We cannot rely on a listener in this test to assert on the API content at all times! + // The listener will not receive an update when a dismissed issue resurfaces, and it will + // not receive an update after subsequent dismissals because as far as the listener cache is + // concerned the dismissed issue never resurfaced. This is working as intended. + SafetyCenterFlags.resurfaceIssueMaxCounts = + mapOf( + SEVERITY_LEVEL_INFORMATION to 0L, + SEVERITY_LEVEL_RECOMMENDATION to 99L, + SEVERITY_LEVEL_CRITICAL_WARNING to 0L) + SafetyCenterFlags.resurfaceIssueDelays = + mapOf( + SEVERITY_LEVEL_INFORMATION to Duration.ZERO, + SEVERITY_LEVEL_RECOMMENDATION to RESURFACE_DELAY, + SEVERITY_LEVEL_CRITICAL_WARNING to Duration.ZERO) + safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) + safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, safetySourceCtsData.recommendationWithIssue) + val apiSafetyCenterData = safetyCenterManager.getSafetyCenterDataWithPermission() + checkState(apiSafetyCenterData == safetyCenterDataRecommendationOneAlert) + val listener = safetyCenterCtsHelper.addListener() + + safetyCenterManager.dismissSafetyCenterIssueWithPermission( + SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, RECOMMENDATION_ISSUE_ID)) + + val safetyCenterDataAfterDismissal = listener.receiveSafetyCenterData() + assertThat(safetyCenterDataAfterDismissal) + .isEqualTo(safetyCenterDataOkReviewRecommendationEntry) + waitForWithTimeout(timeout = RESURFACE_TIMEOUT, checkPeriod = RESURFACE_CHECK) { + val hasResurfacedExactly = + safetyCenterManager.getSafetyCenterDataWithPermission() == + safetyCenterDataRecommendationOneAlert + hasResurfacedExactly + } + } + + @Test + fun dismissSafetyCenterIssue_withFlagDisabled_doesntCallListenerOrDismiss() { + safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) + safetyCenterCtsHelper.setData( + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val listener = safetyCenterCtsHelper.addListener() safetyCenterCtsHelper.setEnabled(false) @@ -2408,10 +2667,11 @@ class SafetyCenterManagerTest { fun executeSafetyCenterIssueAction_existing_callsListenerWithInFlightActionAndExecutes() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val listener = safetyCenterCtsHelper.addListener() SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(RESOLVE_ACTION, SINGLE_SOURCE_ID)] = safetySourceCtsData.information + SafetySourceDataKey(RESOLVE_ACTION, SINGLE_SOURCE_ID)] = + safetySourceCtsData.information safetyCenterManager.executeSafetyCenterIssueActionWithPermissionAndWait( SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, CRITICAL_ISSUE_ID), @@ -2448,7 +2708,7 @@ class SafetyCenterManagerTest { @Test fun executeSafetyCenterIssueAction_existing_errorWithDispatchingResolvingAction() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) - val criticalWithResolvingIssue = safetySourceCtsData.criticalWithResolvingIssue + val criticalWithResolvingIssue = safetySourceCtsData.criticalWithResolvingGeneralIssue criticalWithResolvingIssue.issues.first().actions.first().pendingIntent.cancel() safetyCenterCtsHelper.setData(SINGLE_SOURCE_ID, criticalWithResolvingIssue) val listener = safetyCenterCtsHelper.addListener() @@ -2495,11 +2755,12 @@ class SafetyCenterManagerTest { fun executeSafetyCenterIssueAction_existing_unmarkInFlightWhenInlineActionError() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val listener = safetyCenterCtsHelper.addListener() SafetySourceReceiver.shouldReportSafetySourceError = true SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(RESOLVE_ACTION, SINGLE_SOURCE_ID)] = safetySourceCtsData.information + SafetySourceDataKey(RESOLVE_ACTION, SINGLE_SOURCE_ID)] = + safetySourceCtsData.information safetyCenterManager.executeSafetyCenterIssueActionWithPermissionAndWait( SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, CRITICAL_ISSUE_ID), @@ -2511,7 +2772,7 @@ class SafetyCenterManagerTest { .isEqualTo(safetyCenterDataCriticalOneAlertInFlight) val safetyCenterDataFromListenerAfterInlineAction = listener.receiveSafetyCenterData() assertThat(safetyCenterDataFromListenerAfterInlineAction) - .isEqualTo(safetyCenterDataCriticalOneAlert) + .isEqualTo(safetyCenterDataGeneralCriticalOneAlert) val error = listener.receiveSafetyCenterErrorDetails() assertThat(error) .isEqualTo( @@ -2541,7 +2802,7 @@ class SafetyCenterManagerTest { fun executeSafetyCenterIssueAction_alreadyInFlight_doesntCallListenerOrExecute() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val listener = safetyCenterCtsHelper.addListener() safetyCenterManager.executeSafetyCenterIssueActionWithPermissionAndWait( SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, CRITICAL_ISSUE_ID), @@ -2566,7 +2827,7 @@ class SafetyCenterManagerTest { SafetyCenterFlags.resolveActionTimeout = TIMEOUT_SHORT safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val listener = safetyCenterCtsHelper.addListener() safetyCenterManager.executeSafetyCenterIssueActionWithPermissionAndWait( @@ -2579,7 +2840,7 @@ class SafetyCenterManagerTest { .isEqualTo(safetyCenterDataCriticalOneAlertInFlight) val safetyCenterDataFromListenerAfterInlineAction = listener.receiveSafetyCenterData() assertThat(safetyCenterDataFromListenerAfterInlineAction) - .isEqualTo(safetyCenterDataCriticalOneAlert) + .isEqualTo(safetyCenterDataGeneralCriticalOneAlert) val error = listener.receiveSafetyCenterErrorDetails() assertThat(error) .isEqualTo( @@ -2592,7 +2853,7 @@ class SafetyCenterManagerTest { SafetyCenterFlags.resolveActionTimeout = TIMEOUT_SHORT safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val listener = safetyCenterCtsHelper.addListener() safetyCenterManager.executeSafetyCenterIssueActionWithPermissionAndWait( SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, CRITICAL_ISSUE_ID), @@ -2603,7 +2864,8 @@ class SafetyCenterManagerTest { listener.receiveSafetyCenterErrorDetails() SafetyCenterFlags.resolveActionTimeout = TIMEOUT_LONG SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(RESOLVE_ACTION, SINGLE_SOURCE_ID)] = safetySourceCtsData.information + SafetySourceDataKey(RESOLVE_ACTION, SINGLE_SOURCE_ID)] = + safetySourceCtsData.information safetyCenterManager.executeSafetyCenterIssueActionWithPermissionAndWait( SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, CRITICAL_ISSUE_ID), @@ -2621,7 +2883,7 @@ class SafetyCenterManagerTest { fun executeSafetyCenterIssueAction_withFlagDisabled_doesntCallListenerOrExecute() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val listener = safetyCenterCtsHelper.addListener() safetyCenterCtsHelper.setEnabled(false) @@ -2648,10 +2910,11 @@ class SafetyCenterManagerTest { fun executeSafetyCenterIssueAction_issueIdDoesNotMatch_throwsErrorAndDoesNotResolveIssue() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val listener = safetyCenterCtsHelper.addListener() SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(RESOLVE_ACTION, SINGLE_SOURCE_ID)] = safetySourceCtsData.information + SafetySourceDataKey(RESOLVE_ACTION, SINGLE_SOURCE_ID)] = + safetySourceCtsData.information assertFailsWith(IllegalArgumentException::class) { safetyCenterManager.executeSafetyCenterIssueActionWithPermissionAndWait( @@ -2670,10 +2933,11 @@ class SafetyCenterManagerTest { fun executeSafetyCenterIssueAction_actionIdDoesNotMatch_doesNotResolveIssue() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val listener = safetyCenterCtsHelper.addListener() SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(RESOLVE_ACTION, SINGLE_SOURCE_ID)] = safetySourceCtsData.information + SafetySourceDataKey(RESOLVE_ACTION, SINGLE_SOURCE_ID)] = + safetySourceCtsData.information assertFailsWith(TimeoutCancellationException::class) { safetyCenterManager.executeSafetyCenterIssueActionWithPermissionAndWait( @@ -2692,10 +2956,11 @@ class SafetyCenterManagerTest { fun executeSafetyCenterIssueAction_idsDontMatch_canStillResolve() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) val listener = safetyCenterCtsHelper.addListener() SafetySourceReceiver.safetySourceData[ - SafetySourceDataKey(RESOLVE_ACTION, SINGLE_SOURCE_ID)] = safetySourceCtsData.information + SafetySourceDataKey(RESOLVE_ACTION, SINGLE_SOURCE_ID)] = + safetySourceCtsData.information assertFailsWith(IllegalArgumentException::class) { safetyCenterManager.executeSafetyCenterIssueActionWithPermissionAndWait( SafetyCenterCtsData.issueId(SINGLE_SOURCE_ID, CRITICAL_ISSUE_ID), @@ -2750,7 +3015,8 @@ class SafetyCenterManagerTest { fun clearAllSafetySourceDataForTests_clearsAllSafetySourceData() { safetyCenterCtsHelper.setConfig(MULTIPLE_SOURCES_CONFIG) safetyCenterCtsHelper.setData(SOURCE_ID_1, safetySourceCtsData.unspecified) - safetyCenterCtsHelper.setData(SOURCE_ID_2, safetySourceCtsData.criticalWithResolvingIssue) + safetyCenterCtsHelper.setData( + SOURCE_ID_2, safetySourceCtsData.criticalWithResolvingGeneralIssue) safetyCenterManager.clearAllSafetySourceDataForTestsWithPermission() @@ -2764,7 +3030,7 @@ class SafetyCenterManagerTest { fun clearAllSafetySourceDataForTests_withFlagDisabled_clearsData() { safetyCenterCtsHelper.setConfig(SINGLE_SOURCE_CONFIG) safetyCenterCtsHelper.setData( - SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingIssue) + SINGLE_SOURCE_ID, safetySourceCtsData.criticalWithResolvingGeneralIssue) safetyCenterCtsHelper.setEnabled(false) safetyCenterManager.clearAllSafetySourceDataForTestsWithPermission() @@ -2881,8 +3147,8 @@ class SafetyCenterManagerTest { private fun SafetyCenterData.getGroupSummary(groupId: String): CharSequence = entriesOrGroups - .first { it.entryGroup?.id == SafetyCenterCtsData.entryGroupId(groupId) } - .entryGroup!! + .first { it.entryGroup?.id == SafetyCenterCtsData.entryGroupId(groupId) } + .entryGroup!! .summary!! private fun safetyCenterEntryDefaultBuilder(sourceId: String) = @@ -3000,4 +3266,15 @@ class SafetyCenterManagerTest { arguments["count"] = count return messageFormat.format(arguments) } + + companion object { + private val RESURFACE_DELAY = Duration.ofMillis(500) + // Wait 1.5 times the RESURFACE_DELAY before asserting whether an issue has or has not + // resurfaced. Use a constant additive error buffer if we increase the delay considerably. + private val RESURFACE_TIMEOUT = RESURFACE_DELAY.multipliedBy(3).dividedBy(2) + // Check more than once during a RESURFACE_DELAY before asserting whether an issue has or + // has not resurfaced. Use a different check logic (focused at the expected resurface time) + // if we increase the delay considerably. + private val RESURFACE_CHECK = RESURFACE_DELAY.dividedBy(4) + } } diff --git a/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterUnsupportedTest.kt b/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterUnsupportedTest.kt index cdbeaaa2f..91593fa71 100644 --- a/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterUnsupportedTest.kt +++ b/tests/cts/safetycenter/src/android/safetycenter/cts/SafetyCenterUnsupportedTest.kt @@ -130,7 +130,7 @@ class SafetyCenterUnsupportedTest { safetyCenterManager.setSafetyCenterConfigForTestsWithPermission(SINGLE_SOURCE_CONFIG) safetyCenterManager.setSafetySourceDataWithPermission( SINGLE_SOURCE_ID, - safetySourceCtsData.criticalWithResolvingIssue, + safetySourceCtsData.criticalWithResolvingGeneralIssue, EVENT_SOURCE_STATE_CHANGED) val apiSafetySourceData = @@ -291,7 +291,7 @@ class SafetyCenterUnsupportedTest { safetyCenterManager.setSafetyCenterConfigForTestsWithPermission(SINGLE_SOURCE_CONFIG) safetyCenterManager.setSafetySourceDataWithPermission( SINGLE_SOURCE_ID, - safetySourceCtsData.criticalWithResolvingIssue, + safetySourceCtsData.criticalWithResolvingGeneralIssue, EVENT_SOURCE_STATE_CHANGED) val listener = SafetyCenterCtsListener() safetyCenterManager.addOnSafetyCenterDataChangedListenerWithPermission( @@ -317,7 +317,7 @@ class SafetyCenterUnsupportedTest { safetyCenterManager.setSafetyCenterConfigForTestsWithPermission(SINGLE_SOURCE_CONFIG) safetyCenterManager.setSafetySourceDataWithPermission( SINGLE_SOURCE_ID, - safetySourceCtsData.criticalWithResolvingIssue, + safetySourceCtsData.criticalWithResolvingGeneralIssue, EVENT_SOURCE_STATE_CHANGED) val listener = SafetyCenterCtsListener() safetyCenterManager.addOnSafetyCenterDataChangedListenerWithPermission( @@ -347,7 +347,7 @@ class SafetyCenterUnsupportedTest { safetyCenterManager.setSafetyCenterConfigForTestsWithPermission(SINGLE_SOURCE_CONFIG) safetyCenterManager.setSafetySourceDataWithPermission( SINGLE_SOURCE_ID, - safetySourceCtsData.criticalWithResolvingIssue, + safetySourceCtsData.criticalWithResolvingGeneralIssue, EVENT_SOURCE_STATE_CHANGED) val apiSafetySourceDataBeforeClearing = safetyCenterManager.getSafetySourceDataWithPermission(SINGLE_SOURCE_ID) diff --git a/tests/cts/safetycenter/src/android/safetycenter/cts/testing/Coroutines.kt b/tests/cts/safetycenter/src/android/safetycenter/cts/testing/Coroutines.kt index 6325dbcbb..af916a950 100644 --- a/tests/cts/safetycenter/src/android/safetycenter/cts/testing/Coroutines.kt +++ b/tests/cts/safetycenter/src/android/safetycenter/cts/testing/Coroutines.kt @@ -17,10 +17,12 @@ package android.safetycenter.cts.testing import java.time.Duration +import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withTimeout /** A class that facilitates interacting with coroutines. */ +// TODO(b/228823159) Consolidate with other Coroutines helper functions object Coroutines { /** Behaves in the same way as [runBlocking], but with a timeout. */ @@ -29,6 +31,25 @@ object Coroutines { withTimeout(timeout.toMillis()) { block() } } + /** Check a condition using coroutines with a timeout. */ + fun waitForWithTimeout( + timeout: Duration = TIMEOUT_LONG, + checkPeriod: Duration = CHECK_PERIOD, + condition: () -> Boolean + ) { + runBlockingWithTimeout(timeout) { waitFor(checkPeriod, condition) } + } + + /** Check a condition using coroutines. */ + private suspend fun waitFor(checkPeriod: Duration = CHECK_PERIOD, condition: () -> Boolean) { + while (!condition()) { + delay(checkPeriod.toMillis()) + } + } + + /** A medium period, to be used for conditions that are expected to change. */ + private val CHECK_PERIOD = Duration.ofMillis(250) + /** A long timeout, to be used for actions that are expected to complete. */ val TIMEOUT_LONG: Duration = Duration.ofSeconds(15) diff --git a/tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetySourceCtsData.kt b/tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetySourceCtsData.kt index 4aee85004..397373237 100644 --- a/tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetySourceCtsData.kt +++ b/tests/cts/safetycenter/src/android/safetycenter/cts/testing/SafetySourceCtsData.kt @@ -163,8 +163,11 @@ class SafetySourceCtsData(private val context: Context) { .addIssue(informationIssueWithSubtitle) .build() - /** A [SafetySourceIssue] with a [SEVERITY_LEVEL_RECOMMENDATION] and a redirecting [Action]. */ - val recommendationIssue = + /** + * A [SafetySourceIssue.Builder] with a [SEVERITY_LEVEL_RECOMMENDATION] and a redirecting + * [Action]. + */ + private fun defaultRecommendationIssueBuilder() = SafetySourceIssue.Builder( RECOMMENDATION_ISSUE_ID, "Recommendation issue title", @@ -174,25 +177,31 @@ class SafetySourceCtsData(private val context: Context) { .addAction( Action.Builder(RECOMMENDATION_ISSUE_ACTION_ID, "See issue", redirectPendingIntent) .build()) - .build() /** - * A [SafetySourceIssue] with a [SEVERITY_LEVEL_RECOMMENDATION] and a redirecting [Action], - * related to the account. + * A [SafetySourceIssue] with a [SEVERITY_LEVEL_RECOMMENDATION], general category and a + * redirecting [Action]. */ - val accountRecommendationIssue = - SafetySourceIssue.Builder( - RECOMMENDATION_ISSUE_ID, - "Recommendation issue title", - "Recommendation issue summary", - SEVERITY_LEVEL_RECOMMENDATION, - ISSUE_TYPE_ID) - .addAction( - Action.Builder(RECOMMENDATION_ISSUE_ACTION_ID, "See issue", redirectPendingIntent) - .build()) + val recommendationGeneralIssue = defaultRecommendationIssueBuilder().build() + + /** + * A [SafetySourceIssue] with a [SEVERITY_LEVEL_RECOMMENDATION], account category and a + * redirecting [Action]. + */ + val recommendationAccountIssue = + defaultRecommendationIssueBuilder() .setIssueCategory(SafetySourceIssue.ISSUE_CATEGORY_ACCOUNT) .build() + /** + * A [SafetySourceIssue] with a [SEVERITY_LEVEL_RECOMMENDATION], device category and a + * redirecting [Action]. + */ + val recommendationDeviceIssue = + defaultRecommendationIssueBuilder() + .setIssueCategory(SafetySourceIssue.ISSUE_CATEGORY_DEVICE) + .build() + private val dismissIssuePendingIntent = broadcastPendingIntent( Intent(ACTION_HANDLE_DISMISSED_ISSUE).putExtra(EXTRA_SOURCE_ID, SINGLE_SOURCE_ID)) @@ -201,23 +210,12 @@ class SafetySourceCtsData(private val context: Context) { * A [SafetySourceIssue] with a [SEVERITY_LEVEL_RECOMMENDATION] and a dismiss [PendingIntent]. */ val recommendationIssueWithDismissPendingIntent = - SafetySourceIssue.Builder( - RECOMMENDATION_ISSUE_ID, - "Recommendation issue title", - "Recommendation issue summary", - SEVERITY_LEVEL_RECOMMENDATION, - ISSUE_TYPE_ID) + defaultRecommendationIssueBuilder() .setOnDismissPendingIntent(dismissIssuePendingIntent) - .addAction( - Action.Builder(RECOMMENDATION_ISSUE_ACTION_ID, "See issue", redirectPendingIntent) - .build()) .build() - /** - * A [SafetySourceData] with a [SEVERITY_LEVEL_RECOMMENDATION] redirecting [SafetySourceIssue] - * and [SafetySourceStatus]. - */ - val recommendationWithIssue = + /** A [SafetySourceData.Builder] with a [SEVERITY_LEVEL_RECOMMENDATION] status. */ + fun defaultRecommendationDataBuilder() = SafetySourceData.Builder() .setStatus( SafetySourceStatus.Builder( @@ -226,42 +224,38 @@ class SafetySourceCtsData(private val context: Context) { SEVERITY_LEVEL_RECOMMENDATION) .setPendingIntent(redirectPendingIntent) .build()) - .addIssue(recommendationIssue) - .build() + + /** + * A [SafetySourceData] with a [SEVERITY_LEVEL_RECOMMENDATION] redirecting [SafetySourceIssue] + * and [SafetySourceStatus], only containing a general issue. + */ + val recommendationWithGeneralIssue = + defaultRecommendationDataBuilder().addIssue(recommendationGeneralIssue).build() /** * A [SafetySourceData] with a [SEVERITY_LEVEL_RECOMMENDATION] redirecting [SafetySourceIssue] * and [SafetySourceStatus], only containing an account issue. */ val recommendationWithAccountIssue = - SafetySourceData.Builder() - .setStatus( - SafetySourceStatus.Builder( - "Recommendation title", - "Recommendation summary", - SEVERITY_LEVEL_RECOMMENDATION) - .setPendingIntent(redirectPendingIntent) - .build()) - .addIssue(accountRecommendationIssue) - .build() + defaultRecommendationDataBuilder().addIssue(recommendationAccountIssue).build() + + /** + * A [SafetySourceData] with a [SEVERITY_LEVEL_RECOMMENDATION] redirecting [SafetySourceIssue] + * and [SafetySourceStatus], only containing a device issue. + */ + val recommendationWithDeviceIssue = + defaultRecommendationDataBuilder().addIssue(recommendationDeviceIssue).build() /** * A [SafetySourceData] with a [SEVERITY_LEVEL_RECOMMENDATION] [SafetySourceIssue] that has a * dismiss [PendingIntent], and [SafetySourceStatus]. */ val recommendationDismissPendingIntentIssue = - SafetySourceData.Builder() - .setStatus( - SafetySourceStatus.Builder( - "Recommendation title", - "Recommendation summary", - SEVERITY_LEVEL_RECOMMENDATION) - .setPendingIntent(redirectPendingIntent) - .build()) + defaultRecommendationDataBuilder() .addIssue(recommendationIssueWithDismissPendingIntent) .build() - /** A [PendingIntent] used by the resolving [Action] in [criticalResolvingIssue]. */ + /** A [PendingIntent] used by the resolving [Action] in [criticalResolvingGeneralIssue]. */ val criticalIssueActionPendingIntent = broadcastPendingIntent( Intent(ACTION_HANDLE_INLINE_ACTION) @@ -275,17 +269,6 @@ class SafetySourceCtsData(private val context: Context) { .setWillResolve(true) .build() - /** A [SafetySourceIssue] with a [SEVERITY_LEVEL_CRITICAL_WARNING] and a resolving [Action]. */ - val criticalResolvingIssue = - SafetySourceIssue.Builder( - CRITICAL_ISSUE_ID, - "Critical issue title", - "Critical issue summary", - SEVERITY_LEVEL_CRITICAL_WARNING, - ISSUE_TYPE_ID) - .addAction(criticalResolvingAction) - .build() - /** A resolving Critical [Action] that declares a success message */ val criticalResolvingActionWithSuccessMessage = Action.Builder(CRITICAL_ISSUE_ACTION_ID, "Solve issue", criticalIssueActionPendingIntent) @@ -321,36 +304,80 @@ class SafetySourceCtsData(private val context: Context) { .build() /** - * Account related [SafetySourceIssue] with a [SEVERITY_LEVEL_CRITICAL_WARNING] and a resolving - * [Action]. + * [SafetySourceIssue.Builder] with a [SEVERITY_LEVEL_CRITICAL_WARNING] and a resolving [Action] + * . */ - val criticalResolvingAccountIssue = + fun defaultCriticalResolvingIssueBuilder(issueId: String = CRITICAL_ISSUE_ID) = SafetySourceIssue.Builder( - CRITICAL_ISSUE_ID, + issueId, "Critical issue title", "Critical issue summary", SEVERITY_LEVEL_CRITICAL_WARNING, ISSUE_TYPE_ID) - .addAction( - Action.Builder( - CRITICAL_ISSUE_ACTION_ID, "Solve issue", criticalIssueActionPendingIntent) - .setWillResolve(true) - .build()) + .addAction(criticalResolvingAction) + + /** + * General [SafetySourceIssue] with a [SEVERITY_LEVEL_CRITICAL_WARNING] and a resolving [Action] + * . + */ + val criticalResolvingGeneralIssue = defaultCriticalResolvingIssueBuilder().build() + + /** + * Account related [SafetySourceIssue] with a [SEVERITY_LEVEL_CRITICAL_WARNING] and a resolving + * [Action]. + */ + val criticalResolvingAccountIssue = + defaultCriticalResolvingIssueBuilder() .setIssueCategory(SafetySourceIssue.ISSUE_CATEGORY_ACCOUNT) .build() /** - * A [SafetySourceData] with a [SEVERITY_LEVEL_CRITICAL_WARNING] resolving [SafetySourceIssue] - * and [SafetySourceStatus]. + * Device related [SafetySourceIssue] with a [SEVERITY_LEVEL_CRITICAL_WARNING] and a resolving + * [Action]. */ - val criticalWithResolvingIssue = + val criticalResolvingDeviceIssue = + defaultCriticalResolvingIssueBuilder() + .setIssueCategory(SafetySourceIssue.ISSUE_CATEGORY_DEVICE) + .build() + + /** A [SafetySourceData.Builder] with a [SEVERITY_LEVEL_CRITICAL_WARNING] status. */ + fun defaultCriticalDataBuilder() = SafetySourceData.Builder() .setStatus( SafetySourceStatus.Builder( "Critical title", "Critical summary", SEVERITY_LEVEL_CRITICAL_WARNING) .setPendingIntent(redirectPendingIntent) .build()) - .addIssue(criticalResolvingIssue) + + /** + * A [SafetySourceData] with a [SEVERITY_LEVEL_CRITICAL_WARNING] resolving general + * [SafetySourceIssue] and [SafetySourceStatus]. + */ + val criticalWithResolvingGeneralIssue = + defaultCriticalDataBuilder().addIssue(criticalResolvingGeneralIssue).build() + + /** + * A [SafetySourceData] with a [SEVERITY_LEVEL_CRITICAL_WARNING] resolving account related + * [SafetySourceIssue] and [SafetySourceStatus]. + */ + val criticalWithResolvingAccountIssue = + defaultCriticalDataBuilder().addIssue(criticalResolvingAccountIssue).build() + + /** + * A [SafetySourceData] with a [SEVERITY_LEVEL_CRITICAL_WARNING] resolving device related + * [SafetySourceIssue] and [SafetySourceStatus]. + */ + val criticalWithResolvingDeviceIssue = + defaultCriticalDataBuilder().addIssue(criticalResolvingDeviceIssue).build() + + /** + * A [SafetySourceData] with a [SEVERITY_LEVEL_CRITICAL_WARNING] resolving device related + * [SafetySourceIssue] and [SafetySourceStatus] and a recommendation issue. + */ + val criticalWithResolvingDeviceIssueAndRecommendationIssue = + defaultCriticalDataBuilder() + .addIssue(criticalResolvingDeviceIssue) + .addIssue(recommendationAccountIssue) .build() /** @@ -372,30 +399,7 @@ class SafetySourceCtsData(private val context: Context) { * [SEVERITY_LEVEL_CRITICAL_WARNING] [SafetySourceStatus]. */ val criticalWithInformationIssue = - SafetySourceData.Builder() - .setStatus( - SafetySourceStatus.Builder( - "Critical title", "Critical summary", SEVERITY_LEVEL_CRITICAL_WARNING) - .setPendingIntent(redirectPendingIntent) - .build()) - .addIssue(informationIssue) - .build() - - /** - * A [SafetySourceData] with a [SEVERITY_LEVEL_CRITICAL_WARNING] and a - * [SEVERITY_LEVEL_RECOMMENDATION] [SafetySourceIssue]s and [SEVERITY_LEVEL_CRITICAL_WARNING] - * [SafetySourceStatus]. One issue is account related, other isn't. - */ - val criticalWithTwoIssues = - SafetySourceData.Builder() - .setStatus( - SafetySourceStatus.Builder( - "Critical title", "Critical summary", SEVERITY_LEVEL_CRITICAL_WARNING) - .setPendingIntent(redirectPendingIntent) - .build()) - .addIssue(criticalResolvingAccountIssue) - .addIssue(recommendationIssue) - .build() + defaultCriticalDataBuilder().addIssue(informationIssue).build() /** * Another [SafetySourceData] with a [SEVERITY_LEVEL_CRITICAL_WARNING] redirecting @@ -412,20 +416,6 @@ class SafetySourceCtsData(private val context: Context) { .build() /** - * Another [SafetySourceData] with a [SEVERITY_LEVEL_CRITICAL_WARNING] resolving account related - * [SafetySourceIssue] and [SafetySourceStatus]. - */ - val criticalWithResolvingAccountIssue = - SafetySourceData.Builder() - .setStatus( - SafetySourceStatus.Builder( - "Critical title", "Critical summary", SEVERITY_LEVEL_CRITICAL_WARNING) - .setPendingIntent(redirectPendingIntent) - .build()) - .addIssue(criticalResolvingAccountIssue) - .build() - - /** * A function to generate simple [SafetySourceData] with the given entry [severityLevel] and * [entrySummary], and an optional issue with the same [severityLevel]. */ @@ -470,10 +460,10 @@ class SafetySourceCtsData(private val context: Context) { /** Action ID for the redirecting action in [informationIssue]. */ const val INFORMATION_ISSUE_ACTION_ID = "information_issue_action_id" - /** Issue ID for [recommendationIssue]. */ + /** Issue ID for a recommendation issue */ const val RECOMMENDATION_ISSUE_ID = "recommendation_issue_id" - /** Action ID for the redirecting action in [recommendationIssue]. */ + /** Action ID for the redirecting action in recommendation issue. */ const val RECOMMENDATION_ISSUE_ACTION_ID = "recommendation_issue_action_id" /** Issue ID for the critical issues in this file. */ |