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());
相關文章
相關標籤/搜索