Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
dependencies ▾

Modern-Apps.git / emergency / src / main / AndroidManifest.xml

AndroidManifest.xml364 lines · 19.2 KiBRaw
1<?xml version="1.0" encoding="utf-8"?>
2<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3 xmlns:tools="http://schemas.android.com/tools">
4 <!--
5 A like-for-like replacement for GrapheneOS's EmergencyInfo
6 (platform_packages_apps_EmergencyInfo, package com.android.emergency), namespaced to
7 com.vayunmathur.emergency because a Gradle-built app cannot be platform-signed.
8
9 Component contract mirrored 1:1 (see C:\Users\Vayun\.llms\plans\maos_emergency_app.plan.md):
10 view/edit activities answering the same platform actions (EDIT_EMERGENCY_INFO plus
11 the legacy EDIT_MEDICAL_INFO filter on the same editor), the Settings
12 suggestion alias, the ia.emergency injection alias, the SystemUI SOS entry alias
13 (LAUNCH_EMERGENCY, MANAGE_SENSOR_PRIVACY-guarded like stock), the search
14 indexables provider, the FileProvider for avatar photos, and the gesture provider
15 speaking the settingslib EmergencyNumberUtils call() protocol against our own
16 authorities.
17
18 Privileged-only declarations (MANAGE_USERS, WRITE_SECURE_SETTINGS, CALL_PRIVILEGED,
19 READ_PRIVILEGED_PHONE_STATE) follow the parentalcontrols/screentime precedent: declared
20 with ProtectedPermissions ignored, used only inside runCatching with an explicit denied
21 path. They stay inert until the MAOS build promotes this app; nothing crashes without
22 them. The one deliberate omission is EmergencyDialerTrampoline (DIAL_EMERGENCY), which
23 GrapheneOS itself ships disabled - we delegate call placement to Settings, we are not
24 a dialer.
25 -->
26 <!-- Countdown vibration waveform during the SOS countdown. -->
27 <!-- MAOS: opt out of the GrapheneOS Sensors permission (OTHER_SENSORS). -->
28 <!-- This app uses no motion/environment sensors; MAOS withholds the -->
29 <!-- Sensors permission at install instead of auto-granting it. -->
30 <uses-permission android:name="com.vayunmathur.permission.SENSORS_OPTOUT" />
31
32 <uses-permission android:name="android.permission.VIBRATE" />
33 <!-- The SOS receiver fires the call broadcast from the background alarm. -->
34 <uses-permission android:name="android.permission.START_ACTIVITIES_FROM_BACKGROUND"
35 tools:ignore="ProtectedPermissions" />
36 <!-- The SOS countdown runs as a foreground service with its notification. -->
37 <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
38 <!-- specialUse foreground subtype for the SOS countdown service. -->
39 <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
40 <!-- Reads the SIM emergency-number list so the SOS screen names the real number. -->
41 <uses-permission android:name="android.permission.READ_PHONE_STATE" />
42 <!-- Telephony is optional hardware (e.g. ChromeOS tablets); the SOS flow degrades to the 112 fallback without it. -->
43 <uses-feature android:name="android.hardware.telephony" android:required="false" />
44 <!-- Privileged half of emergency-number lookup. Inert without priv-app promotion. -->
45 <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE"
46 tools:ignore="ProtectedPermissions" />
47 <!-- Places the fallback emergency call when Settings' emergency provider is absent. -->
48 <uses-permission android:name="android.permission.CALL_PHONE" />
49 <!-- Guards the gesture provider, mirroring GrapheneOS. Inert without promotion. -->
50 <uses-permission android:name="android.permission.CALL_PRIVILEGED"
51 tools:ignore="ProtectedPermissions" />
52 <!-- Emergency contacts are read from the contacts provider. Runtime grant. -->
53 <uses-permission android:name="android.permission.READ_CONTACTS" />
54 <!-- Owner name/icon on the view screen. Graceful fallback without it. -->
55 <uses-permission android:name="android.permission.MANAGE_USERS"
56 tools:ignore="ProtectedPermissions" />
57 <!-- Gesture provider persists EMERGENCY_GESTURE_* to Settings.Secure. Priv-only. -->
58 <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"
59 tools:ignore="ProtectedPermissions" />
60 <!-- The SOS alarm must fire at the exact countdown end. -->
61 <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
62 <!-- Re-arms nothing persistent, but the countdown alarm must survive reboot windows. -->
63 <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
64 <!-- SOS countdown and restriction-trip notices. A normal runtime permission. -->
65 <uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
66
67 <!--
68 Read-only Personal Health Record access, to surface allergies and current medications from
69 Health Connect on the view card. Requested from the edit screen and allowed to be refused;
70 only grantable on Android 15 with an updated Health Connect module, so on older devices the
71 card simply shows the stored fields. Mirrors the health app's medical read permissions.
72 -->
73 <uses-permission android:name="android.permission.health.READ_MEDICAL_DATA_ALLERGIES_INTOLERANCES" />
74 <uses-permission android:name="android.permission.health.READ_MEDICAL_DATA_MEDICATIONS" />
75 <uses-permission android:name="android.permission.health.READ_MEDICAL_DATA_CONDITIONS" />
76
77 <!-- Not requested, deliberately: no INTERNET. Medical info, contacts and the SOS
78 countdown are all local; the call itself goes through the telephony stack. -->
79 <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"
80 tools:node="remove" />
81
82 <application
83 android:allowBackup="false"
84 android:dataExtractionRules="@xml/data_extraction_rules"
85 android:defaultToDeviceProtectedStorage="true"
86 android:directBootAware="true"
87 android:icon="@mipmap/ic_launcher"
88 android:label="@string/app_name"
89 android:roundIcon="@mipmap/ic_launcher"
90 android:supportsRtl="true"
91 android:theme="@style/Theme.General">
92 <!--
93 Read-only view: medical info + emergency contacts, reachable over the lock screen.
94 Answers android.telephony.action.EMERGENCY_ASSISTANCE like GrapheneOS's
95 ViewInfoActivity. No launcher entry - reached from Settings, the lock screen and
96 the SOS flow, the same way EmergencyInfo is.
97 -->
98 <!--
99 The single info host. Every former activity entry point below is an alias
100 onto this host, keeping its own label, exported flag, intent-filter and
101 Settings meta-data; MainActivity.routeFor turns the arriving intent into
102 the start route (ViewInfo for EMERGENCY_ASSISTANCE, EditInfo for the edit
103 actions). singleTask so a second Settings tap re-routes the running host
104 via onNewIntent instead of stacking hosts. showWhenLocked and
105 directBootAware are preserved from the old ViewInfoActivity so the view
106 card still opens over the lock screen before unlock; the editor is only
107 launched from Settings after unlock. SOS deliberately does NOT route
108 here: SosActivity keeps its own entry below.
109 -->
110 <activity
111 android:name=".MainActivity"
112 android:configChanges="mcc|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|keyboardHidden|layoutDirection|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
113 android:directBootAware="true"
114 android:exported="true"
115 android:launchMode="singleTask"
116 android:showWhenLocked="true"
117 android:taskAffinity="com.android.settings"
118 android:theme="@style/Theme.General" />
119
120 <!-- The lock-screen view card, answering EMERGENCY_ASSISTANCE. -->
121 <activity-alias
122 android:name=".ui.ViewInfoActivity"
123 android:exported="true"
124 android:label="@string/app_name"
125 android:targetActivity=".MainActivity">
126 <intent-filter>
127 <action android:name="android.telephony.action.EMERGENCY_ASSISTANCE" />
128 <category android:name="android.intent.category.DEFAULT" />
129 </intent-filter>
130 </activity-alias>
131
132 <!--
133 Edit entry: contacts + medical info. Answers android.settings.EDIT_EMERGENCY_INFO
134 like GrapheneOS's EditInfoActivity, and also android.emergency.EDIT_MEDICAL_INFO
135 like its EditMedicalInfoActivity: stock splits those across two activities, but
136 our editor already covers both, so both filters land here and the legacy action
137 keeps resolving.
138 -->
139 <!-- The editor entry: EDIT_EMERGENCY_INFO plus the legacy EDIT_MEDICAL_INFO. -->
140 <activity-alias
141 android:name=".ui.EditInfoActivity"
142 android:exported="true"
143 android:label="@string/app_name"
144 android:targetActivity=".MainActivity">
145 <intent-filter>
146 <action android:name="android.settings.EDIT_EMERGENCY_INFO" />
147 <category android:name="android.intent.category.DEFAULT" />
148 </intent-filter>
149 <intent-filter>
150 <action android:name="android.emergency.EDIT_MEDICAL_INFO" />
151 <category android:name="android.intent.category.DEFAULT" />
152 </intent-filter>
153 </activity-alias>
154
155 <!--
156 Settings first-run suggestion, independent of the edit activity so it can be
157 disabled once any info or contact is set (see EmergencyRepository). Mirrors
158 GrapheneOS's EditInfoSuggestion alias.
159 -->
160 <activity-alias
161 android:name=".ui.EditInfoSuggestion"
162 android:exported="true"
163 android:label="@string/app_name"
164 android:targetActivity=".MainActivity">
165 <intent-filter>
166 <action android:name="android.intent.action.MAIN" />
167 <category android:name="com.android.settings.suggested.category.FIRST_IMPRESSION" />
168 </intent-filter>
169 <meta-data
170 android:name="com.android.settings.dismiss"
171 android:value="11,15,30" />
172 <meta-data
173 android:name="com.android.settings.title"
174 android:resource="@string/settings_suggestion_title" />
175 <meta-data
176 android:name="com.android.settings.summary"
177 android:resource="@string/settings_suggestion_body" />
178 <meta-data
179 android:name="com.android.settings.icon"
180 android:resource="@mipmap/ic_launcher" />
181 </activity-alias>
182
183 <!--
184 The Settings > Safety & emergency row. Mirrors GrapheneOS's EmergencyInfoActivity
185 alias: same IA_SETTINGS action, same ia.emergency category, same order and profile.
186 -->
187 <activity-alias
188 android:name=".ui.EmergencyInfoAlias"
189 android:exported="false"
190 android:icon="@mipmap/ic_launcher"
191 android:label="@string/app_name"
192 android:targetActivity=".MainActivity">
193 <intent-filter>
194 <action android:name="com.android.settings.action.IA_SETTINGS" />
195 <category android:name="android.intent.category.DEFAULT" />
196 </intent-filter>
197 <meta-data
198 android:name="com.android.settings.category"
199 android:value="com.android.settings.category.ia.emergency" />
200 <meta-data
201 android:name="com.android.settings.order"
202 android:value="60" />
203 <meta-data
204 android:name="com.android.settings.icon"
205 android:resource="@mipmap/ic_launcher" />
206 <meta-data
207 android:name="com.android.settings.icon_tintable"
208 android:value="true" />
209 <meta-data
210 android:name="com.android.settings.summary"
211 android:resource="@string/injection_summary_empty" />
212 <meta-data
213 android:name="com.android.settings.profile"
214 android:value="primary_profile_only" />
215 </activity-alias>
216
217 <!--
218 The SOS countdown screen, reached from the power-button gesture via SystemUI
219 (see the SosEntryPoint alias below). Not exported: only the platform gesture
220 path (or our own notification action) starts it explicitly. turnScreenOn wakes
221 the device when the gesture fires with the screen off; noHistory keeps back
222 from returning to the countdown; finishing without cancel hands the countdown
223 to the foreground service. All three mirror stock's EmergencyActionActivity.
224 -->
225 <activity
226 android:name=".ui.SosActivity"
227 android:configChanges="mcc|mnc|colorMode|density|fontScale|fontWeightAdjustment|keyboard|keyboardHidden|layoutDirection|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
228 android:directBootAware="true"
229 android:excludeFromRecents="true"
230 android:exported="false"
231 android:launchMode="singleInstance"
232 android:noHistory="true"
233 android:showWhenLocked="true"
234 android:turnScreenOn="true"
235 android:theme="@style/Theme.General" />
236
237 <!--
238 SystemUI entry point for the power-button SOS gesture. Mirrors stock's
239 EmergencyAction alias: exported, MANAGE_SENSOR_PRIVACY-guarded, answering
240 com.android.systemui.action.LAUNCH_EMERGENCY. SystemUI resolves this action
241 with MATCH_SYSTEM_ONLY and prefers config_preferredEmergencySosPackage, which
242 MAOS leaves empty, so the first (only) match wins - no SystemUI patch needed.
243 The target stays non-exported exactly like stock's EmergencyActionActivity.
244 -->
245 <activity-alias
246 android:name=".ui.SosEntryPoint"
247 android:exported="true"
248 android:label="@string/sos_channel_name"
249 android:permission="android.permission.MANAGE_SENSOR_PRIVACY"
250 android:targetActivity=".ui.SosActivity">
251 <intent-filter>
252 <action android:name="com.android.systemui.action.LAUNCH_EMERGENCY" />
253 <category android:name="android.intent.category.DEFAULT" />
254 </intent-filter>
255 </activity-alias>
256
257 <!--
258 SOS countdown service: notification + exact alarm + vibration + warning sound.
259 Not exported: started explicitly by the SOS screen and the receiver.
260 specialUse, following screentime's FocusService: this is not an ongoing call
261 (phoneCall type would need FOREGROUND_SERVICE_PHONE_CALL and misdescribes a
262 countdown), it keeps the gesture countdown alive while the screen is off.
263 -->
264 <service
265 android:name=".service.SosCountdownService"
266 android:directBootAware="true"
267 android:exported="false"
268 android:foregroundServiceType="specialUse">
269 <property
270 android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE"
271 android:value="Counts down to placing an emergency call so the gesture survives the screen turning off." />
272 </service>
273
274 <!--
275 SOS outcomes: MAKE places the call (via Settings' emergency provider, falling back
276 to an explicit emergency-call intent) and CANCEL stops the service. Not exported:
277 both are explicit-class intents from our own notification, alarm and screen.
278 -->
279 <receiver
280 android:name=".notifications.SosActionReceiver"
281 android:exported="false">
282 <intent-filter>
283 <action android:name="com.vayunmathur.emergency.broadcast.MAKE_EMERGENCY_CALL" />
284 <action android:name="com.vayunmathur.emergency.broadcast.CANCEL_EMERGENCY_COUNTDOWN" />
285 </intent-filter>
286 </receiver>
287
288 <!-- Settings search indexing for the emergency rows. -->
289 <provider
290 android:name=".platform.EmergencySearchIndexablesProvider"
291 android:authorities="com.vayunmathur.emergency"
292 android:exported="true"
293 android:grantUriPermissions="true"
294 android:multiprocess="false"
295 android:permission="android.permission.READ_SEARCH_INDEXABLES">
296 <intent-filter>
297 <action android:name="android.content.action.SEARCH_INDEXABLES_PROVIDER" />
298 </intent-filter>
299 </provider>
300
301 <!-- Avatar photo sharing for the medical-info editor. -->
302 <provider
303 android:name="androidx.core.content.FileProvider"
304 android:authorities="com.vayunmathur.emergency.files"
305 android:exported="false"
306 android:grantUriPermissions="true">
307 <meta-data
308 android:name="android.support.FILE_PROVIDER_PATHS"
309 android:resource="@xml/file_paths" />
310 </provider>
311
312 <!--
313 Gesture state for Settings: number override, gesture/sound toggles, UI-showing
314 heartbeat. Mirrors GrapheneOS's EmergencyGestureContentProvider call() protocol;
315 CALL_PRIVILEGED guards it the same way. Query/insert/update/delete throw.
316 Both authorities serve the same class/state: ours for the MAOS build (whose
317 SettingsLib is rewired to it) and the stock com.android.emergency.gesture for
318 unpatched Settings, whose ContentResolver.call() throws IllegalArgumentException
319 on an unknown authority and crashes Settings on resume. Safe while stock
320 EmergencyInfo is absent (MAOS removes it); a co-installed stock app would
321 conflict at install time instead of silently shadowing.
322 -->
323 <provider
324 android:name=".platform.GestureProvider"
325 android:authorities="com.vayunmathur.emergency.gesture;com.android.emergency.gesture"
326 android:exported="true"
327 android:permission="android.permission.CALL_PRIVILEGED" />
328
329 <!--
330 Health Connect requires an app that reads medical data to answer the permissions
331 rationale intent, and to expose a VIEW_PERMISSION_USAGE entry point. Both mirror the
332 health app: the rationale screen can be empty, and the alias points Settings at it.
333 -->
334 <activity
335 android:name=".ui.PermissionsRationaleActivity"
336 android:exported="true">
337 <intent-filter>
338 <action android:name="androidx.health.ACTION_SHOW_PERMISSIONS_RATIONALE" />
339 </intent-filter>
340 </activity>
341
342 <activity-alias
343 android:name="ViewPermissionUsageActivity"
344 android:exported="true"
345 android:permission="android.permission.START_VIEW_PERMISSION_USAGE"
346 android:targetActivity=".ui.PermissionsRationaleActivity">
347 <intent-filter>
348 <action android:name="android.intent.action.VIEW_PERMISSION_USAGE" />
349 <category android:name="android.intent.category.HEALTH_PERMISSIONS" />
350 </intent-filter>
351 </activity-alias>
352 </application>
353
354 <!-- Avatar capture in the medical-info editor. -->
355 <queries>
356 <intent>
357 <action android:name="android.media.action.IMAGE_CAPTURE" />
358 </intent>
359 <intent>
360 <action android:name="android.intent.action.GET_CONTENT" />
361 <data android:mimeType="image/*" />
362 </intent>
363 </queries>
364</manifest>