-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":926,"versionName":"2108272032","enabled":true,"outputFile":"ICSer_V926_2108272032_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V926_2108272032_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":928,"versionName":"2108272218","enabled":true,"outputFile":"ICSer_V928_2108272218_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V928_2108272218_release.apk","properties":{}}]
\ No newline at end of file
import android.os.PowerManager;
import android.os.RemoteException;
import android.support.annotation.Nullable;
-import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import android.widget.Toast;
mHandler.post(() -> {
registerPhoneStateListener();
});
+ //设置佩戴脱落响应的延时
+ mHandler.post(() -> {
+ String delayTimeStr = Util.getSystemProperties("persist.sys.antiOffDelay", "2");
+ int timeValue;
+ try {
+ timeValue = Integer.parseInt(delayTimeStr);
+ } catch (Exception e) {
+ timeValue = 10;
+ }
+ AntiMonitorService.setAntiOffDelayTime(timeValue * 1000);
+ });
//add by TrillGates =====end
server_starting = true;
String curProcessName = getProcessName(this, android.os.Process.myPid());
private void registerPhoneStateListener() {
Context applicationContext = getApplicationContext();
PhoneCallListener phoneCallListener = new PhoneCallListener(applicationContext);
- TelephonyManager telephonyManager =
- (TelephonyManager) applicationContext.getSystemService(TELEPHONY_SERVICE);
- if (telephonyManager != null) {
- telephonyManager.listen(phoneCallListener, PhoneCallListener.LISTEN_CALL_STATE);
- }
+ phoneCallListener.initObserver();
}
/**
import com.enqualcomm.support.provider.ICDatabaseHelper;
import com.enqualcomm.support.provider.ICGlobalSettingsProvider;
import com.enqualcomm.support.provider.ICNotificationProvider;
+import com.enqualcomm.support.service.AntiMonitorService;
import com.enqualcomm.support.service.AudioService;
import com.enqualcomm.support.service.Deliver;
import com.enqualcomm.support.service.HeartRateManager;
String cmd = tmp[1];
handle_test_cmd(runtime, handler, cmd, "");
}
+ } else if (sms.startsWith(ENCRYPED_HEADER + "#antioff#=") && sms.endsWith("#")) {
+ //#antioff#=10#
+ sms = sms.replace(ENCRYPED_HEADER + "#antioff#=", "");
+ String value = sms.replace("#", "");
+ try {
+ long delayValue = Integer.parseInt(value) * 1000;
+ AntiMonitorService.setAntiOffDelayTime(delayValue);
+ //设置到配置中
+ Util.setSystemProperties("persist.sys.antiOffDelay", value);
+ } catch (Exception e) {
+ sendSMS(phoneNumber, "设置失败.参考格式:#antioff#=10#");
+ }
+ sendSMS(phoneNumber, "脱落通知延时设置成功.");
} else {
return false;
}
}
} else if (cmd.startsWith("airplane")) {
-
-
if (CoreService.getInstance() != null) {
SimSignalUtil.send_at_to_reset_simcard(runtime); //直接下此命令不能实现断网重连,所以干脆采用关闭网络再打开的方式。
SimSignalUtil.setAirMode(CoreService.getInstance(), "OpenAirplane");
}
}
} else if (cmd.startsWith("testCMDRecords")) {
-
if (CoreService.getInstance() != null) {
StringMessage msg = protocolAPIHelper.getLBSLocationMSG(runtime);
runtime.getDbHelper().insertCMDRecord(msg);
public class AntiMonitorService extends AbstractInvokeHandlerService
- implements InputEventReader.InputEventReceiver{
+ implements InputEventReader.InputEventReceiver {
- private InputEventReader m_inputEventReader=null;
+ private InputEventReader m_inputEventReader = null;
private static final String TAG = "AntiMonitorService";
Context mContext;
@Override
public void onInputEventRecevied(int type, int event) {
- if(type==EVENT_TYPE_CUT && event >0 ){
+ if (type == EVENT_TYPE_CUT && event > 0) {
current_cut_status = event;
cut_status_event_reported++;
ICLogger.i("近距离 " + current_cut_status + " input event " + cut_status_event_reported + " times !");
cut_event_receivedTime = System.currentTimeMillis();
reset_timer_cut();
- }else if (type==EVENT_TYPE_ANTI && event >0){
+ } else if (type == EVENT_TYPE_ANTI && event > 0) {
current_anti_status = event;
ant_status_event_reported++;
ICLogger.i("近距离 " + current_anti_status + " input event " + ant_status_event_reported + " times !");
mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, AntiMonitorService.class.getSimpleName());
}
- m_inputEventReader=new InputEventReader(this);
+ m_inputEventReader = new InputEventReader(this);
}
private void play_notify() {
//current_anti_status == 0 表示佩戴 ==10 表示脱腕
switch (current_anti_status) {
- case STATUS_WEARED:
- //佩戴
- {
-
+ //佩戴
+ case STATUS_WEARED: {
Util.setSystemProperties("persist.sys.ic_antioff", "false");
mRuntime.Anti_off_flag = 0;
broadcast_antioff_event_to_other_application(false);
// StringMessage msg = protocolAPIHelper.getWarningMSG(mRuntime);
// Deliver.sendLocationMSG(msg); //消息很重要,所以利用带buffer的对列来发送!
}
-
}
break;
case STATUS_ANTI_OFF: {
+ //做延时发送处理
+ //如果特定的时间内佩戴上了,就不会通知未佩戴的状态
//脱腕
Util.setSystemProperties("persist.sys.ic_antioff", "true");
mRuntime.Anti_off_flag = 1;
broadcast_antioff_event_to_other_application(true);
if (Config.needBroadcastAntiAlarm) {
-
send_anti_event_broadcast(1);
}
if (mRuntime.setAlarmType(Runtime.AlarmType.ALARM_ANTIOFF)) {
last_send_antoff_event = current_anti_status;
ICLogger.i("AntiOff Timeout! send antioff event " + current_anti_status);
}
+
+
private void send_cutoff_event() {
if (last_send_cut_event == current_cut_status) {
ICLogger.i("剪断状态未变,skip!");
last_send_cut_event = current_cut_status;
ICLogger.i("CutOff Timeout! send cutoff event " + current_cut_status);
}
+
public boolean CheckAntiByPoling() {
//检查是否佩戴。佩戴返回true
//send_antiof_event();
return false;
}
+ /**
+ * 由短信设置这个数据
+ *
+ * @param time
+ */
+ public static void setAntiOffDelayTime(long time) {
+ antiOffDelayTime = time;
+ }
+
+ public static long antiOffDelayTime = 10 * 1000;
+
//return 0 表示check 结束, 1表示需要继续check 由coreService中 ACTION_CHECK_ANTIOFF_EVENT进行
public int check_ant_event() {
-
- long currenttime = System.currentTimeMillis();
- ICLogger.i("anti_event_receivedTime in " + (currenttime - anti_event_receivedTime)
+ long currentTime = System.currentTimeMillis();
+ ICLogger.i("anti_event_receivedTime in " + (currentTime - anti_event_receivedTime)
+ "ms ago ,anti_event_count_when_start_timer " + ant_status_event_reported
);
-
- if ((currenttime - anti_event_receivedTime) >= 2000) {
+ if ((currentTime - anti_event_receivedTime) >= antiOffDelayTime) {
send_antiof_event();
-
ant_status_event_reported = 0;
return 0;
} else {
- long restTimeNeedDelay = (2000 + anti_event_receivedTime - currenttime);
+ long restTimeNeedDelay = (antiOffDelayTime + anti_event_receivedTime - currentTime);
ICLogger.i("Still need delay " + restTimeNeedDelay + "ms to check anti_event again!");
setAntiCheckAlarm((int) restTimeNeedDelay);
return 1;
return 1;
}
}
+
public void setAntiCheckAlarm(int ms) {
AlarmHelper.setRealTimeAlarmInMicorSeconds(mRuntime.getContextProxy().context, ms, ACTION_CHECK_ANTIOFF_EVENT);
}
+
public void setCutCheckAlarm(int ms) {
AlarmHelper.setRealTimeAlarmInMicorSeconds(mRuntime.getContextProxy().context, ms, ACTION_CHECK_CUTOFF_EVENT);
}
+
private void reset_timer() {
if (1 == ant_status_event_reported) //出现 ant_status_event_reported=0表示 有消息到来,需要开始,
setAntiCheckAlarm(2000);
}
}
+
private void reset_timer_cut() {
if (1 == cut_status_event_reported) //出现 ant_status_event_reported=0表示 有消息到来,需要开始,
setCutCheckAlarm(2000);
}
}
+
/**
* 启动传感器。
*/
}
public void send_anti_event_broadcast(int antioff) {
-
ICLogger.i("send_anti_event_broadcast " + antioff);
Intent intent = new Intent();
intent.setAction(ACTION_ANTI_OFF0);
@Override
public void onSensorChanged(SensorEvent sensorEvent) {
int event = (int) sensorEvent.values[0];
- if(event==2 || event == 12){
+ if (event == 2 || event == 12) {
current_cut_status = event;
cut_status_event_reported++;
ICLogger.i("近距离 " + current_cut_status + " sensor event " + cut_status_event_reported + " times !");
cut_event_receivedTime = System.currentTimeMillis();
reset_timer_cut();
- }else {
+ } else {
current_anti_status = event;
ant_status_event_reported++;
ICLogger.i("近距离 " + current_anti_status + " sensor event " + ant_status_event_reported + " times !");
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
+import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
import android.os.SystemClock;
-import android.provider.CallLog;
-import android.telephony.PhoneStateListener;
-import android.telephony.ServiceState;
import android.util.Log;
import com.enqualcomm.support.provider.ICDatabaseHelper;
* 监听电话数据库的状态
* 如果有未接电话,创建通知到通知库里,UI上监听到通知库的变化,就会显示通知了
*/
-public class PhoneCallListener extends PhoneStateListener {
+public class PhoneCallListener {
private static final String TAG = "PhoneCallListener";
private final Context mContext;
- private String mLastPhoneNumber;
public PhoneCallListener(Context context) {
this.mContext = context;
}
- @Override
- public void onServiceStateChanged(ServiceState serviceState) {
- super.onServiceStateChanged(serviceState);
- Log.d(TAG, "onServiceStateChanged == > " + serviceState);
+ public void initObserver() {
+ //观察电话本的内容变化
+ mContext.getContentResolver().registerContentObserver(Uri.parse("content://call_log/calls"),
+ true, new ContentObserver(null) {
+ @Override
+ public void onChange(boolean selfChange) {
+ ICLogger.d("isSelfChange ==> " + isSelfChange);
+ if (!isSelfChange) {
+ Log.d(TAG, "on phone calls change.");
+ queryCallState();
+ } else {
+ isSelfChange = false;
+ }
+ }
+ });
}
private final Object mLock = new Object();
- @Override
public void onCallStateChanged(int state, String incomingNumber) {
- super.onCallStateChanged(state, incomingNumber);
ICLogger.d("state == > " + state + " incomingNumber ==> " + incomingNumber);
//挂断的时候,去查询一下是不是未接电话即可
if (state == CALL_STATE_IDLE) {
}
private void queryCallState() {
- String[] projection = {
- CallLog.Calls.NUMBER,
- CallLog.Calls.TYPE
- };
String where = "type=? and is_read=?";
Cursor c = mContext.getContentResolver().query(
Uri.parse("content://call_log/calls"),
- projection,
+ null,
where,
new String[]{"3", "0"},
null
//修改顶部的状态
updateSettingsState(1);
}
+ String[] columnNames = c.getColumnNames();
while (c.moveToNext()) {
- //创建通知,如果大于1的知,说明有未接电话
- String phoneNum = c.getString(0);
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < columnNames.length; i++) {
+ String itemName = columnNames[i];
+ String itemContent = c.getString(c.getColumnIndex(itemName));
+ sb.append(itemName + ":" + itemContent + " ");
+ }
+ Log.d(TAG, "item ==> " + sb.toString());
+ String phoneNum = c.getString(c.getColumnIndex("number"));
createNotification(phoneNum);
}
c.close();
ContentValues updateValues = new ContentValues();
//更新为已读
updateValues.put("is_read", 1);
+ isSelfChange = true;
int update = mContext.getContentResolver().update(Uri.parse("content://call_log/calls"),
updateValues,
where,
new String[]{"3", "0"});
Log.d(TAG, "update ==> " + update);
- this.mLastPhoneNumber = null;
}
+ private boolean isSelfChange = false;
+
private void updateSettingsState(int value) {
ContentResolver resolver = mContext.getContentResolver();
ContentValues values = new ContentValues();
-#Fri Aug 27 20:32:10 CST 2021\r
-VERSION_CODE=926\r
+#Fri Aug 27 22:18:53 CST 2021\r
+VERSION_CODE=928\r