Skip to content

Commit

Permalink
🔒️ Restrict the geofence location event to the current package
Browse files Browse the repository at this point in the history
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
e-mission/e-mission-docs#1079 (comment)

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) }
```
  • Loading branch information
shankari committed Aug 28, 2024
1 parent 271bfc3 commit 01c746e
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 01c746e

Please sign in to comment.