невозможно получить CELL-идентификатор и LAC на Nokia S60 (пробовал в E50) - PullRequest
0 голосов
/ 23 июня 2011

Я пытался получить celllid, lac, mcc и mnc. Хотя mcc и mnc могут быть найдены, cell-id и lac по-прежнему имеют значение null. Вот код (и известно, что он работает в зависимости от количества текущих потоков, но я все еще не могу заставить его работать)

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;


public class LocInfo extends MIDlet {
private Form form;
private Display display;
public void startApp() {
form = new Form("Location...");
String cellid = getCellId();
String getLAC = getLAC();
String getMCC = getMCC();
 String getMNC = getMNC();
form.append(cellid);
form.append("<-this is cell-id");
form.append(getLAC);
 form.append("<-this is LAC");
form.append(getMCC);
form.append("<-this is MCC");
form.append(getMNC);
form.append("<-this is MNC");
display = Display.getDisplay(this);
display.setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}

public static String getCellId(){
String out = "";
try{
out = System.getProperty("com.nokia.mid.cellid");
}catch(Exception e){
System.out.println(e);
out=e.toString();
return out;
}
return out==null?"":out;
}
public static String getLAC(){
String out = "";
try{
out = System.getProperty("com.nokia.mid.lac");
}catch(Exception e){
out=e.toString();
return out;
}
return out==null?"":out;
}


public static String getIMSI(){
String out = "";
try{
out = System.getProperty("IMSI");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("phone.imsi") ;
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.nokia.mid.mobinfo.IMSI");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.nokia.mid.imsi");
if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.sonyericsson.imsi");

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("IMSI");

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.samsung.imei");

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.siemens.imei");

if(out== null ||out.equals("null")|| out.equals(""))
//#= out = GPRSInfo.getCellInfo().getBSIC();

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("imsi");

}catch(Exception e){
return out==null?"":out;
}

return out==null?"":out;
}


public static String getMCC(){
String out = "";
try{

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("phone.mcc") ;

 if(out== null ||out.equals("null")|| out.equals(""))
 out = System.getProperty("com.nokia.mid.mobinfo.IMSI");

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.sonyericsson.net.mcc");

if(out== null ||out.equals("null")|| out.equals("")){
out = getIMSI().equals("")?"": getIMSI().substring(0,3);
}

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.samsung.imei");

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.siemens.imei");

if(out== null ||out.equals("null")|| out.equals(""))//getMNC()
//#= out = GPRSInfo.getCellInfo().getMCC();

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("mcc");


}catch(Exception e){
return out==null?"":out;
}

return out==null?"":out;
}


public static String getMNC(){
String out = "";
try{

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("phone.mnc") ;

if(out== null ||out.equals("null")|| out.equals(""))
out = getIMSI().equals("")?"": getIMSI().substring(3,5);

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.sonyericsson.net.mnc");

if(out== null ||out.equals("null")|| out.equals("")){
out = getIMSI().equals("")?"": getIMSI().substring(3,5);
}

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("com.samsung.imei");



if(out== null ||out.equals("null")|| out.equals(""))//getMNC()
//#= out = GPRSInfo.getCellInfo().getMNC();

if(out== null ||out.equals("null")|| out.equals(""))
out = System.getProperty("mnc");


}catch(Exception e){
return out==null?"":out;
}

return out==null?"":out;
}

}

Я взял код с здесь (я хочу, чтобы он работал на nokia e50 на данный момент и, следовательно, использовал com.nokia.mid.cellid (на самом деле я пробовал все другие опции, упомянутые по этой ссылке) а)) Cellid и lac оба возвращают ноль, в то время как mcc и mnc возвращаются правильно.

Ответы [ 3 ]

1 голос
/ 24 июля 2011

Я подтверждаю, что идентификатор ячейки не может быть получен от E50. Но я написал мультиплатформенное решение и собираюсь проверить это на широком спектре устройств (> 1000 устройств в нашей производственной среде). Я получил прототип по той же ссылке, но, честно говоря, тот, кто его написал, не суетится в деталях.

Я очень сомневаюсь, что мой код будет работать как минимум на половине устройств, но мы все равно скоро его увидим.

    package Device;

import dct.CellData;

public class DeviceInfo {

    static private DeviceInfo instance;

    private int platformID;

