From 266bfdf63927c3d3c1a53bd4c06f24c49fe290cb Mon Sep 17 00:00:00 2001 From: yimiao Date: Wed, 23 Feb 2022 16:53:13 +0800 Subject: [PATCH] =?UTF-8?q?[desc]:=E6=B7=BB=E5=8A=A0=E4=B8=B2=E5=8F=A3?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=20[author]:wangyimiao?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 6 +++++ app/src/main/AndroidManifest.xml | 1 + .../common/commonlibtest/DemoActivity.java | 14 +++++++--- buildCommon/commonLibConfig.gradle | 2 +- .../com/common/commonlib/net/BaseObserve.kt | 14 +++++----- .../com/common/commonlib/serialport/Cmd.java | 2 +- .../commonlib/serialport/SerialPortUtil.java | 24 +++++++++++------- .../innovationapp.jks | Bin 2469 -> 2469 bytes signature/keytool-importkeypair | 0 signature/platform.pk8 | Bin 0 -> 1216 bytes signature/platform.x509.pem | 0 signature/signature.sh | 9 +++++++ 12 files changed, 50 insertions(+), 22 deletions(-) rename innovationapp.jks => signature/innovationapp.jks (59%) create mode 100644 signature/keytool-importkeypair create mode 100644 signature/platform.pk8 create mode 100644 signature/platform.x509.pem create mode 100644 signature/signature.sh diff --git a/app/build.gradle b/app/build.gradle index 862232e..0e37723 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,9 +23,15 @@ android { } buildTypes { + debug{ + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.debug + } release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + signingConfig signingConfigs.release } } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c71955e..8c79654 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -9,6 +9,7 @@ android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" + android:extractNativeLibs="true" android:theme="@style/Theme.CommonLibTest"> diff --git a/app/src/main/java/com/common/commonlibtest/DemoActivity.java b/app/src/main/java/com/common/commonlibtest/DemoActivity.java index 1afb0c6..cb89b1b 100644 --- a/app/src/main/java/com/common/commonlibtest/DemoActivity.java +++ b/app/src/main/java/com/common/commonlibtest/DemoActivity.java @@ -132,14 +132,20 @@ public class DemoActivity extends AppCompatActivity { }); binding.mmkv.setOnClickListener(l -> { - MMKVUtils.INSTANCE.put("key", 100, "aa"); - int value = MMKVUtils.INSTANCE.getInt("key", "bb"); - Toast.makeText(DemoActivity.this, "" + value, Toast.LENGTH_SHORT).show(); +// MMKVUtils.INSTANCE.put("key", 100, "aa"); +// int value = MMKVUtils.INSTANCE.getInt("key", "bb"); +// Toast.makeText(DemoActivity.this, "" + value, Toast.LENGTH_SHORT).show(); + + serialPortUtil.sendSerialPort("AT+START_SCAN=1\r\n"); + serialPortUtil.sendSerialPort("AT+SCAN_RES=0\r\n"); + serialPortUtil.sendSerialPort("AT+CON_16=F9683387BAA1,0001\r\n"); }); binding.port.setOnClickListener(l -> { - SerialPortUtil serialPortUtil = new SerialPortUtil(); + serialPortUtil = new SerialPortUtil(); serialPortUtil.openSerialPort(); }); } + + private SerialPortUtil serialPortUtil = new SerialPortUtil(); } \ No newline at end of file diff --git a/buildCommon/commonLibConfig.gradle b/buildCommon/commonLibConfig.gradle index c3b18d3..a420ec5 100644 --- a/buildCommon/commonLibConfig.gradle +++ b/buildCommon/commonLibConfig.gradle @@ -1,6 +1,6 @@ project.ext { sign = [ - keystore_path : "../innovationapp.jks", + keystore_path : "../signature/innovationapp.jks", keystore_pwd : "123456", keystore_alias: "yinuo" ] diff --git a/commonLib/src/main/java/com/common/commonlib/net/BaseObserve.kt b/commonLib/src/main/java/com/common/commonlib/net/BaseObserve.kt index a665033..324407c 100644 --- a/commonLib/src/main/java/com/common/commonlib/net/BaseObserve.kt +++ b/commonLib/src/main/java/com/common/commonlib/net/BaseObserve.kt @@ -49,13 +49,6 @@ open class BaseObserve { return RequestManager.create(clazz) } - /** - * 初始化服务类 - */ - fun initService(clazz: Class, interceptors: List): T { - return RequestManager.create(clazz, interceptors) - } - /** * 调用接口 * @param observable 可订阅 @@ -89,6 +82,13 @@ open class BaseObserve { }) } + /** + * 初始化服务类 + */ + fun initService(clazz: Class, interceptors: List): T { + return RequestManager.create(clazz, interceptors) + } + /** * 处理错误 * @param e 异常 diff --git a/commonLib/src/main/java/com/common/commonlib/serialport/Cmd.java b/commonLib/src/main/java/com/common/commonlib/serialport/Cmd.java index f7f74b0..91f3e18 100644 --- a/commonLib/src/main/java/com/common/commonlib/serialport/Cmd.java +++ b/commonLib/src/main/java/com/common/commonlib/serialport/Cmd.java @@ -6,4 +6,4 @@ package com.common.commonlib.serialport; public interface Cmd { String OPEN_DOOR = "010100000000FFFF"; -} +} \ No newline at end of file diff --git a/commonLib/src/main/java/com/common/commonlib/serialport/SerialPortUtil.java b/commonLib/src/main/java/com/common/commonlib/serialport/SerialPortUtil.java index b862817..cd4757d 100644 --- a/commonLib/src/main/java/com/common/commonlib/serialport/SerialPortUtil.java +++ b/commonLib/src/main/java/com/common/commonlib/serialport/SerialPortUtil.java @@ -8,13 +8,22 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.charset.StandardCharsets; /** * @author by AllenJ on 2018/4/20. - * + *

