Skip to content

Commit

Permalink
Merge pull request #71 from akwizgran/attach-package-name-to-status-b…
Browse files Browse the repository at this point in the history
…roadcast

Attach package name to status broadcasts.
  • Loading branch information
eighthave committed Feb 17, 2022
2 parents b4e0d59 + b1b7eef commit f44b1d1
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@ public class TorService extends Service {
*/
public final static String EXTRA_PACKAGE_NAME = "org.torproject.android.intent.extra.PACKAGE_NAME";

/**
* The {@link String} {@code packageName} of the app to which this {@code TorService} belongs.
* This allows broadcast receivers to distinguish between broadcasts from different apps that
* use {@code TorService}.
*/
public final static String EXTRA_SERVICE_PACKAGE_NAME = "org.torproject.android.intent.extra.SERVICE_PACKAGE_NAME";

/**
* All tor-related services and daemons are stopped
*/
Expand Down Expand Up @@ -447,6 +454,7 @@ public TorControlConnection getTorControlConnection() {
*/
static void sendBroadcastStatusIntent(Context context) {
Intent intent = getBroadcastIntent(ACTION_STATUS, currentStatus);
intent.putExtra(EXTRA_SERVICE_PACKAGE_NAME, context.getPackageName());
context.sendBroadcast(intent);
}

Expand All @@ -457,6 +465,7 @@ static void sendBroadcastStatusIntent(Context context) {
static void broadcastStatus(Context context, String currentStatus) {
TorService.currentStatus = currentStatus;
Intent intent = getBroadcastIntent(ACTION_STATUS, currentStatus);
intent.putExtra(EXTRA_SERVICE_PACKAGE_NAME, context.getPackageName());
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
context.sendBroadcast(intent);
}
Expand Down

0 comments on commit f44b1d1

Please sign in to comment.