简体   繁体   English

WP7如何在设备上调试飞机模式?

[英]WP7 How to debug airplane mode on device?

Is there a way to debug airplane mode on the device? 有没有办法在设备上调试飞机模式? I tried turning airplane mode on in the device settings and disabling the internet connection on my computer, but NetworkInterface.GetIsNetworkAvailable() still returns true. 我尝试在设备设置中启用飞行模式并禁用计算机上的互联网连接,但NetworkInterface.GetIsNetworkAvailable()仍然返回true。 Am I doing something wrong? 难道我做错了什么?

Notice the comment on the bottom of the official doc : 请注意官方文档底部的注释:

This API will always return true on the Windows Phone 7 emulator. 此API将始终在Windows Phone 7模拟器上返回true。 Testing therefore requires a facade, mock or conditional chunk of code. 因此,测试需要外观,模拟或条件代码块。

I just tested this on an actual device and indeed, it returns a constant true . 我刚刚在一个实际的设备上测试了它,实际上,它返回一个常量true

However, the thing is - it is all because you keep your phone connected to the PC and the Ethernet interface is available. 然而,问题在于 - 这完全是因为您将手机连接到PC并且以太网接口可用。 Once you disconnect the phone and start the app, you will see that a False will be returned. 断开手机并启动应用程序后,您将看到将返回False。

It's possible that WiFi and/or Bluetooth weren't disabled. WiFi和/或蓝牙可能未被禁用。 This might cause GetIsNetworkAvailable() to return true. 这可能导致GetIsNetworkAvailable()返回true。 According to this page : 根据这个页面

While you're in Airplane mode, you can still turn your phone's Wi-Fi and Bluetooth on and off separately. 当您处于飞行模式时,您仍然可以单独打开和关闭手机的Wi-Fi和蓝牙。

Maybe the assumption the device is making is that you probably only want to turn of Cellular access automatically, and Bluetooth/WiFi separately. 也许设备正在做的假设是你可能只想自动转动蜂窝接入,而单独使用蓝牙/ WiFi。

You can check what kind of interface is available: NetworkInterfaceType 您可以检查可用的接口类型: NetworkInterfaceType

NetworkInterfaceType.MobileBroadbandCdma:
NetworkInterfaceType.MobileBroadbandGsm

These should be disabled. 这些应该被禁用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM