获取 静态 IP地址命令:
settings get system ethernet_static_ip
设置静态IP地址命令:
settings put system ethernet_static_ip 192.168.1.222
对应的网关,子网掩码,DNS对应的key string为ethernet_static_netmask,ethernet_static_gateway,ethernet_static_dns1,ethernet_static_dns2
该命令的实现文件目录为:
frameworks/base/cmds/settings/src/com/android/commands/settings/SettingsCmd.java
具体使用提示如下:
private static void printUsage() {
System.err.println("usage: settings [--user NUM] get namespace key");
System.err.println(" settings [--user NUM] put namespace key value");
System.err.println(" settings [--user NUM] delete namespace key");
System.err.println("\n'namespace' is one of {system, secure, global}, case-insensitive");
System.err.println("If '--user NUM' is not given, the operations are performed on the owner user.");
}
settings数据库存放路径:/data/data/com.android.providers.settings/databases
默认数据加载文件:/frameworks/base/packages/SettingsProvider/res/values/defaults.xml
特别补充:
settings put system ethernet_static_ip 192.168.1.222,实际上没有真正的设置到底层去,还需要调用
EthernetManager的setConfiguration(IpConfiguration),具体实现需要自己去研究下