version:6.4.0

fix:
update:更换推送
This commit is contained in:
2023-06-17 09:38:37 +08:00
parent 539203e818
commit 8c948e62be
28 changed files with 1153 additions and 710 deletions

View File

@@ -48,7 +48,6 @@ import android.widget.Toast;
import androidx.annotation.RequiresApi;
import androidx.annotation.VisibleForTesting;
import com.alibaba.fastjson.JSONObject;
import com.aoleyun.sn.BuildConfig;
import com.aoleyun.sn.R;
import com.aoleyun.sn.base.BaseApplication;
@@ -63,6 +62,7 @@ import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
import com.google.zxing.qrcode.QRCodeWriter;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.squareup.moshi.Json;
import com.tencent.mmkv.MMKV;
import java.io.BufferedReader;
@@ -107,6 +107,7 @@ import io.reactivex.rxjava3.core.ObservableOnSubscribe;
import io.reactivex.rxjava3.core.Observer;
import io.reactivex.rxjava3.disposables.Disposable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import vendor.mediatek.hardware.nvram.V1_0.INvram;
import static android.content.Context.WIFI_SERVICE;
@@ -177,6 +178,7 @@ public class Utils {
// } else {
// return getAndroid7MAC();
// }
return getAllMacAddress(context);
}
@@ -375,6 +377,13 @@ public class Utils {
return "未获取到设备Mac地址";
}
private static String getMacAddrApiS(Context context) {
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
String mac = wifiInfo.getMacAddress();
return mac;
}
// MD5 设备地址标识
public static String getMD5(Context context) {
String WLANMAC = getMAC(context);
@@ -781,42 +790,86 @@ public class Utils {
return t1;
}
public static String NOSN = "012345679ABCDEF";
public static final String NOSN = "012345679ABCDEF";
public static final String TECLAST_BRAND = "Teclast";
/**
* 获取设备序列号
*
* @return
*/
@SuppressLint({"MissingPermission", "HardwareIds"})
public static String getSerial(Context context) {
String serial = "unknow";
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+
serial = Build.getSerial();
} else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.N) {//8.0+
serial = Build.SERIAL;
} else {//8.0-
Class<?> c = Class.forName("android.os.SystemProperties");
Method get = c.getMethod("get", String.class);
serial = (String) get.invoke(c, "ro.serialno");
if (TECLAST_BRAND.equalsIgnoreCase(Build.BRAND)) {
return getPushMac(context);
} else {
if (NOSN.equalsIgnoreCase(getSn())) {
return getIMEI(context);
} else {
return getSn();
}
} catch (Exception e) {
e.printStackTrace();
Log.e("getSerial", "读取设备序列号异常:" + e.toString());
}
if (BuildConfig.DEBUG) {
// return "LTPKD22110000051";
// serial = "012345679ABCDEF";
}
if (NOSN.equalsIgnoreCase(serial)) {
return getIMEI(context);
}
return serial;
}
public static String getPushMac(Context context) {
String macaddr = Utils.getMacAddrFromNvram();
return macaddr.replace(":", "").toUpperCase().trim();
}
//mh add start----
private static final int MAC_ADDRESS_ID = 30;
private static final int MAC_ADDRESS_OFFSET = 4;
private static final int MAC_ADDRESS_DIGITS = 6;
private static final int MAX_ADDRESS_VALUE = 0xff;
private static final int INVALID_RSSI = -200;
private static final String MAC_ADDRESS_FILENAME = "/mnt/vendor/nvdata/APCFG/APRDEB/WIFI";
private static String getMacAddrFromNvram() {
StringBuffer nvramBuf = new StringBuffer();
try {
int i = 0;
String buff = null;
INvram agent = INvram.getService();
if (agent == null) {
// mToast.setText("No support MAC address writing due to NVRAM");
// mToast.show();
Log.e("mh_mac", "NvRAMAgent is null");
return "";
}
try {
buff = agent.readFileByName(
MAC_ADDRESS_FILENAME, MAC_ADDRESS_OFFSET + MAC_ADDRESS_DIGITS);
} catch (Exception e) {
e.printStackTrace();
return "";
}
Log.i("mh_mac", "Raw data:" + buff);
if (buff.length() < 2 * (MAC_ADDRESS_OFFSET + MAC_ADDRESS_DIGITS)) {
// mToast.setText("The foramt of NVRAM is not correct");
// mToast.show();
return "";
}
// Remove the \0 special character.
int macLen = buff.length() - 1;
for (i = MAC_ADDRESS_OFFSET * 2; i < macLen; i += 2) {
if ((i + 2) < macLen) {
nvramBuf.append(buff.substring(i, i + 2));
nvramBuf.append(":");
} else {
nvramBuf.append(buff.substring(i));
}
}
Log.d("mh_mac", "buff:" + nvramBuf.toString());
} catch (Exception e) {
e.printStackTrace();
return "";
}
return nvramBuf.toString();
}
//mh add end------
@SuppressLint({"MissingPermission", "HardwareIds"})
public static String getSerial() {
public static String getSn() {
String serial = "unknow";
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {//9.0+
@@ -832,9 +885,6 @@ public class Utils {
e.printStackTrace();
Log.e("getSerial", "读取设备序列号异常:" + e.toString());
}
if (BuildConfig.DEBUG) {
// return "QNG2DKB00463";
}
return serial;
}
@@ -1138,9 +1188,9 @@ public class Utils {
* @param url
* @param jsonObject
*/
public static void ariaDownload(Context context, String url, JSONObject jsonObject) {
public static void ariaDownload(Context context, String url, JsonObject jsonObject) {
String fileName = getFileNamefromURL(url);
String urlMD5 = jsonObject.getString("MD5");
String urlMD5 = jsonObject.get("MD5").getAsString();
Log.e("ariaDownload", "urlMD5=" + urlMD5);
String p = JGYUtils.getInstance().getDownLoadPath();
File file = new File(JGYUtils.getInstance().getDownLoadPath() + fileName);
@@ -1158,7 +1208,7 @@ public class Utils {
.load(url) //读取下载地址
.setFilePath(JGYUtils.getInstance().getDownLoadPath() + fileName)
.ignoreFilePathOccupy()
.setExtendField(jsonObject.toJSONString())
.setExtendField(jsonObject.toString())
.create(); //启动下载}
// }
}
@@ -1167,7 +1217,7 @@ public class Utils {
.load(url) //读取下载地址
.setFilePath(JGYUtils.getInstance().getDownLoadPath() + fileName)
.ignoreFilePathOccupy()
.setExtendField(jsonObject.toJSONString())
.setExtendField(jsonObject.toString())
.create(); //启动下载}
}
}
@@ -1317,7 +1367,7 @@ public class Utils {
imei = tm.getDeviceId(slotIndex);
}
if (TextUtils.isEmpty(imei)) {
return "暂无数据";
return context.getString(R.string.no_data);
}
return imei;
}
@@ -1330,7 +1380,7 @@ public class Utils {
//8.0及以后版本获取
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
IMEI = TelephonyMgr.getDeviceId();
// } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
// try {
// Method method = TelephonyMgr.getClass().getMethod("getImei");
// IMEI = (String) method.invoke(TelephonyMgr);
@@ -1341,11 +1391,11 @@ public class Utils {
// IMEI = TelephonyMgr.getDeviceId();
// } else {//9.0到10.0获取
// IMEI = Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
IMEI = Settings.System.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
}
Log.e("IMEI:", "IMEI: " + IMEI);
if (null == IMEI) {
return "-";
return "";
} else {
return IMEI.toUpperCase();
}
@@ -1390,18 +1440,18 @@ public class Utils {
String firmware_version = getRomVersion();
String rom = Utils.getCustomVersion();
String screen_rate = getAndroiodScreenProperty(context);
JSONObject jsonObject = new JSONObject();
jsonObject.put("device", device);
jsonObject.put("imei", imei);
jsonObject.put("system_version", system_version);
jsonObject.put("firmware_version", firmware_version);
jsonObject.put("rom", rom);
jsonObject.put("screen_rate", screen_rate);
jsonObject.put("working_time", SystemClock.elapsedRealtime() / 1000);
jsonObject.put("restart_count", SPUtils.get(context, "restart_count", 0));
jsonObject.put("storage_usable", getRemnantSize(context));
jsonObject.put("storage_total", getDataTotalSize(context));
String jsonString = jsonObject.toJSONString();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("device", device);
jsonObject.addProperty("imei", imei);
jsonObject.addProperty("system_version", system_version);
jsonObject.addProperty("firmware_version", firmware_version);
jsonObject.addProperty("rom", rom);
jsonObject.addProperty("screen_rate", screen_rate);
jsonObject.addProperty("working_time", SystemClock.elapsedRealtime() / 1000);
jsonObject.addProperty("restart_count", (int) SPUtils.get(context, "restart_count", 0));
jsonObject.addProperty("storage_usable", getRemnantSize(context));
jsonObject.addProperty("storage_total", getDataTotalSize(context));
String jsonString = jsonObject.toString();
Log.e(TAG, "getMachine: " + jsonString);
return jsonString;
}
@@ -1414,14 +1464,14 @@ public class Utils {
Log.e("getHardware", "Memory: " + memory);
String storage = getRemnantSize(context) + "/" + getDataTotalSize(context);
int CPU = getNumCores();
JSONObject jsonObject = new JSONObject();
jsonObject.put("electric", electric);
jsonObject.put("charging", charging);
jsonObject.put("memory", memory);
jsonObject.put("storage", storage);
jsonObject.put("battery_capacity", Utils.getBatterymAh(context));
jsonObject.put("CPU", CPU + "核");
String jsonString = jsonObject.toJSONString();
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("electric", electric);
jsonObject.addProperty("charging", charging);
jsonObject.addProperty("memory", memory);
jsonObject.addProperty("storage", storage);
jsonObject.addProperty("battery_capacity", Utils.getBatterymAh(context));
jsonObject.addProperty("CPU", CPU + "核");
String jsonString = jsonObject.toString();
Log.e(TAG, "getHardware: " + jsonString);
return jsonString;
}
@@ -1704,6 +1754,7 @@ public class Utils {
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.CubePlatform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTKPlatform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.MTK11Platform
|| JGYUtils.getInstance().checkAppPlatform() == JGYUtils.TeclastP20sPlatform
) {
return Utils.getProperty("ro.build.display.id", "获取失败");
} else {