4.4设置增加租约时间显示

2018-06-13  本文已影响0人  小磊长江大
diff --git a/res/values-zh-rCN/arrays.xml b/res/values-zh-rCN/arrays.xml
index f7ad187..c7879db 100755
--- a/res/values-zh-rCN/arrays.xml
+++ b/res/values-zh-rCN/arrays.xml
@@ -60,12 +60,20 @@
     <item msgid="9002737361305019353">"10 分钟"</item>
     <item msgid="4322676235684793329">"30 分钟"</item>
   </string-array>
-  <string-array name="network_status_entries">
+  <string-array name="network_status_entries_dhcp">
    <item>IP 地址</item>
    <item>子网掩码</item>
    <item>网关</item>
    <item>域名系统(DNS)</item>
    <item>Mac 地址</item>
+   <item>租约时间</item>
+  </string-array>
+  <string-array name="network_status_entries">
+        <item>IP 地址</item>
+        <item>子网掩码</item>
+        <item>网关</item>
+        <item>域名系统(DNS)</item>
+        <item>Mac 地址</item>
   </string-array>
   <string-array name="entries_font_size">
     <item msgid="8166647333858618801">"小"</item>
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index 405d3f7..0f96a74 100755
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -59,6 +59,15 @@
         <item>30 minutes</item>
         <item>"Never timeout"</item>
     </string-array>
+    <string-array name="network_status_entries_dhcp">
+        <item>IP Adddress</item>
+        <item>Subnet Mask</item>
+        <item>Gateway</item>
+        <item>DNS</item>
+        <item>Mac Address</item>
+        <item>Lease Time</item>
+    </string-array>
+   
     <string-array name="network_status_entries">
         <item>IP Adddress</item>
         <item>Subnet Mask</item>
diff --git a/src/com/android/settings/NetworkStatus.java b/src/com/android/settings/NetworkStatus.java
index 177cd3a..307d2df 100755
--- a/src/com/android/settings/NetworkStatus.java
+++ b/src/com/android/settings/NetworkStatus.java
@@ -100,7 +100,7 @@ public class NetworkStatus extends Fragment implements
         mListContainer = mRootView.findViewById(R.id.list_view);
         ListView lv = (ListView) mListContainer.findViewById(R.id.listview);
         Resources res =getResources();
-        netstatusname = res.getStringArray(R.array.network_status_entries);
+        netstatusname = res.getStringArray(R.array.network_status_entries_dhcp);
         mListView =lv;
         // this tmpinfo array should be wifi status info,now have no idea to get wifi info,so set null at present
         String ip_address = null;
@@ -108,6 +108,7 @@ public class NetworkStatus extends Fragment implements
         String gate_way = null;
         String dns = null;
         String mac_address = null;
+        String lease_time = null;
         mac_address = getWifiMacAddress();
         String [] tmpinfo;
         String wifi_dev_status = getIfDevStatus(WIFI_DEV_STATUS);
@@ -118,9 +119,10 @@ public class NetworkStatus extends Fragment implements
                 subnet_mask = NetworkUtils.intToInetAddress(dinfo.netmask).getHostAddress();
                 gate_way = NetworkUtils.intToInetAddress(dinfo.gateway).getHostAddress();
                 dns = NetworkUtils.intToInetAddress(dinfo.dns1).getHostAddress();
+                lease_time = String.valueOf(dinfo.leaseDuration);
             }
         }
-        tmpinfo = new String[] {ip_address, subnet_mask, gate_way, dns, mac_address};
+        tmpinfo = new String[] {ip_address, subnet_mask, gate_way, dns, mac_address, lease_time};
         NetStatusAdapter netStatusAdapter = new NetStatusAdapter(getActivity(), netstatusname, tmpinfo);
         mListView.setAdapter(netStatusAdapter);
         mTabHost = (TabHost) inflater.inflate(R.layout.network_status_tabhost, container, false);
@@ -170,6 +172,10 @@ public class NetworkStatus extends Fragment implements
     public void onTabChanged(String tabId) {
         try {
             String []statusinfo = showCurrentTab();
+            if(statusinfo.length == 5)
+              netstatusname = getResources().getStringArray(R.array.network_status_entries);
+            else
+              netstatusname = getResources().getStringArray(R.array.network_status_entries_dhcp);
             NetStatusAdapter netStatusAdapter = new NetStatusAdapter(getActivity(), netstatusname, statusinfo);
             mListView.setAdapter(netStatusAdapter);
         } catch (Exception e) {
@@ -196,6 +202,7 @@ public class NetworkStatus extends Fragment implements
         String wifi_dev_status = getIfDevStatus(WIFI_DEV_STATUS);
         String pppoe_dev_status = getIfDevStatus(PPPOE_DEV_STATUS);
         String statusinfo[];
+        String lease_time = null;
         EthernetDevInfo info = mEthManager.getSavedEthConfig();
         statusinfo  = new String[] {null,null,null,null,null};
         if (TAB_WIFI.equalsIgnoreCase(tabId)) {
@@ -207,9 +214,10 @@ public class NetworkStatus extends Fragment implements
                     subnet_mask = NetworkUtils.intToInetAddress(dinfo.netmask).getHostAddress();
                     gate_way = NetworkUtils.intToInetAddress(dinfo.gateway).getHostAddress();
                     dns = NetworkUtils.intToInetAddress(dinfo.dns1).getHostAddress();
+                    lease_time = String.valueOf(dinfo.leaseDuration);
                 }
             }
-            statusinfo = new String[] {ip_address, subnet_mask, gate_way, dns, mac_address};
+            statusinfo = new String[] {ip_address, subnet_mask, gate_way, dns, mac_address, lease_time};
         } else if (TAB_ETHNET.equalsIgnoreCase(tabId)) {
             mac_address = readMacAddress();
             if("up".equals(ethernet_dev_status) &&
@@ -222,8 +230,9 @@ public class NetworkStatus extends Fragment implements
                     subnet_mask = NetworkUtils.intToInetAddress(dinfo.netmask).getHostAddress();
                     gate_way = NetworkUtils.intToInetAddress(dinfo.gateway).getHostAddress();
                     dns = NetworkUtils.intToInetAddress(dinfo.dns1).getHostAddress();
+                    lease_time = String.valueOf(dinfo.leaseDuration);
                 }
-                statusinfo = new String[] {ip_address, subnet_mask, gate_way, dns, mac_address};
+                statusinfo = new String[] {ip_address, subnet_mask, gate_way, dns, mac_address, lease_time};
             } else if("up".equals(ethernet_dev_status) &&
                     info.getConnectMode().equals(EthernetDevInfo.ETH_CONN_MODE_MANUAL)) {
                 Log.d(TAG, "----------connected mode:manual");
@@ -248,9 +257,10 @@ public class NetworkStatus extends Fragment implements
                     subnet_mask = NetworkUtils.intToInetAddress(dinfo.netmask).getHostAddress();
                     gate_way = NetworkUtils.intToInetAddress(dinfo.gateway).getHostAddress();
                     dns = NetworkUtils.intToInetAddress(dinfo.dns1).getHostAddress();
+                    lease_time = String.valueOf(dinfo.leaseDuration);
                 }
             }
-            statusinfo = new String[] {ip_address, subnet_mask, gate_way, dns, mac_address};
+            statusinfo = new String[] {ip_address, subnet_mask, gate_way, dns, mac_address, lease_time};
         } else if (TAB_IPV6.equalsIgnoreCase(tabId)) {
             mac_address = readMacAddress();
             Log.d(TAG,"----------------ipv6 status");
上一篇下一篇

猜你喜欢

热点阅读