https://blog.csdn.net/zhouyuanjing/article/details/78415891
Android 7.0 自带EthernetService,默认开机就会启动,默认ip获取方式是动态分配(DHCP),有时候公司路由器DNS设置有问题,导致无法上网(能ping通局域网,无法上外网),手动设置静态IP就派上用场了。
废话不多说了,上图
修改记录:
alps/device/xxxxx/xxx6737t_35g_n/device.mk
alps/frameworks/base/core/java/android/net/EthernetManager.java
alps/frameworks/base/core/java/android/net/IEthernetManager.aidl
alps/frameworks/base/core/java/android/provider/Settings.java
alps/frameworks/base/core/res/res/values/config.xml
alps/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
alps/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
alps/frameworks/base/proto/src/metrics_constants.proto
alps/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java
alps/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetServiceImpl.java
alps/packages/apps/Settings/AndroidManifest.xml
alps/packages/apps/Settings/res/drawable-hdpi/ic_settings_ethernet.png
alps/packages/apps/Settings/res/layout/ethernet_configure.xml
alps/packages/apps/Settings/res/values-zh-rCN/strings.xml
alps/packages/apps/Settings/res/values/strings.xml
alps/packages/apps/Settings/res/xml/ethernet_settings.xml
alps/packages/apps/Settings/src/com/android/settings/Settings.java
alps/packages/apps/Settings/src/com/android/settings/SettingsActivity.java
alps/packages/apps/Settings/src/com/android/settings/ethernet/EthernetDialog.java
alps/packages/apps/Settings/src/com/android/settings/ethernet/EthernetEnabler.java
alps/packages/apps/Settings/src/com/android/settings/ethernet/EthernetSettings.java
alps/packages/apps/Settings/src/com/android/settings/ethernet/ip/AbsEditText.java
alps/packages/apps/Settings/src/com/android/settings/ethernet/ip/AbsEditTextGroup.java
alps/packages/apps/Settings/src/com/android/settings/ethernet/ip/IPEditText.java
alps/packages/apps/Settings/src/com/android/settings/ethernet/ip/IPView.java
1. device/xxxxx/xxx6737t_35g_n/device.mk
diff --git a/alps/device/xxxxx/xxx6737t_35g_n/device.mk b/alps/device/xxxxx/xxx6737t_35g_n/device.mk
index 71f1a5c..8ce0e36 100755 (executable)
--- a/alps/device/xxxxx/xxx6737t_35g_n/device.mk
+++ b/alps/device/xxxxx/xxx6737t_35g_n/device.mk
@@ -141,6 +141,9 @@ endif
# USB OTG
PRODUCT_COPY_FILES += frameworks/native/data/etc/android.hardware.usb.host.xml:system/etc/permissions/android.hardware.usb.host.xml
+# Ethernet
+PRODUCT_COPY_FILES += frameworks/native/data/etc/android.hardware.ethernet.xml:system/etc/permissions/android.hardware.ethernet.xml
+
# GPS relative file
ifeq ($(MTK_GPS_SUPPORT),yes)
2. frameworks/base/core/java/android/net/EthernetManager.java
diff --git a/alps/frameworks/base/core/java/android/net/EthernetManager.java b/alps/frameworks/base/core/java/android/net/EthernetManager.java
index 664b7b4..44592be 100755 (executable)
--- a/alps/frameworks/base/core/java/android/net/EthernetManager.java
+++ b/alps/frameworks/base/core/java/android/net/EthernetManager.java
@@ -35,6 +35,10 @@ public class EthernetManager {
private static final String TAG = "EthernetManager";
private static final int MSG_AVAILABILITY_CHANGED = 1000;
+ public static final int ETHERNET_STATE_UNKNOWN = 0;
+ public static final int ETHERNET_STATE_DISABLED = 1;
+ public static final int ETHERNET_STATE_ENABLED = 2;
+
private final Context mContext;
private final IEthernetManager mService;
private final Handler mHandler = new Handler() {
@@ -152,4 +156,19 @@ public class EthernetManager {
}
}
}
+
+ public void start() {
+ try {
+ mService.trackStart();
+ } catch (NullPointerException | RemoteException e) {
+ }
+ }
+
+ public void stop() {
+ try {
+ mService.trackStop();
+ } catch (NullPointerException | RemoteException e) {
+ }
+ }
+
}
3. frameworks/base/core/java/android/net/IEthernetManager.aidl
diff --git a/alps/frameworks/base/core/java/android/net/IEthernetManager.aidl b/alps/frameworks/base/core/java/android/net/IEthernetManager.aidl
index 7a92eb9..d2014ad 100755 (executable)
--- a/alps/frameworks/base/core/java/android/net/IEthernetManager.aidl
+++ b/alps/frameworks/base/core/java/android/net/IEthernetManager.aidl
@@ -31,4 +31,6 @@ interface IEthernetManager
boolean isAvailable();
void addListener(in IEthernetServiceListener listener);
void removeListener(in IEthernetServiceListener listener);
+ void trackStart();
+ void trackStop();
}
4. frameworks/base/core/java/android/provider/Settings.java
diff --git a/alps/frameworks/base/core/java/android/provider/Settings.java b/alps/frameworks/base/core/java/android/provider/Settings.java
index 1e0a53a..817b008 100755 (executable)
--- a/alps/frameworks/base/core/java/android/provider/Settings.java
+++ b/alps/frameworks/base/core/java/android/provider/Settings.java
@@ -9832,6 +9832,48 @@ public final class Settings {
public static final String CURRENT_NETWORK_CALL = "current_network_call";
/// MTK ADD END. @}
+ /**
+ * ethernet setting is enabled or disable.
+ *
+ * @hide
+ */
+ public static final String ETHERNET_ON = "ethernet_on";
+
+ /**
+ * ethernet_static_ip setting
+ *
+ * @hide
+ */
+ public static final String ETHERNET_STATIC_IP = "ethernet_static_ip";
+
+ /**
+ * ethernet_static_mask setting
+ *
+ * @hide
+ */
+ public static final String ETHERNET_STATIC_MASK = "ethernet_static_mask";
+
+ /**
+ * ethernet_static_gateway setting
+ *
+ * @hide
+ */
+ public static final String ETHERNET_STATIC_GATEWAY = "ethernet_static_gateway";
+
+ /**
+ * ethernet_static_dns1 setting
+ *
+ * @hide
+ */
+ public static final String ETHERNET_STATIC_DNS1 = "ethernet_static_dns1";
+
+ /**
+ * ethernet_static_dns2 setting
+ *
+ * @hide
+ */
+ public static final String ETHERNET_STATIC_DNS2 = "ethernet_static_dns2";
+
}
/**
5. frameworks/base/core/res/res/values/config.xml
diff --git a/alps/frameworks/base/core/res/res/values/config.xml b/alps/frameworks/base/core/res/res/values/config.xml
index 9aac18e..d790573 100755 (executable)
--- a/alps/frameworks/base/core/res/res/values/config.xml
+++ b/alps/frameworks/base/core/res/res/values/config.xml
@@ -232,6 +232,7 @@
does not require auto-restore. -->
<!-- the 6th element indicates boot-time dependency-met value. -->
<string-array translatable="false" name="networkAttributes">
+ <item>"ethernet,9,9,1,-1,true"</item>
<item>"wifi,1,1,2,-1,true"</item>
<item>"tedongle,49,49,1,-1,true"</item>
<item>"mobile,0,0,0,-1,true"</item>
6. frameworks/base/packages/SettingsProvider/res/values/defaults.xml
diff --git a/alps/frameworks/base/packages/SettingsProvider/res/values/defaults.xml b/alps/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
index f50436b..72298cc 100755 (executable)
--- a/alps/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
+++ b/alps/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
@@ -219,4 +219,17 @@
<!-- Default for Settings.Secure.SKIP_FIRST_USE_HINTS -->
<integer name="def_skip_first_use_hints">1</integer>
+
+ <!-- Default for Settings.Global.ETHERNET_ON {ETHERNET_STATE_UNKNOWN,ETHERNET_STATE_DISABLED,ETHERNET_STATE_ENABLED}-->
+ <integer name="def_ethernet_on">2</integer>
+ <!-- Default for Settings.Global.ETHERNET_STATIC_IP-->
+ <string name="def_ethernet_static_ip"></string>
+ <!-- Default for Settings.Global.ETHERNET_STATIC_MASK-->
+ <string name="def_ethernet_static_mask">255.255.255.0</string>
+ <!-- Default for Settings.Global.ETHERNET_STATIC_GATEWAY-->
+ <string name="def_ethernet_static_gateway"></string>
+ <!-- Default for Settings.Global.ETHERNET_STATIC_DNS1-->
+ <string name="def_ethernet_static_dns1"></string>
+ <!-- Default for Settings.Global.ETHERNET_STATIC_DNS2-->
+ <string name="def_ethernet_static_dns2"></string>
</resources>
7. frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
diff --git a/alps/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java b/alps/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
index 3ad22dd..3eb3fe7 100755 (executable)
--- a/alps/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
+++ b/alps/frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/DatabaseHelper.java
@@ -2755,6 +2755,19 @@ class DatabaseHelper extends SQLiteOpenHelper {
loadSetting(stmt, Settings.Global.ENHANCED_4G_MODE_ENABLED,
ImsConfig.FeatureValueConstants.ON);
+ loadIntegerSetting(stmt, Settings.Global.ETHERNET_ON,
+ R.integer.def_ethernet_on);
+ loadStringSetting(stmt, Settings.Global.ETHERNET_STATIC_IP,
+ R.string.def_ethernet_static_ip);
+ loadStringSetting(stmt, Settings.Global.ETHERNET_STATIC_MASK,
+ R.string.def_ethernet_static_mask);
+ loadStringSetting(stmt, Settings.Global.ETHERNET_STATIC_GATEWAY,
+ R.string.def_ethernet_static_gateway);
+ loadStringSetting(stmt, Settings.Global.ETHERNET_STATIC_DNS1,
+ R.string.def_ethernet_static_dns1);
+ loadStringSetting(stmt, Settings.Global.ETHERNET_STATIC_DNS2,
+ R.string.def_ethernet_static_dns2);
+
/// M: Load MTK added Global providers before Android M.
mUtils.loadCustomGlobalSettings(stmt);
8. frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java
diff --git a/alps/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java b/alps/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java
index 0b091f2..5a268ab 100755 (executable)
--- a/alps/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java
+++ b/alps/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetNetworkFactory.java
@@ -105,6 +105,8 @@ class EthernetNetworkFactory {
private IpManager mIpManager;
private Thread mIpProvisioningThread;
+ private Handler mHandler;
+
EthernetNetworkFactory(RemoteCallbackList<IEthernetServiceListener> listeners) {
mNetworkInfo = new NetworkInfo(ConnectivityManager.TYPE_ETHERNET, 0, NETWORK_TYPE, "");
mLinkProperties = new LinkProperties();
@@ -298,6 +300,12 @@ class EthernetNetworkFactory {
if (config.getIpAssignment() == IpAssignment.STATIC) {
if (!setStaticIpAddress(config.getStaticIpConfiguration())) {
// We've already logged an error.
+ //if error then stop and restart
+ if((mContext != null) && (mHandler != null)) {
+ Log.d(TAG, "Setting static ip failed now restart");
+ stop();
+ start(mContext,mHandler);
+ }
return;
}
linkProperties = config.getStaticIpConfiguration().toLinkProperties(mIface);
@@ -426,6 +434,7 @@ class EthernetNetworkFactory {
mFactory.register();
mContext = context;
+ mHandler = target;
// Start tracking interface change events.
mInterfaceObserver = new InterfaceObserver();
@@ -449,6 +458,9 @@ class EthernetNetworkFactory {
// configuring it. Since we're already holding the lock,
// any real link up/down notification will only arrive
// after we've done this.
+ if(!iface.equals("eth0")) {
+ continue;
+ }
if (mNMService.getInterfaceConfig(iface).hasFlag("running")) {
updateInterfaceState(iface, true);
}
9. frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetServiceImpl.java
diff --git a/alps/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetServiceImpl.java b/alps/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetServiceImpl.java
index 42996d6..9508b79 100755 (executable)
--- a/alps/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetServiceImpl.java
+++ b/alps/frameworks/opt/net/ethernet/java/com/android/server/ethernet/EthernetServiceImpl.java
@@ -18,6 +18,7 @@ package com.android.server.ethernet;
import android.content.Context;
import android.content.pm.PackageManager;
+import android.net.EthernetManager;
import android.net.IEthernetManager;
import android.net.IEthernetServiceListener;
import android.net.IpConfiguration;
@@ -26,6 +27,7 @@ import android.net.IpConfiguration.ProxySettings;
import android.os.Binder;
import android.os.Handler;
import android.os.HandlerThread;
+import android.os.Looper;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.provider.Settings;
@@ -38,6 +40,12 @@ import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.concurrent.atomic.AtomicBoolean;
+import android.net.Uri;
+import android.provider.Settings.System;
+import android.net.StaticIpConfiguration;
+import android.net.LinkAddress;
+import java.net.InetAddress;
+
/**
* EthernetServiceImpl handles remote Ethernet operation requests by implementing
* the IEthernetManager interface.
@@ -87,11 +95,42 @@ public class EthernetServiceImpl extends IEthernetManager.Stub {
handlerThread.start();
mHandler = new Handler(handlerThread.getLooper());
+ int enable = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.ETHERNET_ON, 0);
+ if(enable != EthernetManager.ETHERNET_STATE_ENABLED) {
+ Log.i(TAG, "Ethernet is not enable");
+ return;
+ }
+
mTracker.start(mContext, mHandler);
mStarted.set(true);
}
+ public void trackStart() {
+ Log.i(TAG, "Statr ethernet service");
+ new Thread(new Runnable() {
+ public void run() {
+ Looper.prepare();
+ mTracker.start(mContext, mHandler);
+ mStarted.set(true);
+ Looper.loop();
+ }
+ }).start();;
+ }
+
+ public void trackStop() {
+ Log.i(TAG, "Stop ethernet service");
+ new Thread(new Runnable() {
+ public void run() {
+ Looper.prepare();
+ mTracker.stop();
+ mStarted.set(false);
+ Looper.loop();
+ }
+ }).start();;
+ }
+
/**
* Get Ethernet configuration
* @return the Ethernet Configuration, contained in {@link IpConfiguration}.
10. packages/apps/Settings/AndroidManifest.xml
diff --git a/alps/packages/apps/Settings/AndroidManifest.xml b/alps/packages/apps/Settings/AndroidManifest.xml
index 8f1cfc1..9a02ea3 100644 (file)
--- a/alps/packages/apps/Settings/AndroidManifest.xml
+++ b/alps/packages/apps/Settings/AndroidManifest.xml
@@ -465,6 +465,46 @@
</intent-filter>
</activity>
+ <activity
+ android:name="Settings$EthernetSettingsActivity"
+ android:label="@string/ethernet_settings"
+ android:icon="@drawable/ic_settings_ethernet"
+ android:taskAffinity="" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <action android:name="com.android.settings.ETHERNET_SETTINGS" />
+ <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>
+
+ <intent-filter android:priority="3">
+ <action android:name="com.android.settings.action.SETTINGS" />
+ </intent-filter>
+ <meta-data
+ android:name="com.android.settings.category"
+ android:value="com.android.settings.category.wireless" />
+ <meta-data
+ android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.ethernet.EthernetSettings" />
+ <meta-data
+ android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
+ android:value="true" />
+ </activity>
+
+ <!-- Keep compatibility with old shortcuts. -->
+ <activity-alias android:name=".ethernet.EthernetSettings"
+ android:label="@string/ethernet_settings"
+ android:targetActivity="Settings$EthernetSettingsActivity"
+ android:exported="true"
+ android:clearTaskOnLaunch="true">
+ <meta-data
+ android:name="com.android.settings.FRAGMENT_CLASS"
+ android:value="com.android.settings.ethernet.EthernetSettings" />
+ </activity-alias>
+
<service android:name=".TetherService"
android:exported="true"
android:permission="android.permission.TETHER_PRIVILEGED" />
@@ -2404,11 +2444,11 @@
android:label="@string/crypt_keeper_encrypt_title">
11. packages/apps/Settings/res/drawable-hdpi/ic_settings_ethernet.png
12. packages/apps/Settings/res/layout/ethernet_configure.xml
13. packages/apps/Settings/res/values-zh-rCN/strings.xml
diff --git a/alps/packages/apps/Settings/res/values-zh-rCN/strings.xml b/alps/packages/apps/Settings/res/values-zh-rCN/strings.xml
index 47cbe80..5fd7ba5 100755 (executable)
--- a/alps/packages/apps/Settings/res/values-zh-rCN/strings.xml
+++ b/alps/packages/apps/Settings/res/values-zh-rCN/strings.xml
@@ -3099,4 +3099,31 @@
<string name="bluetooth_talkback_headphone" msgid="26580326066627664">"耳机"</string>
<string name="bluetooth_talkback_input_peripheral" msgid="5165842622743212268">"外围输入设备"</string>
<string name="bluetooth_talkback_bluetooth" msgid="5615463912185280812">"蓝牙"</string>
+ <!-- Ethernet settings string -->
+ <string name="ethernet_settings">以太网</string>
+ <string name="eth_config_title">配置以太网</string>
+ <string name="eth_setting">以太网</string>
+ <string name="eth_dev_list">以太网:</string>
+ <string name="eth_con_type">连接类型</string>
+ <string name="eth_con_type_dhcp">自动获取 IP</string>
+ <string name="eth_con_type_manual">静态 IP</string>
+ <string name="eth_dns1">首选 DNS 服务器</string>
+ <string name="eth_dns2">备用 DNS 服务器</string>
+ <string name="eth_gw">默认网关</string>
+ <string name="eth_ipaddr">IP 地址</string>
+ <string name="eth_quick_toggle_title">以太网</string>
+ <string name="eth_quick_toggle_summary">开启以太网</string>
+ <string name="eth_conf_perf_title">配置以太网</string>
+ <string name="eth_conf_summary">配置以太网</string>
+ <string name="eth_mask">子网掩码</string>
+ <string name="eth_toggle_summary_off">关闭以太网</string>
+ <string name="eth_toggle_summary_on">开启以太网</string>
+ <string name="eth_settings_error">请输入有效字符0~255</string>
+ <string name="eth_settings_empty">网络信息不能为空</string>
+ <string name="eth_settings_not_complete">网络信息需填写完整</string>
+ <!-- Label for the network prefix of the network [CHAR LIMIT=25] -->
+ <string name="eth_network_prefix_length">前缀长度</string>
+ <string name="eth_open_ethernet_tip">请打开以太网.</string>
+ <string name="eth_state_on">已开启</string>
+ <string name="eth_state_off">已关闭</string>
</resources>
14. packages/apps/Settings/res/values/strings.xml
diff --git a/alps/packages/apps/Settings/res/values/strings.xml b/alps/packages/apps/Settings/res/values/strings.xml
index 38bc124..c3798fd 100755 (executable)
--- a/alps/packages/apps/Settings/res/values/strings.xml
+++ b/alps/packages/apps/Settings/res/values/strings.xml
@@ -7500,4 +7500,32 @@
<!-- Message for telling the user the kind of BT device being displayed in list. -->
<string name="bluetooth_talkback_bluetooth">Bluetooth</string>
+
+ <!-- Ethernet settings string -->
+ <string name="ethernet_settings">Ethernet</string>
+ <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_dns1">Preferred DNS address</string>
+ <string name="eth_dns2">Alternate 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">Please enter the valid characters 0~255</string>
+ <string name="eth_settings_empty">Network information can\'t be empty</string>
+ <string name="eth_settings_not_complete">Network information must be completely</string>
+ <!-- Label for the network prefix of the network [CHAR LIMIT=25] -->
+ <string name="eth_network_prefix_length">Network prefix length</string>
+ <string name="eth_open_ethernet_tip">Please turn on ethernet.</string>
+ <string name="eth_state_on">On</string>
+ <string name="eth_state_off">Off</string>
</resources>
15. packages/apps/Settings/res/xml/ethernet_settings.xml
16. packages/apps/Settings/src/com/android/settings/Settings.java
diff --git a/alps/packages/apps/Settings/src/com/android/settings/Settings.java b/alps/packages/apps/Settings/src/com/android/settings/Settings.java
index 3508406..f423077 100644 (file)
--- a/alps/packages/apps/Settings/src/com/android/settings/Settings.java
+++ b/alps/packages/apps/Settings/src/com/android/settings/Settings.java
@@ -29,6 +29,7 @@ public class Settings extends SettingsActivity {
* Settings subclasses for launching independently.
*/
public static class BluetoothSettingsActivity extends SettingsActivity { /* empty */ }
+ public static class EthernetSettingsActivity extends SettingsActivity { /* empty */ }
public static class WirelessSettingsActivity extends SettingsActivity { /* empty */ }
public static class SimSettingsActivity extends SettingsActivity { /* empty */ }
public static class TetherSettingsActivity extends SettingsActivity { /* empty */ }
17. packages/apps/Settings/src/com/android/settings/SettingsActivity.java
diff --git a/alps/packages/apps/Settings/src/com/android/settings/SettingsActivity.java b/alps/packages/apps/Settings/src/com/android/settings/SettingsActivity.java
index 9b82a5f..efa99a1 100644 (file)
--- a/alps/packages/apps/Settings/src/com/android/settings/SettingsActivity.java
+++ b/alps/packages/apps/Settings/src/com/android/settings/SettingsActivity.java
@@ -81,6 +81,7 @@ import com.android.settings.deviceinfo.PublicVolumeSettings;
import com.android.settings.deviceinfo.SimStatus;
import com.android.settings.deviceinfo.Status;
import com.android.settings.deviceinfo.StorageSettings;
+import com.android.settings.ethernet.EthernetSettings;
import com.android.settings.fuelgauge.BatterySaverSettings;
import com.android.settings.fuelgauge.PowerUsageDetail;
import com.android.settings.fuelgauge.PowerUsageSummary;
@@ -239,6 +240,7 @@ public class SettingsActivity extends SettingsDrawerActivity
//wireless_section
WifiSettingsActivity.class.getName(),
Settings.BluetoothSettingsActivity.class.getName(),
+ Settings.EthernetSettingsActivity.class.getName(),
Settings.DataUsageSummaryActivity.class.getName(),
Settings.SimSettingsActivity.class.getName(),
Settings.WirelessSettingsActivity.class.getName(),
@@ -278,6 +280,7 @@ public class SettingsActivity extends SettingsDrawerActivity
AdvancedWifiSettings.class.getName(),
SavedAccessPointsWifiSettings.class.getName(),
BluetoothSettings.class.getName(),
+ EthernetSettings.class.getName(),
SimSettings.class.getName(),
TetherSettings.class.getName(),
WifiP2pSettings.class.getName(),
@@ -1085,6 +1088,10 @@ public class SettingsActivity extends SettingsDrawerActivity
pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH), isAdmin, pm);
setTileEnabled(new ComponentName(packageName,
+ Settings.EthernetSettingsActivity.class.getName()),
+ pm.hasSystemFeature(PackageManager.FEATURE_ETHERNET), isAdmin, pm);
+
+ setTileEnabled(new ComponentName(packageName,
Settings.DataUsageSummaryActivity.class.getName()),
Utils.isBandwidthControlEnabled(), isAdmin, pm);
18. packages/apps/Settings/src/com/android/settings/ethernet/EthernetDialog.java
19. packages/apps/Settings/src/com/android/settings/ethernet/EthernetEnabler.java
20. packages/apps/Settings/src/com/android/settings/ethernet/EthernetSettings.java
21. packages/apps/Settings/src/com/android/settings/ethernet/ip/AbsEditText.java
22. packages/apps/Settings/src/com/android/settings/ethernet/ip/AbsEditTextGroup.java
23. packages/apps/Settings/src/com/android/settings/ethernet/ip/IPEditText.java
24. packages/apps/Settings/src/com/android/settings/ethernet/ip/IPView.java
标红文件见 Android 7.0 增加Ethernet设置(DHCP与Static ip)
感谢
http://blog.csdn.net/hclydao/article/details/50972932
https://github.com/lanyan520/Idea-EditText