Java Code Examples for com.google.ipc.invalidation.ticl.InvalidationClientCore#createConfig()
The following examples show how to use
com.google.ipc.invalidation.ticl.InvalidationClientCore#createConfig() .
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: AndroidListener.java From 365browser with Apache License 2.0 | 6 votes |
/** 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; }
Example 2
Source File: AndroidClientProxy.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** * Creates a new InvalidationClient instance that the proxy will delegate requests to and listen * for events from. */ // Overridden by tests to inject mock clients or for listener interception InvalidationClient createClient(SystemResources resources, int clientType, byte[] clientName, String applicationName, InvalidationListener listener, ClientConfigP config) { // We always use C2DM, so set the channel-supports-offline-delivery bit on our config. final ClientConfigP.Builder configBuilder; if (config == null) { configBuilder = InvalidationClientCore.createConfig(); } else { configBuilder = ClientConfigP.newBuilder(config); } configBuilder.setChannelSupportsOfflineDelivery(true); config = configBuilder.build(); Random random = new Random(resources.getInternalScheduler().getCurrentTimeMs()); return new InvalidationClientImpl(resources, random, clientType, clientName, config, applicationName, listener); }
Example 3
Source File: AndroidClientProxy.java From android-chromium with BSD 2-Clause "Simplified" License | 6 votes |
/** * Creates a new InvalidationClient instance that the proxy will delegate requests to and listen * for events from. */ // Overridden by tests to inject mock clients or for listener interception InvalidationClient createClient(SystemResources resources, int clientType, byte[] clientName, String applicationName, InvalidationListener listener, ClientConfigP config) { // We always use C2DM, so set the channel-supports-offline-delivery bit on our config. final ClientConfigP.Builder configBuilder; if (config == null) { configBuilder = InvalidationClientCore.createConfig(); } else { configBuilder = ClientConfigP.newBuilder(config); } configBuilder.setChannelSupportsOfflineDelivery(true); config = configBuilder.build(); Random random = new Random(resources.getInternalScheduler().getCurrentTimeMs()); return new InvalidationClientImpl(resources, random, clientType, clientName, config, applicationName, listener); }
Example 4
Source File: AndroidClientFactory.java From 365browser with Apache License 2.0 | 3 votes |
/** * 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); }