private float y2 = 0.0F;
- private static ProcessReceiver processReceiver=null;
+ private static ProcessReceiver processReceiver = null;
+
public ProcessReceiver() {
if (mHandler == null) {
HandlerThread handlerThread = new HandlerThread("ic:process-receiver-handler-thread");
handlerThread.start();
mHandler = new Handler(handlerThread.getLooper());
}
- if (processReceiver == null){
+ if (processReceiver == null) {
processReceiver = this;
}
}
- public static ProcessReceiver getInstance(){
+ public static ProcessReceiver getInstance() {
return processReceiver;
}
+
private static Handler mHandler = null;
}
@Override
- public void onReceive(Context paramContext, Intent paramIntent) {
+ public void onReceive(Context context, Intent intent) {
boolean isSilence;
Contact contact;
- String str = paramIntent.getAction();
+ String action = intent.getAction();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("action==");
- stringBuilder.append(str);
+ stringBuilder.append(action);
ICLogger.i(stringBuilder.toString());
if (CoreService.getInstance() == null) {
- ICLogger.i("CoreService is null skip deal with this message! " + str);
- paramContext.startService(new Intent(paramContext, CoreService.class));// protocol service
+ ICLogger.i("CoreService is null skip deal with this message! " + action);
+ context.startService(new Intent(context, CoreService.class));// protocol service
return;
}
- if (RESUME_ACTION.equals(str)) {
- SharePreferenceUtil.setPrefBoolean(paramContext, "key_is_resume", paramIntent.getBooleanExtra("is_resume", false));
+ if ("com.ic.action.ON_WE_TALK_CREATE".equals(action)) {
+ ICLogger.d("微聊打开,请求一下微聊的消息.");
+ //这个是微聊起来的时候,调用一下获取消息
+ protocolAPIHelper.requestWeTalkMsg();
+ } else if (RESUME_ACTION.equals(action)) {
+ SharePreferenceUtil.setPrefBoolean(context, "key_is_resume", intent.getBooleanExtra("is_resume", false));
return;
- } else if (ACTION_MESSAGE_SENT.equals(str)) {
+ } else if (ACTION_MESSAGE_SENT.equals(action)) {
- String msgType = paramIntent.getStringExtra(KEY_MESSAGE_TYPE);
- String msgFrom = paramIntent.getStringExtra(KEY_MESSAGE_FROM);
- String msgUrl = paramIntent.getStringExtra(KEY_MESSAGE_URL);
+ String msgType = intent.getStringExtra(KEY_MESSAGE_TYPE);
+ String msgFrom = intent.getStringExtra(KEY_MESSAGE_FROM);
+ String msgUrl = intent.getStringExtra(KEY_MESSAGE_URL);
ICLogger.i("receive msg to send type=" + msgType + ", msg from = " + msgFrom + ", msgUrl" + msgUrl);
if (msgFrom == null) msgFrom = "123";
/**
*/
if (msgType.equals("voice")) {
//创建voiceConent并添加到数据
- final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom,"0000", msgUrl, 1, 3);
+ final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom, "0000", msgUrl, 1, 3);
// 把voiceContent拆解成1024的分包
- Util.parseToVoicePacketSent(voiceContent,1024);
+ Util.parseToVoicePacketSent(voiceContent, 1024);
//trigger 分包发送
if (CoreService.getInstance().getConnection() != null)
CoreService.getInstance().getConnection().DeliverCMDMessageToSystem("SentVoicePacket", "");
} else if (msgType.equals("pic")) {
//创建voiceConent并添加到数据
- final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom,"0000", msgUrl, 2, 3);
+ final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom, "0000", msgUrl, 2, 3);
// 把voiceContent拆解成1024的分包
- Util.parseToVoicePacketSent(voiceContent,1024);
+ Util.parseToVoicePacketSent(voiceContent, 1024);
//trigger 分包发送
if (CoreService.getInstance().getConnection() != null) {
CoreService.getInstance().getConnection().DeliverCMDMessageToSystem("SentVoicePacket", "");
}
}
- } else if (ACTION_SHUTDOWN.equals(str)) {
- playshutdownsound(paramContext);
+ } else if (ACTION_SHUTDOWN.equals(action)) {
+ playshutdownsound(context);
Util.shutdown();
return;
- } else if (ACTION_PLAYTIME.equals(str)) {
+ } else if (ACTION_PLAYTIME.equals(action)) {
LedUtil.setBlueLedOn(true);
mHandler.postDelayed(new Runnable() {
@Override
}
}, 2000L);
return;
- } else if (ACTION_REMOTE_CAMERA.equals(str)) {
- if (paramIntent.hasExtra("remote_number")) {
+ } else if (ACTION_REMOTE_CAMERA.equals(action)) {
+ if (intent.hasExtra("remote_number")) {
//接收拍照命令,执行拍照
- String str1 = paramIntent.getStringExtra("remote_number");
+ String str1 = intent.getStringExtra("remote_number");
mHandler.post(new Runnable() {
@Override
public void run() {
- (new CameraUtil(paramContext)).getPicture(str1);
+ (new CameraUtil(context)).getPicture(str1);
}
});
} else {
//接收到拍照完毕命令,发送照片
- String msgFrom = paramIntent.getStringExtra("number");
- String msgUrl = paramIntent.getStringExtra("filepath");
+ String msgFrom = intent.getStringExtra("number");
+ String msgUrl = intent.getStringExtra("filepath");
ICLogger.i("receive taken photo to send " + msgUrl);
//创建voiceConent并添加到数据
- final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom,"0000", msgUrl, 2, 2);
+ final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, msgFrom, "0000", msgUrl, 2, 2);
// 把voiceContent拆解成1024的分包
- Util.parseToVoicePacketSent(voiceContent,1024);
+ Util.parseToVoicePacketSent(voiceContent, 1024);
//trigger 分包发送
if (CoreService.getInstance().getConnection() != null) {
return;
- } else if (DIALOG_ACTION.equals(str)) {
- if (paramIntent.hasExtra("contact")) {
- contact = (Contact) paramIntent.getParcelableExtra("contact");
- SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false);
- isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false);
+ } else if (DIALOG_ACTION.equals(action)) {
+ if (intent.hasExtra("contact")) {
+ contact = (Contact) intent.getParcelableExtra("contact");
+ SharePreferenceUtil.getPrefBoolean(context, "key_is_resume", false);
+ isSilence = SharePreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false);
if (contact != null && !isSilence) {
- if (!DeviceInfoUtil.isTopActivity(paramContext)) {
- this.initMyDialog(paramContext, contact, 1, "", false);
+ if (!DeviceInfoUtil.isTopActivity(context)) {
+ this.initMyDialog(context, contact, 1, "", false);
}
//屏幕量了
- if (!Util.isScreenON(paramContext)) {
- this.screenOn(paramContext);
- VibrateUtil.getInstance(paramContext).vibrateOn(true);
- this.playNotificationVoice(paramContext);
+ if (!Util.isScreenON(context)) {
+ this.screenOn(context);
+ VibrateUtil.getInstance(context).vibrateOn(true);
+ this.playNotificationVoice(context);
}
}
- } else if (paramIntent.hasExtra("talkTextMsg")) {
- contact = (Contact) paramIntent.getParcelableExtra("talkTextMsg");
- SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false);
- isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false);
+ } else if (intent.hasExtra("talkTextMsg")) {
+ contact = (Contact) intent.getParcelableExtra("talkTextMsg");
+ SharePreferenceUtil.getPrefBoolean(context, "key_is_resume", false);
+ isSilence = SharePreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false);
if (contact != null && !isSilence) {
- if (!DeviceInfoUtil.isTopActivity(paramContext)) {
- this.initMyDialog(paramContext, contact, 1, "", false);
+ if (!DeviceInfoUtil.isTopActivity(context)) {
+ this.initMyDialog(context, contact, 1, "", false);
}
//屏幕量了
- if (!Util.isScreenON(paramContext)) {
- this.screenOn(paramContext);
- VibrateUtil.getInstance(paramContext).vibrateOn(true);
- this.playNotificationVoice(paramContext);
+ if (!Util.isScreenON(context)) {
+ this.screenOn(context);
+ VibrateUtil.getInstance(context).vibrateOn(true);
+ this.playNotificationVoice(context);
}
}
- } else if (paramIntent.hasExtra("sms")) {
- String sms = paramIntent.getStringExtra("sms");
- SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false);
- isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false);
+ } else if (intent.hasExtra("sms")) {
+ String sms = intent.getStringExtra("sms");
+ SharePreferenceUtil.getPrefBoolean(context, "key_is_resume", false);
+ isSilence = SharePreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false);
if (sms != null && !isSilence) {
//if (!DeviceInfoUtil.isTopActivity(paramContext)) {
- this.initMyDialog(paramContext, null, 3, sms, false);
- this.playNotificationVoice(paramContext);
- VibrateUtil.getInstance(paramContext).vibrateOn(true);
+ this.initMyDialog(context, null, 3, sms, false);
+ this.playNotificationVoice(context);
+ VibrateUtil.getInstance(context).vibrateOn(true);
//}
- this.screenOn(paramContext);
+ this.screenOn(context);
}
- } else if (paramIntent.hasExtra("pushtxt")) {
- String sms = paramIntent.getStringExtra("pushtxt");
+ } else if (intent.hasExtra("pushtxt")) {
+ String sms = intent.getStringExtra("pushtxt");
boolean needreply = false;
- if (paramIntent.hasExtra("needreply")) {
- needreply = paramIntent.getBooleanExtra("needreply", false);
+ if (intent.hasExtra("needreply")) {
+ needreply = intent.getBooleanExtra("needreply", false);
}
- SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false);
- isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false);
+ SharePreferenceUtil.getPrefBoolean(context, "key_is_resume", false);
+ isSilence = SharePreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false);
if (sms != null && !isSilence) {
- if (!DeviceInfoUtil.isTopActivity(paramContext)) {
- this.initMyDialog(paramContext, null, 4, sms, needreply);
- this.playNotificationVoice(paramContext);
- VibrateUtil.getInstance(paramContext).vibrateOn(true);
+ if (!DeviceInfoUtil.isTopActivity(context)) {
+ this.initMyDialog(context, null, 4, sms, needreply);
+ this.playNotificationVoice(context);
+ VibrateUtil.getInstance(context).vibrateOn(true);
}
- this.screenOn(paramContext);
+ this.screenOn(context);
}
- } else if (paramIntent.hasExtra("findDev")) {
- String finddevtxt = paramIntent.getStringExtra("findDev");
- SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false);
- isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false);
+ } else if (intent.hasExtra("findDev")) {
+ String finddevtxt = intent.getStringExtra("findDev");
+ SharePreferenceUtil.getPrefBoolean(context, "key_is_resume", false);
+ isSilence = SharePreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false);
if (finddevtxt != null && !isSilence) {
- this.initMyDialog(paramContext, null, 5, finddevtxt, false);
- this.playFindDevVoice(paramContext);
- VibrateUtil.getInstance(paramContext).vibrateOn(true);
+ this.initMyDialog(context, null, 5, finddevtxt, false);
+ this.playFindDevVoice(context);
+ VibrateUtil.getInstance(context).vibrateOn(true);
- this.screenOn(paramContext);
+ this.screenOn(context);
}
- } else if (paramIntent.hasExtra("takephoto")) {
- String takephoto = paramIntent.getStringExtra("takephoto");
- SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false);
- isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false);
+ } else if (intent.hasExtra("takephoto")) {
+ String takephoto = intent.getStringExtra("takephoto");
+ SharePreferenceUtil.getPrefBoolean(context, "key_is_resume", false);
+ isSilence = SharePreferenceUtil.getPrefBoolean(context, "KEY_ISSILENCE", false);
if (takephoto != null && !isSilence) {
- this.initMyDialog(paramContext, null, 6, takephoto, false);
- this.playNotificationVoice(paramContext);
- VibrateUtil.getInstance(paramContext).vibrateOn(true);
+ this.initMyDialog(context, null, 6, takephoto, false);
+ this.playNotificationVoice(context);
+ VibrateUtil.getInstance(context).vibrateOn(true);
- this.screenOn(paramContext);
+ this.screenOn(context);
}
}
- } else if (ACTION_SET_SIT_RANGE.equals(str)) {
- if (paramIntent.hasExtra(Constants.KEY_SIT_RANGE)) {
- int sitrange = paramIntent.getIntExtra(Constants.KEY_SIT_RANGE, 0);
- Config.setKeepSitRangeInMinutes(paramContext, sitrange);
+ } else if (ACTION_SET_SIT_RANGE.equals(action)) {
+ if (intent.hasExtra(Constants.KEY_SIT_RANGE)) {
+ int sitrange = intent.getIntExtra(Constants.KEY_SIT_RANGE, 0);
+ Config.setKeepSitRangeInMinutes(context, sitrange);
ICLogger.i("set KeepSitRange int " + sitrange + " minutes!");
ICLogger.i("则重置 lastCheckSitTime 以及 lastSitCheckStepCount");
Runtime.lastSitCheckStepCount = CoreService.getInstance().getRuntime().getTotalStepCount();
}
- public void showWarningText(Context context,String txt){
+ public void showWarningText(Context context, String txt) {
initMyDialog(context, null, 5, txt, false);
playFindDevVoice(context);
VibrateUtil.getInstance(context).vibrateOn(true);