Galaxy Note-当使用WPA2打开wifi连接时,Android操作系统崩溃(不是应用程序)
下面的方法Galaxy Note-当使用WPA2打开wifi连接时,Android操作系统崩溃(不是应用程序),android,android-wifi,wifimanager,wifi,Android,Android Wifi,Wifimanager,Wifi,下面的方法enablehost适用于开放式网络,但如果我使用这些未注释的配置设置WPA2网络,wifi连接将保持开启约10秒,并且没有执行任何其他操作或触摸屏幕,操作系统崩溃,我会看到一个黑屏。3秒钟后,wifi连接被禁用,应用程序关闭 如果我在Galaxy Tab 7“或中文设备上运行相同的进程,设备将自行重新启动 以下是上述方法: public static void enableHotspot(String networkSSID,String networkPass, Context c
enablehost
适用于开放式网络,但如果我使用这些未注释的配置设置WPA2网络,wifi连接将保持开启约10秒,并且没有执行任何其他操作或触摸屏幕,操作系统崩溃,我会看到一个黑屏。3秒钟后,wifi连接被禁用,应用程序关闭
如果我在Galaxy Tab 7“或中文设备上运行相同的进程,设备将自行重新启动
以下是上述方法:
public static void enableHotspot(String networkSSID,String networkPass, Context context){
// Enable tethering
WifiConfiguration config = new WifiConfiguration();
config.SSID = networkSSID;
//WPA2
config.hiddenSSID = true;
config.preSharedKey = quoteNonHex(networkPass, 64);
config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
config.allowedProtocols.set(WifiConfiguration.Protocol.RSN); // For WPA2
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP); //this needs a server radius
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
//Simpler WPA2
//config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK);
//config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
//config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
//OPEN
//config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
WifiApManager wapm = new WifiApManager(context);
wapm.setWifiApEnabled(config, true);
Log.d("","Wifi Tethering is enabled.");
}
private static String quoteNonHex(String value, int... allowedLengths) {
return isHexOfLength(value, allowedLengths) ? value : convertToQuotedString(value);
}
private static boolean isHexOfLength(CharSequence value, int... allowedLengths) {
if (value == null || !HEX_DIGITS.matcher(value).matches()) {
return false;
}
if (allowedLengths.length == 0) {
return true;
}
for (int length : allowedLengths) {
if (value.length() == length) {
return true;
}
}
return false;
}
更新1
以下是按我的应用程序名称过滤的日志,单击卡片按钮的正是启用热点
开始执行的位置:
04-25 16:43:10.610: I/SalesTest.activity.SalesCheckout(12526): Clicked on Card Button
04-25 16:43:10.710: D/(12526): Wifi Tethering is enabled.
04-25 16:43:10.840: D/dalvikvm(12526): GC_CONCURRENT freed 1709K, 35% free 32659K/49991K, paused 1ms+3ms
04-25 16:43:34.805: I/ActivityThread(12526): Removing dead content provider: settings
04-25 16:43:36.060: E/InputQueue-JNI(12526): channel 'xxxx' ~ Publisher closed input channel or an error occurred. events=0x8
04-25 16:43:36.060: E/InputQueue-JNI(12526): channel 'xxxx' ~ Publisher closed input channel or an error occurred. events=0x8
04-25 16:43:36.060: E/InputQueue-JNI(12526): channel 'xxxx' ~ Publisher closed input channel or an error occurred. events=0x8
04-25 16:43:36.060: E/InputQueue-JNI(12526): channel 'xxxx' ~ Publisher closed input channel or an error occurred. events=0x8
04-25 16:43:36.060: E/InputQueue-JNI(12526): channel 'xxxx' ~ Publisher closed input channel or an error occurred. events=0x8
04-25 16:43:36.065: E/InputQueue-JNI(12526): channel 'xxxx' ~ Publisher closed input channel or an error occurred. events=0x8
04-25 16:43:36.065: E/InputQueue-JNI(12526): channel 'xxxx' ~ Publisher closed input channel or an error occurred. events=0x8
04-25 16:43:36.065: E/InputQueue-JNI(12526): channel 'xxxx' ~ Publisher closed input channel or an error occurred. events=0x8
04-25 16:43:36.065: E/InputQueue-JNI(12526): channel 'xxxx' ~ Publisher closed input channel or an error occurred. events=0x8
04-25 16:43:36.065: E/InputQueue-JNI(12526): channel 'xxxx' ~ Publisher closed input channel or an error occurred. events=0x8
这是完整的日志,请注意系统进程中的***致命异常
:
04-25 16:43:10.610: I/testSalesactivity.SalesCheckout(12526): Clicked on Card Button
04-25 16:43:10.625: I/power(8588): *** acquire_dvfs_lock : lockType : 1 freq : 1000000
04-25 16:43:10.625: I/ActivityManager(8588): START {intent.toShortString} from pid 12526
04-25 16:43:10.625: D/PowerManagerService(8588): acquireDVFSLockLocked : type : DVFS_MIN_LIMIT frequency : 1000000 uid : 1000 pid : 8588 tag : ActivityManager
04-25 16:43:10.625: W/ActivityManager(8588): mDVFSLock.acquire()
04-25 16:43:10.645: D/ActivityManager(8588): Trying to launch applicationName
04-25 16:43:10.660: I/SurfaceFlinger(1690): id=161(18) createSurface 0x33e6c (1x1),1 flag=0
04-25 16:43:10.660: D/PowerManagerService(8588): acquireWakeLock flags=0xa tag=KEEP_SCREEN_ON_FLAG uid=1000 pid=8588 myUID=1000 myPID=8588 myTID=8588
04-25 16:43:10.705: E/WifiService(8588): Invoking mWifiStateMachine.setWifiEnabled
04-25 16:43:10.705: D/WifiService(8588): setWifiApEnabled: allowWifiAp: true
04-25 16:43:10.710: D/(12526): Wifi Tethering is enabled.
04-25 16:43:10.710: D/WifiP2pService(8588): P2pDisabledState{ what=131203 when=-1ms }
04-25 16:43:10.720: E/WifiHW(8588): check .ccode.info
04-25 16:43:10.720: E/WifiHW(8588): /data/.ccode.info already exist!
04-25 16:43:10.720: E/WifiHW(8588): ====[WIFI]MODULE is semcove=====
04-25 16:43:10.725: D/com.android.internal.telephony.gsm.FastDormancyStateHelper(8782): onReceive() action=android.net.wifi.WIFI_AP_STATE_CHANGED
04-25 16:43:10.765: I/SurfaceFlinger(1690): id=162(19) createSurface 0x3ffe4 (800x1280),2 flag=400
04-25 16:43:10.765: V/PhoneStatusBar(8701): setLightsOn(true)
04-25 16:43:10.790: I/ClipboardServiceEx(8588): mCBPickerDialog enter case. MSG_DISMISS_DIALOG
04-25 16:43:10.840: D/dalvikvm(12526): GC_CONCURRENT freed 1709K, 35% free 32659K/49991K, paused 1ms+3ms
04-25 16:43:10.850: D/DEFERED_APP_VISIBILITY(8588): tweaking closing app
04-25 16:43:10.855: I/ActivityManager(8588): Displayed shortComponentName: +213ms
04-25 16:43:11.080: I/SurfaceFlinger(1690): id=160 Removed idx=2 Map Size=5
04-25 16:43:11.080: I/SurfaceFlinger(1690): id=160 Removed idx=-2 Map Size=5
04-25 16:43:11.080: I/power(8588): *** release_dvfs_lock : lockType : 1
04-25 16:43:11.080: D/PowerManagerService(8588): releaseDVFSLockLocked : all DVFS_MIN_LIMIT are released
04-25 16:43:11.080: W/ActivityManager(8588): mDVFSLock.release()
04-25 16:43:11.840: D/com.android.internal.telephony.gsm.FastDormancyStateHelper(8782): onReceive() action=android.net.conn.TETHER_STATE_CHANGED
04-25 16:43:11.840: D/Tethering(8588): sendTetherStateChangedBroadcast 1, 0, 0
04-25 16:43:11.840: E/MTPJNIInterface(10598): tethering status = false
04-25 16:43:11.855: D/Tethering(8588): InitialState.processMessage what=4
04-25 16:43:11.860: D/Tethering(8588): sendTetherStateChangedBroadcast 0, 0, 0
04-25 16:43:11.860: D/com.android.internal.telephony.gsm.FastDormancyStateHelper(8782): onReceive() action=android.net.conn.TETHER_STATE_CHANGED
04-25 16:43:11.865: E/MTPJNIInterface(10598): tethering status = false
04-25 16:43:11.870: D/SoftapController(8552): Softap fwReload - Ok
04-25 16:43:11.870: W/dalvikvm(8588): threadid=83: thread exiting with uncaught exception (group=0x40c721f8)
04-25 16:43:11.875: E/AndroidRuntime(8588): *** FATAL EXCEPTION IN SYSTEM PROCESS: Thread-127
04-25 16:43:11.875: E/AndroidRuntime(8588): java.lang.NullPointerException
04-25 16:43:11.875: E/AndroidRuntime(8588): at java.nio.charset.ModifiedUtf8.countBytes(ModifiedUtf8.java:75)
04-25 16:43:11.875: E/AndroidRuntime(8588): at java.nio.charset.ModifiedUtf8.encode(ModifiedUtf8.java:119)
04-25 16:43:11.875: E/AndroidRuntime(8588): at java.io.DataOutputStream.writeUTF(DataOutputStream.java:197)
04-25 16:43:11.875: E/AndroidRuntime(8588): at android.net.wifi.WifiApConfigStore.writeApConfiguration(WifiApConfigStore.java:187)
04-25 16:43:11.875: E/AndroidRuntime(8588): at android.net.wifi.WifiApConfigStore.access$400(WifiApConfigStore.java:47)
04-25 16:43:11.875: E/AndroidRuntime(8588): at android.net.wifi.WifiApConfigStore$ActiveState$1.run(WifiApConfigStore.java:118)
04-25 16:43:11.875: E/AndroidRuntime(8588): at java.lang.Thread.run(Thread.java:856)
04-25 16:43:11.880: E/android.os.Debug(8588): !@Dumpstate > dumpstate -k -t -n -z -d -o /data/log/dumpstate_sys_error
04-25 16:43:11.905: I/dumpstate(12661): Check if stand-alone
04-25 16:43:11.920: I/dumpstate(12661): begin
04-25 16:43:12.045: E/lights(8588): write_int: path /sys/devices/virtual/sec/sec_touchkey/brightness, value 2
04-25 16:43:12.045: W/PowerManagerService(8588): Timer 0x7->0x3|0x3
04-25 16:43:12.045: I/PowerManagerService(8588): Ulight 7->3|0
04-25 16:43:12.045: D/PowerManagerService(8588): setLightBrightness : mButtonLight : 0
04-25 16:43:12.055: E/DataRouter(1688): usb connection is true
04-25 16:43:12.055: E/DataRouter(1688): DSR is ON. Don't send DTR ON.
04-25 16:43:12.900: D/Tethering(8588): sendTetherStateChangedBroadcast 1, 0, 0
有人有过类似的问题吗?对发生的事情有什么线索吗
非常感谢当您使用反射调用setWifiApConfiguration的WifiManager方法时,ssid的WifiConfiguration参数不能为空,否则会导致一些电话系统设置入口,一些电话直接重启,您将看到以下llogcat中的og:
java.lang.NullPointerException
at java.nio.charset.ModifiedUtf8.countBytes(ModifiedUtf8.java:75)
at java.nio.charset.ModifiedUtf8.encode(ModifiedUtf8.java:119)
at java.io.DataOutputStream.writeUTF(DataOutputStream.java:197)
at android.net.wifi.WifiApConfigStore.writeApConfiguration(WifiApConfigStore.java:207)
at android.net.wifi.WifiApConfigStore.access$400(WifiApConfigStore.java:57)
at android.net.wifi.WifiApConfigStore$ActiveState$1.run(WifiApConfigStore.java:138)
at java.lang.Thread.run(Thread.java:848)
发布日志,我们需要查看崩溃的stacktrace。谢谢@StevenByle,请查看上面的更新1…Android SDK中没有WifiApManager
。那就是makes@Commonware,我是否可以使用另一个类来启用wifi连接?不。但是,我的观点是,当你使用未记录和不支持的东西时,它们将在某些设备和/或某些Android操作系统版本上中断。