• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.v33.PermissionEventCleanupJobService;
25 
26 /**
27  * App-global constants
28  */
29 public class Constants {
30 
31     /**
32      * ID for the periodic job in
33      * {@link com.android.permissioncontroller.permission.service.LocationAccessCheck}.
34      */
35     public static final int PERIODIC_LOCATION_ACCESS_CHECK_JOB_ID = 0;
36 
37     /**
38      * ID for the on-demand, but delayed job in
39      * {@link com.android.permissioncontroller.permission.service.LocationAccessCheck}.
40      */
41     public static final int LOCATION_ACCESS_CHECK_JOB_ID = 1;
42 
43     /**
44      * ID of the periodic job
45      * {@link HibernationJobService}
46      */
47     public static final int HIBERNATION_JOB_ID = 2;
48 
49     /**
50      * ID of the periodic job
51      * {@link PermissionEventCleanupJobService}
52      */
53     public static final int OLD_PERMISSION_EVENT_CLEANUP_JOB_ID = 3;
54 
55     /**
56      * ID for the periodic job in
57      * {@link com.android.permissioncontroller.privacysources.NotificationListenerCheck}.
58      */
59     public static final int PERIODIC_NOTIFICATION_LISTENER_CHECK_JOB_ID = 4;
60 
61     /**
62      * ID for the on-demand, but delayed job in
63      * {@link com.android.permissioncontroller.privacysources.NotificationListenerCheck}.
64      */
65     public static final int NOTIFICATION_LISTENER_CHECK_JOB_ID = 5;
66 
67     /**
68      * Name of file to containing the packages we already showed a notification for.
69      *
70      * @see com.android.permissioncontroller.permission.service.LocationAccessCheck
71      */
72     public static final String LOCATION_ACCESS_CHECK_ALREADY_NOTIFIED_FILE =
73             "packages_already_notified_location_access";
74 
75     /**
76      * Name of file to containing the packages we already showed a notification for.
77      *
78      * @see com.android.permissioncontroller.privacysources.NotificationListenerCheck
79      */
80     public static final String NOTIFICATION_LISTENER_CHECK_ALREADY_NOTIFIED_FILE =
81             "packages_already_notified_notification_listener";
82 
83     /**
84      * ID for notification shown by
85      * {@link com.android.permissioncontroller.permission.service.LocationAccessCheck}.
86      */
87     public static final int LOCATION_ACCESS_CHECK_NOTIFICATION_ID = 0;
88 
89     /**
90      * ID for notification shown by
91      * {@link HibernationJobService}.
92      */
93     public static final int UNUSED_APPS_NOTIFICATION_ID = 1;
94 
95     /**
96      * ID for notification shown by
97      * {@link com.android.permissioncontroller.auto.DrivingDecisionReminderService}.
98      */
99     public static final int PERMISSION_DECISION_REMINDER_NOTIFICATION_ID = 2;
100 
101     /**
102      * ID for notification shown by
103      * {@link com.android.permissioncontroller.privacysources.NotificationListenerCheck}.
104      */
105     public static final int NOTIFICATION_LISTENER_CHECK_NOTIFICATION_ID = 3;
106 
107     /**
108      * String action for navigating to the auto revoke screen.
109      */
110     public static final String ACTION_MANAGE_AUTO_REVOKE = "manageAutoRevoke";
111 
112     /**
113      * Key for Notification.Builder.setGroup() for the incident report approval notification.
114      */
115     public static final String INCIDENT_NOTIFICATION_GROUP_KEY = "incident confirmation";
116 
117     /**
118      * Key for Notification.Builder.setChannelId() for the incident report approval notification.
119      */
120     public static final String INCIDENT_NOTIFICATION_CHANNEL_ID = "incident_confirmation";
121 
122     /**
123      * ID for our notification.  We always post it with a tag which is the uri in string form.
124      */
125     public static final int INCIDENT_NOTIFICATION_ID = 66900652;
126 
127     /**
128      * Channel of the notifications shown by
129      * {@link com.android.permissioncontroller.permission.service.LocationAccessCheck},
130      * {@link com.android.permissioncontroller.privacysources.NotificationListenerCheck},
131      * {@link com.android.permissioncontroller.hibernation.HibernationPolicyKt}, and
132      * {@link com.android.permissioncontroller.auto.DrivingDecisionReminderService}
133      */
134     public static final String PERMISSION_REMINDER_CHANNEL_ID = "permission reminders";
135 
136     /**
137      * Name of generic shared preferences file.
138      */
139     public static final String PREFERENCES_FILE = "preferences";
140 
141     /**
142      * Key in the generic shared preferences that stores when the location access feature
143      * was enabled, specifically when it was picked up by the code managing the feature.
144      */
145     public static final String KEY_LOCATION_ACCESS_CHECK_ENABLED_TIME =
146             "location_access_check_enabled_time";
147 
148     /**
149      * Key in the generic shared preferences that stores when the last notification was shown by
150      * {@link com.android.permissioncontroller.permission.service.LocationAccessCheck}
151      */
152     public static final String KEY_LAST_LOCATION_ACCESS_NOTIFICATION_SHOWN =
153             "last_location_access_notification_shown";
154 
155     /**
156      * Key in the generic shared preferences that stores when the last notification was shown by
157      * {@link com.android.permissioncontroller.privacysources.NotificationListenerCheck}
158      */
159     public static final String KEY_LAST_NOTIFICATION_LISTENER_NOTIFICATION_SHOWN =
160             "last_notification_listener_notification_shown";
161 
162     /**
163      * Key in the generic shared preferences that stores if the user manually selected the "none"
164      * role holder for a role.
165      */
166     public static final String IS_NONE_ROLE_HOLDER_SELECTED_KEY = "is_none_role_holder_selected:";
167 
168     /**
169      * Key in the generic shared preferences that stores if the user manually selected the "none"
170      * role holder for a role.
171      */
172     public static final String SEARCH_INDEXABLE_PROVIDER_PASSWORD_KEY =
173             "search_indexable_provider_password";
174 
175     /**
176      * Key in the generic shared preferences that stores the name of the packages that are currently
177      * have an overridden user sensitivity.
178      */
179     public static final String FORCED_USER_SENSITIVE_UIDS_KEY = "forced_user_sensitive_uids_key";
180 
181     /**
182      * Key in the generic shared preferences that stores if all packages should be considered user
183      * sensitive
184      */
185     public static final String ALLOW_OVERRIDE_USER_SENSITIVE_KEY =
186             "allow_override_user_sensitive_key";
187 
188     /**
189      * Key in the generic shared preferences that controls if the
190      * {@link android.Manifest.permission#RECORD_AUDIO} of the currently registered assistant is
191      * user sensitive.
192      */
193     public static final String ASSISTANT_RECORD_AUDIO_IS_USER_SENSITIVE_KEY =
194             "assistant_record_audio_is_user_sensitive_key";
195 
196     /**
197      * Name of file containing the permissions that should be restored, but have not been restored
198      * yet.
199      */
200     public static final String DELAYED_RESTORE_PERMISSIONS_FILE = "delayed_restore_permissions.xml";
201 
202     /**
203      * Name of file containing the user denied status for requesting roles.
204      */
205     public static final String REQUEST_ROLE_USER_DENIED_FILE = "request_role_user_denied";
206 
207     /**
208      * Logs to dump
209      */
210     public static final String LOGS_TO_DUMP_FILE = "LogToDump.log";
211 
212     /**
213      * Key in the user denied status for requesting roles shared preferences that stores a string
214      * set for the names of the roles that an application has been denied for once.
215      */
216     public static final String REQUEST_ROLE_USER_DENIED_ONCE_KEY_PREFIX = "denied_once:";
217 
218     /**
219      * Key in the user denied status for requesting roles shared preferences that stores a string
220      * set for the names of the roles that an application is always denied for.
221      */
222     public static final String REQUEST_ROLE_USER_DENIED_ALWAYS_KEY_PREFIX = "denied_always:";
223 
224     /**
225      * Intent extra used to pass current sessionId between Permission Controller fragments.
226      */
227     public static final String EXTRA_SESSION_ID =
228             "com.android.permissioncontroller.extra.SESSION_ID";
229 
230     /**
231      * Invalid session id.
232      */
233     public static final long INVALID_SESSION_ID = 0;
234 
235     /**
236      * Key for NotificationManager.notify for auto-granted permissions notification,
237      * when silently displayed to the user.
238      */
239     public static final String ADMIN_AUTO_GRANTED_PERMISSIONS_NOTIFICATION_CHANNEL_ID =
240             "auto granted permissions";
241 
242     /**
243      * Key for NotificationManager.notify the auto-granted permissions notification,
244      * when alerting the user (with sound and vibration).
245      */
246     public static final String ADMIN_AUTO_GRANTED_PERMISSIONS_ALERTING_NOTIFICATION_CHANNEL_ID =
247             "alerting auto granted permissions";
248     /**
249      * ID for notification of auto-granted permissions shown by
250      * {@link com.android.permissioncontroller.permission.ui.AutoGrantPermissionsNotifier}.
251      */
252     public static final int PERMISSION_GRANTED_BY_ADMIN_NOTIFICATION_ID = 1;
253 
254     /**
255      * Package name of the Android platform.
256      */
257     public static final String OS_PACKAGE_NAME = "android";
258 
259     // TODO(b/231624295) add to API
260     @RequiresApi(Build.VERSION_CODES.TIRAMISU)
261     public static final String OPSTR_RECEIVE_AMBIENT_TRIGGER_AUDIO =
262             "android:receive_ambient_trigger_audio";
263 }
264