Android->Eth:fix can not save static ip

This commit is contained in:
sjf
2016-05-25 09:59:47 +08:00
committed by linjc
parent e1a8a70b87
commit 5d164df41b
2 changed files with 89 additions and 0 deletions

View File

@ -76,6 +76,8 @@ import android.preference.ListPreference;
import com.android.settings.ethernet_static_ip_dialog;
import android.provider.Settings.System;
public class EthernetSettings extends SettingsPreferenceFragment
implements DialogInterface.OnClickListener ,OnPreferenceChangeListener {
private static final String TAG = "EthernetSettings";
@ -275,6 +277,7 @@ public class EthernetSettings extends SettingsPreferenceFragment
if(preference==mkeyEthMode) {
String value=(String)newValue;
if(value.equals("DHCP")){
System.putInt(getContentResolver(), System.ETHERNET_USE_STATIC_IP, 0);
mEthManager.setConfiguration(new IpConfiguration(IpAssignment.DHCP, ProxySettings.NONE,null,null));
log("switch to dhcp");
}else if(value.equals("StaticIP")){
@ -499,6 +502,7 @@ public class EthernetSettings extends SettingsPreferenceFragment
if(button==ethernet_static_ip_dialog.BUTTON_SUBMIT) {
mDialog.saveIpSettingInfo(); //从Dialog获取静态数据
if(setStaticIpConfiguration()) {
System.putInt(getContentResolver(), System.ETHERNET_USE_STATIC_IP, 1);
mEthManager.setConfiguration(mIpConfiguration);
} else {
Log.e(TAG, mIpConfiguration.toString());