Set the package name of the registration service, to be extra sure it is not routed to a bad application ( which wouldn't be able to to anything bad, since receiving is protected by permissions, but may disrupt registration )

This commit is contained in:
costin
2010-05-25 21:52:22 +00:00
parent 9b7518d603
commit 20d0a396a0

View File

@@ -34,6 +34,7 @@ public class C2DMessaging {
public static final String REQUEST_REGISTRATION_INTENT = "com.google.android.c2dm.intent.REGISTER";
public static final String LAST_REGISTRATION_CHANGE = "last_registration_change";
public static final String BACKOFF = "backoff";
public static final String GSF_PACKAGE = "com.google.android.gsf";
// package
@@ -47,6 +48,7 @@ public class C2DMessaging {
public static void register(Context context,
String senderId) {
Intent registrationIntent = new Intent(REQUEST_REGISTRATION_INTENT);
registrationIntent.setPackage(GSF_PACKAGE);
registrationIntent.putExtra(EXTRA_APPLICATION_PENDING_INTENT,
PendingIntent.getBroadcast(context, 0, new Intent(), 0));
registrationIntent.putExtra(EXTRA_SENDER, senderId);
@@ -59,6 +61,7 @@ public class C2DMessaging {
*/
public static void unregister(Context context) {
Intent regIntent = new Intent(REQUEST_UNREGISTRATION_INTENT);
regIntent.setPackage(GSF_PACKAGE);
regIntent.putExtra(EXTRA_APPLICATION_PENDING_INTENT, PendingIntent.getBroadcast(context,
0, new Intent(), 0));
context.startService(regIntent);