MobileUtils.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:TowerCollector 作者:
private static boolean isApi1CellInfoAvailable(Context context) {
    TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    CellLocation cell;
    try {
        cell = telephonyManager.getCellLocation();
    } catch (SecurityException ex) {
        Log.d("isApi1CellInfoAvailable(): Result = coarse location permission is denied", ex);
        return false;
    }
    if (cell == null) {
        Log.d("isApi1CellInfoAvailable(): Result = no cell location");
        return false;
    }
    int mcc = Measurement.UNKNOWN_CID;
    int mnc = Measurement.UNKNOWN_CID;
    if (cell instanceof GsmCellLocation) {
        String operatorCode = telephonyManager.getNetworkOperator();
        int[] mccMncPair = getMccMncPair(operatorCode);
        if (mccMncPair == null) {
            Log.d("isApi1CellInfoAvailable(): Result = no operator code");
            return false;
        }
        mcc = mccMncPair[0];
        mnc = mccMncPair[1];
    }
    CellLocationValidator validator = new CellLocationValidator();
    boolean result = validator.isValid(cell, mcc, mnc);
    Log.d("isApi1CellInfoAvailable(): Result = %s", result);
    return result;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号