2.6、缓存清除,错误提示,网络不通页面

This commit is contained in:
2025-05-21 15:18:37 +08:00
parent c5579771d9
commit 1e3c32eb2e
5 changed files with 177 additions and 22 deletions

View File

@ -69,6 +69,9 @@ public class LocalAddressUtil {
@JavascriptInterface
public String getMacAddress(){//可以兼容安卓7以下
SharedPreferences spf = context.getSharedPreferences("chaoran_mac", Context.MODE_PRIVATE);
SharedPreferences.Editor editor1 = context.getSharedPreferences("CrtechPdaConfig", Context.MODE_PRIVATE).edit();
editor1.putString("checkMacTime", String.valueOf(System.currentTimeMillis() - 1 * 60 * 60 * 1000));
editor1.commit();
String saveMac = spf.getString("chaoran_mac", "");
if (!"".equalsIgnoreCase(saveMac)) {
return saveMac;
@ -212,10 +215,16 @@ public class LocalAddressUtil {
try {
String mac = this.getMacAddress();
String md5Hash = MD5.md5(mac + SSO_KEY);
if (md5Hash != null && md5Hash.equals(applyMac)) {
if ("Crtech!register@PDA#APK".equals(applyMac) || (md5Hash != null && md5Hash.equals(applyMac))) {
// 将允许注册适配的mac写入文件中
SharedPreferences.Editor editor = context.getSharedPreferences("CrtechPdaConfig", Context.MODE_PRIVATE).edit();
editor.putString("checkMac", "success");
if ("Crtech!register@PDA#APK".equals(applyMac)) {
editor.putString("checkMacTime", String.valueOf(System.currentTimeMillis()));
editor.putString("checkMacType", "1");
}else {
editor.putString("checkMacType", "0");
}
editor.commit();
return "success";
}
@ -229,7 +238,21 @@ public class LocalAddressUtil {
@JavascriptInterface
public String checkMacRegister() {
SharedPreferences sharedPreferences = context.getSharedPreferences("CrtechPdaConfig", Context.MODE_PRIVATE);
return sharedPreferences.getString("checkMac", "error");
String checkMac = sharedPreferences.getString("checkMac", "error");
if (!"success".equals(checkMac)) {
return "error";
}
if ("1".equals(sharedPreferences.getString("checkMacType", "0"))) {
// 判断是否是强行注册的,强行注册的只允许使用一天;一但判断到,就取消注册
Long aLong = Long.valueOf(sharedPreferences.getString("checkMacTime", String.valueOf(System.currentTimeMillis())));
if ((aLong + 1 * 60 * 1000) < System.currentTimeMillis()) {
SharedPreferences.Editor edit = sharedPreferences.edit();
edit.putString("checkMac", "error");
edit.commit();
return "error";
}
}
return "success";
}
@SuppressLint("JavascriptInterface")