import android.util.Log;
import android.widget.Toast;
+
import com.ic.jni.ICJniUtils;
import com.ic.protocolSrv.adapter.LBSHelper;
import com.ic.protocolSrv.bean.Contact;
if (query != null) {
if (query.moveToNext()) {
String value = query.getString(0);
- disableSos = "0".equals(value);
- ICLogger.d("sos on value ==> " + value+" "+disableSos);
+ disableSos = "0".equals(value);
+ ICLogger.d("sos on value ==> " + value + " " + disableSos);
}
query.close();
}
//拨打电话走流程
//只要判断是否需要发短信即可
ICLogger.d("start check need SOS SMS...");
- checkSendSMS(resolver);
+ //是否需要拨号
+ boolean needCall = checkSendSMS(resolver);
+ //需要拨号再拨号
+ if (needCall) {
+ //50ms后开始拨打电话
+ mHandler.postDelayed(mTriggerSOSCALLThread, 1000);
+ }
});
+ } else {
+ if (!Config.SOSNoNeedDial) {
+ //50ms后开始拨打电话
+ mHandler.postDelayed(mTriggerSOSCALLThread, 1000);
+ }
}
//add by TrillGates=====end
runtime.setAlarmType(Runtime.AlarmType.ALARM_SOS);
}
//设置5分钟后结束紧急定位模式
setEmegencyLocationSTOPAlarm(5);
- if (!Config.SOSNoNeedDial) {
- //50ms后开始拨打电话
- mHandler.postDelayed(mTriggerSOSCALLThread, 500);
- }
} else if (ACTION_QUERY_WEATHER.equals(param1Intent.getAction())) {
ICLogger.i("ACTION_QUERY_WEATHER ");
connection.send(protocolAPIHelper.getWeatherMSG(runtime));
*
* @param resolver
*/
- private void checkSendSMS(ContentResolver resolver) {
+ private boolean checkSendSMS(ContentResolver resolver) {
Cursor query = resolver.query(Uri.parse(SETTINGS), new String[]{"s_value"}, "s_key=?",
new String[]{"sos_notify_type"}, null);
if (query != null) {
}
if (sosNumbers.size() == 0) {
ICLogger.d("no sos number...");
- return;
+ return value == 3;
}
//发送短信
//获取短信内容
smsManager.sendSMS(sosNumber, smsContent);
}
}
+ // public static final int TYPE_CHECK_PHONE = 1;
+ // public static final int TYPE_CHECK_SMS = 2;
+ // public static final int TYPE_CHECK_PHONE_AND_SMS = 3;
+ return value == 1 || value == 3;
} else {
ICLogger.d("no sos settings value...");
}
query.close();
}
+ return true;
}
private TriggerSOSCALLThread mTriggerSOSCALLThread = new TriggerSOSCALLThread();
@Override
public void onCreate() {
+ ICJniUtils.enablePedometer();
if (mHandler == null) {
HandlerThread handlerThread = new HandlerThread("ic:core-thread");
handlerThread.start();
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
+import android.support.v4.app.INotificationSideChannel;
import android.view.Display;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
+import android.widget.TextView;
import com.ic.protocolSrv.utils.ICLogger;
import com.ic.protocolSrv.utils.SimSignalUtil;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
public class toolActivity extends Activity {
- private static boolean usbstat=true;
+ private static boolean usbstat = true;
- void resizeSquare(){
- if (Util.needResizeSquare()){
+ void resizeSquare() {
+ if (Util.needResizeSquare()) {
Display display = getWindowManager().getDefaultDisplay(); // 为获取屏幕宽、高
Window window = getWindow();
ViewGroup.LayoutParams windowLayoutParams = window.getAttributes(); // 获取对话框当前的参数值
int width = display.getWidth();
int height = display.getHeight();
- windowLayoutParams.width = (int)(width*0.8);//(int) (display.getWidth() * 0.7); // 宽度设置为屏幕的0.95
- windowLayoutParams.height = (int)(height*0.8);//(int) (display.getHeight() * 0.6); // 高度设置为屏幕的0.6
- ICLogger.d("Resize to " + windowLayoutParams.width +"X" + windowLayoutParams.height);
+ windowLayoutParams.width = (int) (width * 0.8);//(int) (display.getWidth() * 0.7); // 宽度设置为屏幕的0.95
+ windowLayoutParams.height = (int) (height * 0.8);//(int) (display.getHeight() * 0.6); // 高度设置为屏幕的0.6
+ ICLogger.d("Resize to " + windowLayoutParams.width + "X" + windowLayoutParams.height);
}
}
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tool);
- Button btnSim=(Button)findViewById(R.id.btn_simReset);
- Button btnSimReload=(Button)findViewById(R.id.btn_sim2);
- Button btnLogctl=(Button)findViewById(R.id.btn_logctl);
- Button btnmod1=(Button)findViewById(R.id.btn_location1);
- Button btnmod3=(Button)findViewById(R.id.btn_location3);
- Button btnmod530=(Button)findViewById(R.id.btn_location530);
+ Button btnSim = (Button) findViewById(R.id.btn_simReset);
+ Button btnSimReload = (Button) findViewById(R.id.btn_sim2);
+ Button btnLogctl = (Button) findViewById(R.id.btn_logctl);
+ Button btnmod1 = (Button) findViewById(R.id.btn_location1);
+ Button btnmod3 = (Button) findViewById(R.id.btn_location3);
+ Button btnmod530 = (Button) findViewById(R.id.btn_location530);
- Button btnRestSrv=(Button)findViewById(R.id.btn_restartSrv);
- Button btnUsbEnable=(Button)findViewById(R.id.btn_usb);
- Button btnSlog=(Button)findViewById(R.id.btn_cpslog);
+ Button btnRestSrv = (Button) findViewById(R.id.btn_restartSrv);
+ Button btnUsbEnable = (Button) findViewById(R.id.btn_usb);
+ Button btnSlog = (Button) findViewById(R.id.btn_cpslog);
// protocol_mqtt_client mqttClient=new protocol_mqtt_client(toolActivity.this);
// mqttClient.connectservice();
public void onClick(View view) {
// protocol_mqtt.handleLGZONE(null,CoreService.getInstance().runtime,"001D,-8,08:00:00,2016-01-12");
- Intent intent=new Intent();
- intent.putExtra("smsCmd","#setlocation#=1,30#");
- CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD",intent);
- Util.ShowToast(CoreService.getInstance().runtime,"设置模式1 , 间隔900秒定位。");
+ Intent intent = new Intent();
+ intent.putExtra("smsCmd", "#setlocation#=1,30#");
+ CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD", intent);
+ Util.ShowToast(CoreService.getInstance().runtime, "设置模式1 , 间隔900秒定位。");
}
});
btnmod3.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- Intent intent=new Intent();
- intent.putExtra("smsCmd","#setlocation#=3,30#");
- CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD",intent);
- Util.ShowToast(CoreService.getInstance().runtime,"设置模式3 , 间隔60秒定位。");
+ Intent intent = new Intent();
+ intent.putExtra("smsCmd", "#setlocation#=3,30#");
+ CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD", intent);
+ Util.ShowToast(CoreService.getInstance().runtime, "设置模式3 , 间隔60秒定位。");
// mqttClient.attemptConnectMqtt(protocol_mqtt.defaultServerIP,"IC_H88_1063",60);
}
btnmod530.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- Intent intent=new Intent();
- intent.putExtra("smsCmd","#setlocation#=8,300#");
- CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD",intent);
- Util.ShowToast(CoreService.getInstance().runtime,"设置模式8, 间隔300秒定位。");
+ Intent intent = new Intent();
+ intent.putExtra("smsCmd", "#setlocation#=8,300#");
+ CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD", intent);
+ Util.ShowToast(CoreService.getInstance().runtime, "设置模式8, 间隔300秒定位。");
// mqttClient.sendMessage("WBG100/v1/BREQ/1","[0016,QWER15WTF156OQRT1230]");
// mqttClient.sendMessage("WBG100/v1/KA/1","[001B,120414,50,100,100, 123456789]");
-
}
});
btnSim.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SimSignalUtil.send_at_to_reset_simcard(CoreService.getInstance().runtime);
- Util.ShowToast(CoreService.getInstance().runtime,"Reset SimCard!");
+ Util.ShowToast(CoreService.getInstance().runtime, "Reset SimCard!");
}
});
@Override
public void onClick(View view) {
- Intent intent=new Intent();
+ Intent intent = new Intent();
ComponentName var3 = new ComponentName("com.ic.protocolSrv", "com.ic.protocolSrv.GPSActivity");
intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
intent.setComponent(var3);
btnLogctl.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- Intent intent=new Intent();
- intent.putExtra("smsCmd","#logctl#=upload,SDLogInfo:Android/V20");
- CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD",intent);
+ Intent intent = new Intent();
+ intent.putExtra("smsCmd", "#logctl#=upload,SDLogInfo:Android/V20");
+ CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD", intent);
}
});
-
btnUsbEnable.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- if(usbstat) {
- Intent intent=new Intent();
+ if (usbstat) {
+ Intent intent = new Intent();
intent.putExtra("smsCmd", "#USB#=mtp");
- CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD",intent);
- Util.ShowToast(CoreService.getInstance().runtime,"Enable MTP");
- }else{
- Intent intent=new Intent();
+ CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD", intent);
+ Util.ShowToast(CoreService.getInstance().runtime, "Enable MTP");
+ } else {
+ Intent intent = new Intent();
intent.putExtra("smsCmd", "#USB#=none");
- CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD",intent);
- Util.ShowToast(CoreService.getInstance().runtime,"Diable MTP");
+ CoreService.getInstance().runtime.getContextProxy().sendBroadcast("com.ic.protocolSrv.SMSCMD", intent);
+ Util.ShowToast(CoreService.getInstance().runtime, "Diable MTP");
}
}
@Override
public void onClick(View view) {
- if (CoreService.getInstance()!=null)
+ if (CoreService.getInstance() != null)
Util.ShowToast(CoreService.getInstance().runtime, "Stop ProtocolService!");
- stopService(new Intent(toolActivity.this, CoreService.class));// protocol service
+ stopService(new Intent(toolActivity.this, CoreService.class));// protocol service
Util.mSleep(3000);
- if (CoreService.getInstance()!=null)
- Util.ShowToast(CoreService.getInstance().runtime, "Start ProtocolService!");
- startService(new Intent(toolActivity.this, CoreService.class));// protocol service
+ if (CoreService.getInstance() != null)
+ Util.ShowToast(CoreService.getInstance().runtime, "Start ProtocolService!");
+ startService(new Intent(toolActivity.this, CoreService.class));// protocol service
}
});
btnSlog.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- if(Config.forceGPSMoveCheck)
- {
- Config.forceGPSMoveCheck=false;
- }else{
- Config.forceGPSMoveCheck=true;
+ if (Config.forceGPSMoveCheck) {
+ Config.forceGPSMoveCheck = false;
+ } else {
+ Config.forceGPSMoveCheck = true;
}
- Util.ShowToast(CoreService.getInstance().runtime,"Set forceGPSMoveCheck "+ Config.forceGPSMoveCheck);
+ Util.ShowToast(CoreService.getInstance().runtime, "Set forceGPSMoveCheck " + Config.forceGPSMoveCheck);
}
});
resizeSquare();
}
+
+ /**
+ * 打开心跳
+ *
+ * @param view
+ */
+ public void openHeartBeat(View view) {
+ setUpHeartBeanAlarm(Config.getHeartBeatCycle(this));
+ }
+
+ private void setUpHeartBeanAlarm(int targetCycle) {
+ CoreService instance = CoreService.getInstance();
+ instance.runtime.setHeartBeatCycle(targetCycle);
+ //默认时间为5分钟
+ instance.setHeartBeatAlarm();
+ //设置UI上的时间
+ int cycle = instance.runtime.getHeartBeatCycle();
+ ICLogger.d("cycle ==> " + cycle);
+ TextView heartBeatTv = (TextView) findViewById(R.id.heart_beat_cycle_text);
+ heartBeatTv.setText("当前心跳周期:" + cycle);
+ }
+
+ /**
+ * 关闭心跳
+ *
+ * @param view
+ */
+ public void closeHeartBeat(View view) {
+ setUpHeartBeanAlarm(65535);
+ }
}
android:orientation="vertical"\r
tools:context=".toolActivity">\r
\r
- <LinearLayout\r
+ <ScrollView\r
android:layout_width="match_parent"\r
- android:layout_height="wrap_content"\r
- android:layout_weight="1"\r
- android:orientation="horizontal">\r
+ android:layout_height="wrap_content">\r
\r
- <Button\r
- android:id="@+id/btn_logctl"\r
- android:layout_width="wrap_content"\r
+ <LinearLayout\r
+ android:layout_width="match_parent"\r
android:layout_height="wrap_content"\r
- android:layout_weight="1"\r
- android:text="上传日志"\r
- android:textSize="18sp" />\r
+ android:orientation="vertical">\r
\r
- <Button\r
- android:id="@+id/btn_simReset"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_weight="1"\r
- android:text="重置sim"\r
- android:textSize="18sp" />\r
+ <Button\r
+ android:id="@+id/btn_logctl"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="wrap_content"\r
+ android:text="上传日志"\r
+ android:textSize="18sp" />\r
\r
- <Button\r
- android:id="@+id/btn_sim2"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_weight="1"\r
- android:text="GPS"\r
- android:textSize="18sp" />\r
- </LinearLayout>\r
+ <Button\r
+ android:id="@+id/btn_simReset"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="wrap_content"\r
+ android:text="重置sim"\r
+ android:textSize="18sp" />\r
\r
- <LinearLayout\r
- android:layout_width="match_parent"\r
- android:layout_height="wrap_content"\r
- android:layout_weight="1"\r
- android:orientation="horizontal">\r
+ <Button\r
+ android:id="@+id/btn_sim2"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="wrap_content"\r
+ android:text="GPS"\r
+ android:textSize="18sp" />\r
\r
- <Button\r
- android:id="@+id/btn_location3"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_weight="1"\r
- android:text="模式3"\r
- android:textSize="18sp" />\r
\r
- <Button\r
- android:id="@+id/btn_location530"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_weight="1"\r
- android:text="模式8"\r
- android:textSize="18sp" />\r
+ <Button\r
+ android:id="@+id/btn_location3"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="wrap_content"\r
+ android:text="模式3"\r
+ android:textSize="18sp" />\r
\r
- <Button\r
- android:id="@+id/btn_location1"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_weight="1"\r
- android:text="模式1"\r
- android:textSize="18sp" />\r
- </LinearLayout>\r
- <LinearLayout\r
- android:layout_width="match_parent"\r
- android:layout_height="wrap_content"\r
- android:layout_weight="1"\r
- android:orientation="horizontal">\r
+ <Button\r
+ android:id="@+id/btn_location530"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="wrap_content"\r
+ android:text="模式8"\r
+ android:textSize="18sp" />\r
\r
- <Button\r
- android:id="@+id/btn_usb"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_weight="1"\r
- android:text="MTP"\r
- android:textSize="18sp" />\r
+ <Button\r
+ android:id="@+id/btn_location1"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="wrap_content"\r
+ android:text="模式1"\r
+ android:textSize="18sp" />\r
\r
- <Button\r
- android:id="@+id/btn_restartSrv"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_weight="1"\r
- android:text="重启Srv"\r
- android:textSize="18sp" />\r
+ <Button\r
+ android:id="@+id/btn_usb"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="wrap_content"\r
+ android:text="MTP"\r
+ android:textSize="18sp" />\r
+\r
+ <Button\r
+ android:id="@+id/btn_restartSrv"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="wrap_content"\r
+ android:text="重启Srv"\r
+ android:textSize="18sp" />\r
+\r
+ <Button\r
+ android:id="@+id/btn_cpslog"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="wrap_content"\r
+ android:text="运动检测"\r
+ android:textSize="18sp" />\r
+\r
+\r
+ <TextView\r
+ android:layout_width="match_parent"\r
+ android:id="@+id/heart_beat_cycle_text"\r
+ android:layout_height="wrap_content"\r
+ android:gravity="center"\r
+ android:padding="10dp"\r
+ android:text="当前心跳周期:"\r
+ android:textSize="18sp" />\r
+\r
+\r
+ <Button\r
+ android:id="@+id/close_heart_beat"\r
+ android:onClick="closeHeartBeat"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="wrap_content"\r
+ android:text="关闭心跳"\r
+ android:textSize="18sp" />\r
+\r
+ <Button\r
+ android:id="@+id/open_heart_beat"\r
+ android:layout_width="match_parent"\r
+ android:layout_height="wrap_content"\r
+ android:onClick="openHeartBeat"\r
+ android:text="打开心跳"\r
+ android:textSize="18sp" />\r
+\r
+\r
+ </LinearLayout>\r
+\r
+ </ScrollView>\r
\r
- <Button\r
- android:id="@+id/btn_cpslog"\r
- android:layout_width="wrap_content"\r
- android:layout_height="wrap_content"\r
- android:layout_weight="1"\r
- android:text="运动检测"\r
- android:textSize="18sp" />\r
- </LinearLayout>\r
</LinearLayout>
\ No newline at end of file