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 3ddd979..20f47af 100644 Binary files a/innovationapp.jks and b/signature/innovationapp.jks differ 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 0000000..e27a393 Binary files /dev/null and b/signature/platform.pk8 differ 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