public boolean sendMessage(Message message, boolean encrypt) { if (!Network.hasNetwork(this.mContext)) { return false; } Intent intent = createServiceIntent(); String perfData = MessageProfiling.getPrefString(); if (!TextUtils.isEmpty(perfData)) { CommonPacketExtension perfExt = new CommonPacketExtension("pf", null, (String[]) null, (String[]) null); CommonPacketExtension sentPerfExt = new CommonPacketExtension( PushServiceConstants.SEND_MSG_EVENT_TYPE_SENT, null, (String[]) null, (String[]) null); sentPerfExt.setText(perfData); perfExt.appendChild(sentPerfExt); message.addExtension(perfExt); } Bundle messageBundle = message.toBundle(); if (messageBundle == null) { return false; } MyLog.v("SEND:" + message.toXML()); intent.setAction(PushConstants.ACTION_SEND_MESSAGE); intent.putExtra(PushConstants.EXTRA_SESSION, sSession); intent.putExtra(PushConstants.EXTRA_PACKET, messageBundle); intent.putExtra(PushConstants.EXTRA_ENCYPT, encrypt); this.mContext.startService(intent); return true; }
public boolean batchSendMessage(Message[] messages, boolean encrypt) { if (!Network.hasNetwork(this.mContext)) { return false; } Intent intent = createServiceIntent(); Bundle[] messageBundles = new Bundle[messages.length]; for (int i = 0; i < messages.length; i++) { String perfData = MessageProfiling.getPrefString(); if (!TextUtils.isEmpty(perfData)) { CommonPacketExtension perfExt = new CommonPacketExtension("pf", null, (String[]) null, (String[]) null); CommonPacketExtension sentPerfExt = new CommonPacketExtension( PushServiceConstants.SEND_MSG_EVENT_TYPE_SENT, null, (String[]) null, (String[]) null); sentPerfExt.setText(perfData); perfExt.appendChild(sentPerfExt); messages[i].addExtension(perfExt); } MyLog.v("SEND:" + messages[i].toXML()); messageBundles[i] = messages[i].toBundle(); } if (messageBundles.length <= 0) { return false; } intent.setAction(PushConstants.ACTION_BATCH_SEND_MESSAGE); intent.putExtra(PushConstants.EXTRA_SESSION, sSession); intent.putExtra(PushConstants.EXTRA_PACKETS, messageBundles); intent.putExtra(PushConstants.EXTRA_ENCYPT, encrypt); this.mContext.startService(intent); return true; }
private ServiceClient(Context context) { this.mIsMiuiPushServiceEnabled = false; this.mProvisioned = 0; this.mContext = context.getApplicationContext(); if (serviceInstalled()) { MyLog.v("use miui push service"); this.mIsMiuiPushServiceEnabled = true; } }
public boolean sendPresence(Presence presence) { if (!Network.hasNetwork(this.mContext)) { return false; } Intent intent = createServiceIntent(); Bundle presBundle = presence.toBundle(); if (presBundle == null) { return false; } MyLog.v("SEND:" + presence.toXML()); intent.setAction(PushConstants.ACTION_SEND_PRESENCE); intent.putExtra(PushConstants.EXTRA_SESSION, sSession); intent.putExtra(PushConstants.EXTRA_PACKET, presBundle); this.mContext.startService(intent); return true; }
public boolean sendIQ(IQ iq) { if (!Network.hasNetwork(this.mContext)) { return false; } Intent intent = createServiceIntent(); Bundle iqBundle = iq.toBundle(); if (iqBundle == null) { return false; } MyLog.v("SEND:" + iq.toXML()); intent.setAction(PushConstants.ACTION_SEND_IQ); intent.putExtra(PushConstants.EXTRA_SESSION, sSession); intent.putExtra(PushConstants.EXTRA_PACKET, iqBundle); this.mContext.startService(intent); return true; }