android 7.1 "移動網絡" 選項 不存在問題。
1、celluar networks 字符串定義
首先在設置APK的資源文件去找到這一串字符
<!-- Wireless controls, item title to go into the network settings -->
<string name="network_settings_title">Mobile networks</string>
2、network_settings_title引用
packages/apps/Settings/src/com/android/settings/WirelessSettings.java中找到:"mobile_network_settings"
private static final String KEY_MOBILE_NETWORK_SETTINGS = "mobile_network_settings";
把 network_settings_title賦值給 KEY_MOBILE_NETWORK_SETTINGS,再跟進一下 KEY_MOBILE_NETWORK_SETTINGS這個變量吧。
在相同的文件中我們找到:
RemovMobile Network Settings if it's a wifi-only device.
if (Utils.isWifiOnly(getActivity())) {
getPreferenceScreen().removePreference(findPreference(KEY_MOBILE_NETWORK_SETTINGS));
}
getSystemService(Context.CONNECTIVITY_SERVICE);獲得網絡連接服務,然后判斷是否支持TYPE_MOBILE,現在判斷應該是不支持,也就是if判斷中:Utils.isWifiOnly(getActivity())=1
所以把“移動網絡”的選項移除,現在我們就重點去分析Utils.isWifiOnly(getActivity()),找到不顯示的原因,也就是if()中的判斷條件,跟進這段代碼
3、我們去看下ifWifiOnly()是何方神圣?
packages/apps/Settings/src/com/android/settings/Utils.Java中找到
.import android.net.ConnectivityManager;
.public static boolean isWifiOnly(Context context) {
ConnectivityManager cm = (ConnectivityManager)context.getSystemService(
Context.CONNECTIVITY_SERVICE);
return (cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE) == false);
.}
Utils.isWifiOnly(getActivity())=1也就是
cm.isNetworkSupported(ConnectivityManager.TYPE_MOBILE) = false,可是我們現在要的值是true,為什么會出現false呢,我們繼續往下看cm.isNetworkSupported
4、 再分析isNetworkSupported
frameworks/base/core/java/android/net/ ConnectivityManager.java
.public boolean isNetworkSupported(int networkType) {
.try {
.return mService.isNetworkSupported(networkType);
.} catch (RemoteException e) {}
.return false;
.}
07.}
繼續跟進 mService.isNetworkSupported這個函數的實現
5、 mService.isNetworkSupported的實現
\frameworks\base\core\java\android\net
public boolean isNetworkSupported(int networkType) {
try {
return mService.isNetworkSupported(networkType);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}
6、到最后是device\rockchip\common\overlay\frameworks\base\core\res\res\values\config.xml
<!-- the 6th element indicates boot-time dependency-met value. -->
<string-array translatable="false" name="networkAttributes">
<item>"wifi,1,1,2,-1,true"</item>
<item>"mobile,0,0,0,-1,true"</item>
<item>"mobile_mms,2,0,2,60000,true"</item>
<item>"mobile_supl,3,0,2,60000,true"</item>
<item>"mobile_dun,4,0,2,60000,true"</item>
<item>"mobile_hipri,5,0,3,60000,true"</item>
<item>"mobile_fota,10,0,2,60000,true"</item>
<item>"mobile_ims,11,0,2,60000,true"</item>
<item>"mobile_cbs,12,0,2,60000,true"</item>
<item>"bluetooth,7,7,0,-1,true"</item>
<item>"ethernet,9,9,9,-1,true"</item> 要注意這里
</string-array>
<!-- This string array should be overridden by the device to present a list of radio
attributes. This is used by the connectivity manager to decide which networks can coexist
based on the hardware -->
<!-- An Array of "[ConnectivityManager connectionType],
[# simultaneous connection types]" -->
<string-array translatable="false" name="radioAttributes">
<item>"0,1"</item>
<item>"1,1"</item>
<item>"7,1"</item>
<item>"9,1"</item> 注意這里
</string-array>
7、最好要開啟rild相關的資源,這是4G模塊就可以加載成功。
在boardconfig.mk文件增加此功能
BOARD_HAVE_DONGLE:=true
在android7.1可以成功利用4G模塊上網
|