<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
+ <!-- Ethernet controls -->
+ <activity android:name="EthernetSettings"
+ android:label="@string/eth_radio_ctrl_title"
+ >
+ <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" />
+ </intent-filter>
+ </activity>
+
+ <activity android:name=".ethernet.EthernetEnabler" android:label="@string/eth_setting"
+ android:clearTaskOnLaunch="true"
+ >
+ <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>
+ </activity>
+ <activity android:name=".ethernet.EthernetConfigure" android:label="@string/eth_conf_perf_title"
+ android:clearTaskOnLaunch="true"
+ >
+ <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>
+ </activity>
<!-- Wireless Controls -->
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content">
+
+ <LinearLayout
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:padding="8dip"
+ android:orientation="vertical">
+
+ <LinearLayout
+ android:id="@+id/table"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="vertical">
+ </LinearLayout>
+
+ <!-- Device list -->
+
+ <TextView android:id="@+id/eth_dev_list_text"
+ style="?android:attr/textAppearanceSmallInverse"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dip"
+ android:text="@string/eth_dev_list" />
+
+ <!-- The entries will be set programmatically -->
+ <Spinner android:id="@+id/eth_dev_spinner"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+
+ <!-- Connection type -->
+ <TextView android:id="@+id/eth_con_type"
+ style="?android:attr/textAppearanceSmallInverse"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dip"
+ android:text="@string/eth_con_type" />
+ <RadioGroup android:id="@+id/con_type"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ >
+ <RadioButton android:id="@+id/dhcp_radio"
+ style="?android:attr/textAppearanceSmallInverse"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/eth_con_type_dhcp"
+ ></RadioButton>
+ <RadioButton android:id="@+id/manual_radio"
+ style="?android:attr/textAppearanceSmallInverse"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/eth_con_type_manual"
+ ></RadioButton>
+ </RadioGroup>
+
+ <!-- IP address -->
+ <LinearLayout android:id="@+id/enterprise_wrapper"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:padding="0dip"
+ android:orientation="vertical">
+ <TextView android:id="@+id/ipaddr_text"
+ style="?android:attr/textAppearanceSmallInverse"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dip"
+ android:text="@string/eth_ipaddr" />
+ <EditText android:id="@+id/ipaddr_edit"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="2dip"
+ android:singleLine="true" />
+ <TextView android:id="@+id/netmask_text"
+ style="?android:attr/textAppearanceSmallInverse"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dip"
+ android:text="@string/eth_mask" />
+ <EditText android:id="@+id/netmask_edit"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="2dip"
+ android:singleLine="true" />
+ <TextView android:id="@+id/dns_text"
+ style="?android:attr/textAppearanceSmallInverse"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dip"
+ android:text="@string/eth_dns" />
+ <EditText android:id="@+id/eth_dns_edit"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="2dip"
+ android:singleLine="true" />
+ <TextView android:id="@+id/gw_text"
+ style="?android:attr/textAppearanceSmallInverse"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="8dip"
+ android:text="@string/eth_gw" />
+ <EditText android:id="@+id/eth_gw_edit"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="2dip"
+ android:singleLine="true" />
+ </LinearLayout>
+
+ </LinearLayout>
+
+</ScrollView>
<string name="softkeyboard_enable_summary">Enable SoftKeyBoard</string>
<string name="keyboard_layout_title">Keyboard layout setting</string>
<string name="keyboard_layout_summary">Choose a keyboard layout</string>
+
+ <!-- Ethernet configuration dialog -->
+ <string name="eth_config_title">Configure Ethernet device</string>
+ <string name="eth_setting">Ethernet setting</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">Default Router</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_radio_ctrl_title">Ethernet configuration</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>
</resources>
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:title="@string/eth_radio_ctrl_title">
+ <!-- Programmatically will have dynamic summary, but we provide the fallback summary. -->
+ <CheckBoxPreference
+ android:key="toggle_eth"
+ android:title="@string/eth_quick_toggle_title"
+ android:summaryOn="@string/eth_toggle_summary_off"
+ android:summaryOff="@string/eth_toggle_summary_on"
+ android:persistent="false" />
+ <Preference
+ android:title="@string/eth_conf_perf_title"
+ android:summary="@string/eth_conf_summary"
+ android:key="ETHERNET_config"
+ android:persistent="false" />
+</PreferenceScreen>
</com.android.settings.IconPreferenceScreen>
<com.android.settings.IconPreferenceScreen
+ android:title="@string/eth_radio_ctrl_title"
+ settings:icon="@drawable/ic_settings_ethernet">
+ <intent
+ android:action="android.intent.action.MAIN"
+ android:targetPackage="com.android.settings"
+ android:targetClass="com.android.settings.EthernetSettings" />
+ </com.android.settings.IconPreferenceScreen>
+
+ <com.android.settings.IconPreferenceScreen
android:key="call_settings"
settings:icon="@drawable/ic_settings_call"
android:title="@string/call_settings_title">
--- /dev/null
+/*
+ * Copyright (C) 2010 The Android-x86 Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Author: Yi Sun <beyounn@gmail.com>
+ */
+
+package com.android.settings;
+
+import com.android.settings.R;
+import com.android.settings.ethernet.EthernetConfigDialog;
+import com.android.settings.ethernet.EthernetEnabler;
+
+import android.net.ethernet.EthernetManager;
+import android.os.Bundle;
+import android.preference.CheckBoxPreference;
+import android.preference.Preference;
+import android.preference.PreferenceActivity;
+import android.preference.PreferenceScreen;
+
+public class EthernetSettings extends PreferenceActivity {
+ private static final String KEY_TOGGLE_ETH = "toggle_eth";
+ private static final String KEY_CONF_ETH = "ETHERNET_config";
+ private EthernetEnabler mEthEnabler;
+ private EthernetConfigDialog mEthConfigDialog;
+ private Preference mEthConfigPref;
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+ super.onPreferenceTreeClick(preferenceScreen, preference);
+
+ if (preference == mEthConfigPref) {
+ mEthConfigDialog.show();
+ }
+ return false;
+ }
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ addPreferencesFromResource(R.xml.ethernet_settings);
+ final PreferenceScreen preferenceScreen = getPreferenceScreen();
+ mEthConfigPref = preferenceScreen.findPreference(KEY_CONF_ETH);
+ /*
+ * TO DO:
+ * Add new perference screen for Etherenet Configuration
+ */
+
+ initToggles();
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ mEthEnabler.resume();
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ mEthEnabler.pause();
+ }
+
+ private void initToggles() {
+ mEthEnabler = new EthernetEnabler(this,
+ (EthernetManager) getSystemService(ETHERNET_SERVICE),
+ (CheckBoxPreference) findPreference(KEY_TOGGLE_ETH));
+ mEthConfigDialog = new EthernetConfigDialog(this, mEthEnabler);
+ mEthEnabler.setConfigDialog(mEthConfigDialog);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2010 The Android-x86 Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Author: Yi Sun <beyounn@gmail.com>
+ */
+
+package com.android.settings.ethernet;
+
+
+import java.util.List;
+
+import com.android.settings.R;
+
+import android.app.AlertDialog;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.net.NetworkInfo;
+import android.net.ethernet.EthernetManager;
+import android.net.ethernet.EthernetDevInfo;
+import android.os.Bundle;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.AdapterView;
+import android.widget.ArrayAdapter;
+import android.widget.CheckBox;
+import android.widget.EditText;
+import android.widget.RadioButton;
+import android.widget.RadioGroup;
+import android.widget.Spinner;
+import android.widget.TextView;
+import android.util.Slog;
+
+public class EthernetConfigDialog extends AlertDialog implements
+ DialogInterface.OnClickListener, AdapterView.OnItemSelectedListener, View.OnClickListener {
+ private final String TAG = "EtherenetSettings";
+ private static final boolean localLOGV = false;
+
+ private EthernetEnabler mEthEnabler;
+ private View mView;
+ private Spinner mDevList;
+ private TextView mDevs;
+ private RadioButton mConTypeDhcp;
+ private RadioButton mConTypeManual;
+ private EditText mIpaddr;
+ private EditText mDns;
+ private EditText mGw;
+ private EditText mMask;
+
+ private EthernetLayer mEthLayer;
+ private EthernetManager mEthManager;
+ private EthernetDevInfo mEthInfo;
+ private boolean mEnablePending;
+
+ public EthernetConfigDialog(Context context, EthernetEnabler Enabler) {
+ super(context);
+ mEthLayer = new EthernetLayer(this);
+ mEthEnabler = Enabler;
+ mEthManager=Enabler.getManager();
+ buildDialogContent(context);
+ }
+
+ public int buildDialogContent(Context context) {
+ this.setTitle(R.string.eth_config_title);
+ this.setView(mView = getLayoutInflater().inflate(R.layout.eth_configure, null));
+ mDevs = (TextView) mView.findViewById(R.id.eth_dev_list_text);
+ mDevList = (Spinner) mView.findViewById(R.id.eth_dev_spinner);
+ mConTypeDhcp = (RadioButton) mView.findViewById(R.id.dhcp_radio);
+ mConTypeManual = (RadioButton) mView.findViewById(R.id.manual_radio);
+ mIpaddr = (EditText)mView.findViewById(R.id.ipaddr_edit);
+ mMask = (EditText)mView.findViewById(R.id.netmask_edit);
+ mDns = (EditText)mView.findViewById(R.id.eth_dns_edit);
+ mGw = (EditText)mView.findViewById(R.id.eth_gw_edit);
+
+ mConTypeDhcp.setChecked(true);
+ mConTypeManual.setChecked(false);
+ mIpaddr.setEnabled(false);
+ mMask.setEnabled(false);
+ mDns.setEnabled(false);
+ mGw.setEnabled(false);
+ mConTypeManual.setOnClickListener(new RadioButton.OnClickListener() {
+ public void onClick(View v) {
+ mIpaddr.setEnabled(true);
+ mDns.setEnabled(true);
+ mGw.setEnabled(true);
+ mMask.setEnabled(true);
+ }
+ });
+
+ mConTypeDhcp.setOnClickListener(new RadioButton.OnClickListener() {
+ public void onClick(View v) {
+ mIpaddr.setEnabled(false);
+ mDns.setEnabled(false);
+ mGw.setEnabled(false);
+ mMask.setEnabled(false);
+ }
+ });
+
+ this.setInverseBackgroundForced(true);
+ this.setButton(BUTTON_POSITIVE, context.getText(R.string.menu_save), this);
+ this.setButton(BUTTON_NEGATIVE, context.getText(R.string.menu_cancel), this);
+ String[] Devs = mEthEnabler.getManager().getDeviceNameList();
+ if (Devs != null) {
+ if (localLOGV)
+ Slog.v(TAG, "found device: " + Devs[0]);
+ updateDevNameList(Devs);
+ if (mEthManager.isConfigured()) {
+ mEthInfo = mEthManager.getSavedConfig();
+ for (int i = 0 ; i < Devs.length; i++) {
+ if (Devs[i].equals(mEthInfo.getIfName())) {
+ mDevList.setSelection(i);
+ break;
+ }
+ }
+ mIpaddr.setText(mEthInfo.getIpAddress());
+ mGw.setText(mEthInfo.getRouteAddr());
+ mDns.setText(mEthInfo.getDnsAddr());
+ mMask.setText(mEthInfo.getNetMask());
+ if (mEthInfo.getConnectMode().equals(EthernetDevInfo.ETHERNET_CONN_MODE_DHCP)) {
+ mIpaddr.setEnabled(false);
+ mDns.setEnabled(false);
+ mGw.setEnabled(false);
+ mMask.setEnabled(false);
+ } else {
+ mConTypeDhcp.setChecked(false);
+ mConTypeManual.setChecked(true);
+ mIpaddr.setEnabled(true);
+ mDns.setEnabled(true);
+ mGw.setEnabled(true);
+ mMask.setEnabled(true);
+ }
+ }
+ }
+ return 0;
+ }
+
+ private void handle_saveconf() {
+ EthernetDevInfo info = new EthernetDevInfo();
+ info.setIfName(mDevList.getSelectedItem().toString());
+ if (localLOGV)
+ Slog.v(TAG, "Config device for " + mDevList.getSelectedItem().toString());
+ if (mConTypeDhcp.isChecked()) {
+ info.setConnectMode(EthernetDevInfo.ETHERNET_CONN_MODE_DHCP);
+ info.setIpAddress(null);
+ info.setRouteAddr(null);
+ info.setDnsAddr(null);
+ info.setNetMask(null);
+ } else {
+ info.setConnectMode(EthernetDevInfo.ETHERNET_CONN_MODE_MANUAL);
+ info.setIpAddress(mIpaddr.getText().toString());
+ info.setRouteAddr(mGw.getText().toString());
+ info.setDnsAddr(mDns.getText().toString());
+ info.setNetMask(mMask.getText().toString());
+ }
+ mEthManager.updateDevInfo(info);
+ if (mEnablePending) {
+ mEthManager.setEnabled(true);
+ mEnablePending = false;
+ }
+ }
+
+ public void onClick(DialogInterface dialog, int which) {
+ switch (which) {
+ case BUTTON_POSITIVE:
+ handle_saveconf();
+ break;
+ case BUTTON_NEGATIVE:
+ //Don't need to do anything
+ break;
+ default:
+ Slog.e(TAG,"Unknow button");
+ }
+ }
+
+ public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
+
+ }
+
+ public void onNothingSelected(AdapterView<?> parent) {
+
+ }
+
+ public void onClick(View v) {
+
+ }
+
+ public void updateDevNameList(String[] DevList) {
+ if (DevList != null) {
+ ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(
+ getContext(), android.R.layout.simple_spinner_item, DevList);
+ adapter.setDropDownViewResource(
+ android.R.layout.simple_spinner_dropdown_item);
+ mDevList.setAdapter(adapter);
+ }
+
+ }
+
+ public void enableAfterConfig() {
+ mEnablePending = true;
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2010 The Android-x86 Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Author: Yi Sun <beyounn@gmail.com>
+ */
+
+package com.android.settings.ethernet;
+
+
+import static android.net.ethernet.EthernetManager.ETHERNET_STATE_DISABLED;
+import static android.net.ethernet.EthernetManager.ETHERNET_STATE_ENABLED;
+import static android.net.ethernet.EthernetManager.ETHERNET_STATE_UNKNOWN;
+
+import com.android.settings.R;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.NetworkInfo;
+import android.net.ethernet.EthernetManager;
+import android.preference.Preference;
+import android.preference.CheckBoxPreference;
+import android.text.TextUtils;
+import android.util.Config;
+import android.util.Slog;
+
+public class EthernetEnabler implements Preference.OnPreferenceChangeListener {
+ private static final boolean LOCAL_LOGD = true;
+ private static final String TAG = "SettingsEthEnabler";
+ //private final IntentFilter mEthStateFilter;
+ private Context mContext;
+ private EthernetManager mEthManager;
+ private CheckBoxPreference mEthCheckBoxPref;
+ private final CharSequence mOriginalSummary;
+ private EthernetConfigDialog mEthConfigDialog;
+
+ private final BroadcastReceiver mEthStateReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ if (intent.getAction().equals(EthernetManager.ETHERNET_STATE_CHANGED_ACTION)) {
+ handleEthStateChanged(
+ intent.getIntExtra(EthernetManager.EXTRA_ETHERNET_STATE,
+ EthernetManager.ETHERNET_STATE_UNKNOWN),
+ intent.getIntExtra(EthernetManager.EXTRA_PREVIOUS_ETHERNET_STATE,
+ EthernetManager.ETHERNET_STATE_UNKNOWN));
+ } else if (intent.getAction().equals(EthernetManager.NETWORK_STATE_CHANGED_ACTION)) {
+ handleNetworkStateChanged(
+ (NetworkInfo) intent.getParcelableExtra(EthernetManager.EXTRA_NETWORK_INFO));
+ }
+ }
+ };
+
+ public void setConfigDialog (EthernetConfigDialog Dialog) {
+ mEthConfigDialog = Dialog;
+ }
+
+ public EthernetEnabler(Context context, EthernetManager ethernetManager, CheckBoxPreference ethernetCheckBoxPreference) {
+ mContext = context;
+ mEthCheckBoxPref = ethernetCheckBoxPreference;
+ mEthManager = ethernetManager;
+
+ mOriginalSummary = ethernetCheckBoxPreference.getSummary();
+ ethernetCheckBoxPreference.setPersistent(false);
+ if (mEthManager.getState() == ETHERNET_STATE_ENABLED) {
+ mEthCheckBoxPref.setChecked(true);
+ }
+
+ /*
+ mEthStateFilter = new IntentFilter(EthernetManager.ETHERNET_STATE_CHANGED_ACTION);
+ mEthStateFilter.addAction(EthernetManager.NETWORK_STATE_CHANGED_ACTION);
+ */
+ }
+
+ public EthernetManager getManager() {
+ return mEthManager;
+ }
+
+ public void resume() {
+ mEthCheckBoxPref.setOnPreferenceChangeListener(this);
+ }
+
+ public void pause() {
+ // mContext.unregisterReceiver(mEthStateReceiver);
+ mEthCheckBoxPref.setOnPreferenceChangeListener(null);
+ }
+
+ public boolean onPreferenceChange(Preference preference, Object newValue) {
+ setEthEnabled((Boolean)newValue);
+ return false;
+ }
+
+ private void setEthEnabled(final boolean enable) {
+
+ int state = mEthManager.getState();
+
+ Slog.i(TAG,"Show configuration dialog " + enable);
+ // Disable button
+ mEthCheckBoxPref.setEnabled(false);
+
+ if (state != ETHERNET_STATE_ENABLED && enable) {
+ if (mEthManager.isConfigured() != true) {
+ // Now, kick off the setting dialog to get the configurations
+ mEthConfigDialog.enableAfterConfig();
+ mEthConfigDialog.show();
+ } else {
+ mEthManager.setEnabled(enable);
+ }
+ } else {
+ mEthManager.setEnabled(enable);
+ }
+
+ mEthCheckBoxPref.setChecked(enable);
+ // Disable button
+ mEthCheckBoxPref.setEnabled(true);
+ }
+
+ private void handleEthStateChanged(int ethState, int previousEthState) {
+
+ }
+
+ private void handleNetworkStateChanged(NetworkInfo networkInfo) {
+ if (LOCAL_LOGD) {
+ Slog.d(TAG, "Received network state changed to " + networkInfo);
+ }
+ }
+
+ private boolean isEnabledByDependency() {
+ Preference dep = getDependencyPreference();
+ if (dep == null) {
+ return true;
+ }
+
+ return !dep.shouldDisableDependents();
+ }
+
+ private Preference getDependencyPreference() {
+ String depKey = mEthCheckBoxPref.getDependency();
+ if (TextUtils.isEmpty(depKey)) {
+ return null;
+ }
+
+ return mEthCheckBoxPref.getPreferenceManager().findPreference(depKey);
+ }
+
+ private static String getHumanReadableEthState(int wifiState) {
+ switch (wifiState) {
+ case ETHERNET_STATE_DISABLED:
+ return "Disabled";
+ case ETHERNET_STATE_ENABLED:
+ return "Enabled";
+ case ETHERNET_STATE_UNKNOWN:
+ return "Unknown";
+ default:
+ return "Some other state!";
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2010 The Android-x86 Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Author: Yi Sun <beyounn@gmail.com>
+ */
+
+package com.android.settings.ethernet;
+
+import static android.net.ethernet.EthernetManager.ETHERNET_DEVICE_SCAN_RESULT_READY;
+
+import com.android.settings.R;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.net.NetworkInfo;
+import android.net.NetworkInfo.DetailedState;
+import android.net.NetworkInfo.State;
+import android.net.ethernet.EthernetManager;
+import android.os.Handler;
+import android.os.Message;
+import android.provider.Settings;
+import android.text.TextUtils;
+import android.util.Config;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+public class EthernetLayer {
+ private static final String TAG = "EthernetLayer";
+
+ private EthernetManager mEthManager;
+ private String[] mDevList;
+ private EthernetConfigDialog mDialog;
+
+ EthernetLayer (EthernetConfigDialog configdialog) {
+ mDialog = configdialog;
+ }
+
+ private BroadcastReceiver mReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ final String action = intent.getAction();
+ if (action.equals(EthernetManager.ETHERNET_DEVICE_SCAN_RESULT_READY)) {
+ handleDevListChanges();
+ }
+ }
+ };
+
+ private void handleDevListChanges() {
+ mDevList = mEthManager.getDeviceNameList();
+ mDialog.updateDevNameList(mDevList);
+ }
+}