java代码备份

编程

从api获取基站信息

public static JSONArray getMncInfo(JSONObject latLngJo, String operatorCode, String mncKey, CellRepository cellRepository) {

if (!operatorCode.equals("0") && !operatorCode.equals("1")) {

operatorCode = "11";

}

HttpRes httpRes = new HttpRes();

JSONObject latLngJoNew;

JSONArray mncInfoJaOld = new JSONArray(), mncInfoJa = new JSONArray();

// api服务停止,暂时从数据库随机获取

/*List<CellInfo> cellInfoList = cellRepository.findCellInfo(r.nextInt(14));

for (int i=0; i<cellInfoList.size(); i++) {

CellInfo cellInfo = cellInfoList.get(i);

JSONObject mncInfoJo = new JSONObject();

mncInfoJo.put("acc", cellInfo.getAcc());

mncInfoJo.put("mnc", cellInfo.getMnc());

mncInfoJo.put("lng", cellInfo.getLon());

mncInfoJo.put("lat", cellInfo.getLat());

mncInfoJo.put("arfcn", r.nextInt(32767));

mncInfoJo.put("bsic", r.nextInt(63));

mncInfoJo.put("mcc", "460");

mncInfoJo.put("sid", operatorCode);

mncInfoJo.put("cid", cellInfo.getCi());

mncInfoJo.put("lac", cellInfo.getLac());

mncInfoJa.put(mncInfoJo);

}*/

// 随机从备份的基站信息获取一些

int mncI = r.nextInt(34);

mncInfoJaOld = new JSONArray(utils.rlFromF("mncCache/mncInfo" + mncI));

if (mncInfoJaOld.length() > 1) {

for (int i=0; i<mncInfoJaOld.length(); i++) {

JSONObject mncInfoJo = mncInfoJaOld.getJSONObject(i);

logger.info(mncInfoJo.toString());

try {

CellInfo cellInfo = new CellInfo(Integer.parseInt(operatorCode));

cellInfo.setAcc(mncInfoJo.optInt("radius"));

cellInfo.setCi(mncInfoJo.optInt("cell"));

cellInfo.setLac(mncInfoJo.optInt("lac"));

cellInfo.setLat(mncInfoJo.optDouble("lat"));

cellInfo.setLon(mncInfoJo.optDouble("lng"));

cellRepository.save(cellInfo);

}catch (Exception e) {

}

mncInfoJo.remove("gcjlat");

mncInfoJo.remove("gcjlng");

mncInfoJo.remove("address");

mncInfoJo.put("acc", mncInfoJo.remove("radius"));

mncInfoJo.put("mnc", operatorCode);

mncInfoJo.put("arfcn", r.nextInt(32767));

mncInfoJo.put("bsic", r.nextInt(63));

mncInfoJo.put("mcc", "460");

mncInfoJo.put("sid", operatorCode);

mncInfoJo.put("cid", mncInfoJo.remove("cell"));

mncInfoJa.put(mncInfoJo);

}

}

// mncInfoJa = new JSONArray(utils.rlFromF("mncInfoJa"));

return mncInfoJa;

}

从api获取wifi信息

ist<WifiInfo> wifiInfoList =wifiRepository.findWifiInfo(r.nextInt(29));

for (int i=0; i<wifiInfoList.size(); i++) {

JSONObject wifiInfoJo = new JSONObject();

String Ssid = RandomData.SSID_PRE_ARR[r.nextInt(RandomData.SSID_PRE_ARR.length)] + RandomData.getRandomAlphabetNumber(6);

// 生成ScanResult的参数

// 先生成随机0或1,0代表2.4G,1代表5G

int is24 = r.nextInt(2);

if (is24 == 0) {

wifiInfoJo.put("frequency", r.nextInt(98) + 2401);

} else {

// 如果是5G,给无线名称后面加上5g标志的后缀:_5G

Ssid += "_5G";

wifiInfoJo.put("frequency", r.nextInt(998) + 4901);

}

wifiInfoJo.put("Ssid", Ssid);

WifiInfo wifiInfo = wifiInfoList.get(i);

wifiInfoJo.put("acc", wifiInfo.getAcc());

wifiInfoJo.put("BSSID", wifiInfo.getMacAddress());

// hessid、anqpDomainId不知道代表什么,默认先为0,osuProviders不知道是什么,设置为null

wifiInfoJo.put("hessid", 0);

wifiInfoJo.put("anqpDomainId", 0);

// 加密方式,一般都用下面这种的,就不搞随机的了

wifiInfoJo.put("caps", "[WPA-PSK-CCMP][WPA2-PSK-CCMP][ESS]");

// tsf为timestamp,wifi启动的时间戳

wifiInfoJo.put("tsf", System.currentTimeMillis() * 1000);

// distCm手机距离路由器的大概距离,单位为厘米,默认为-1

wifiInfoJo.put("distCm", -1);

// distSdCm,手机距离路由器的标准距离,单位为厘米,默认为-1

wifiInfoJo.put("distSdCm", -1);

// centerFreq0,centerFreq1不知道是什么,默认为0

wifiInfoJo.put("centerFreq0", 0);

wifiInfoJo.put("centerFreq1", 0);

// is80211McRTTResponder,不知道是什么,默认为false

wifiInfoJo.put("is80211McRTTResponder", false);

JSONObject locationJo = new JSONObject();

locationJo.put("lon", wifiInfo.getLon());

locationJo.put("lat", wifiInfo.getLat());

wifiInfoJo.put("location", locationJo);

wifiInfoJa.put(wifiInfoJo);

}

设置真实的imei

//设置真实的imei,用于测试

RealImei realImei = realImeiRepository.getOneByUseNum();

realImei.setUseNum(realImei.getUseNum() + 1);

realImei.setLastUseTime(sdf.format(new Date()));

realImeiRepository.saveAndFlush(realImei);

globalJo.put("persist.sys.imei0", realImei.getImei1());

globalJo.put("persist.sys.imei1", realImei.getImei2());

globalJo.put("persist.sys.wifi_address", realImei.getWifi());

globalJo.put("persist.sys.bt_address", realImei.getBt());

globalJo.put("persist.sys.meid0", realImei.getMeid());

systemProperJo.put("ro.serialno", realImei.getSn());

systemProperJo.put("ro.boot.serialno", realImei.getSn());

fileJo.put("serial", "0x" + realImei.getSn());

以上是 java代码备份 的全部内容, 来源链接: utcz.com/z/512039.html

回到顶部