Skip to content
Snippets Groups Projects
Unverified Commit f44b1d15 authored by Hans-Christoph Steiner's avatar Hans-Christoph Steiner Committed by GitHub
Browse files

Merge pull request #71 from akwizgran/attach-package-name-to-status-broadcast

Attach package name to status broadcasts.
parents b4e0d59f b1b7eef8
Branches
No related tags found
No related merge requests found
...@@ -83,6 +83,13 @@ public class TorService extends Service { ...@@ -83,6 +83,13 @@ public class TorService extends Service {
*/ */
public final static String EXTRA_PACKAGE_NAME = "org.torproject.android.intent.extra.PACKAGE_NAME"; 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 * All tor-related services and daemons are stopped
*/ */
...@@ -447,6 +454,7 @@ public class TorService extends Service { ...@@ -447,6 +454,7 @@ public class TorService extends Service {
*/ */
static void sendBroadcastStatusIntent(Context context) { static void sendBroadcastStatusIntent(Context context) {
Intent intent = getBroadcastIntent(ACTION_STATUS, currentStatus); Intent intent = getBroadcastIntent(ACTION_STATUS, currentStatus);
intent.putExtra(EXTRA_SERVICE_PACKAGE_NAME, context.getPackageName());
context.sendBroadcast(intent); context.sendBroadcast(intent);
} }
...@@ -457,6 +465,7 @@ public class TorService extends Service { ...@@ -457,6 +465,7 @@ public class TorService extends Service {
static void broadcastStatus(Context context, String currentStatus) { static void broadcastStatus(Context context, String currentStatus) {
TorService.currentStatus = currentStatus; TorService.currentStatus = currentStatus;
Intent intent = getBroadcastIntent(ACTION_STATUS, currentStatus); Intent intent = getBroadcastIntent(ACTION_STATUS, currentStatus);
intent.putExtra(EXTRA_SERVICE_PACKAGE_NAME, context.getPackageName());
LocalBroadcastManager.getInstance(context).sendBroadcast(intent); LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
context.sendBroadcast(intent); context.sendBroadcast(intent);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment