如何通过修改build.prop文件来修改Android 首选网络模式默认值
推荐于2018-02-27 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517184
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
修改系统属性:ro.telephony.default_network
修改说明:
可连续给两个值(如4,1),卡1用的是4,卡2用的是1。数字代表的意义见下方的相关代码片段。
相关源码位置:
frameworks/base/telephony/java/com/android/internal/telephony/RILConstants.java
frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
相关代码片段:
/* NETWORK_MODE_* See ril.h RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE */
int NETWORK_MODE_WCDMA_PREF = 0; /* GSM/WCDMA (WCDMA preferred) */
int NETWORK_MODE_GSM_ONLY = 1; /* GSM only */
int NETWORK_MODE_WCDMA_ONLY = 2; /* WCDMA only */
int NETWORK_MODE_GSM_UMTS = 3; /* GSM/WCDMA (auto mode, according to PRL)
AVAILABLE Application Settings menu*/
int NETWORK_MODE_CDMA = 4; /* CDMA and EvDo (auto mode, according to PRL)
AVAILABLE Application Settings menu*/
int NETWORK_MODE_CDMA_NO_EVDO = 5; /* CDMA only */
int NETWORK_MODE_EVDO_NO_CDMA = 6; /* EvDo only */
int NETWORK_MODE_GLOBAL = 7; /* GSM/WCDMA, CDMA, and EvDo (auto mode, according to PRL)
AVAILABLE Application Settings menu*/
int NETWORK_MODE_LTE_CDMA_EVDO = 8; /* LTE, CDMA and EvDo */
int NETWORK_MODE_LTE_GSM_WCDMA = 9; /* LTE, GSM/WCDMA */
int NETWORK_MODE_LTE_CMDA_EVDO_GSM_WCDMA = 10; /* LTE, CDMA, EvDo, GSM/WCDMA */
int NETWORK_MODE_LTE_ONLY = 11; /* LTE Only mode. */
int NETWORK_MODE_LTE_WCDMA = 12; /* LTE/WCDMA */
int NETWORK_MODE_TD_SCDMA_ONLY = 13; /* TD-SCDMA only */
int NETWORK_MODE_TD_SCDMA_WCDMA = 14; /* TD-SCDMA and WCDMA */
int NETWORK_MODE_TD_SCDMA_LTE = 15; /* TD-SCDMA and LTE */
int NETWORK_MODE_TD_SCDMA_GSM = 16; /* TD-SCDMA and GSM */
int NETWORK_MODE_TD_SCDMA_GSM_LTE = 17; /* TD-SCDMA,GSM and LTE */
int NETWORK_MODE_TD_SCDMA_GSM_WCDMA = 18; /* TD-SCDMA, GSM/WCDMA */
int NETWORK_MODE_TD_SCDMA_WCDMA_LTE = 19; /* TD-SCDMA, WCDMA and LTE */
int NETWORK_MODE_TD_SCDMA_GSM_WCDMA_LTE = 20; /* TD-SCDMA, GSM/WCDMA and LTE */
int NETWORK_MODE_TD_SCDMA_CDMA_EVDO_GSM_WCDMA = 21; /*TD-SCDMA,EvDo,CDMA,GSM/WCDMA*/
int NETWORK_MODE_TD_SCDMA_LTE_CDMA_EVDO_GSM_WCDMA = 22; /* TD-SCDMA/LTE/GSM/WCDMA, CDMA, and
EvDo */
复制代码
// Set the preferred network mode
int defaultNetworkType = RILConstants.PREFERRED_NETWORK_MODE;
int numPhones = MSimTelephonyManager.getDefault().getPhoneCount();
String networkMode = SystemProperties.get("ro.telephony.default_network");
if (networkMode != null) {
if (numPhones == MSimConstants.MAX_PHONE_COUNT_SINGLE_SIM) {
loadSetting(
stmt,
Settings.Global.PREFERRED_NETWORK_MODE,
MSimTelephonyManager.getTelephonyProperty(
"ro.telephony.default_network", 0,
Integer.toString(defaultNetworkType)));
} else {
loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, networkMode);
}
} else {
StringBuilder sb = new StringBuilder(defaultNetworkType);
for (int i = 0; i < numPhones - 1; i++) {
sb.append(",");
sb.append(RILConstants.NETWORK_MODE_GSM_ONLY);
}
loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, sb.toString());
修改说明:
可连续给两个值(如4,1),卡1用的是4,卡2用的是1。数字代表的意义见下方的相关代码片段。
相关源码位置:
frameworks/base/telephony/java/com/android/internal/telephony/RILConstants.java
frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
相关代码片段:
/* NETWORK_MODE_* See ril.h RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE */
int NETWORK_MODE_WCDMA_PREF = 0; /* GSM/WCDMA (WCDMA preferred) */
int NETWORK_MODE_GSM_ONLY = 1; /* GSM only */
int NETWORK_MODE_WCDMA_ONLY = 2; /* WCDMA only */
int NETWORK_MODE_GSM_UMTS = 3; /* GSM/WCDMA (auto mode, according to PRL)
AVAILABLE Application Settings menu*/
int NETWORK_MODE_CDMA = 4; /* CDMA and EvDo (auto mode, according to PRL)
AVAILABLE Application Settings menu*/
int NETWORK_MODE_CDMA_NO_EVDO = 5; /* CDMA only */
int NETWORK_MODE_EVDO_NO_CDMA = 6; /* EvDo only */
int NETWORK_MODE_GLOBAL = 7; /* GSM/WCDMA, CDMA, and EvDo (auto mode, according to PRL)
AVAILABLE Application Settings menu*/
int NETWORK_MODE_LTE_CDMA_EVDO = 8; /* LTE, CDMA and EvDo */
int NETWORK_MODE_LTE_GSM_WCDMA = 9; /* LTE, GSM/WCDMA */
int NETWORK_MODE_LTE_CMDA_EVDO_GSM_WCDMA = 10; /* LTE, CDMA, EvDo, GSM/WCDMA */
int NETWORK_MODE_LTE_ONLY = 11; /* LTE Only mode. */
int NETWORK_MODE_LTE_WCDMA = 12; /* LTE/WCDMA */
int NETWORK_MODE_TD_SCDMA_ONLY = 13; /* TD-SCDMA only */
int NETWORK_MODE_TD_SCDMA_WCDMA = 14; /* TD-SCDMA and WCDMA */
int NETWORK_MODE_TD_SCDMA_LTE = 15; /* TD-SCDMA and LTE */
int NETWORK_MODE_TD_SCDMA_GSM = 16; /* TD-SCDMA and GSM */
int NETWORK_MODE_TD_SCDMA_GSM_LTE = 17; /* TD-SCDMA,GSM and LTE */
int NETWORK_MODE_TD_SCDMA_GSM_WCDMA = 18; /* TD-SCDMA, GSM/WCDMA */
int NETWORK_MODE_TD_SCDMA_WCDMA_LTE = 19; /* TD-SCDMA, WCDMA and LTE */
int NETWORK_MODE_TD_SCDMA_GSM_WCDMA_LTE = 20; /* TD-SCDMA, GSM/WCDMA and LTE */
int NETWORK_MODE_TD_SCDMA_CDMA_EVDO_GSM_WCDMA = 21; /*TD-SCDMA,EvDo,CDMA,GSM/WCDMA*/
int NETWORK_MODE_TD_SCDMA_LTE_CDMA_EVDO_GSM_WCDMA = 22; /* TD-SCDMA/LTE/GSM/WCDMA, CDMA, and
EvDo */
复制代码
// Set the preferred network mode
int defaultNetworkType = RILConstants.PREFERRED_NETWORK_MODE;
int numPhones = MSimTelephonyManager.getDefault().getPhoneCount();
String networkMode = SystemProperties.get("ro.telephony.default_network");
if (networkMode != null) {
if (numPhones == MSimConstants.MAX_PHONE_COUNT_SINGLE_SIM) {
loadSetting(
stmt,
Settings.Global.PREFERRED_NETWORK_MODE,
MSimTelephonyManager.getTelephonyProperty(
"ro.telephony.default_network", 0,
Integer.toString(defaultNetworkType)));
} else {
loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, networkMode);
}
} else {
StringBuilder sb = new StringBuilder(defaultNetworkType);
for (int i = 0; i < numPhones - 1; i++) {
sb.append(",");
sb.append(RILConstants.NETWORK_MODE_GSM_ONLY);
}
loadSetting(stmt, Settings.Global.PREFERRED_NETWORK_MODE, sb.toString());
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
大雅新科技有限公司
2024-11-19 广告
2024-11-19 广告
这方面更多更全面的信息其实可以找下大雅新。深圳市大雅新科技有限公司从事KVM延长器,DVI延长器,USB延长器,键盘鼠标延长器,双绞线视频传输器,VGA视频双绞线传输器,VGA延长器,VGA视频延长器,DVI KVM 切换器等,优质供应商,...
点击进入详情页
本回答由大雅新科技有限公司提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询