Android6.0添加获取当前连接wifi的密码接口

  • Post author:
  • Post category:其他

Android6.0应用通过WifiManager的getConfiguredNetworks()方法获取 WifiConfiguration时,WifiConfiguration获取到的wifi密码是星号。 如果要让应用能够获取到明文的密码,需要做一下修改。

 1.首先在frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiStateMachine.java中添加public List<WifiConfiguration> getWifiConfigurationwithpassword()方法。这个方法调用WifiConfigStore.getPrivilegedConfiguredNetworks()返回可以获取明文密码的WifiConfiguration实例。

--- a/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/frameworks/opt/net/wifi/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -2265,6 +2265,15 @@ public class WifiStateMachine extends StateMachine implements WifiNative.WifiPno
         return result;
     }
 
+
+	public List<WifiConfiguration> getWifiConfigurationwithpassword(){
+		if(mWifiConfigStore != null){
+			List<WifiConfiguration> result &

版权声明:本文为qq503393230原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。