* 通过串口用于接收或发送数据 */ public class SerialPortUtil { + /** + * 串口名称 + */ + private static final String DEVICE_PATH = "/dev/ttyMSM1"; + /** + * 串口比特率 + */ + private static final int DEVICE_BIT_RATE = 115200; private SerialPort serialPort = null; private InputStream inputStream = null; private OutputStream outputStream = null; @@ -28,13 +37,12 @@ public class SerialPortUtil { public void openSerialPort() { try { // 设置当前设备SU命令的位置 - SerialPort.setSuPath("/system/xbin/su"); - serialPort = new SerialPort(new File("/dev/ttyS0"), 9600, 0); +// SerialPort.setSuPath("/system/xbin/su"); + serialPort = new SerialPort(new File(DEVICE_PATH), DEVICE_BIT_RATE, 0); //调用对象SerialPort方法,获取串口中"读和写"的数据流 inputStream = serialPort.getInputStream(); outputStream = serialPort.getOutputStream(); isStart = true; - } catch (IOException e) { e.printStackTrace(); } @@ -58,7 +66,6 @@ public class SerialPortUtil { } catch (IOException e) { e.printStackTrace(); } - } /** @@ -69,7 +76,7 @@ public class SerialPortUtil { */ public void sendSerialPort(String data) { try { - byte[] sendData = DataUtils.HexToByteArr(data); + byte[] sendData = data.getBytes(StandardCharsets.US_ASCII); outputStream.write(sendData); outputStream.flush(); } catch (IOException e) { @@ -100,10 +107,9 @@ public class SerialPortUtil { try { int size = inputStream.read(readData); if (size > 0) { - String readString = DataUtils.ByteArrToHex(readData, 0, size); -// EventBus.getDefault().post(readString); + String readString = new String(readData, 0, size, StandardCharsets.US_ASCII); + Log.d("wangym", "got msg = "+ readString); } - } catch (IOException e) { e.printStackTrace(); } diff --git a/innovationapp.jks b/signature/innovationapp.jks similarity index 59% rename from innovationapp.jks rename to signature/innovationapp.jks index 3ddd97943194e75a13a012a8f497bd563a0c26ef..20f47af44008d7917ea92859b81b9e0190351a0b 100644 GIT binary patch delta 1004 zcmVnqj*0|3KNfPw>nt@ZjQ+%9jE z3T588DJX|5B?hL56_h?CiZqX!&B#&A0HG~`ioi}}+IhlQ|9!X~RWyU!K-)Jt8Xsb-1C3}lUk%&1nJurOyIxdQdg|L~I+|!y)%oF( z%^UtmtLuU2ZEb&1gsAe0khKmn1G25}@aWESh+Q`Z&E;wUR;!H?MLp9G%zjY>+imK&e*{cDooc#Gwm zxF;-Bu;et{Jza*u{QP-QlrY+MP^V}j?!9ZT3)M((yWg`JRxN;Q9R@Ef3IQq9BCsr zyg^b2>+h8wt*r6iw(R_98@e`#{V#wZ&)qy^gy!c2f_Y)vN^l<5gjGa z)KWqzKCE$2QT*b^a$PQ_{jF+IvOw}Dq=bU}mEd(m?Hk}Ahk1sB4M?(n-f=H zTzrX$iWQgnbz}2HIz0$8Ui97JKTFGSmzHFH7J1A#gsPj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8`Usqa6YR0fwLs6x#Cu diff --git a/signature/keytool-importkeypair b/signature/keytool-importkeypair new file mode 100644 index 0000000..e69de29 diff --git a/signature/platform.pk8 b/signature/platform.pk8 new file mode 100644 index 0000000000000000000000000000000000000000..e27a3933e82ee93d4faa03ed06467bfecf81bf80 GIT binary patch literal 1216 zcmV;x1V8&Qf&{z*0RS)!1_>&LNQUrrZ9p8q5=T`0)hbn0GxOQlB^9~ zI2_)pW$ehN0B$x&3~h1;u^n%{9o*76`CfXB^Ed)p=?JBom8CbLTu zbt9ybXd+1j+yO~Gdh~&0EeWy&v4>s~ zteC;7cRgqTx$6DpZCJk8=-L+fqhJY~H>fnG-|e@yv`Pe?2cl{G&n#4y^3OKbP5BBt zjgK^=x~oj}GjXdYahp4(hg7W$Q~VU++eOtLBTu{OJe#EL`OZ`(6Hx3^RtLXnqW?;u zeYN-MAPoto!L*(sKre~y5s-;Gt6GtO@lxn7g``(g&tJiiamDV)CjtQj0)hbmXix*U z9bP^qXq0i8NQJ}zNqL1`o=gQGzzfthuF=Qrc<8GU>Pv)=OciWZ+KAp#k{NA%2LMPJ z%-px5Z5Uyi!G;4pRxs33vEOE{g`-ar0#ZOAX$ts^ELH2B9voUC&by28`W!GG26nB> zuapdP5P=*|ennN$M^o-d<xX;JnQoNPm9p-SYQM4# zVRJ*i(v&d>pk0OlG^Hsj``%F~3Mc5Xd{g{k?{<&Lsrldj*QmHzuGYJo0)c@5$R~Hg z?l7?sF8|84X|na>^?Wnles)*kBpG)f)o@X}2lylQRTMobi5g+k@HxLB&scnds{7ys zn-cu~ixUUTjs#taYUvfKp>|Yq?Ja?{ z4Z$WokggqDfdQ)Zr~>(grr#5{7x_v0m`d4U=oIQv`fjl84I{_${{@4kBtN)^T;61o zp)3>=qK8b?nJsX!m=;8{G?$bjYk5yw1g<`4r_nL@x!HY-FbcVJ8qu0Gg-Rs*0)c@5 zg>R)Sp35M$bgG9Vo6Mu_PEyT2{`rsVZDvnuj!NMtTBU7H<6_fs1`(ExO3^A7iaPzQ zas5C85)7!RvJ9`?w0EZH(l{V#*YsZD4FLu6*`kL0++;~x>qsB#t(p+DAhe1;F@hKT zQxv~?`qtv_AwA~ZPB}4?R!o+8(U%5;0)c@5g=)`bdL*JlPgwg+@;ye{M@9~D!1;}# z^K+}sUVy|Y3m(2b0ISDNZ~^ZNNz5ve?xN&)^Bc%A zHCABO#0G6v)>>x`wWPcwb=sAH2Vo4G@gcF51Nd^%fH#Qt9l13)a12|{9ee~BLjha` e)`?Ej7eZFsUzB0T-7pi1g}8>P$D#^4VDU$4aXRP# literal 0 HcmV?d00001 diff --git a/signature/platform.x509.pem b/signature/platform.x509.pem new file mode 100644 index 0000000..e69de29 diff --git a/signature/signature.sh b/signature/signature.sh new file mode 100644 index 0000000..ae6faf4 --- /dev/null +++ b/signature/signature.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# 转换平台签名命令 +./keytool-importkeypair -k innovationapp.jks -p 123456 -pk8 platform.pk8 -cert platform.x509.pem -alias yinuo + +# innovationapp.jks : 签名文件 +# 123456 : 签名文件密码 +# platform.pk8、platform.x509.pem : 系统签名文件 +# yinuo : 签名文件别名 \ No newline at end of file