From dd839b26e44f184f8b974ae30260522469b6b52e Mon Sep 17 00:00:00 2001 From: Karishma Vakil Date: Mon, 24 Jan 2022 12:52:03 +0000 Subject: [PATCH 1/2] [SafetyCenter] Delete refresh API constants from `android.content.Intent` * Suggested by API council to move them to `android.safetycenter.SafetyCenterManager` Test: Will be tested in use in SafetyCenterManager refresh API Bug: 215555855 Change-Id: I4f84ae5a9037b4938f0ba7feb151c50149362fdd --- .../android/os/PowerExemptionManager.java | 2 +- core/api/system-current.txt | 5 - core/java/android/content/Intent.java | 112 ------------------ core/res/AndroidManifest.xml | 2 +- 4 files changed, 2 insertions(+), 119 deletions(-) diff --git a/apex/jobscheduler/framework/java/android/os/PowerExemptionManager.java b/apex/jobscheduler/framework/java/android/os/PowerExemptionManager.java index 9fb12277fa5ee..127bdff7612cb 100644 --- a/apex/jobscheduler/framework/java/android/os/PowerExemptionManager.java +++ b/apex/jobscheduler/framework/java/android/os/PowerExemptionManager.java @@ -259,7 +259,7 @@ public class PowerExemptionManager { */ public static final int REASON_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED = 207; /** - * Broadcast {@link android.content.Intent#ACTION_REFRESH_SAFETY_SOURCES}. + * Broadcast {@link android.safetycenter.SafetyCenterManager#ACTION_REFRESH_SAFETY_SOURCES}. * @hide */ public static final int REASON_ACTION_REFRESH_SAFETY_SOURCES = 208; diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 5084b40ee4f57..2d83ff021f29e 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -2718,7 +2718,6 @@ package android.content { field public static final String ACTION_PENDING_INCIDENT_REPORTS_CHANGED = "android.intent.action.PENDING_INCIDENT_REPORTS_CHANGED"; field public static final String ACTION_PRE_BOOT_COMPLETED = "android.intent.action.PRE_BOOT_COMPLETED"; field public static final String ACTION_QUERY_PACKAGE_RESTART = "android.intent.action.QUERY_PACKAGE_RESTART"; - field public static final String ACTION_REFRESH_SAFETY_SOURCES = "android.intent.action.REFRESH_SAFETY_SOURCES"; field public static final String ACTION_RESOLVE_INSTANT_APP_PACKAGE = "android.intent.action.RESOLVE_INSTANT_APP_PACKAGE"; field @RequiresPermission(android.Manifest.permission.REVIEW_ACCESSIBILITY_SERVICES) public static final String ACTION_REVIEW_ACCESSIBILITY_SERVICES = "android.intent.action.REVIEW_ACCESSIBILITY_SERVICES"; field @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) public static final String ACTION_REVIEW_ONGOING_PERMISSION_USAGE = "android.intent.action.REVIEW_ONGOING_PERMISSION_USAGE"; @@ -2749,10 +2748,6 @@ package android.content { field public static final String EXTRA_PACKAGES = "android.intent.extra.PACKAGES"; field public static final String EXTRA_PERMISSION_NAME = "android.intent.extra.PERMISSION_NAME"; field public static final String EXTRA_REASON = "android.intent.extra.REASON"; - field public static final int EXTRA_REFRESH_REQUEST_TYPE_FETCH_FRESH_DATA = 0; // 0x0 - field public static final int EXTRA_REFRESH_REQUEST_TYPE_GET_DATA = 1; // 0x1 - field public static final String EXTRA_REFRESH_SAFETY_SOURCES_REQUEST_TYPE = "android.intent.extra.REFRESH_SAFETY_SOURCES_REQUEST_TYPE"; - field public static final String EXTRA_REFRESH_SAFETY_SOURCE_IDS = "android.intent.extra.REFRESH_SAFETY_SOURCE_IDS"; field public static final String EXTRA_REMOTE_CALLBACK = "android.intent.extra.REMOTE_CALLBACK"; field public static final String EXTRA_RESULT_NEEDED = "android.intent.extra.RESULT_NEEDED"; field public static final String EXTRA_ROLE_NAME = "android.intent.extra.ROLE_NAME"; diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java index 58a7d8796ffb9..34996f77256b2 100644 --- a/core/java/android/content/Intent.java +++ b/core/java/android/content/Intent.java @@ -3796,47 +3796,6 @@ public class Intent implements Parcelable, Cloneable { public static final String ACTION_IDLE_MAINTENANCE_END = "android.intent.action.ACTION_IDLE_MAINTENANCE_END"; - /** - * Broadcast Action: A broadcast sent by the system to indicate that - * {@link android.safetycenter.SafetyCenterManager} is requesting data from safety sources - * regarding their safety state. - * - * This broadcast is sent when a user triggers a data refresh from the Safety Center UI or when - * Safety Center detects that its stored safety information is stale and needs to be updated. - * - * This broadcast is sent explicitly to safety sources by targeting intents to a specified set - * of components provided by the safety sources in the safety source configuration. - * The receiving components should be manifest-declared receivers so that safety sources can be - * requested to send data even if they are not running. - * - * On receiving this broadcast, safety sources should determine their safety state - * according to the parameters specified in the intent extras (see below) and send Safety Center - * data about their safety state using - * {@link android.safetycenter.SafetyCenterManager#sendSafetyCenterUpdate(android.safetycenter.SafetySourceData)}. - * - *

This is a protected intent that can only be sent by the system. - * - *

Includes the following extras: - *

- * - * @hide - */ - // TODO(b/210805082): Define the term "safety sources" more concretely here once safety sources - // are configured in xml config. - // TODO(b/210979035): Determine recommendation for sources if they are requested for fresh data - // but cannot provide it. - @SystemApi - @SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION) - public static final String ACTION_REFRESH_SAFETY_SOURCES = - "android.intent.action.REFRESH_SAFETY_SOURCES"; - /** * Broadcast Action: a remote intent is to be broadcasted. * @@ -6461,77 +6420,6 @@ public class Intent implements Parcelable, Cloneable { public static final String EXTRA_VISIBILITY_ALLOW_LIST = "android.intent.extra.VISIBILITY_ALLOW_LIST"; - - /** - * Used as a {@code String[]} extra field in - * {@link android.content.Intent#ACTION_REFRESH_SAFETY_SOURCES} intents to specify the safety - * source ids of the safety sources being requested for data by Safety Center. - * - * When this extra field is not specified in the intent, it is assumed that Safety Center is - * requesting data from all safety sources supported by the component receiving the broadcast. - * @hide - */ - @SystemApi - public static final String EXTRA_REFRESH_SAFETY_SOURCE_IDS = - "android.intent.extra.REFRESH_SAFETY_SOURCE_IDS"; - - /** - * Used as an {@code int} extra field in - * {@link android.content.Intent#ACTION_REFRESH_SAFETY_SOURCES} intents to specify the type of - * data request from Safety Center. - * - * Possible values are all values in {@link RefreshRequestType}. - * - * @hide - */ - @SystemApi - public static final String EXTRA_REFRESH_SAFETY_SOURCES_REQUEST_TYPE = - "android.intent.extra.REFRESH_SAFETY_SOURCES_REQUEST_TYPE"; - - /** - * All possible types of data refresh requests in broadcasts with intent action - * {@link android.content.Intent#ACTION_REFRESH_SAFETY_SOURCES}. - * - * @hide - */ - @IntDef(prefix = { "EXTRA_REFRESH_REQUEST_TYPE_" }, value = { - EXTRA_REFRESH_REQUEST_TYPE_FETCH_FRESH_DATA, - EXTRA_REFRESH_REQUEST_TYPE_GET_DATA, - }) - @Retention(RetentionPolicy.SOURCE) - public @interface RefreshRequestType {} - - /** - * Used as an int value for - * {@link android.content.Intent#EXTRA_REFRESH_SAFETY_SOURCES_REQUEST_TYPE} - * to indicate that the safety source should fetch fresh data relating to their safety state - * upon receiving a broadcast with intent action - * {@link android.content.Intent#ACTION_REFRESH_SAFETY_SOURCES} and provide it to Safety Center. - * - * The term "fresh" here means that the sources should ensure that the safety data is accurate - * as possible at the time of providing it to Safety Center, even if it involves performing an - * expensive and/or slow process. - * - * @hide - */ - @SystemApi - public static final int EXTRA_REFRESH_REQUEST_TYPE_FETCH_FRESH_DATA = 0; - - /** - * Used as an int value for - * {@link android.content.Intent#EXTRA_REFRESH_SAFETY_SOURCES_REQUEST_TYPE} - * to indicate that upon receiving a broadcasts with intent action - * {@link android.content.Intent#ACTION_REFRESH_SAFETY_SOURCES}, the safety source should - * provide data relating to their safety state to Safety Center. - * - * If the source already has its safety data cached, it may provide it without triggering a - * process to fetch state which may be expensive and/or slow. - * - * @hide - */ - @SystemApi - public static final int EXTRA_REFRESH_REQUEST_TYPE_GET_DATA = 1; - // --------------------------------------------------------------------- // --------------------------------------------------------------------- // Intent flags (see mFlags variable). diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml index a95cccfba7507..9e9d4eb0754fa 100644 --- a/core/res/AndroidManifest.xml +++ b/core/res/AndroidManifest.xml @@ -715,7 +715,7 @@ - + From 04d0971b07d29361a7fbcccb789c8487f9508fd9 Mon Sep 17 00:00:00 2001 From: Karishma Vakil Date: Wed, 19 Jan 2022 00:19:02 +0000 Subject: [PATCH 2/2] [SafetyCenter] Add REASON_REFRESH_SAFETY_SOURCES to System API Test: Will be tested in use in SafetyCenterManager refresh API Bug: 210431135 Change-Id: Ide16d6c2d18f211840e06e923aa0e92abc4f5a90 --- .../framework/java/android/os/PowerExemptionManager.java | 9 ++++----- core/api/system-current.txt | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apex/jobscheduler/framework/java/android/os/PowerExemptionManager.java b/apex/jobscheduler/framework/java/android/os/PowerExemptionManager.java index 127bdff7612cb..8519e24486f96 100644 --- a/apex/jobscheduler/framework/java/android/os/PowerExemptionManager.java +++ b/apex/jobscheduler/framework/java/android/os/PowerExemptionManager.java @@ -260,9 +260,8 @@ public class PowerExemptionManager { public static final int REASON_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED = 207; /** * Broadcast {@link android.safetycenter.SafetyCenterManager#ACTION_REFRESH_SAFETY_SOURCES}. - * @hide */ - public static final int REASON_ACTION_REFRESH_SAFETY_SOURCES = 208; + public static final int REASON_REFRESH_SAFETY_SOURCES = 208; /* Reason code range 300-399 are reserved for other internal reasons */ /** @@ -404,7 +403,7 @@ public class PowerExemptionManager { REASON_TIME_CHANGED, REASON_LOCALE_CHANGED, REASON_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED, - REASON_ACTION_REFRESH_SAFETY_SOURCES, + REASON_REFRESH_SAFETY_SOURCES, REASON_SYSTEM_ALLOW_LISTED, REASON_ALARM_MANAGER_ALARM_CLOCK, REASON_ALARM_MANAGER_WHILE_IDLE, @@ -688,8 +687,8 @@ public class PowerExemptionManager { return "LOCALE_CHANGED"; case REASON_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED: return "REASON_SCHEDULE_EXACT_ALARM_PERMISSION_STATE_CHANGED"; - case REASON_ACTION_REFRESH_SAFETY_SOURCES: - return "REASON_ACTION_REFRESH_SAFETY_SOURCES"; + case REASON_REFRESH_SAFETY_SOURCES: + return "REASON_REFRESH_SAFETY_SOURCES"; case REASON_SYSTEM_ALLOW_LISTED: return "SYSTEM_ALLOW_LISTED"; case REASON_ALARM_MANAGER_ALARM_CLOCK: diff --git a/core/api/system-current.txt b/core/api/system-current.txt index 2d83ff021f29e..37a903be93eb8 100644 --- a/core/api/system-current.txt +++ b/core/api/system-current.txt @@ -9178,6 +9178,7 @@ package android.os { field public static final int REASON_OTHER = 1; // 0x1 field public static final int REASON_PUSH_MESSAGING = 101; // 0x65 field public static final int REASON_PUSH_MESSAGING_OVER_QUOTA = 102; // 0x66 + field public static final int REASON_REFRESH_SAFETY_SOURCES = 208; // 0xd0 field public static final int REASON_UNKNOWN = 0; // 0x0 field public static final int TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_ALLOWED = 0; // 0x0 field public static final int TEMPORARY_ALLOW_LIST_TYPE_FOREGROUND_SERVICE_NOT_ALLOWED = 1; // 0x1