From 9bd16b4831607ffb3957bae93d3115ed83bd0f4a Mon Sep 17 00:00:00 2001 From: Shankari Date: Wed, 28 Aug 2024 14:22:35 -0700 Subject: [PATCH 1/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20Use=20the=20Explici?= =?UTF-8?q?tIntent=20wrapper=20to=20set=20the=20package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build on https://github.com/e-mission/e-mission-data-collection/pull/233/commits/01c746e35284de284fe3a5bcade47c41f43d9948 by using the ExplicitIntent wrapper that adds the package name. It looks like we handled this earlier, but forgot this location --- .../location/actions/GeofenceLocationIntentService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/android/location/actions/GeofenceLocationIntentService.java b/src/android/location/actions/GeofenceLocationIntentService.java index 97ee9a0..fdd5ad0 100644 --- a/src/android/location/actions/GeofenceLocationIntentService.java +++ b/src/android/location/actions/GeofenceLocationIntentService.java @@ -111,8 +111,7 @@ protected void onHandleIntent(Intent intent) { } private void broadcastLoc(Location loc) { - Intent answerIntent = new Intent(INTENT_NAME); - answerIntent.setPackage(this.getPackageName()); + Intent answerIntent = new ExplicitIntent(this, INTENT_NAME); answerIntent.putExtra(INTENT_RESULT_KEY, loc); Log.i(this, TAG, "broadcasting intent "+answerIntent); LocalBroadcastManager.getInstance(this).sendBroadcast(answerIntent); From ca208b592ebb63301152cf172148b3d9fd86617a Mon Sep 17 00:00:00 2001 From: Shankari Date: Mon, 7 Oct 2024 13:20:27 -0700 Subject: [PATCH 2/3] Single-line changes to remove notification checks in the background checker As part of https://github.com/e-mission/e-mission-docs/issues/1094, we made the notification permission optional. Since it is not required for silent push notifications, notifications are nice-to-have. They are still helpful to ensure that people know if there are issues, and hopefully help them label their trips, but the app will still work if the permission is turned off. Since this is no longer required for normal operation, we don't need to check it in the background every hour, and nag the user to fix it if it is turned off. This is a super-easy change (two lines), so rolling this in while fixing https://github.com/e-mission/e-mission-docs/issues/1094 instead of coming in as a future fix. Testing done: - Replaced the data collection plugin with the most recent version - Code compiles - Wasn't able to test in the emulator since with the permission turned off, without https://github.com/e-mission/e-mission-phone/pull/1182 in place, we got a prompt to fix the notification, so we couldn't simulate a remote push Pushing this and testing all the changes together --- src/android/verification/SensorControlBackgroundChecker.java | 1 - src/ios/Verification/SensorControlBackgroundChecker.m | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/android/verification/SensorControlBackgroundChecker.java b/src/android/verification/SensorControlBackgroundChecker.java index 22007fe..b2f841a 100644 --- a/src/android/verification/SensorControlBackgroundChecker.java +++ b/src/android/verification/SensorControlBackgroundChecker.java @@ -107,7 +107,6 @@ public static void checkAppState(final Context ctxt) { SensorControlChecks.checkLocationPermissions(ctxt), SensorControlChecks.checkIgnoreBatteryOptimizations(ctxt), SensorControlChecks.checkMotionActivityPermissions(ctxt), - SensorControlChecks.checkNotificationsEnabled(ctxt), }; boolean allOtherChecksPass = true; for (boolean check: allOtherChecks) { diff --git a/src/ios/Verification/SensorControlBackgroundChecker.m b/src/ios/Verification/SensorControlBackgroundChecker.m index 8c36e50..c3761af 100644 --- a/src/ios/Verification/SensorControlBackgroundChecker.m +++ b/src/ios/Verification/SensorControlBackgroundChecker.m @@ -47,8 +47,7 @@ +(void)checkAppState @([TripDiarySensorControlChecks checkLocationSettings]), @([TripDiarySensorControlChecks checkLocationPermissions]), @([TripDiarySensorControlChecks checkMotionActivitySettings]), - @([TripDiarySensorControlChecks checkMotionActivityPermissions]), - @([TripDiarySensorControlChecks checkNotificationsEnabled]) + @([TripDiarySensorControlChecks checkMotionActivityPermissions]) ]; BOOL allChecksPass = TRUE; for (NSNumber* check in allChecks) { From 15b7a7a3892b66667e00acddb7079807900fd411 Mon Sep 17 00:00:00 2001 From: Shankari Date: Wed, 28 Aug 2024 14:22:35 -0700 Subject: [PATCH 3/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20Use=20the=20Explici?= =?UTF-8?q?tIntent=20wrapper=20to=20set=20the=20package?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Build on https://github.com/e-mission/e-mission-data-collection/pull/233/commits/01c746e35284de284fe3a5bcade47c41f43d9948 by using the ExplicitIntent wrapper that adds the package name. It looks like we handled this earlier, but forgot this location --- 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 fdd5ad0..28e05f9 100644 --- a/src/android/location/actions/GeofenceLocationIntentService.java +++ b/src/android/location/actions/GeofenceLocationIntentService.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.Objects; +import edu.berkeley.eecs.emission.cordova.tracker.ExplicitIntent; import edu.berkeley.eecs.emission.cordova.unifiedlogger.Log; /**