com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.C2dmConstants Java Examples

The following examples show how to use com.google.ipc.invalidation.ticl.android2.channel.AndroidChannelConstants.C2dmConstants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AndroidChannelPreferences.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/** Sets the token echoed on subsequent HTTP requests. */
static void setEchoToken(Context context, String token) {
  SharedPreferences.Editor editor = getPreferences(context).edit();

  // This might fail, but at worst it just means we lose an echo token; the channel
  // needs to be able to handle that anyway since it can never assume an echo token
  // makes it to the client (since the channel can drop messages).
  editor.putString(C2dmConstants.ECHO_PARAM, token);
  if (!editor.commit()) {
    logger.warning("Failed writing shared preferences for: setEchoToken");
  }
}
 
Example #2
Source File: AndroidChannelPreferences.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Sets the token echoed on subsequent HTTP requests. */
static void setEchoToken(Context context, String token) {
  SharedPreferences.Editor editor = getPreferences(context).edit();

  // This might fail, but at worst it just means we lose an echo token; the channel
  // needs to be able to handle that anyway since it can never assume an echo token
  // makes it to the client (since the channel can drop messages).
  editor.putString(C2dmConstants.ECHO_PARAM, token);
  commitEditor(editor, "setEchoToken");
}
 
Example #3
Source File: AndroidMessageReceiverService.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onMessage(Intent intent) {
  // Forward the message to the Ticl service.
  if (intent.hasExtra(C2dmConstants.CONTENT_PARAM)) {
    String content = intent.getStringExtra(C2dmConstants.CONTENT_PARAM);
    byte[] msgBytes = Base64.decode(content, Base64.URL_SAFE);
    try {
      // Look up the name of the Ticl service class from the manifest.
      String serviceClass = new AndroidTiclManifest(this).getTiclServiceClass();
      AddressedAndroidMessage addrMessage = AddressedAndroidMessage.parseFrom(msgBytes);
      Intent msgIntent =
          ProtocolIntents.InternalDowncalls.newServerMessageIntent(addrMessage.getMessage());
      msgIntent.setClassName(this, serviceClass);
      startService(msgIntent);
    } catch (InvalidProtocolBufferException exception) {
      logger.warning("Failed parsing inbound message: %s", exception);
    }
  } else {
    logger.fine("GCM Intent has no message content: %s", intent);
  }

  // Store the echo token.
  String echoToken = intent.getStringExtra(C2dmConstants.ECHO_PARAM);
  if (echoToken != null) {
    AndroidChannelPreferences.setEchoToken(this, echoToken);
  }
}
 
Example #4
Source File: AndroidChannelPreferences.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Sets the token echoed on subsequent HTTP requests. */
static void setEchoToken(Context context, String token) {
  SharedPreferences.Editor editor = getPreferences(context).edit();

  // This might fail, but at worst it just means we lose an echo token; the channel
  // needs to be able to handle that anyway since it can never assume an echo token
  // makes it to the client (since the channel can drop messages).
  editor.putString(C2dmConstants.ECHO_PARAM, token);
  commitEditor(editor, "setEchoToken");
}
 
Example #5
Source File: AndroidMessageReceiverService.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected void onMessage(Intent intent) {
  // Forward the message to the Ticl service.
  if (intent.hasExtra(C2dmConstants.CONTENT_PARAM)) {
    String content = intent.getStringExtra(C2dmConstants.CONTENT_PARAM);
    byte[] msgBytes = Base64.decode(content, Base64.URL_SAFE);
    try {
      // Look up the name of the Ticl service class from the manifest.
      String serviceClass = new AndroidTiclManifest(this).getTiclServiceClass();
      AddressedAndroidMessage addrMessage = AddressedAndroidMessage.parseFrom(msgBytes);
      Intent msgIntent =
          ProtocolIntents.InternalDowncalls.newServerMessageIntent(addrMessage.getMessage());
      msgIntent.setClassName(this, serviceClass);
      startService(msgIntent);
    } catch (InvalidProtocolBufferException exception) {
      logger.warning("Failed parsing inbound message: %s", exception);
    }
  } else {
    logger.fine("GCM Intent has no message content: %s", intent);
  }

  // Store the echo token.
  String echoToken = intent.getStringExtra(C2dmConstants.ECHO_PARAM);
  if (echoToken != null) {
    AndroidChannelPreferences.setEchoToken(this, echoToken);
  }
}
 
Example #6
Source File: AndroidChannelPreferences.java    From 365browser with Apache License 2.0 4 votes vote down vote up
/** Returns the echo token that should be included on HTTP requests. */

public static String getEchoToken(Context context) {
  return getPreferences(context).getString(C2dmConstants.ECHO_PARAM, null);
}
 
Example #7
Source File: AndroidChannelPreferences.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/** Returns the echo token that should be included on HTTP requests. */

public static String getEchoToken(Context context) {
  return getPreferences(context).getString(C2dmConstants.ECHO_PARAM, null);
}
 
Example #8
Source File: AndroidChannelPreferences.java    From android-chromium with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/** Returns the echo token that should be included on HTTP requests. */

public static String getEchoToken(Context context) {
  return getPreferences(context).getString(C2dmConstants.ECHO_PARAM, null);
}