Compare commits
6 Commits
5769b7670b
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d43980458 | |||
| 0800e0eaf0 | |||
| ce30c6cf7b | |||
| cdc07256ee | |||
| 47715f0fd6 | |||
| 59c228f36c |
@ -11,7 +11,7 @@ android {
|
||||
minSdk 28
|
||||
targetSdk 28
|
||||
versionCode 1
|
||||
versionName "1.18"
|
||||
versionName "2.4"
|
||||
|
||||
// 1.0 IDATA广播模式处理
|
||||
// 1.1 霍尼韦尔的监听修改(扫描网站二维码跳出程序,监听失效,调整)、斑马PDA广播模式设置
|
||||
@ -32,6 +32,11 @@ android {
|
||||
// 1.16 idata pda 不设置模式
|
||||
// 1.17 霍尼韦尔EDA51、EDA50P,调用扫描枪的方法,在关闭的时候停止调用扫描枪
|
||||
// 1.18 瑞兴平板,读取扫描结果,使用同步加锁模式
|
||||
// 1.19 index页面接入初始化数据
|
||||
// 2.1 注册PDA的信息存储到文件内部,采取mac+固定加密串的MD5加密校验
|
||||
// 2.2 安卓14以上,无法获取mac地址,修改成获取唯一id作为mac地址
|
||||
// 2.3 适配IOT_Device:sc55g PDA 广播模式
|
||||
// 2.4 适配 qualcomm:mc50 PDA 广播模式
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
ndk {
|
||||
abiFilters 'armeabi-v7a'
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -10,6 +10,8 @@ package chaoran.business;
|
||||
|
||||
public enum BrandEnum {
|
||||
//枚举名即为valueOf()
|
||||
QUALCOMM("qualcomm", "qualcomm"),
|
||||
IOT_DEVICE("新大陆", "iot_device"),
|
||||
NEW_LAND("新大陆", "newland"),
|
||||
HISENSE("海信", "hisense"),
|
||||
UROVO("DT50 Lite", "urovo"),
|
||||
@ -44,7 +46,7 @@ public enum BrandEnum {
|
||||
code = new String();
|
||||
}
|
||||
for (BrandEnum brandEnum : values()) {
|
||||
if (brandEnum.code.equals(code.toLowerCase())) {
|
||||
if (brandEnum.code.equalsIgnoreCase(code)) {
|
||||
return brandEnum;
|
||||
}
|
||||
}
|
||||
|
||||
@ -164,6 +164,12 @@ public class MainActivity extends AppCompatActivity implements ResultListener{
|
||||
case NEW_LAND:
|
||||
adapter = new NewlandAdapter(this, this);
|
||||
break;
|
||||
case IOT_DEVICE:
|
||||
adapter = new IOT_DeviceAdapter(this, this);
|
||||
break;
|
||||
case QUALCOMM:
|
||||
adapter = new QualcommAdapter(this, this);
|
||||
break;
|
||||
}
|
||||
if (null != adapter) {
|
||||
adapter.start();
|
||||
|
||||
@ -8,6 +8,10 @@ import android.content.IntentFilter;
|
||||
import chaoran.business.activity.ResultListener;
|
||||
import chaoran.business.strategy.Strategy;
|
||||
|
||||
/**
|
||||
* 23-6-13 霍尼韦尔EDA56使用
|
||||
* 25-1-14 兰陵县人民医院 测试可以使用(唐圆圆)
|
||||
*/
|
||||
public class HoneywellEda56Adapter implements Adapter {
|
||||
private Context context;
|
||||
private ResultListener resultListener;
|
||||
|
||||
@ -0,0 +1,56 @@
|
||||
package chaoran.business.adapter;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
import chaoran.business.activity.ResultListener;
|
||||
import chaoran.business.strategy.Strategy;
|
||||
|
||||
/**
|
||||
* 适配 sc55g
|
||||
*/
|
||||
public class IOT_DeviceAdapter implements Adapter {
|
||||
private Context context;
|
||||
private ResultListener resultListener;
|
||||
private Strategy strategy;
|
||||
|
||||
|
||||
public IOT_DeviceAdapter(Context context, ResultListener resultListener) {
|
||||
this.context = context;
|
||||
this.resultListener = resultListener;
|
||||
strategy = new Receiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
strategy.executeStrategy(resultListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
strategy.exclusiveStrategy();
|
||||
}
|
||||
|
||||
public class Receiver extends BroadcastReceiver implements Strategy {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
resultListener.result(intent.getStringExtra("message"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeStrategy(ResultListener resultListener) {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction("com.speedata.showdecodedata");
|
||||
filter.setPriority(2);
|
||||
context.registerReceiver(this, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exclusiveStrategy() {
|
||||
context.unregisterReceiver(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,56 @@
|
||||
package chaoran.business.adapter;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
|
||||
import chaoran.business.activity.ResultListener;
|
||||
import chaoran.business.strategy.Strategy;
|
||||
|
||||
/**
|
||||
* 适配 mc50
|
||||
*/
|
||||
public class QualcommAdapter implements Adapter {
|
||||
private Context context;
|
||||
private ResultListener resultListener;
|
||||
private Strategy strategy;
|
||||
|
||||
|
||||
public QualcommAdapter(Context context, ResultListener resultListener) {
|
||||
this.context = context;
|
||||
this.resultListener = resultListener;
|
||||
strategy = new Receiver();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
strategy.executeStrategy(resultListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
strategy.exclusiveStrategy();
|
||||
}
|
||||
|
||||
public class Receiver extends BroadcastReceiver implements Strategy {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
resultListener.result(intent.getStringExtra("data"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeStrategy(ResultListener resultListener) {
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction("com.scanner.broadcast");
|
||||
filter.setPriority(2);
|
||||
context.registerReceiver(this, filter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exclusiveStrategy() {
|
||||
context.unregisterReceiver(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -1,11 +1,16 @@
|
||||
package chaoran.business.utils;
|
||||
|
||||
import static androidx.core.content.ContextCompat.getSystemService;
|
||||
|
||||
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.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
@ -18,13 +23,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;
|
||||
@ -63,6 +67,14 @@ public class LocalAddressUtil {
|
||||
@SuppressLint("JavascriptInterface")
|
||||
@JavascriptInterface
|
||||
public String getMacAddress(){//可以兼容安卓7以下
|
||||
if (Build.VERSION.SDK_INT >= 34) { // Android 14 is code-named Tiramisu
|
||||
try {
|
||||
return Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "02:00:00:00:00:02";
|
||||
}
|
||||
}
|
||||
String macAddress = null;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
NetworkInterface networkInterface = null;
|
||||
@ -160,6 +172,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() {
|
||||
|
||||
34
app/src/main/java/chaoran/business/utils/MD5.java
Normal file
34
app/src/main/java/chaoran/business/utils/MD5.java
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user