无法在诺基亚S60上检索CELL-id和LAC(在E50中尝试过)

时间:2011-06-23 10:28:33

标签: java-me nokia s60 cellid

我一直试图获得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;
}

}

我已经从here获取代码(我希望它现在可以在nokia e50上运行,因此使用了com.nokia.mid.cellid(事实上我已尝试过此链接中提到的所有其他选项) ))Cellid和lac都返回null,同时正确返回mcc和mnc。

3 个答案:

答案 0 :(得分:1)

我确认无法从E50收到小区ID。但我已经编写了多种平台解决方案,我将在各种设备(我们的生产环境中使用> 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());
    }
}

答案 1 :(得分:0)

您在网站上提及的内容是否已阅读此行

  

但是获得Cellid仍然受到手机平台,签名证书和运营商的限制:

     

诺基亚   s40第3版Fp1版,要求运营商或制造商签字   S60第3版,FP2(2008年发布,更新版,不适用于N95),不需要唱歌。

答案 2 :(得分:0)

我刚刚在工作中得到了一个诺基亚设备S60惠普Symbian第5版,我正在尝试根据手机ID获取手机位置,而不是gps。所以,为此,我使用http://www.opencellid.org/,这个页面检索我的位置,但它不完全像gps'。但是,为了做到这一点,我需要mnc,mcc,cellid和lac,令我惊讶的是,这个设备并没有给我lac,mnc和mcc,这样的lalchetian说。我们这里有一个严重的问题。可能这些属性仅在某些设备中可用。