    static public DeviceInfo instance(int platformID) {
        if (instance == null || instance.platformID != platformID)
            instance = new DeviceInfo(platformID);
        return instance;
    }

    private DeviceInfo(int platformID) {
        this.platformID = platformID;
    }

    private String readProperty(String propertyName) {
        String val = System.getProperty(propertyName);
        return (val == null || val.length() == 0 || val.equals("null")) ? "" : val;
    }

    /**
     * get the cell id in the phone
     *
     * @return
     */
    public String getCellId() {

        try {
            String out = readProperty("Device-ID");
            if (out.length() > 0) return out;

            out = readProperty("CellID");
            if (out.length() > 0) return out;

            out = readProperty("phone.cid");
            if (out.length() > 0) return out;

            String propertyName = null;
            switch (platformID) {
                case Platforms.PLATFORM_NOKIA:
                    propertyName = "com.nokia.mid.cellid";
                    break;
                case Platforms.PLATFORM_SONY_ERICSSON:
                    propertyName = "com.sonyericsson.net.cellid";
                    break;
                case Platforms.PLATFORM_SAMSUNG:
                    propertyName = "com.samsung.cellid";
                    break;
                case Platforms.PLATFORM_LG:
                    propertyName = "com.lge.net.cellid";
                    break;
                case Platforms.PLATFORM_MOTOROLA:
                    propertyName = "phone.cid";
                    break;
                case Platforms.PLATFORM_SIEMENS:
                    propertyName = "com.siemens.cellid";
                    break;
                case Platforms.PLATFORM_NOT_DEFINED:
                default:
                    propertyName = "cid";
                    break;
            }
            return readProperty(propertyName);
        }
        catch (Exception ex) {
            return "";
        }
    }

    /**
     * get the lac sring from phone
     */
    public String getLAC() {

        try {
            String out = readProperty("phone.lac");
            if (out.length() > 0) return out;

            String propertyName = null;
            switch (platformID) {
                case Platforms.PLATFORM_NOKIA:
                    propertyName = "com.nokia.mid.lac";
                    break;
                case Platforms.PLATFORM_SONY_ERICSSON:
                    propertyName = "com.sonyericsson.net.lac";
                    break;
                case Platforms.PLATFORM_MOTOROLA:
                    propertyName = "LocAreaCode";
                    break;
                case Platforms.PLATFORM_SIEMENS: // didn't try to find
                case Platforms.PLATFORM_SAMSUNG: // can't find
                case Platforms.PLATFORM_LG: // not supported (http://sourceforge.net/tracker/index.php?func=detail&aid=3310226&group_id=192084&atid=939977)
                case Platforms.PLATFORM_NOT_DEFINED:
                default:
                    return "";
            }
            return readProperty(propertyName);
        }
        catch (Exception ex) {
            return "";
        }
    }

    /**
     * Example IMSI (O2 UK): 234103530089555
     * <p/>
     * String mcc = imsi.substring(0,3); // 234 (UK)
     * <p/>
     * String mnc = imsi.substring(3,5); // 10 (O2)
     *
     * @return
     */
    public String getIMSI() {

        try {
            String out = readProperty("IMSI");
            if (out.length() > 0) return out;
            out = readProperty("phone.imsi");
            if (out.length() > 0) return out;

            String propertyName = null;
            switch (platformID) {
                case Platforms.PLATFORM_NOKIA:
                    out = readProperty("com.nokia.mid.mobinfo.IMSI");
                    if (out.length() > 0) return out;
                    propertyName = "com.nokia.mid.imsi";
                    break;
                case Platforms.PLATFORM_SONY_ERICSSON:
                    propertyName = "com.sonyericsson.imsi";
                    break;
                case Platforms.PLATFORM_LG:
                    propertyName = "com.lge.imsi";
                    break;
                case Platforms.PLATFORM_SAMSUNG:
                case Platforms.PLATFORM_MOTOROLA:
                case Platforms.PLATFORM_SIEMENS:
                case Platforms.PLATFORM_NOT_DEFINED:
                default:
                    return "";
            }
            return readProperty(propertyName);
        }
        catch (Exception ex) {
            return "";
        }
    }

