(2)Settings部分修改
拷贝eth_configure.xml到Settings/res/layout/
拷贝ic_setttings_ethernet.png到Settings/res/drawable-hdpi与drawable-mdpi
拷贝ethernet_settings.xml到Settings/res/xml下
修改xml下settings_headers.xml在wifi下增加如下内容
<!-- Ethernet --><headerandroid:id="@+id/ethernet_settings"android:title="@string/eth_setting"android:icon="@drawable/ic_settings_ethernet"android:fragment="com.android.settings.ethernet.EthernetSettings"/>
修改values/strings.xml增加如下内容
<!-- Ethernet configuration dialog --><string name="eth_config_title">Configure Ethernet device</string><string name="eth_setting">Ethernet</string><string name="eth_dev_list">Ethernet Devices:</string><string name="eth_con_type">Connection Type</string><string name="eth_con_type_dhcp">DHCP</string><string name="eth_con_type_manual">Static IP</string><string name="eth_dns">DNS address</string><string name="eth_gw">Gateway address</string><string name="eth_ipaddr">IP address</string><string name="eth_quick_toggle_title">Ethernet</string><string name="eth_quick_toggle_summary">Turn on Ethernet</string><string name="eth_conf_perf_title">Ethernet configuration</string><string name="eth_conf_summary">Configure Ethernet devices</string><string name="eth_mask">Netmask</string><string name="eth_toggle_summary_off">Turn off Ethernet</string><string name="eth_toggle_summary_on">Turn on Ethernet</string><string name="eth_settings_error">Failed to set: Please enter the valid characters 0~255</string>
拷贝Settings/src/ethernet到Settings/src文件夹下
修改Settings/AndroidManifest.xml
在
<!-- Wireless Controls -->
<activity android:name="Settings$WirelessSettingsActivity"
android:taskAffinity="com.android.settings"
android:label="@string/wireless_networks_settings_title"
android:parentActivityName="Settings">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.settings.WIRELESS_SETTINGS" />
<action android:name="android.settings.AIRPLANE_MODE_SETTINGS" />
<action android:name="android.settings.NFC_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE_LAUNCH" />
</intent-filter>
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
android:value="com.android.settings.WirelessSettings" />
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
android:resource="@id/wireless_settings" />
</activity>
下增加如下代码
<!-- Ethernet controls add by hclydao--><activity android:name="Settings$EthernetSettingsActivity"android:label="@string/eth_setting"><intent-filter><action android:name="android.intent.action.MAIN" /><action android:name="android.settings.ETHERNET_SETTINGS" /><category android:name="android.intent.category.DEFAULT" /><category android:name="android.intent.category.VOICE_LAUNCH" /><category android:name="com.android.settings.SHORTCUT" /></intent-filter><meta-data android:name="com.android.settings.FRAGMENT_CLASS"android:value="com.android.settings.ethernet.EthernetSettings" /><meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"android:resource="@id/ethernet_settings" /></activity>
修改Settings/src/Utils.java
在
public static String getWifiIpAddresses(Context context) {
ConnectivityManager cm = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
LinkProperties prop = cm.getLinkProperties(ConnectivityManager.TYPE_WIFI);
return formatIpAddresses(prop);
}
下增加如下代码
public static String getEtherProperties(Context context) {ConnectivityManager cm = (ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);LinkProperties prop = cm.getLinkProperties(ConnectivityManager.TYPE_ETHERNET);return prop.toString();}
修改Settings/src/Settings.java
加上
import com.android.settings.ethernet.EthernetSettings;
在
R.id.wifi_settings,
下加上
R.id.ethernet_settings,
在
WifiSettings.class.getName(),
下加上
EthernetSettings.class.getName(),