From 271bfc39fd7b27b6846e988c3e54bff1fb2a3851 Mon Sep 17 00:00:00 2001 From: Shankari Date: Sun, 25 Aug 2024 17:00:39 -0700 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9B=82=20Manifest-related=20changes?= =?UTF-8?q?=20to=20support=20the=20foreground=20service=20in=20android=201?= =?UTF-8?q?4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This addresses a couple of the issues in https://github.com/e-mission/e-mission-docs/issues/1079#issuecomment-2309049358 ❌ If apps that target Android 14 use a foreground service, they must declare a specific permission, based on the foreground service type, that Android 14 introduces. **FIXed by** ✔️ Added `FOREGROUND_SERVICE_HEALTH` and `FOREGROUND_SERVICE_LOCATION` permissions ❌ ACTIVITY_RECOGNITION permission seems to imply health as part of the foreground service as well **FIXed by** ✔️ Changed the type to `android:foregroundServiceType="location|health"` Bumped up the plugin version as well --- plugin.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin.xml b/plugin.xml index 3ead8f0..c396714 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,7 +1,7 @@ + version="1.8.9"> DataCollection Background data collection FTW! This is the part that I really @@ -54,6 +54,8 @@ + + @@ -109,7 +111,7 @@ Date: Wed, 28 Aug 2024 13:56:08 -0700 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=92=EF=B8=8F=20Restrict=20the=20ge?= =?UTF-8?q?ofence=20location=20event=20to=20the=20current=20package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is one of the security recommendations https://developer.android.com/develop/background-work/background-tasks/broadcasts#java I also tried to change the receiver to be NOT_EXPORTED, but could not get that to work in the limited time available. I also tried to send the message via an Intent that specified the context and the class, but that does not work with broadcast intents https://github.com/e-mission/e-mission-docs/issues/1079#issuecomment-2314436185 Testing done: - Before the change ``` 08-27 22:36:18.466 4901 5581 I GeofenceLocationIntentService: broadcasting intent Intent { act=GEOFENCE_LOCATION_RESULT (has extras) } ``` - After the change ``` 08-27 22:42:29.312 6785 7442 I GeofenceLocationIntentService: broadcasting intent Intent { act=GEOFENCE_LOCATION_RESULT pkg=edu.berkeley.eecs.emission (has extras) } ``` --- src/android/location/actions/GeofenceLocationIntentService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/android/location/actions/GeofenceLocationIntentService.java b/src/android/location/actions/GeofenceLocationIntentService.java index 1f97fd7..97ee9a0 100644 --- a/src/android/location/actions/GeofenceLocationIntentService.java +++ b/src/android/location/actions/GeofenceLocationIntentService.java @@ -112,6 +112,7 @@ protected void onHandleIntent(Intent intent) { private void broadcastLoc(Location loc) { Intent answerIntent = new Intent(INTENT_NAME); + answerIntent.setPackage(this.getPackageName()); answerIntent.putExtra(INTENT_RESULT_KEY, loc); Log.i(this, TAG, "broadcasting intent "+answerIntent); LocalBroadcastManager.getInstance(this).sendBroadcast(answerIntent);