1 /* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.permissioncontroller; 18 19 import android.os.Build; 20 21 import androidx.annotation.RequiresApi; 22 23 import com.android.permissioncontroller.hibernation.HibernationJobService; 24 import com.android.permissioncontroller.permission.service.PermissionEventCleanupJobService; 25 import com.android.permissioncontroller.permission.service.v34.SafetyLabelChangesJobService; 26 27 /** 28 * App-global constants 29 */ 30 public class Constants { 31 32 /** 33 * ID for the periodic job in 34 * {@link com.android.permissioncontroller.permission.service.LocationAccessCheck}. 35 */ 36 public static final int PERIODIC_LOCATION_ACCESS_CHECK_JOB_ID = 0; 37 38 /** 39 * ID for the on-demand, but delayed job in 40 * {@link com.android.permissioncontroller.permission.service.LocationAccessCheck}. 41 */ 42 public static final int LOCATION_ACCESS_CHECK_JOB_ID = 1; 43 44 /** 45 * ID of the periodic job 46 * {@link HibernationJobService} 47 */ 48 public static final int HIBERNATION_JOB_ID = 2; 49 50 /** 51 * ID of the periodic job 52 * {@link PermissionEventCleanupJobService} 53 */ 54 public static final int OLD_PERMISSION_EVENT_CLEANUP_JOB_ID = 3; 55 56 /** 57 * ID for the periodic job in 58 * {@link com.android.permissioncontroller.privacysources.NotificationListenerCheck}. 59 */ 60 public static final int PERIODIC_NOTIFICATION_LISTENER_CHECK_JOB_ID = 4; 61 62 /** 63 * ID for the on-demand, but delayed job in 64 * {@link com.android.permissioncontroller.privacysources.NotificationListenerCheck}. 65 */ 66 public static final int NOTIFICATION_LISTENER_CHECK_JOB_ID = 5; 67 68 /** 69 * ID for the periodic job in 70 * {@link com.android.permissioncontroller.privacysources.AccessibilitySourceService}. 71 */ 72 public static final int PERIODIC_ACCESSIBILITY_CHECK_JOB_ID = 6; 73 74 /** 75 * ID for Safety Centers periodic background refresh job, scheduled after boot and after Safety 76 * Center is enabled, in {@link 77 * com.android.permissioncontroller.safetycenter.service.SafetyCenterBackgroundRefreshJobService 78 * }. 79 */ 80 public static final int SAFETY_CENTER_BACKGROUND_REFRESH_JOB_ID = 7; 81 82 83 /** 84 * ID for the detect updates job in {@link SafetyLabelChangesJobService}. 85 */ 86 public static final int SAFETY_LABEL_CHANGES_DETECT_UPDATES_JOB_ID = 8; 87 88 /** 89 * ID for the periodic notification job in {@link SafetyLabelChangesJobService}. 90 */ 91 public static final int SAFETY_LABEL_CHANGES_PERIODIC_NOTIFICATION_JOB_ID = 9; 92 93 /** 94 * Name of file to containing the packages we already showed a notification for. 95 * 96 * @see com.android.permissioncontroller.permission.service.LocationAccessCheck 97 */ 98 public static final String LOCATION_ACCESS_CHECK_ALREADY_NOTIFIED_FILE = 99 "packages_already_notified_location_access"; 100 101 /** 102 * ID for notification shown by 103 * {@link com.android.permissioncontroller.permission.service.LocationAccessCheck}. 104 */ 105 public static final int LOCATION_ACCESS_CHECK_NOTIFICATION_ID = 0; 106 107 /** 108 * ID for notification shown by 109 * {@link HibernationJobService}. 110 */ 111 public static final int UNUSED_APPS_NOTIFICATION_ID = 1; 112 113 /** 114 * ID for notification shown by 115 * {@link com.android.permissioncontroller.auto.DrivingDecisionReminderService}. 116 */ 117 public static final int PERMISSION_DECISION_REMINDER_NOTIFICATION_ID = 2; 118 119 /** 120 * ID for notification shown by 121 * {@link com.android.permissioncontroller.privacysources.NotificationListenerCheck}. 122 */ 123 public static final int NOTIFICATION_LISTENER_CHECK_NOTIFICATION_ID = 3; 124 125 /** 126 * ID for notification shown by 127 * {@link com.android.permissioncontroller.privacysources.AccessibilitySourceService}. 128 */ 129 public static final int ACCESSIBILITY_CHECK_NOTIFICATION_ID = 4; 130 131 /** 132 * ID for notification shown by 133 * {@link SafetyLabelChangesJobService}. 134 */ 135 public static final int SAFETY_LABEL_CHANGES_NOTIFICATION_ID = 5; 136 137 /** 138 * ID for notification of auto-granted permissions shown by 139 * {@link com.android.permissioncontroller.permission.ui.AutoGrantPermissionsNotifier}. 140 */ 141 public static final int PERMISSION_GRANTED_BY_ADMIN_NOTIFICATION_ID = 6; 142 143 /** 144 * Summary notification ID for the group of admin auto-granted permission notifications 145 */ 146 public static final int ADMIN_AUTO_GRANTED_PERMISSIONS_NOTIFICATION_SUMMARY_ID = 7; 147 148 /** 149 * Group ID for all admin auto-granted permission notifications 150 */ 151 public static final String ADMIN_AUTO_GRANTED_PERMISSIONS_NOTIFICATION_GROUP_ID = 152 "auto granted permission group id"; 153 154 /** 155 * String action for navigating to the auto revoke screen. 156 */ 157 public static final String ACTION_MANAGE_AUTO_REVOKE = "manageAutoRevoke"; 158 159 /** 160 * Key for Notification.Builder.setGroup() for the incident report approval notification. 161 */ 162 public static final String INCIDENT_NOTIFICATION_GROUP_KEY = "incident confirmation"; 163 164 /** 165 * Key for Notification.Builder.setChannelId() for the incident report approval notification. 166 */ 167 public static final String INCIDENT_NOTIFICATION_CHANNEL_ID = "incident_confirmation"; 168 169 /** 170 * ID for our notification. We always post it with a tag which is the uri in string form. 171 */ 172 public static final int INCIDENT_NOTIFICATION_ID = 66900652; 173 174 /** 175 * Channel of the notifications shown by 176 * {@link com.android.permissioncontroller.permission.service.LocationAccessCheck}, 177 * {@link com.android.permissioncontroller.privacysources.NotificationListenerCheck}, 178 * {@link com.android.permissioncontroller.hibernation.HibernationPolicyKt}, 179 * {@link com.android.permissioncontroller.auto.DrivingDecisionReminderService}, and 180 * {@link SafetyLabelChangesJobService} 181 */ 182 public static final String PERMISSION_REMINDER_CHANNEL_ID = "permission reminders"; 183 184 /** 185 * Name of generic shared preferences file. 186 */ 187 public static final String PREFERENCES_FILE = "preferences"; 188 189 /** 190 * Key in the generic shared preferences that stores when the location access feature 191 * was enabled, specifically when it was picked up by the code managing the feature. 192 */ 193 public static final String KEY_LOCATION_ACCESS_CHECK_ENABLED_TIME = 194 "location_access_check_enabled_time"; 195 196 /** 197 * Key in the generic shared preferences that stores when the last notification was shown by 198 * {@link com.android.permissioncontroller.permission.service.LocationAccessCheck} 199 */ 200 public static final String KEY_LAST_LOCATION_ACCESS_NOTIFICATION_SHOWN = 201 "last_location_access_notification_shown"; 202 203 /** 204 * Key in the generic shared preferences that stores when the last notification was shown by 205 * {@link com.android.permissioncontroller.privacysources.NotificationListenerCheck} 206 */ 207 public static final String KEY_LAST_NOTIFICATION_LISTENER_NOTIFICATION_SHOWN = 208 "last_notification_listener_notification_shown"; 209 210 /** 211 * Key in the generic shared preferences that stores if the user manually selected the "none" 212 * role holder for a role. 213 */ 214 public static final String IS_NONE_ROLE_HOLDER_SELECTED_KEY = "is_none_role_holder_selected:"; 215 216 /** 217 * Key in the generic shared preferences that stores if the user manually selected the "none" 218 * role holder for a role. 219 */ 220 public static final String SEARCH_INDEXABLE_PROVIDER_PASSWORD_KEY = 221 "search_indexable_provider_password"; 222 223 /** 224 * Key in the generic shared preferences that stores the name of the packages that are currently 225 * have an overridden user sensitivity. 226 */ 227 public static final String FORCED_USER_SENSITIVE_UIDS_KEY = "forced_user_sensitive_uids_key"; 228 229 /** 230 * Key in the generic shared preferences that stores if all packages should be considered user 231 * sensitive 232 */ 233 public static final String ALLOW_OVERRIDE_USER_SENSITIVE_KEY = 234 "allow_override_user_sensitive_key"; 235 236 /** 237 * Key in the generic shared preferences that controls if the 238 * {@link android.Manifest.permission#RECORD_AUDIO} of the currently registered assistant is 239 * user sensitive. 240 */ 241 public static final String ASSISTANT_RECORD_AUDIO_IS_USER_SENSITIVE_KEY = 242 "assistant_record_audio_is_user_sensitive_key"; 243 244 /** 245 * Name of file containing the permissions that should be restored, but have not been restored 246 * yet. 247 */ 248 public static final String DELAYED_RESTORE_PERMISSIONS_FILE = "delayed_restore_permissions.xml"; 249 250 /** 251 * Name of file containing the user denied status for requesting roles. 252 */ 253 public static final String REQUEST_ROLE_USER_DENIED_FILE = "request_role_user_denied"; 254 255 /** 256 * Logs to dump 257 */ 258 public static final String LOGS_TO_DUMP_FILE = "LogToDump.log"; 259 260 /** 261 * Key in the user denied status for requesting roles shared preferences that stores a string 262 * set for the names of the roles that an application has been denied for once. 263 */ 264 public static final String REQUEST_ROLE_USER_DENIED_ONCE_KEY_PREFIX = "denied_once:"; 265 266 /** 267 * Key in the user denied status for requesting roles shared preferences that stores a string 268 * set for the names of the roles that an application is always denied for. 269 */ 270 public static final String REQUEST_ROLE_USER_DENIED_ALWAYS_KEY_PREFIX = "denied_always:"; 271 272 /** 273 * Intent extra used to pass current sessionId between Permission Controller fragments. 274 */ 275 public static final String EXTRA_SESSION_ID = 276 "com.android.permissioncontroller.extra.SESSION_ID"; 277 278 /** 279 * Intent extra used to pass if the restriction dialog is triggered in-app. 280 */ 281 public static final String EXTRA_IS_ECM_IN_APP = 282 "com.android.permissincontroller.extra.IS_ECM_IN_APP"; 283 284 /** 285 * Intent extra used to pass privacy source details to safety center. 286 */ 287 public static final String EXTRA_PRIVACY_SOURCE = 288 "com.android.permissioncontroller.extra.PRIVACY_SOURCE"; 289 290 /** 291 * Invalid session id. 292 */ 293 public static final long INVALID_SESSION_ID = 0; 294 295 /** 296 * Key for NotificationManager.notify for auto-granted permissions notification, 297 * when silently displayed to the user. 298 */ 299 public static final String ADMIN_AUTO_GRANTED_PERMISSIONS_NOTIFICATION_CHANNEL_ID = 300 "auto granted permissions"; 301 302 /** 303 * Key for NotificationManager.notify the auto-granted permissions notification, 304 * when alerting the user (with sound and vibration). 305 */ 306 public static final String ADMIN_AUTO_GRANTED_PERMISSIONS_ALERTING_NOTIFICATION_CHANNEL_ID = 307 "alerting auto granted permissions"; 308 309 /** 310 * Package name of the Android platform. 311 */ 312 public static final String OS_PACKAGE_NAME = "android"; 313 314 /** 315 * Source id for safety center source for unused apps. 316 */ 317 public static final String UNUSED_APPS_SAFETY_CENTER_SOURCE_ID = "AndroidPermissionAutoRevoke"; 318 319 /** 320 * Issue id for safety center issue for unused apps. 321 */ 322 public static final String UNUSED_APPS_SAFETY_CENTER_ISSUE_ID = "unused_apps_issue"; 323 324 /** 325 * Action id for safety center "See unused apps" action. 326 */ 327 public static final String UNUSED_APPS_SAFETY_CENTER_SEE_UNUSED_APPS_ID = "see_unused_apps"; 328 329 /** 330 * Fallback Settings package name 331 */ 332 public static final String SETTINGS_PACKAGE_NAME_FALLBACK = "com.android.settings"; 333 334 /** 335 * Extra launcher icon for notification 336 */ 337 public static final String NOTIFICATION_EXTRA_USE_LAUNCHER_ICON = 338 "com.android.car.notification.EXTRA_USE_LAUNCHER_ICON"; 339 340 // TODO(b/231624295) add to API 341 @RequiresApi(Build.VERSION_CODES.TIRAMISU) 342 public static final String OPSTR_RECEIVE_AMBIENT_TRIGGER_AUDIO = 343 "android:receive_ambient_trigger_audio"; 344 345 /** 346 * Extra used by Settings to indicate an Intent should be treated as if opened directly by 347 * Settings app itself. 348 */ 349 public static final String EXTRA_FROM_SETTINGS = "is_from_settings_homepage"; 350 351 /** 352 * Extra used by Settings to indicate an Intent should be treated as if opened by a slice 353 * within Settings. 354 * 355 * <p>Slices are opened within settings by firing a PendingIntent, so we can use this extra to 356 * allow the same UX path to be taken as for slices. 357 */ 358 public static final String EXTRA_IS_FROM_SLICE = "is_from_slice"; 359 } 360