• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ProtocolIntents类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.ipc.invalidation.ticl.android2.ProtocolIntents的典型用法代码示例。如果您正苦于以下问题:Java ProtocolIntents类的具体用法?Java ProtocolIntents怎么用?Java ProtocolIntents使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ProtocolIntents类属于com.google.ipc.invalidation.ticl.android2包,在下文中一共展示了ProtocolIntents类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onHandleIntent

import com.google.ipc.invalidation.ticl.android2.ProtocolIntents; //导入依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
  if (AndroidChannelPreferences.getGcmChannelType(this) != GcmChannelType.GCM_UPSTREAM) {
    logger.warning("Incorrect channel type for using GCM Upstream");
    return;
  }
  if (intent == null) {
    return;
  }

  if (intent.hasExtra(ProtocolIntents.OUTBOUND_MESSAGE_KEY)) {
    // Request from the Ticl service to send a message.
    handleOutboundMessage(intent.getByteArrayExtra(ProtocolIntents.OUTBOUND_MESSAGE_KEY));
  } else if (intent.hasExtra(AndroidChannelConstants.MESSAGE_SENDER_SVC_GCM_REGID_CHANGE)) {
    handleGcmRegIdChange();
  } else {
    logger.warning("Ignoring intent: %s", intent);
  }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:20,代码来源:GcmUpstreamSenderService.java


示例2: sendMessage

