WIFI 状态栏显示的wifi信号强度与wifisetting列表不一致

[DESCRIPTION]
状态栏显示的wifi信号强度与wifisetting列表不一致(不同步)

[ANALYSIS]
1、apk都是接收RSSI_CHANGED intent,并调用WifiManager.calculateSignalLevel()方法计算信号个数
2、WifiSettings界面和状态栏的调用点分别是AccessPoints.java和NetworkController(Gemini).java,可以看到两个地方所传给WifiManager.calculateSignalLevel()的level值不同,一个是4一个是5,所以计算下来有可能格数不一致
3、当处于WifiSettings列表界面时,会6s钟刷新一次信号,定义在WifiSettings.WIFI_RESCAN_INTERVAL_MS
4、状态条刷新的时间是3s,定义在wifiStatemachine.java中(POLL_RSSI_INTERVAL_MSECS),若信号变化会丢RSSI_CHANGE出来
 
[SOLUTION]
1、把两边的level都改成5级(注意数组不要越界)
2、在wifiSettings接受RSSI_CHANGED消息,之后调用updateAccesspoint把界面和状态条同步更新
3、需要注意的是,假定两边的rssi值一个是-69、一个是-66,送给WifiManager.calculateSignalLevel()的计算值会有区别:
31 × 4 / 45 = 124 / 45 = 2.xxx
34 × 4 / 45 = 136 / 45 = 3.xxx
这种情况下可以按rssi范围返回level值,减少浮点数转int带来的误差,比如:
if(rssi 在-55和-65之间)返回4
if(rssi 在-65和-75之间)返回xxx


【MODIFY:】
按照MTK给的方案进行了修改,另外还加了一些字符串数组的修改:

--------------- apps/Settings/res/drawable/wifi_signal_lock.xml ---------------
index 2ad6d91..f7953d2 100644
@@ -15,9 +15,12 @@
 -->

 
-    
-    
-    
-    
+    
+    
+    
+    
+    
+    
+    
 


--------------- apps/Settings/res/drawable/wifi_signal_open.xml ---------------
index b506dd3..44dfb9b 100644
@@ -15,9 +15,12 @@
 -->

 
-    
-    
-    
-    
+    
+    
+    
+    
+    
+    
+    
 


------------------ apps/Settings/res/values-zh-rCN/arrays.xml
------------------
index 4f92ef6..19e6bb8 100644
@@ -122,12 +122,16 @@
     "1 小时"
     "永不超时"
   
+  
+    
   
+    "极弱"
     "弱"
     "一般"
     "较强"
     "强"
   
+    
   
     "始终"
     "仅限充电时"

--------------------- apps/Settings/res/values/arrays.xml ---------------------
index bf83879..c0a5f08 100644
@@ -358,12 +358,15 @@

      
     
+
     
+        Poorest
         Poor
         Fair
         Good
         Excellent
     
+

     
     

--------- apps/Settings/src/com/android/settings/wifi/AccessPoint.java
---------
index d30be9d..5ca64b0 100644
@@ -371,13 +371,16 @@ class AccessPoint extends Preference {
         if (mRssi == Integer.MAX_VALUE) {
             return -1;
         }
+
+        //modify by BW_APP_zengdakui for bug(39969) .start
         /**[Add/Comment] by BW_APP [wangyao] for [39862 wifi signal cts
failed.] --start*/
         if (SystemProperties.getBoolean("ro.bw.show_huawei_wifi", false)) {
-            return WifiManager.calculateSignalLevelCustom(mRssi, 4);
+            return WifiManager.calculateSignalLevelCustom(mRssi, 5);
         } else {
-            return WifiManager.calculateSignalLevel(mRssi, 4);
+            return WifiManager.calculateSignalLevel(mRssi, 5);
         }
         /**[Add/Comment] by BW_APP [wangyao] for [39862 wifi signal cts
failed.] --end*/
+        //modify by BW_APP_zengdakui for bug(39969) .end
     }

     WifiConfiguration getConfig() {

-------- apps/Settings/src/com/android/settings/wifi/WifiSettings.java --------
index c668a1c..2813aed 100644
@@ -1111,6 +1111,9 @@ public class WifiSettings extends
SettingsPreferenceFragment
             }
         } else if (WifiManager.RSSI_CHANGED_ACTION.equals(action)) {
             updateConnectionState(null);
+            //modify by BW_APP_zengdakui for bug(39969) .start
+            updateAccessPoints(); 
+            //modify by BW_APP_zengdakui for bug(39969) .end
         } else if (WifiManager.NO_CERTIFICATION_ACTION.equals(action)) { 
             /// M: show error message @{
             String apSSID = "";

------- apps/Settings/src/com/android/settings/wifi/p2p/WifiP2pPeer.java
-------
index d05c9a3..eb169ee 100644
@@ -39,8 +39,9 @@ public class WifiP2pPeer extends Preference {

     private int mRssi;
     private ImageView mSignal;
-
-    private static final int SIGNAL_LEVELS = 4;
+//modify by BW_APP_zengdakui for bug(39969) .start
+    private static final int SIGNAL_LEVELS = 5;
+//modify by BW_APP_zengdakui for bug(39969) .end

     public WifiP2pPeer(Context context, WifiP2pDevice dev) {
         super(context);

你可能感兴趣的:(工作记录)