From: snickersun Date: Sat, 6 Mar 2021 13:47:29 +0000 (+0800) Subject: release V740 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=1112f0ec5e3d806e2bdc6cb1caa6fc3d938274dd;p=protocol_srv.git release V740 添加sc7a21 跌倒功能 --- diff --git a/app/build.gradle b/app/build.gradle index f3bc2d3f..b4dde886 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.application' // APK 名称 static def getApkBaseName() { - return "ICSer" + return "L05_ICSer" } android { diff --git a/app/release/L05_ICSer_V740_2103062145_release.apk b/app/release/L05_ICSer_V740_2103062145_release.apk new file mode 100644 index 00000000..0f21192c Binary files /dev/null and b/app/release/L05_ICSer_V740_2103062145_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index 617ce711..a9dcace5 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":738,"versionName":"2012221145","enabled":true,"outputFile":"ICSer_V738_2012221145_release.apk","fullName":"release","baseName":"release"},"path":"ICSer_V738_2012221145_release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":740,"versionName":"2103062145","enabled":true,"outputFile":"L05_ICSer_V740_2103062145_release.apk","fullName":"release","baseName":"release"},"path":"L05_ICSer_V740_2103062145_release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/enqualcomm/support/service/AntiMonitorService.java b/app/src/main/java/com/enqualcomm/support/service/AntiMonitorService.java index 427bd5ec..977cbf22 100644 --- a/app/src/main/java/com/enqualcomm/support/service/AntiMonitorService.java +++ b/app/src/main/java/com/enqualcomm/support/service/AntiMonitorService.java @@ -16,12 +16,14 @@ import com.enqualcomm.support.CoreService; import com.enqualcomm.support.LocationClient; import com.enqualcomm.support.R; import com.enqualcomm.support.bean.Runtime; +import com.enqualcomm.support.bean.StringMessage; import com.enqualcomm.support.service.base.AbstractInvokeHandlerService; import com.enqualcomm.support.utils.AlarmHelper; import com.enqualcomm.support.utils.Connection; import com.enqualcomm.support.utils.ICLogger; import com.enqualcomm.support.utils.Util; import com.enqualcomm.support.utils.VibrateUtil; +import com.ic.protocols.protocolAPIHelper; import java.lang.ref.WeakReference; @@ -33,7 +35,7 @@ import static com.enqualcomm.support.Constants.KEY_ANTI_TXT; import static java.lang.Thread.sleep; -public class AntiMonitorService extends AbstractInvokeHandlerService { +public class AntiMonitorService extends AbstractInvokeHandlerService implements InputEventReader.InputEventReceiver { private static final String TAG = "AntiMonitorService"; @@ -42,7 +44,7 @@ public class AntiMonitorService extends AbstractInvokeHandlerService { Runtime mRuntime; Connection mConnection; - + private InputEventReader m_inputEventReader=null; private SensorManager mSensorManager; //current_anti_status == 2 表示表带 锁定 , ==12 表示表带非法解锁 //current_anti_status == 0 表示佩戴 ==10 表示脱腕 @@ -58,6 +60,19 @@ public class AntiMonitorService extends AbstractInvokeHandlerService { private Handler mHandler = null; PowerManager.WakeLock mWakeLock = null; + @Override + public void onInputEventRecevied(int type, int event) { + if(type== InputEventReader.EVENT_TYPE_CUT && event == InputEventReader.EVENT_FALLOFF){ + send_fall_off_event(); + } + } + + private void send_fall_off_event(){ + mRuntime.setAlarmType(Runtime.AlarmType.ALARM_FALL); + StringMessage alarmmsg=protocolAPIHelper.getWarningMSG(mRuntime); + Deliver.sendLocationMSG(alarmmsg); + ICLogger.i(" send fall off event !"); + } private static class InnerHandler extends Handler { @@ -98,6 +113,8 @@ public class AntiMonitorService extends AbstractInvokeHandlerService { // mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, AntiMonitorService.class.getSimpleName()); mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, AntiMonitorService.class.getSimpleName()); } + + m_inputEventReader=new InputEventReader(this); } private void play_notify() { diff --git a/app/src/main/java/com/enqualcomm/support/service/InputEventReader.java b/app/src/main/java/com/enqualcomm/support/service/InputEventReader.java new file mode 100644 index 00000000..f09aa756 --- /dev/null +++ b/app/src/main/java/com/enqualcomm/support/service/InputEventReader.java @@ -0,0 +1,267 @@ +package com.enqualcomm.support.service; + +import com.enqualcomm.support.utils.ICLogger; +import com.enqualcomm.support.utils.ThreadPool; +import com.enqualcomm.support.utils.Util; + +import java.io.FileInputStream; + +public class InputEventReader { + public static final int EVENT_TYPE_ANTI=0; + public static final int EVENT_TYPE_CUT=0; + public static final int EVENT_ANTI_OFF=10; + public static final int EVENT_WEARED=1; + public static final int EVENT_CUT_OFF=12; + public static final int EVENT_LOCKED=2; + public static final int EVENT_FALLOFF=3; + + + /*** + *循环读取设备的name 匹配对应的设备名,确定是否制定设备 + * /sys/class/input/input0/name + * /sys/class/input/input1/name + * ... + * /sys/class/input/inputX/name + */ + private static final String SYS_INPUT_BASE="/sys/class/input/input"; + private static final String EVENT_PATH_BASE="/dev/input/event"; + /*** + * 读取/sys/class/input/inputX/name 对应的名称 符合 antiDevNames 即是 佩戴检测事件节点 + * 检测对应 /dev/input/eventX 节点可以获取佩戴事件 + */ + private static final String antiDevNames= Util.getSystemProperties("persist.sys.AntiInputName",""); + /*** + * 读取/sys/class/input/inputX/name 对应的名称 符合 cutDevNames 即是 剪断检测事件节点 + * 检测对应 /dev/input/eventX 节点可以获取剪断事件 + */ + private static final String cutDevNames= Util.getSystemProperties("persist.sys.ic.falldev",""); + + + private String getInputDevNameByID(int id){ + byte buffer[]=new byte[255]; + String ret=""; + String input=SYS_INPUT_BASE+id+"/name"; + try { + FileInputStream fis=new FileInputStream(input); + int len=fis.read(buffer); + if (len > 0){ + ret=new String(buffer,0,len); + } + } catch (Exception e) { + e.printStackTrace(); + } + ICLogger.i("getInputDevNameByID "+input+ " "+ret); + return ret.trim(); + } + + private int get_DevID_By_Name(String name){ + int devid=-1; + for ( int i=0;i< 10;i++){ + if(getInputDevNameByID(i).startsWith(name.trim())) { + devid = i; + break; + } + } + return devid; + } + + + + public int getEventFromData(boolean isAntiEvent,byte[] eventMsgs){ + /*** + * 4d3bfc5fd1ab0a0001008e00010000004d3bfc5fd1ab0a0001008e00000000004d3bfc5fd1ab0a000000000000000000 + * + * 4d3bfc5fd1ab0a00 timestamp 8bytes + * 0100 eventtype 2bytes + * 8e00 eventcode 2bytes + * 01000000 value 4bytes + * 4d3bfc5fd1ab0a00 timestamp + * 0100 eventtype + * 8e00 eventcode + * 00000000 value + * 4d3bfc5fd1ab0a00 timestamp + * 0000 eventtype + * 0000 eventcode + * 00000000 value + * + * 0001 008e 00000001 + * 0001 008e 00000000 + * 0000 0000 00000000 + */ + int ret=0; + byte int_bytes[]=new byte[4]; + boolean msg_printted=false; + if(eventMsgs.length%16==0){ + int eventtype,eventvalue; + long eventcode; + for(int i=0;i-1){ + + try{ + String antipath=EVENT_PATH_BASE+devid; + ICLogger.i("open AntiEventPATH "+antipath); + FileInputStream br=new FileInputStream(antipath); + byte buf[]=new byte[50]; + int len=0; + while(true){ + len=br.read(buf); + if(len>0) { + byte t[]=new byte[len]; + for(int i=0;i-1){ + + try{ + String cutpath=EVENT_PATH_BASE+devid; + ICLogger.i("open CutEventPATH "+cutpath); + FileInputStream br=new FileInputStream(cutpath); + byte buf[]=new byte[50]; + int len=0; + while(true){ + len=br.read(buf); + if(len>0) { + byte t[]=new byte[len]; + for(int i=0;i submitThreadPool(Runnable runnable) { + if (runnable == null) { + return null; + } + return mService.submit(runnable); + } +} diff --git a/app/src/main/java/com/enqualcomm/support/utils/Util.java b/app/src/main/java/com/enqualcomm/support/utils/Util.java index 25949705..41a8c4ce 100644 --- a/app/src/main/java/com/enqualcomm/support/utils/Util.java +++ b/app/src/main/java/com/enqualcomm/support/utils/Util.java @@ -37,6 +37,7 @@ import java.io.UnsupportedEncodingException; import java.lang.reflect.Method; import java.net.InetAddress; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Enumeration; @@ -1159,5 +1160,58 @@ public class Util { private static byte charToByte(char c) { return (byte) "0123456789ABCDEF".indexOf(c); } + + public static int byteArray4ToInt(byte[] b) { + return b[3] & 0xFF | + (b[2] & 0xFF) << 8 | + (b[1] & 0xFF) << 16 | + (b[0] & 0xFF) << 24; + } + public static byte[] intToByteArray4(int a) { + return new byte[] { + (byte) ((a >> 24) & 0xFF), + (byte) ((a >> 16) & 0xFF), + (byte) ((a >> 8) & 0xFF), + (byte) (a & 0xFF) + }; + } + + /** + * 将字节数组转为long
+ * 如果input为null,或offset指定的剩余数组长度不足8字节则抛出异常 + * @param input + * @param offset 起始偏移量 + * @param littleEndian 输入数组是否小端模式 + * @return + */ + public static long longFrom8Bytes(byte[] input, int offset, boolean littleEndian){ + if(offset <0 || offset+8>input.length) + throw new IllegalArgumentException(String.format("less than 8 bytes from index %d is insufficient for long",offset)); + long value=0; + for(int count=0;count<8;++count){ + int shift=(littleEndian?count:(7-count))<<3; + value |=((long)0xff<< shift) & ((long)input[offset+count] << shift); + } + return value; + } + + /** + * 利用 {@link java.nio.ByteBuffer}实现byte[]转long + * @param input + * @param offset + * @param littleEndian 输入数组是否小端模式 + * @return + */ + public static long bytesToLong(byte[] input, int offset, boolean littleEndian) { + if(offset <0 || offset+8>input.length) + throw new IllegalArgumentException(String.format("less than 8 bytes from index %d is insufficient for long",offset)); + ByteBuffer buffer = ByteBuffer.wrap(input,offset,8); + if(littleEndian){ + // ByteBuffer.order(ByteOrder) 方法指定字节序,即大小端模式(BIG_ENDIAN/LITTLE_ENDIAN) + // ByteBuffer 默认为大端(BIG_ENDIAN)模式 + buffer.order(ByteOrder.LITTLE_ENDIAN); + } + return buffer.getLong(); + } } diff --git a/app/version_code.properties b/app/version_code.properties index 5d97b960..82028c58 100644 --- a/app/version_code.properties +++ b/app/version_code.properties @@ -1,2 +1,2 @@ -#Tue Dec 22 11:45:50 CST 2020 -VERSION_CODE=738 +#Sat Mar 06 21:45:52 CST 2021 +VERSION_CODE=740 diff --git a/icsupport.iml b/icsupport.iml deleted file mode 100644 index 30277a3e..00000000 --- a/icsupport.iml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file