import com.google.ipc.invalidation.ticl.android2.ProtocolIntents; //导入依赖的package包/类
@Override
public void sendMessage(byte[] outgoingMessage) {
  Intent intent = ProtocolIntents.newOutboundMessageIntent(outgoingMessage);

  // Select the sender service to use for upstream message.
  if (AndroidChannelPreferences.getGcmChannelType(context) == GcmChannelType.GCM_UPSTREAM){
    String upstreamServiceClass = new AndroidTiclManifest(context).getGcmUpstreamServiceClass();
    if (upstreamServiceClass == null || upstreamServiceClass.isEmpty()) {
      logger.warning("GcmUpstreamSenderService class not found.");
      return;
    }
    intent.setClassName(context, upstreamServiceClass);
  } else {
    intent.setClassName(context, AndroidMessageSenderService.class.getName());
  }
  try {
    context.startService(intent);
  } catch (IllegalStateException exception) {
    logger.warning("Unable to send message: %s", exception);
  }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:22,代码来源:AndroidNetworkChannel.java


示例3: onHandleIntent

import com.google.ipc.invalidation.ticl.android2.ProtocolIntents; //导入依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
  if (intent == null) {
    return;
  }

  if (intent.hasExtra(ProtocolIntents.OUTBOUND_MESSAGE_KEY)) {
    // Request from the Ticl service to send a message.
    handleOutboundMessage(intent.getByteArrayExtra(ProtocolIntents.OUTBOUND_MESSAGE_KEY));
  } else if (intent.hasExtra(AndroidChannelConstants.AuthTokenConstants.EXTRA_AUTH_TOKEN)) {
    // Reply from the app with an auth token and a message to send.
    handleAuthTokenResponse(intent);
  } else if (intent.hasExtra(AndroidChannelConstants.MESSAGE_SENDER_SVC_GCM_REGID_CHANGE)) {
    handleGcmRegIdChange();
  } else {
    logger.warning("Ignoring intent: %s", intent);
  }
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:19,代码来源:AndroidMessageSenderService.java


示例4: tryHandleStartIntent

import com.google.ipc.invalidation.ticl.android2.ProtocolIntents; //导入依赖的package包/类
/** Tries to handle a start intent. Returns {@code true} iff the intent is a start intent. */
private boolean tryHandleStartIntent(Intent intent) {
  StartCommand command = AndroidListenerIntents.findStartCommand(intent);
  if ((command == null) || !AndroidListenerProtos.isValidStartCommand(command)) {
    return false;
  }
  // Reset the state so that we make no assumptions about desired registrations and can ignore
  // messages directed at the wrong instance.
  state = new AndroidListenerState(initialMaxDelayMs, maxDelayFactor);
  boolean skipStartForTest = false;
  ClientConfigP clientConfig = InvalidationClientCore.createConfig();
  if (command.getAllowSuppression() != clientConfig.getAllowSuppression()) {
    ClientConfigP.Builder clientConfigBuilder = clientConfig.toBuilder();
    clientConfigBuilder.allowSuppression = command.getAllowSuppression();
    clientConfig = clientConfigBuilder.build();
  }
  Intent startIntent = ProtocolIntents.InternalDowncalls.newCreateClientIntent(
      command.getClientType(), command.getClientName(), clientConfig, skipStartForTest);
  AndroidListenerIntents.issueTiclIntent(getApplicationContext(), startIntent);
  return true;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:22,代码来源:AndroidListener.java


示例5: tryHandleBackgroundInvalidationsIntent

import com.google.ipc.invalidation.ticl.android2.ProtocolIntents; //导入依赖的package包/类
/**
 * Tries to handle a background invalidation intent. Returns {@code true} iff the intent is a
 * background invalidation intent.
 */
private boolean tryHandleBackgroundInvalidationsIntent(Intent intent) {
  byte[] data = intent.getByteArrayExtra(ProtocolIntents.BACKGROUND_INVALIDATION_KEY);
  if (data == null) {
    return false;
  }
  try {
    InvalidationMessage invalidationMessage = InvalidationMessage.parseFrom(data);
    List<Invalidation> invalidations = new ArrayList<Invalidation>();
    for (InvalidationP invalidation : invalidationMessage.getInvalidation()) {
      invalidations.add(ProtoWrapperConverter.convertFromInvalidationProto(invalidation));
    }
    backgroundInvalidateForInternalUse(invalidations);
  } catch (ValidationException exception) {
    logger.info("Failed to parse background invalidation intent payload: %s",
        exception.getMessage());
  }
  return false;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:23,代码来源:AndroidListener.java


示例6: onRegistered

import com.google.ipc.invalidation.ticl.android2.ProtocolIntents; //导入依赖的package包/类
@Override
protected void onRegistered(String registrationId) {
  // Inform the sender service that the registration id has changed. If the sender service
  // had buffered a message because no registration id was previously available, this intent
  // will cause it to send that message.
  Intent sendBuffered = new Intent();
  final String ignoredData = "";
  sendBuffered.putExtra(AndroidChannelConstants.MESSAGE_SENDER_SVC_GCM_REGID_CHANGE, ignoredData);
  sendBuffered.setClass(this, AndroidMessageSenderService.class);
  startService(sendBuffered);

  // Inform the Ticl service that the registration id has changed. This will cause it to send
  // a message to the data center and update the GCM registration id stored at the data center.
  Intent updateServer = ProtocolIntents.InternalDowncalls.newNetworkAddrChangeIntent();
  updateServer.setClassName(this, new AndroidTiclManifest(this).getTiclServiceClass());
  startService(updateServer);
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:18,代码来源:AndroidMessageReceiverService.java


示例7: tryHandleStartIntent

import com.google.ipc.invalidation.ticl.android2.ProtocolIntents; //导入依赖的package包/类
/** Tries to handle a start intent. Returns {@code true} iff the intent is a start intent. */
private boolean tryHandleStartIntent(Intent intent) {
  StartCommand command = AndroidListenerIntents.findStartCommand(intent);
  if ((command == null) || !AndroidListenerProtos.isValidStartCommand(command)) {
    return false;
  }
  // Reset the state so that we make no assumptions about desired registrations and can ignore
  // messages directed at the wrong instance.
  state = new AndroidListenerState(initialMaxDelayMs, maxDelayFactor);
  boolean skipStartForTest = false;
  Intent startIntent = ProtocolIntents.InternalDowncalls.newCreateClientIntent(
      command.getClientType(), command.getClientName().toByteArray(),
      ClientConfigP.getDefaultInstance(), skipStartForTest);
  AndroidListenerIntents.issueTiclIntent(getApplicationContext(), startIntent);
  return true;
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:17,代码来源:AndroidListener.java


示例8: onHandleIntent

import com.google.ipc.invalidation.ticl.android2.ProtocolIntents; //导入依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
  if (intent.hasExtra(ProtocolIntents.OUTBOUND_MESSAGE_KEY)) {
    // Request from the Ticl service to send a message.
    handleOutboundMessage(intent.getByteArrayExtra(ProtocolIntents.OUTBOUND_MESSAGE_KEY));
  } else if (intent.hasExtra(AndroidChannelConstants.AuthTokenConstants.EXTRA_AUTH_TOKEN)) {
    // Reply from the app with an auth token and a message to send.
    handleAuthTokenResponse(intent);
  } else if (intent.hasExtra(AndroidChannelConstants.MESSAGE_SENDER_SVC_GCM_REGID_CHANGE)) {
    handleGcmRegIdChange();
  } else {
    logger.warning("Ignoring intent: %s", intent);
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:15,代码来源:AndroidMessageSenderService.java


示例9: onMessage

import com.google.ipc.invalidation.ticl.android2.ProtocolIntents; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:28,代码来源:AndroidMessageReceiverService.java


示例10: sendMessage

import com.google.ipc.invalidation.ticl.android2.ProtocolIntents; //导入依赖的package包/类
@Override
public void sendMessage(byte[] outgoingMessage) {
  Intent intent = ProtocolIntents.newOutboundMessageIntent(outgoingMessage);
  intent.setClassName(context, AndroidMessageSenderService.class.getName());
  context.startService(intent);
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:7,代码来源:AndroidNetworkChannel.java


示例11: createClient

import com.google.ipc.invalidation.ticl.android2.ProtocolIntents; //导入依赖的package包/类
/**
 * Creates a new client.
 * <p>
 * REQUIRES: no client exist, or a client exists with the same type and name as provided. In
 * the latter case, this call is a no-op.
 *
 * @param context Android system context
 * @param clientType type of the client to create
 * @param clientName name of the client to create
 */
public static void createClient(Context context, int clientType, byte[] clientName) {
  ClientConfigP config = InvalidationClientCore.createConfig();
  Intent intent = ProtocolIntents.InternalDowncalls.newCreateClientIntent(
      clientType, Bytes.fromByteArray(clientName), config, false);
  intent.setClassName(context, new AndroidTiclManifest(context).getTiclServiceClass());
  context.startService(intent);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:18,代码来源:AndroidClientFactory.java


示例12: createClient

import com.google.ipc.invalidation.ticl.android2.ProtocolIntents; //导入依赖的package包/类
/**
 * Creates a new client.
 * <p>
 * REQUIRES: no client exist, or a client exists with the same type and name as provided. In
 * the latter case, this call is a no-op.
 *
 * @param context Android system context
 * @param clientType type of the client to create
 * @param clientName name of the client to create
 */
public static void createClient(Context context, ClientType.Type clientType, byte[] clientName) {
  ClientConfigP config = InvalidationClientCore.createConfig().build();
  Intent intent = ProtocolIntents.InternalDowncalls.newCreateClientIntent(
      clientType.getNumber(), clientName, config, false);
  intent.setClassName(context, new AndroidTiclManifest(context).getTiclServiceClass());
  context.startService(intent);
}
 
开发者ID:morristech,项目名称:android-chromium,代码行数:18,代码来源:AndroidClientFactory.java



注:本文中的com.google.ipc.invalidation.ticl.android2.ProtocolIntents类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EphemeralKeyPairGenerator类代码示例发布时间:2022-05-23
下一篇:
Java ProfileActivationContext类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap