Add a 'debug' option, which will send the collapse_key back to the server. This is controlled by server - to minimize extra traffic.

This commit is contained in:
costin
2010-06-21 22:33:37 +00:00
parent 11e794d477
commit 0913a87687
2 changed files with 27 additions and 1 deletions

View File

@@ -16,6 +16,12 @@
package com.google.android.apps.chrometophone;
import java.io.IOException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
@@ -63,6 +69,26 @@ public class C2DMReceiver extends C2DMBaseReceiver {
String url = (String) extras.get("url");
String title = (String) extras.get("title");
String sel = (String) extras.get("sel");
String debug = (String) extras.get("debug");
if (debug != null) {
// server-controlled debug - the server wants to know
// we received the message, and when. This is not user-controllable,
// we don't want extra traffic on the server or phone. Server may
// turn this on for a small percentage of requests or for users
// who report issues.
DefaultHttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(DeviceRegistrar.BASE_URL + "/debug?id="
+ extras.get("collapse_key"));
// No auth - the purpose is only to generate a log/confirm delivery
// (to avoid overhead of getting the token)
try {
client.execute(get);
} catch (ClientProtocolException e) {
// ignore
} catch (IOException e) {
// ignore
}
}
if (url != null && title != null) {
if (url.startsWith("http")) {
// Put selection in clipboard

View File

@@ -52,7 +52,7 @@ import android.util.Log;
public class DeviceRegistrar {
private static final String TAG = "DeviceRegistrar";
static final String SENDER_ID = "stp.chrome@gmail.com";
private static final String BASE_URL = "https://chrometophone.appspot.com";
static final String BASE_URL = "https://chrometophone.appspot.com";
// Appengine authentication
private static final String AUTH_URL = BASE_URL + "/_ah/login";