Compare commits

...

2 Commits

5 changed files with 98 additions and 19 deletions

View File

@ -11,7 +11,7 @@ android {
minSdk 28
targetSdk 28
versionCode 1
versionName "1.18"
versionName "2.1"
// 1.0 IDATA广播模式处理
// 1.1 霍尼韦尔的监听修改扫描网站二维码跳出程序监听失效调整、斑马PDA广播模式设置
@ -32,6 +32,8 @@ android {
// 1.16 idata pda 不设置模式
// 1.17 霍尼韦尔EDA51、EDA50P调用扫描枪的方法在关闭的时候停止调用扫描枪
// 1.18 瑞兴平板,读取扫描结果,使用同步加锁模式
// 1.19 index页面接入初始化数据
// 2.1 注册PDA的信息存储到文件内部采取mac+固定加密串的MD5加密校验
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ndk {
abiFilters 'armeabi-v7a'

View File

@ -99,20 +99,6 @@
</style>
<script>
function saveSetting(){
var data=JSON.stringify({
"address":document.getElementById('address').value,
"port":document.getElementById('port').value,
"path":document.getElementById('path').value,
"screen_rotation":document.getElementById('screen_rotation').value,
"hide_bar":document.getElementById('hide_bar').value
});
window.NetworkSettingEngine.saveSetting(data);
window.View.reload();
}
</script>
</head>
@ -148,4 +134,35 @@
</div>
</div>
</body>
<script>
function init() {
var dstr = window.NetworkSettingEngine.getStringSetting();
if (dstr.length > 0) {
var d = JSON.parse(dstr);
document.getElementById('address').value = d.address;
document.getElementById('port').value = d.port;
document.getElementById('path').value = d.path;
document.getElementById('screen_rotation').value = d.screen_rotation;
document.getElementById('hide_bar').value = d.hide_bar;
console.log("d_data_end_=========================");
}
}
init();
function saveSetting(){
var data=JSON.stringify({
"address":document.getElementById('address').value,
"port":document.getElementById('port').value,
"path":document.getElementById('path').value,
"screen_rotation":document.getElementById('screen_rotation').value,
"hide_bar":document.getElementById('hide_bar').value
});
window.NetworkSettingEngine.saveSetting(data);
window.View.reload();
}
</script>
</html>

View File

@ -45,6 +45,7 @@ public class NetworkSettingEngine implements SettingEngine {
networkSetting.setPort(port);
networkSetting.setPath(path);
networkSetting.setScreen_rotation(screen_rotation);
networkSetting.setHide_bar(spf.getInt("hide_bar", 3));
return networkSetting;
}

View File

@ -2,8 +2,8 @@ package chaoran.business.utils;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.bluetooth.le.ScanSettings;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.os.Build;
import android.util.Log;
@ -18,13 +18,12 @@ import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import chaoran.business.BrandEnum;
import chaoran.business.BuildConfig;
import chaoran.business.R;
import chaoran.business.activity.MainActivity;
public class LocalAddressUtil {
public final static String SSO_KEY = "!~CROP@CRTECH@PDA~!";
private Context context;
private Activity activity;
@ -160,6 +159,32 @@ public class LocalAddressUtil {
}
}
@SuppressLint("JavascriptInterface")
@JavascriptInterface
public String registerMac(String applyMac) {
try {
String mac = this.getMacAddress();
String md5Hash = MD5.md5(mac + SSO_KEY);
if (md5Hash != null && md5Hash.equals(applyMac)) {
// 将允许注册适配的mac写入文件中
SharedPreferences.Editor editor = context.getSharedPreferences("CrtechPdaConfig", Context.MODE_PRIVATE).edit();
editor.putString("checkMac", "success");
editor.commit();
return "success";
}
}catch (Exception ignored) {
}
return "error";
}
@SuppressLint("JavascriptInterface")
@JavascriptInterface
public String checkMacRegister() {
SharedPreferences sharedPreferences = context.getSharedPreferences("CrtechPdaConfig", Context.MODE_PRIVATE);
return sharedPreferences.getString("checkMac", "error");
}
@SuppressLint("JavascriptInterface")
@JavascriptInterface
public String getApkVersion() {

View File

@ -0,0 +1,34 @@
package chaoran.business.utils;
import java.security.MessageDigest;
// 从框架的MD5加密类拷贝过来的
public class MD5 {
private static final String key = "aa";
private static final char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
public static final String md5(String s) {
return s == null ? null : md5(s.getBytes());
}
public static final String md5(byte[] bytes) {
try {
MessageDigest mdTemp = MessageDigest.getInstance("MD5");
mdTemp.update(bytes);
byte[] md = mdTemp.digest();
int j = md.length;
char[] str = new char[j * 2];
int k = 0;
for(int i = 0; i < j; ++i) {
byte byte0 = md[i];
str[k++] = hexDigits[byte0 >>> 4 & 15];
str[k++] = hexDigits[byte0 & 15];
}
return new String(str);
} catch (Exception var8) {
return null;
}
}
}