    /**
     * For moto, Example IMSI (O2 UK): 234103530089555
     * <p/>
     * String mcc = imsi.substring(0,3); // 234 (UK)
     *
     * @return
     */
    public String getMCC() {


        try {
            String out = readProperty("phone.mcc");
            if (out.length() > 0) return out;

            String propertyName = null;
            switch (platformID) {
                case Platforms.PLATFORM_NOKIA:
                    propertyName = "com.nokia.mid.countrycode";
                    break;
                case Platforms.PLATFORM_SONY_ERICSSON:
                    propertyName = "com.sonyericsson.net.mcc";
                    break;
                case Platforms.PLATFORM_LG:
                    propertyName = "com.lge.cmcc";
                    break;
            }
            if (propertyName != null)
                out = readProperty(propertyName);
            if (out.length() == 0) {
                out = getIMSI();
                if (out.length() > 0)
                    out = out.substring(0, 3);
            }
            return out;
        } catch (Exception e) {
            return "";
        }
    }


    /**
     * For moto, Example IMSI (O2 UK): 234103530089555
     * <p/>
     * String mnc = imsi.substring(3,5); // 10 (O2)
     *
     * @return
     */
    public String getMNC() {

        try {
            String out = readProperty("phone.mnc");
            if (out.length() > 0) return out;

            String propertyName = null;
            switch (platformID) {
                case Platforms.PLATFORM_NOKIA:
                    propertyName = "com.nokia.mid.networkid";
                    break;
                case Platforms.PLATFORM_SONY_ERICSSON:
                    propertyName = "com.sonyericsson.net.mnc";
                    break;
                case Platforms.PLATFORM_LG:
                    propertyName = "com.lge.cmnc";
                    break;
            }
            if (propertyName != null)
                out = readProperty(propertyName);
            if (out.length() == 0) {
                out = getIMSI();
                if (out.length() > 0)
                    out = out.substring(3, 5);
            }
            return out;
        } catch (Exception e) {
            return "";
        }

    }


    /**
     * not used now
     * <p/>
     * get the IMEI (International Mobile Equipment Identity (IMEI)) in the phone
     *
     * @return
     */
    public String getIMEI() {

        try {
            String out = readProperty("com.imei");
            if (out.length() > 0) return out;

            String propertyName = null;
            switch (platformID) {
                case Platforms.PLATFORM_NOKIA:
                    propertyName = "com.nokia.mid.imei";
                    break;
                case Platforms.PLATFORM_SONY_ERICSSON:
                    propertyName = "com.sonyericsson.imei";
                    break;
                case Platforms.PLATFORM_SAMSUNG:
                    propertyName = "com.samsung.imei";
                    break;
                case Platforms.PLATFORM_LG:
                    propertyName = "com.lge.imei";
                    break;
                case Platforms.PLATFORM_MOTOROLA:
                    propertyName = "com.motorola.imei";
                    break;
                case Platforms.PLATFORM_SIEMENS:
                    propertyName = "com.simens.imei";
                    break;
                case Platforms.PLATFORM_NOT_DEFINED:
                default:
                    propertyName = "";
                    break;
            }
            return readProperty(propertyName);
        } catch (Exception e) {
            return "";
        }
    }

    public void fillCellData(CellData data) {
        data.setCellid(getCellId());
        data.setLAC(getLAC());
        data.setMCC(getMCC());
        data.setMNC(getMNC());
    }
}
0 голосов
/ 24 июня 2011

Я только что получил устройство Nokia S60 с версией Symbian 5 здесь на работе, и я пытаюсь определить местоположение сотового телефона на основе идентификатора сотовой связи, а не GPS.Итак, для этого я использую http://www.opencellid.org/,, эта страница возвращает мне позицию, но она не совсем такая, как у gps.Но для этого мне нужны mnc, mcc, cellid и lac, и, к моему удивлению, это устройство не дает мне lac, mnc и mcc, сказал такой лалчетян.У нас здесь серьезная проблема.Возможно, эти свойства доступны только на некоторых устройствах.

0 голосов
/ 23 июня 2011

Что вы упомянули на сайте, когда читали эту строку

Но получить Cellid по-прежнему ограничено платформой мобильного телефона, Sign-сертификатом и оператором:

Nokia s40 3rd Fp1редакция, оператор заявки или производитель подписывает S60 3-е издание, FP2 (выпущено в 2008 и новее, не работает, например, на N95), пение не требуется.

...