package loc; import android.content.Context; import com.gui.Utils; import java.util.*; import java.io.*; import java.net.HttpURLConnection; import translate.Translator; //import javax.microedition.io.Connector; //import javax.microedition.io.HttpConnection; public class CellGps { private Hashtable table = new Hashtable(); private int mcc2, mnc2, lac2, cid2; private int elev = 0; private volatile int acc = 0; boolean emulate = false; public String mode = "0"; public String data = "0"; protected char[] koi8rmap = "\u2500\u2502\u250C\u2510\u2514\u2518\u251C\u2524\u252C\u2534\u253C\u2580\u2584\u2588\u258C\u2590\u2591\u2592\u2593\u2320\u25A0\u2219\u221A\u2248\u2264\u2265\u00A0\u2321\u00B0\u00B2\u00B7\u00F7\u2550\u2551\u2552\u0451\u2553\u2554\u2555\u2556\u2557\u2558\u2559\u255A\u255B\u255C\u255D\u255E\u255F\u2560\u2561\u0401\u2562\u2563\u2564\u2565\u2566\u2567\u2568\u2569\u256A\u256B\u256C\u00A9\u044E\u0430\u0431\u0446\u0434\u0435\u0444\u0433\u0445\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u044F\u0440\u0441\u0442\u0443\u0436\u0432\u044C\u044B\u0437\u0448\u044D\u0449\u0447\u044A\u042E\u0410\u0411\u0426\u0414\u0415\u0424\u0413\u0425\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u042F\u0420\u0421\u0422\u0423\u0416\u0412\u042C\u042B\u0417\u0428\u042D\u0429\u0427\u042A" .toCharArray(); protected char[] cp1251map = "\u0402\u0403\u201A\u0453\u201E\u2026\u2020\u2021\u20AC\u2030\u0409\u2039\u040A\u040C\u040B\u040F\u0452\u2018\u2019\u201C\u201D\u2022\u2013\u2014\uFFFD\u2122\u0459\u203A\u045A\u045C\u045B\u045F\u00A0\u040E\u045E\u0408\u00A4\u0490\u00A6\u00A7\u0401\u00A9\u0404\u00AB\u00AC\u00AD\u00AE\u0407\u00B0\u00B1\u0406\u0456\u0491\u00B5\u00B6\u00B7\u0451\u2116\u0454\u00BB\u0458\u0405\u0455\u0457\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F" .toCharArray(); protected char[] cp1257map = "\u20AC\0\u201A\0\u201E\u2026\u2020\u2021\0\u2030\0\u2039\0\250\u02C7\270\0\u2018\u2019\u201C\u201D\u2022\u2013\u2014\0\u2122\0\u203A\0\257\u02DB\0\240\0\242\243\244\0\246\247\330\251\u0156\253\254\255\256\306\260\261\262\263\264\265\266\267\370\271\u0157\273\274\275\276\346\u0104\u012E\u0100\u0106\304\305\u0118\u0112\u010C\311\u0179\u0116\u0122\u0136\u012A\u013B\u0160\u0143\u0145\323\u014C\325\326\327\u0172\u0141\u015A\u016A\334\u017B\u017D\337\u0105\u012F\u0101\u0107\344\345\u0119\u0113\u010D\351\u017A\u0117\u0123\u0137\u012B\u013C\u0161\u0144\u0146\363\u014D\365\366\367\u0173\u0142\u015B\u016B\374\u017C\u017E\u02D9" .toCharArray(); protected char[] iso8859_2map = "\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\u0104\u02D8\u0141\244\u013D\u015A\247\250\u0160\u015E\u0164\u0179\255\u017D\u017B\260\u0105\u02DB\u0142\264\u013E\u015B\u02C7\270\u0161\u015F\u0165\u017A\u02DD\u017E\u017C\u0154\301\302\u0102\304\u0139\u0106\307\u010C\311\u0118\313\u011A\315\316\u010E\u0110\u0143\u0147\323\324\u0150\326\327\u0158\u016E\332\u0170\334\335\u0162\337\u0155\341\342\u0103\344\u013A\u0107\347\u010D\351\u0119\353\u011B\355\356\u010F\u0111\u0144\u0148\363\364\u0151\366\367\u0159\u016F\372\u0171\374\375\u0163\u02D9" .toCharArray(); public final int AUTO = -1; public String error = "0"; public CellGps() { } // преобразовывает адрес в широту и долготу public String[] geocodeG(String string_1) { if (table.containsKey(string_1)) { return (String[]) table.get(string_1); } String[] strings_1 = new String[2]; String string_3 = ""; try { String string_2 = ""; string_2 = Utils.encodeSequence(string_1); string_2 = "http://maps.googleapis.com/maps/api/geocode/xml?address=" .concat(String.valueOf(string_2)).concat( "&sensor=false&language=ru"); string_3 = get(string_2); string_3 = string_3.replace((char) 39, (char) 32); string_3 = Utils.replace(string_3, " ", ""); string_3 = Utils.replace(string_3, "\n", ""); if (string_3.indexOf("") != -1) { string_3 = string_3 .substring(string_3.indexOf("") + "".length(), string_3.length()); } else { throw new Exception("String is not valid: " + string_3); } if (string_3.indexOf("") != -1) { string_3 = string_3.substring(0, string_3.indexOf("")); } else { throw new Exception("String is not valid: " + string_3); } strings_1 = Utils.splitString(string_3, ""); // //System.out.println(string_3); // } // httpconnection_1.close(); if (reallyNull(strings_1[0]) || reallyNull(strings_1[1])) { return new String[]{"0.0", "0.0"}; } } catch (Exception e) { return new String[]{e.toString(), string_3}; // main.m.addError("Google geocode " + "Error: '" + // exception_1.toString() + "\n" + exception_1.getMessage() + "'"); } table.put(string_1, strings_1); return strings_1; } // конвертим из уникода в удобочитаемое (\u0123 > A) private String uni2string(String res) { int index = res.indexOf("\\u"); while (index != -1) { try { int l = Integer.parseInt( new String(res.substring(index + 2, index + 6)), 16); res = Utils.replace(res, res.substring(index, index + 6), new String(new char[]{(char) l})); index = res.indexOf("\\u"); } catch (Exception ex) { System.out.println(getClass().getName() + ":" + ex.toString()); index = -1; } } return res; } // декодировщик текста private String byteArrayToString(byte[] bytes, String charSet) { String output; char[] map = null; if (charSet.toUpperCase().equals("WINDOWS-1251") || charSet.toUpperCase().equals("WINDOWS1251") || charSet.toUpperCase().equals("WIN1251") || charSet.toUpperCase().equals("CP1251")) { map = cp1251map; } else if (charSet.toUpperCase().equals("KOI8-R")) { map = koi8rmap; } else if (charSet.toUpperCase().equals("WINDOWS-1257")) { map = cp1257map; } else if (charSet.toUpperCase().equals("ISO-8859-2")) { map = iso8859_2map; } else if (charSet.toUpperCase().equals("UTF-8")) { try { return uni2string(decodeUTF8(bytes, false)); } catch (UTFDataFormatException udfe) { } map = cp1251map; } else if (charSet.toUpperCase().equals("UNICODE")) { return uni2string(new String(bytes)); } if (map != null) { char[] chars = new char[bytes.length]; for (int i = 0; i < bytes.length; i++) { byte b = bytes[i]; chars[i] = (b >= 0) ? (char) b : map[b + 128]; } output = new String(chars); } else { try { output = new String(bytes, charSet); } catch (Exception e) { output = new String(bytes); } } return uni2string(output); } private String decodeUTF8(byte[] data, boolean gracious) throws UTFDataFormatException { byte a, b, c; StringBuffer ret = new StringBuffer(); for (int i = 0; i < data.length; i++) { try { a = data[i]; if ((a & 0x80) == 0) { ret.append((char) a); } else if ((a & 0xe0) == 0xc0) { b = data[i + 1]; if ((b & 0xc0) == 0x80) { ret.append((char) (((a & 0x1F) << 6) | (b & 0x3F))); i++; } else { throw new UTFDataFormatException("Illegal 2-byte group"); } } else if ((a & 0xf0) == 0xe0) { b = data[i + 1]; c = data[i + 2]; if (((b & 0xc0) == 0x80) && ((c & 0xc0) == 0x80)) { ret.append((char) (((a & 0x0F) << 12) | ((b & 0x3F) << 6) | (c & 0x3F))); i += 2; } else { throw new UTFDataFormatException("Illegal 3-byte group"); } } else if (((a & 0xf0) == 0xf0) || ((a & 0xc0) == 0x80)) { throw new UTFDataFormatException( "Illegal first byte of a group"); } } catch (UTFDataFormatException udfe) { if (gracious) { ret.append("?"); } else { throw udfe; } } catch (ArrayIndexOutOfBoundsException aioobe) { if (gracious) { ret.append("?"); } else { throw new UTFDataFormatException("Unexpected EOF"); } } } data = null; return ret.toString(); } public double[] getCurrentLocation() throws Exception { String mcc, mnc, lac, cid; lac = LAC(); // mcc = MCC(); // mnc = MNC(); // // cid = CellId(); // mode = "MODE: CellID"; // data = "mcc " + mcc + "; mnc " + mnc + "; lac " + lac + "; cellid " // + cid; System.out.println(lac); if (!reallyNull(lac)) { mcc = MCC(); mnc = MNC(); lac = LAC(); cid = CellId(); mode = "MODE: CellID"; data = "mcc " + mcc + "; mnc " + mnc + "; lac " + lac + "; cellid " + cid; System.out.println(data); return LatLon(Integer.parseInt(mcc), Integer.parseInt(mnc), Integer.parseInt(lac), Integer.parseInt(cid)); } else if (emulate) { lac = "49500"; cid = "8521"; mnc = "3"; mcc = "255"; mode = "MODE: CellID"; data = "mcc " + mcc + "; mnc " + mnc + "; lac " + lac + "; cellid " + cid; System.out.println(data); return LatLon(Integer.parseInt(mcc), Integer.parseInt(mnc), Integer.parseInt(lac), Integer.parseInt(cid)); } mode = "MODE: IP"; double[] dat = ip(); data = "IP " + host; return dat; } public double[] coord = null; // текущий адрес где находимся public String getCurrentAddres() throws Exception { coord = getCurrentLocation(); return reverseGeocoding(coord[0] + "", coord[1] + ""); } // выходит ли за радиус public boolean outOfRadius(double lat, double lon, int radius) throws Exception { Coordinates center = new Coordinates(lat, lon); double[] coord = getCurrentLocation(); Coordinates device = new Coordinates(coord[0], coord[1]); if (Coordinates.distance(center, device) <= (double) radius) { return false; } return true; } // расстояние до точки от текущего местоположения public int distanceToCenter(double lat, double lon) throws Exception { Coordinates center = new Coordinates(lat, lon); double[] coord = getCurrentLocation(); Coordinates device = new Coordinates(coord[0], coord[1]); return (int) Coordinates.distance(center, device); } public String host = ""; public double[] ip() throws Exception { String ip = ""; if (table.containsKey("ip")) { return (double[]) table.get("ip"); } double[] latlon = new double[3]; String lang = "ru"; lang = Locale.getDefault().getLanguage(); lang = lang.replace('_', '-'); if (lang.indexOf('-') == -1) { lang = lang; } else { lang = lang.substring(0, lang.indexOf('-')); } lang = lang.toLowerCase(); ip = get("http://ru.smart-ip.net/geoip-xml/google.com/auto?lang=" + lang); host = ip.substring(ip.indexOf("") + "".length(), ip.indexOf("")); ip = ip.substring(ip.indexOf("") + "".length(), ip.indexOf("")); latlon[0] = Double.parseDouble(ip.substring(0, ip.indexOf(""))); latlon[1] = Double.parseDouble(ip.substring(ip.indexOf("") + "".length(), ip.length())); latlon[2] = -1; table.put("ip", latlon); return latlon; } private boolean numeric(String s) { try { int a = Integer.parseInt(s); return true; } catch (Exception Exception_1) { } return false; } // кодирует координаты в адресс public String reverseGeocoding(String lat, String lon) { if (table.containsKey("adress/" + lat + "/" + lon)) { return (String) table.get("adress/" + lat + "/" + lon); } String string_5 = ""; try { String string_4; String lang = "ru"; lang = Locale.getDefault().getLanguage(); lang = lang.replace('_', '-'); if (lang.indexOf('-') == -1) { lang = lang; } else { lang = lang.substring(0, lang.indexOf('-')); } lang = lang.toLowerCase(); string_4 = "http://maps.googleapis.com/maps/api/geocode/json?address=" + String.valueOf(lat.trim()) + "," + String.valueOf(lon.trim()) + "&sensor=false&language=" + lang; string_5 = get(string_4); if (string_5.indexOf("formatted_address") != -1) { string_5 = string_5.substring( string_5.indexOf("formatted_address") + "formatted_address".length(), string_5.length()); } if (string_5.indexOf("\",") != -1) { string_5 = string_5.substring(0, string_5.indexOf("\",")); } string_5 = string_5.replace((char) 34, (char) 32) .replace((char) 58, (char) 32).trim(); String[] strings_1 = Utils.splitString(string_5, ","); try { int c = 1; if (strings_1[strings_1.length - 1].trim().length() == 0 || numeric(strings_1[strings_1.length - 1].trim())) { c = 2; } else { c = 1; } string_5 = strings_1[strings_1.length - c].trim(); for (int i = strings_1.length - c - 1; i >= 0; i--) { string_5 = String.valueOf(string_5).concat(",") .concat(String.valueOf(strings_1[i].trim())); } } catch (Exception e) { } } catch (Exception e) { } table.put("adress/" + lat + "/" + lon, string_5); return string_5; } class MyThread1 extends Thread { public void run() { table.put("ya/" + mcc2 + "/" + mnc2 + "/" + lac2 + "/" + cid2, YandexLatLon(mcc2, mnc2, lac2, cid2)); } } class MyThread2 extends Thread { public void run() { table.put("google/" + mcc2 + "/" + mnc2 + "/" + lac2 + "/" + cid2, GoogleLatLon(mcc2, mnc2, lac2, cid2)); } } private void starter(Thread t) { t.start(); } public double[] LatLon(int mcc, int mnc, int lac, int cid) throws Exception { elev = 0; acc = 0; mcc2 = mcc; mnc2 = mnc; lac2 = lac; cid2 = cid; Thread ya, google;// , open;//, location; starter(ya = new MyThread1()); starter(google = new MyThread2()); // starter(open = new MyThread3()); // starter(location = new MyThread4()); boolean flag = true; while (flag) { if (ya.isAlive() != true && google.isAlive() != true/* * && * open.isAlive * () != true/* * && * location.isAlive * () != true */) { flag = false; } } double[] doubles_1, doubles_2/* , doubles_3/*, doubles_4, */, doubles_5; doubles_1 = doubles_2/* = doubles_3 /*= doubles_4 */ = doubles_5 = new double[]{ 0, 0}; doubles_1 = (double[]) table.get("ya/" + mcc + "/" + mnc + "/" + lac + "/" + cid); doubles_2 = (double[]) table.get("google/" + mcc + "/" + mnc + "/" + lac + "/" + cid); // doubles_3 = (double[]) table.get("open/" + mcc + "/" + mnc + "/" + // lac + "/" + cid); // doubles_4 = (double[]) table.get("loc/" + mcc + "/" + mnc + "/" + lac // + "/" + cid); // if (table.containsKey("other/" + mcc + "/" + mnc + "/" + lac + "/" + // cid)) { doubles_5 = (double[]) table.get("other/" + mcc + "/" + mnc + "/" + lac + "/" + cid); // } if (doubles_5[0] != 0) { acc = (int) doubles_5[0]; } if (doubles_5[1] != 0) { elev = (int) doubles_5[1]; } double countlat = 0; double countlon = 0; double lt = 0; double ln = 0; if (doubles_1[0] != 0) { lt = lt + doubles_1[0]; countlat++; } if (doubles_2[0] != 0) { lt = lt + doubles_2[0]; countlat++; } lt = lt / countlat; if (doubles_1[1] != 0) { ln = ln + doubles_1[1]; countlon++; } if (doubles_2[1] != 0) { ln = ln + doubles_2[1]; countlon++; } ln = ln / countlon; String lat = "" + lt; String lon = "" + ln; lat = lat.substring(0, lat.indexOf('.') + 6); lon = lon.substring(0, lon.indexOf('.') + 6); System.out.println(getClass().getName() + ":" + "mcc " + mcc + " mnc " + mnc + " lac " + cid + " lat " + lat + " lon " + lon + " accuracy " + acc + " elevation " + elev); return new double[]{Double.parseDouble(lat), Double.parseDouble(lon), (double) acc}; } public byte[] get(String url, String u) { return Translator.get(url, u); } public String get(String string_4) { return byteArrayToString(get(string_4, "ru"), "UTF-8"); } // получаем координаты с Google DB // double[0] - Lat; double[1] - Lon private double[] GoogleLatLon(int MCC, int MNC, int LAC, int CID) { if (table.containsKey("google/" + MCC + "/" + MNC + "/" + LAC + "/" + CID)) { return (double[]) table.get("google/" + MCC + "/" + MNC + "/" + LAC + "/" + CID); } double[] latlon = new double[2]; try { byte[] data = new byte[55]; data[0x01] = 14; // fixed // data[0x01] = (byte) 0x0E; // fixed data[0x10] = 27; // fixed // data[0x10] = (byte) 0x1B; // fixed for (int i = 0x2F; i <= 0x32; i++) { data[i] = Byte.MAX_VALUE; // fixed } if (CID > 65536) { data[0x1c] = 5; // UTMS - 6 hex digits } else { data[0x1c] = 3; // GSM - 4 hex digits } int stOfs = 0x1f; data[stOfs++] = (byte) ((CID >> 24) & 0xFF); // 0x1f data[stOfs++] = (byte) ((CID >> 16) & 0xFF); data[stOfs++] = (byte) ((CID >> 8) & 0xFF); data[stOfs++] = (byte) ((CID) & 0xFF); data[stOfs++] = (byte) ((LAC >> 24) & 0xFF); // 0x23 data[stOfs++] = (byte) ((LAC >> 16) & 0xFF); data[stOfs++] = (byte) ((LAC >> 8) & 0xFF); data[stOfs++] = (byte) ((LAC) & 0xFF); data[stOfs++] = (byte) ((MNC >> 24) & 0xFF); // 0x27 data[stOfs++] = (byte) ((MNC >> 16) & 0xFF); data[stOfs++] = (byte) ((MNC >> 8) & 0xFF); data[stOfs++] = (byte) ((MNC) & 0xFF); data[stOfs++] = (byte) ((MCC >> 24) & 0xFF); // 0x2b data[stOfs++] = (byte) ((MCC >> 16) & 0xFF); data[stOfs++] = (byte) ((MCC >> 8) & 0xFF); data[stOfs++] = (byte) ((MCC) & 0xFF); String url = "http://www.google.com/glm/mmap"; HttpURLConnection net; java.net.URL urls = new java.net.URL(url); net = (java.net.HttpURLConnection) urls.openConnection(); net.setAllowUserInteraction(false); net.setInstanceFollowRedirects(true); net.setDoInput(true); net.setDoOutput(true); net.setRequestMethod("POST"); net.setRequestProperty("Content-Type", "application/binary"); net.setRequestProperty("Content-Length", Integer.toString(data.length)); // net.setDoOutput(true); OutputStream os = net.getOutputStream(); os.write(data); os.close(); DataInputStream in = new DataInputStream(net.getInputStream()); in.readShort(); in.readByte(); if (in.readInt() == 0) { double latitude = (double) in.readInt() / 1000000; double longitude = (double) in.readInt() / 1000000; int accurasy = in.readInt(); elev = in.readInt(); if (acc != 0) { acc = (acc + accurasy) / 2; table.put("other/" + MCC + "/" + MNC + "/" + LAC + "/" + CID, new double[]{(double) acc, (double) elev}); System.out.println(getClass().getName() + ":" + "google " + latitude + " " + longitude + " " + acc + " " + elev + "\n"); } else { acc = accurasy; System.out.println(getClass().getName() + ":" + "google " + latitude + " " + longitude + " " + acc + " " + elev + "\n"); table.put("other/" + MCC + "/" + MNC + "/" + LAC + "/" + CID, new double[]{(double) acc, (double) elev}); } in.close(); net.disconnect(); return new double[]{latitude, longitude}; } in.close(); net.disconnect(); return latlon; } catch (Exception e) { e.printStackTrace(); System.out.println(getClass().getName() + ":" + "cellgps.google: " + e.toString() + "\n"); // throw new Exception("cellgps.google: " + e.toString() + "\n"); } // return new double[] { 0, 0 }; return latlon; } // получаем координаты с Yandex DB // double[0] - Lat; double[1] - Lon private double[] YandexLatLon(int MCC, int MNC, int LAC, int CID) { if (table.containsKey("ya/" + MCC + "/" + MNC + "/" + LAC + "/" + CID)) { return (double[]) table.get("ya/" + MCC + "/" + MNC + "/" + LAC + "/" + CID); } double[] latlon = new double[2]; try { String url2 = "http://mobile.maps.yandex.net/cellid_location/" + "?countrycode=" + Integer.toString(MCC) + "&operatorid=" + Integer.toString(MNC) + "&lac=" + Integer.toString(LAC) + "&cellid=" + Integer.toString(CID); String s = get(url2); s = Utils.replace(s, "\"", ""); System.out.println(getClass().getName() + ":yandex " + s); String[] s1 = Utils.splitString(s, " "); String sLat = "0.0", sLon = "0.0"; for (int i = 0; i < s1.length; i++) { if (s1[i].startsWith("latitude=")) { sLat = Utils.splitString(s1[i], "=")[1].trim(); } if (s1[i].startsWith("longitude=")) { sLon = Utils.splitString(s1[i], "=")[1].trim(); } } latlon[0] = Double.parseDouble(sLat); latlon[1] = Double.parseDouble(sLon); return latlon; } catch (Exception te) { System.out.println(getClass().getName() + ":" + "cellgps.yandex: " + te.toString() + "\n"); } return latlon; } public boolean reallyNull(String string_3) { try { if (string_3 == null) { return true; } } catch (Exception e) { } try { if (string_3.equals("null")) { return true; } } catch (Exception e) { } try { if (string_3.equals("0")) { return true; } } catch (Exception e) { } try { if (string_3.equals("0.0")) { return true; } } catch (Exception e) { } try { if (string_3.trim().length() == 0) { return true; } } catch (Exception e) { } return false; } private String convert(String s) { if (reallyNull(s)) { return s; } if (s.indexOf("a") != -1 || s.indexOf("b") != -1 || s.indexOf("c") != -1 || s.indexOf("d") != -1 || s.indexOf("e") != -1 || s.indexOf("f") != -1) { try { s = Integer.toString(Integer.parseInt(s, 16)); } catch (Exception Exception_1) { } } return ("" + Integer.parseInt(s)); } public String norm(String tmp) { if (tmp.length() < 2) { tmp = "0" + tmp; } return tmp; } public String CellId() { String string_1 = ""; try { if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.3g.net.roaming.cellid"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.lge.net.cellid"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("device.cellid"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("Cell-ID"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("CellID"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("Siemens.CID"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("phone.cid"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.cellid"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { try { // string_1 = Integer.toString(Integer.parseInt(System.getProperty("com.sonyericsson.net.cellid"), 16)); string_1 = System.getProperty("com.sonyericsson.net.cellid"); } catch (Exception Exception_1) { } } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { try { string_1 = Integer.toString(Integer.parseInt(System.getProperty("com.sonyericsson.net.cid"), 16)); } catch (Exception Exception_2) { } } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("phone.cid"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.samsung.cellid"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("MPJC_CID"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("cid"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("CELLID"); } else { return "" + convert(string_1); } /* // blackbary RIM if (string_1 == null || string_1.equals("null") || string_1.equals("")) { try { string_1 = net.rim.device.api.system.GPRSInfo.getCellInfo().getCellId(); } catch (Exception e) { } } else { return "" + convert(string_1); } */ //android if (string_1 == null || string_1.equals("null") || string_1.equals("")) { try { Class.forName("android.telephony.TelephonyManager"); android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) (context).getSystemService(android.content.Context.TELEPHONY_SERVICE); if (tm != null) { android.telephony.gsm.GsmCellLocation location = (android.telephony.gsm.GsmCellLocation) tm.getCellLocation(); string_1 = "" + location.getCid(); } } catch (Exception e) { } } else { return "" + convert(string_1); } } catch (Exception Exception_3) { string_1 = Exception_3.toString(); } return string_1 == null ? "" : "" + convert(string_1); } public String LAC() { String string_1 = ""; try { string_1 = System.getProperty("phone.lac"); if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.3g.net.roaming.lac"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.lge.net.lac"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("device.lac"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("Siemens.LAC"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.lac"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("phone.lai"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.LAC"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { try { // string_1 = Integer.toString(Integer.parseInt(System.getProperty("com.sonyericsson.net.lac"), 16)); string_1 = System.getProperty("com.sonyericsson.net.lac"); } catch (Exception Exception_1) { } } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("LocAreaCode"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.samsung.lac"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("MPJC_LAC"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("lac"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("LAC"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.lge.net.rat"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.areacode"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.locareacode"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.LocAreaCode"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.lai"); } else { return "" + convert(string_1); } /* //blackbary RIM if (string_1 == null || string_1.equals("null") || string_1.equals("")) { try { string_1 = net.rim.device.api.system.GPRSInfo.getCellInfo().getLAC(); } catch (Exception e) { } } else { return "" + convert(string_1); } */ //android if (string_1 == null || string_1.equals("null") || string_1.equals("")) { try { Class.forName("android.telephony.TelephonyManager"); android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) (context).getSystemService(android.content.Context.TELEPHONY_SERVICE); if (tm != null) { android.telephony.gsm.GsmCellLocation location = (android.telephony.gsm.GsmCellLocation) tm.getCellLocation(); string_1 = "" + location.getLac(); } } catch (Exception e) { } } else { return "" + convert(string_1); } } catch (Exception Exception_2) { string_1 = Exception_2.toString(); } return string_1 == null ? "" : "" + convert(string_1); } private String getIMSI() { String string_1 = ""; try { string_1 = System.getProperty("IMSI"); if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("phone.imsi"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.lge.imsi"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.3g.net.phone.imsi"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.mobinfo.IMSI"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.imsi"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.Mobinfo.IMSI"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.sonyericsson.imsi"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("IMSI"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("imsi"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.siemens.imsi"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.samsung.imsi"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.imsi"); } else { return "" + convert(string_1); } /* if (string_1 == null || string_1.equals("null") || string_1.equals("")) { try { string_1 = net.rim.device.api.system.GPRSInfo.getCellInfo().getBSIC(); } catch (Exception e) { } } else { return "" + convert(string_1); } */ } catch (Exception Exception_1) { string_1 = Exception_1.toString(); } return string_1 == null ? "" : "" + convert(string_1); } private Context context = null; public void setContext(Context context123) { context = context123; } public String MCC() { String string_1 = ""; try { if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.3g.net.roaming.mcc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.lge.net.mcc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("device.mcc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("MCC"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("Siemens.MCC"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("phone.mcc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.countrycode"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.mcc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.sonyericsson.net.mcc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.sonyericsson.net.cmcc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.samsung.mcc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.siemens.mcc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("mcc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = getIMSI().equals("") ? "" : getIMSI().substring(0, 3); } else { return "" + convert(string_1); } //blackbary RIM if (string_1 == null || string_1.equals("null") || string_1.equals("")) { try { // string_1 = net.rim.device.api.system.GPRSInfo.getCellInfo().getMCC(); } catch (Exception e) { } } else { return "" + convert(string_1); } //android if (string_1 == null || string_1.equals("null") || string_1.equals("")) { try { Class.forName("android.telephony.TelephonyManager"); android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) (context).getSystemService(android.content.Context.TELEPHONY_SERVICE); String mccAndMnc = tm.getNetworkOperator(); if (mccAndMnc != null && mccAndMnc.length() > 3) { string_1 = mccAndMnc.substring(0, 3); } } catch (Exception e) { } } else { return "" + convert(string_1); } } catch (Exception Exception_1) { string_1 = Exception_1.toString(); } return string_1 == null ? "" : "" + convert(string_1); } public String MNC() { String string_1 = ""; try { if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.3g.net.roaming.mnc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.lge.net.mnc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("device.mnc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("MNC"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("Siemens.MNC"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("phone.mnc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.networkID"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("NETWORK"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("device.network"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.networkid"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.mnc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.nokia.mid.MNC"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.sonyericsson.net.mnc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.sonyericsson.net.cmnc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.samsung.mnc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("com.siemens.mnc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = System.getProperty("mnc"); } else { return "" + convert(string_1); } if (string_1 == null || string_1.equals("null") || string_1.equals("")) { string_1 = getIMSI().equals("") ? "" : getIMSI().substring(3, 5); } else { return "" + convert(string_1); } //blackbary RIM if (string_1 == null || string_1.equals("null") || string_1.equals("")) { try { // string_1 = net.rim.device.api.system.GPRSInfo.getCellInfo().getMNC(); } catch (Exception e) { } } else { return "" + convert(string_1); } //android if (string_1 == null || string_1.equals("null") || string_1.equals("")) { try { Class.forName("android.telephony.TelephonyManager"); android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) (context).getSystemService(android.content.Context.TELEPHONY_SERVICE); String mccAndMnc = tm.getNetworkOperator(); if (mccAndMnc != null && mccAndMnc.length() > 3) { string_1 = mccAndMnc.substring(3, 5); } } catch (Exception e) { } } else { return "" + convert(string_1); } } catch (Exception Exception_1) { string_1 = Exception_1.toString(); } return string_1 == null ? "" : "" + convert(string_1); } }