1. 在如下目录增加 GeoCodingQueryEN.java
PATH: [4.2 JB] alps\mediatek\frameworks-ext\base\telephony\java\com\android\internal\telephony\
[4.4 KK] alps\mediatek\frameworks\base\geododing\java\com\mediatek\Geocoding\
主要负责打开 geocoding_en.db 后 query 号码归属地。
GeoCodingQueryEN.java 参考 GeoCodingQuery.java 而来。
2. 添加一个归属地数据库 geocoding_en.db
PATH: alps\mediatek\external\GeoCoding\
手机号码英文版归属地geocoding_en.db 参考中文版而来。
在同目录下的Android.mk中增加数据库,如下:
LOCAL_PATH:= mediatek/external/GeoCoding PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/geocoding.db:system/etc/geocoding.db \
$(LOCAL_PATH)/geocoding.db:system/etc/geocoding_en.db
3. 在CallerInfo.java 和 DefaultCallLogInsertionHelper.java 中调用 GeoCodingQueryEN 的 queryByNumberforEn() 方法查归属地
import com.android.internal.telephony.GeoCodingQueryEN; // For EN version
... ...
GeoCodingQueryEN gcQuery = GeoCodingQueryEN.getInstance(mContext);
String geoInfo = gcQuery.queryByNumberforEn(number);
if (!TextUtils.isEmpty(geoInfo)) {
return geoInfo;
}
... ...
NOTE:
protected void onQueryComplete(int token, Object cookie, Cursor cursor) {
Rlog.d(LOG_TAG, "##### onQueryComplete() ##### query complete for token: " + token);
.......
if (ENABLE_UNKNOWN_NUMBER_GEO_DESCRIPTION) {
if (TextUtils.isEmpty(mCallerInfo.name) ||
(SystemProperties.get("ro.mtk_phone_number_geo").equals("1"))) {
mCallerInfo.updateGeoDescription(mContext, cw.number);
}
}
......
}
/frameworks/base/telephony/java/com/android/internal/telephony/CallerInfo.java
public void updateGeoDescription(Context context, String fallbackNumber) {
String number = TextUtils.isEmpty(phoneNumber) ? fallbackNumber : phoneNumber;
geoDescription = getGeoDescription(context, number);
}
//在下面的函数中对传人的number的这个号码做相应的客制化。
private static String getGeoDescription(Context context, String number) {
if (VDBG) Rlog.v(TAG, "getGeoDescription('" + number + "')...");
if (TextUtils.isEmpty(number)) {
return null;
}
/// M: CC: Query city name via GeoCodingQuery @{
// [ALPS00286530]Query Geocoding description
if (SystemProperties.get("ro.mtk_phone_number_geo").equals("1")) {
GeoCodingQuery geoCodingQuery = GeoCodingQuery.getInstance(context);
String cityName = geoCodingQuery.queryByNumber(number);
Rlog.v(TAG, "[GeoCodingQuery] cityName = " + cityName);
if ((cityName != null) && (!cityName.equals(""))) {
return cityName;
}
}
/// @}
PhoneNumberUtil util = PhoneNumberUtil.getInstance();
PhoneNumberOfflineGeocoder geocoder = PhoneNumberOfflineGeocoder.getInstance();
Locale locale = context.getResources().getConfiguration().locale;
String countryIso = getCurrentCountryIso(context, locale);
PhoneNumber pn = null;
try {
if (VDBG) Rlog.v(TAG, "parsing '" + number
+ "' for countryIso '" + countryIso + "'...");
pn = util.parse(number, countryIso);
if (VDBG) Rlog.v(TAG, "- parsed number: " + pn);
} catch (NumberParseException e) {
Rlog.d(TAG, "getGeoDescription: NumberParseException for incoming number '"
+ number + "'");
}
if (pn != null) {
String description = geocoder.getDescriptionForNumber(pn, locale);
if (VDBG) Rlog.v(TAG, "- got description: '" + description + "'");
return description;
} else {
return null;
}
}