Entering flight mode - best practices (RIL / TAPI etc) - Windows Mobile Development and Hacking General

Hi,
I am attempting to develop a program which must have good control over the state of the built in GPRS or CDMA unit of a Windows Mobile 2003 PDA device.
One requirement is to be able to enter “flight mode” on demand (when the user selects a menu option). The user can not select the connection manager notification and manually select the “enter flight mode” link as this is a fully locked down application (the user does not have access to it). Hence I am looking for ways to programmatically enter/leave/query the status of flight mode.
At present we are using Connection Manager to deal with connection management and RIL to deal with entering/leaving flight mode. In previous versions we used TAPI (the lineGetEquipmentState and lineSetEquipmentState functions) to enter/leave flight mode.
Both approaches (using RIL or TAPI) are causing us grief, mainly due to having to support numerous PDA devices from numerous OEMs.
How have other people approached entering a device into flight mode via code? I am interested in suggestions on the following issues we have having with various techniques, and wondering if anyone has a solution which works well across a wide range of devices (we support various Symbol, Intermec, HTC, HHP, and Panasonic devices to name a few).
Our current issues are as follows:
If using TAPI to enter flight mode:
On some devices such as the Intermec 760 after using lineSetEquipmentState to enter LINEEQUIPSTATE_MINIMUM, querying the state via lineGetEquipmentState only returns the error LINEERR_OPERATIONFAILED. Entering full power mode again means lineGetEquipmentState starts returning proper values again. However you can’t assume that lineGetEquipmentState returning LINERR_OPERATIONFAILED means being in flight mode as periodically some devices are returning this even while in full power mode (i.e. call it 5 times, three might return LINEERR_OPERATIONFAILED and the other two will return valid results).
Alternatively I have tried using the lineGetLineDevStatus function and checking flags within the returned dwDevStatusFlags field. For instance LINEDEVSTATUSFLAGS_CONNECTED or, LINEDEVSTATUSFLAGS_INSERVICE. Again in testing this on numerous devices (eg. Xda IIi and Intermec 760 for instance) both the connect and inservice fields appear to be constantly set, even if in a GPRS based devices there is no SIM card present.
If using RIL to enter flight mode:
We have also tried accessing RIL (using information from http://www.xda-developers.com/ was very helpful in using this “undocumented” API), via calling RIL_SetEquipmentState(RIL_EQSTATE_MINIMUM) and listening for RIL_NOTIFY_RADIOEQUIPMENTSTATECHANGED notifications to tell us when the radio enters/leaves various power states. The problem with this approach is that on some devices (in certain cases) we appear to never get a notification indicating that we have returned to FULL power mode, instead we get RIL_EQSTATE_UNKNOWN being constantly returned.
On one device using the RIL interface even appears to lock up the device (followed by a soft reset a couple of minutes later) while we attempt to enter flight mode by calling, RIL_Hangup, RIL_UnregisterFromNetwork and RIL_SetEquipmentState in that sequence.
I’m open to suggestions on how to enter flight mode via code. Does Microsoft provide an API to do this across all devices in a consistent manor? I guess from previous similar experiences that is wishing too much.
At present I am somewhat dubious about using the RIL interface to enter flight mode while also using Connection Manager at the same time to maintain a connection. At present before attempting to enter flight mode I’m calling ConnMgrReleaseConnection in order to try to tidy up Connection Manager’s state as much as possible, but is it possible that Connection Manager is still getting confused by me going in underneath it (via RIL) and “pulling the carpet out from underneath it”?
Thanks,
Christopher Fairbairn

Related

detect device radio state (flight mode)

My application needs to know if device has flight mode turned on (radio is shut down). The ExTAPI API, lineGetEquipmentState, works well for other PocketPc phone devices but fails frequently on M1000.
lineGetEquipmentState frequently fails with 80000048 (LINEERR_OPERATIONFAILED)
I have attached code snippet.
Pseudo code looks like
1, initialize with lineInitializeEx
2. look for phone device by calling lineGetDevCaps and then checking media mode for the line device is LINEMEDIAMODE_INTERACTIVEVOICE
3. negotiate version with lineNegotiateAPIVersion
4. negotiate extension version with lineNegotiateExtVersion
5. open line with lineOpen
6. get radio state with lineGetEquipmentState
7. close line with lineClose
8. shut it down with lineShutdown
Step 6 frequently fails with 8000048 (LINEERR_OPERATIONFAILED)
Any idea, clue why it fails.
Your response is highly appreciated

detect device flight mode

How can I detect if the device has flight mode turned on?
On phone devices it means radio is off.
On wifi devices it would mean wifi is turned off.
Thanks in advance,
Flightmode on means NO Radio.
Ie.: NO GSM, NO Bluetooth, NO WiFi.
On Himalaya there is a cross in that title-bar where normally the GSM signal strenth is shown. Also taping the GSM signal strength indicator shows whether or not youre in flight mode.
Take a look at the lineSetEquipmentState & lineGetEquipmentState in the SDK.
lineGetEquipmentState fails with LINEERR_OPERATIONFAILED
My application need to know if device has flight mode turned on (radio is shut down). The ExTAPI API, lineGetEquipmentState, works well for other PocketPc phone devices but fails frequently on XDAs and M1000.
lineGetEquipmentState frequently fails with 80000048 (LINEERR_OPERATIONFAILED)
Pseudo code looks like
1, initialize with lineInitializeEx
2. negotiate version with lineNegotiateAPIVersion for each line device
3. look for phone device by calling lineGetDevCaps and then checking media mode for the line device is LINEMEDIAMODE_INTERACTIVEVOICE
4. negotiate extension version with lineNegotiateExtVersion
5. open line with lineOpen
6. get radio state with lineGetEquipmentState
7. close line with lineClose
8. shut it down with lineShutdown
Step 6 frequently fails with 8000048 (LINEERR_OPERATIONFAILED)
Any idea, clue why it fails.
Your response is highly appreciated
Flight mode on Wifi devices
For non phone devices having wifi,
I tried looking for wifi line device by calling lineGetDevCaps and then checking media mode for LINEMEDIAMODE_DATAMODEM
Here all the line devices have this media mode.
Now when I call lineGetEquipmentState, it fails with LINEERR_OPERATIONUNAVAIL
I am still not sure how to detect flight mode is turned on on the wifi devices.
i´m using lineSetEquipmentState & lineGetEquipmentState on T-Mobil´s MDA 1, MDA 2 and MDA 3. Everything is working fine(On more then 40.000 Clients).
When you want to check FlightMode on MDA 3 for you WIFI Card you should use NDIS.
What do you mean by us NDIS?
I get the same errors on MDA III devices.
Yes, because you are using TAPI.
TAPI means Telephony Application Programming Interface and is not interessting when you would like to check WIFI.
NDIS means Network Driver Interface Specification and that is what you need.
Take a look at MSDN or the SDK.
Thanks
I have zero knowledge about NDIS, can you please give me starting pointers - relevant APIs.
Depands on what you would like to do.
Take a look at the NDIS faq.
http://www.ndis.com/faq/default.htm
I just want to check if the flight mode is turned on.

Atom problems - WiFi, ActiveSync, Hang, Drops

I dumped my three year old Sony Ericsson P800 for a sleek, chic O2 XDA Atom in March 2006.
It was a dream device and I enjoyed discovering myriad of features as this was my first PPC. My main usage is as a highly used phone (more than 6 hours per day on long conference calls) and PIM applications (calendar, contacts etc). I hardly play games, I only have Scrabble loaded. O2 Plus is my today plugin, I don't use any other. I have a 0.5 GB miniSD card on which I load podcasts or videos, though I watch rarely.
I started facing a number of problems that I haven't been able to solve:
1) If I set up the SETTINGS > SYSTEM > POWER > ADVANCED > ON BATTERY POWER TURN OFF DEVICE IF NOT USED FOR 2 MINUTES; it is supposed to turn off the screen. If a call or SMS comes it is supposed to come alive.
This never worked for me. Invariably the screen would fail to come back alive and I'd need to poke with stylus to Soft-Reset the device. As a result my screen was always on. Expectedly battery life was very very low. This is my biggest grouse.
2) The WiFi stopped working one day in July. It used to work very well and I was using Agile Messenger with my home network for few months. That day, it just crashed as I turned it on WiFi and surfed for sometime. The screen turned kind of white and a mix of colors. I tried a lot of things after that including flashing the May ROM, old ROM and so on. No avail. Nowadays if I turn WiFi on it may work for sometime. I may even be able to connect to O2-Connect or the web. But crash it will. And after that the WiFi option also sometimes disappears from the Wireless Manager. It reappears after a number of reboots. Practically WiFi has become unavailable.
3) Browsing using pass-through with ActiveSync using the Internet connection on laptop never worked for me. Tried many tweaks but never got it working.
4) 2 and 3 above mean I have no working Internet connection on my Atom. I used GSM dial-up networking through my ISP account. But it is so damn expensive. Haven't tried out GPRS yet (no idea how well Airtel's Mobile Office GPRS in Bangalore India will work with Atom).
5) Recently, I have been experiencing silence on my phone during calls where I can't hear the other people talking whereas they can hear me. I tested dialing into same conference with Atom and another Nokia set. On the Nokia there weren't any silences while my Atom had multiple silences of couple of minutes each. This has made my Atom practically useless for the phone function.
I'd be very happy to try out any suggestions that you may have. Before I totally give up on it.
XDA Atom
ROM:20060426B1WWE
RADIO:R060428N_MN1ARC_RS00049
ExtROMEX0018
upgrade to 0822 RadioRom which you can find in the Upgrade part of this Atom forum, and see if there will be any improvement.
Wi-fi Shut-off when we do the first activesync.
I tried closing all programs by going to settings => memory => running programs => close all.
After that I did the soft reset and started the process "Start => Settings => Connections => WiFi Utility => Menu => Turn on WiFi.
Menu => Jump to Network Cards 3. Under Wireless, select your desired network. (If your network is hidden, kindly tap on "Add New")
Enter your network name (if needed), proceed to Network Key.
Select your Authentication, Data Encryption type and your Network key.
Proceed to 802.1x if needed (it is usually disabled)
Tap on Ok, go to Network Adapters => O2 Wi-Fi Wireless Adapter
Configure your IP and Name Server if needed. (If your network allows automatic assign, you might want to exclude this portion)
Tap on Ok, Ok. Proceed to WiFi Status, check if the status is Connected and IP Address is obtained.
Kindly try to use Internet Explorer to surf the internet"
and started the Wi-fi but it would not go on it showed Wi-fi off instead of the routine radio off.
When if went to Wi-fi => about. It showed Driver: Wi-fi not enabled, Firmware Version: Wi-fi not enabled, MAC Address: Wi-fi not enabled.
I tried the hard reset also yet the Wi-fi would not turn on.
So I reinstalled latest version 20060426-mot0822 of the Atom and before I did activesync I ran the Wi-fi and it worked well . After the first Activesync the same problem started.
For Activesync I am using the new version 4.5.0, Build 5059, Beta taken from the Microsoft site where it has the facility to keep on the Allow wireless connection on device when connected to the desktop yet the Wi-fi switches off.
There seems to be a problem with you software and your technical department needs to study it deeply and provide a suitable solution for it

GPS Works Once (No GPS reconnect for 50 minutes)

After obtaining a fix, and then disconnecting manually or automatically (via an app closure) I have to start the gps again within 10 seconds in airplane mode or 25 seconds out of airplane mode to reconnect. If I dont reconnect within this time frame it will not reconnect for about 40-50 minutes. Rebooting or shutting down does not help. This renders the gps specific functions of the phone useless. This does not impact the location services provided by other chips i.e. wifi, cdma (3g data).
If sats are only in view and no more than two are in use (a fix has not been obtained). You can end the session and restart it anytime without a reboot.
This test was actioned in and out of airplane mode but never connected to the network i.e only searching for the network. Its unlikely being connected to the network would impact the outcome of these tests. If you wish to test your own device you should download and use GPS test from the app store. Having or not having AGPS data has no impact on the tests outcome.
From reviewing the logs and assuming this is not a hardware issue my supposition is it appears that when an active gps session with a fix is closed the device does a gps_cleanup. Upon reconnecting it attemps to call back this session against cache that no longer exists. After about 50 minutes a new session is initiated. This problem is somewhat highlighted in this example code. https://github.com/android/platform_frameworks_base/commit/0a5098106c116f2b67c9e77e4ec0afbc92acd61c
I would also be interested in some insight into the cache cleanup commands in the gps.conf script file for this device. It appears GPS1_ CLEANUP_ENABLED=0 does not appear to work for this device. This example was pulled from another example http://forum.xda-developers.com/showthread.php?t=1338486 for another brand so maybe the commands are different with each device. I am also unsure if the gps.conf is read/executed too, per boot/ session/ agps call etc. I'm also unsure which permissions should be set.
I have also attached some log files of the various operations along with a copy of the GPS conf/ system files. In addition I have also noticed cleanup errors when im having problems getting a fix including status 9 errors and wrong prn errors too, I have no idea what these are.
I have already factory reset the phone without success and tried other roms. I do not believe this is a hardware error as it wouldn't function in the first instance.
Any insight would be appreciated.
Peter
Samsung R720
Android 2.3.4 Gingerbread
Log Details
B1 - It finds some sats but I intentionally terminate the session.
B2 - I then restart it. It finds sats again and gets a fix.
B3 - A continuation of B2 but it is terminated manually. A2 would occur next.
A1 - Reconnects at end of the long searching/ downtime period (50 minutes) and gets a fix. I'm not sure why it starts working at this point or what triggers this and im not sure if it´s captured in the log.
A2 - This attempts to reconnect to the previous session via a callback but it fails even though the session is ongoing.

Persistent Bluetooth / NFC in Airplane mode

Hi all,
On my previous device (gt-i9502 dual sim Galaxy S4), I used a ROM in which you could find a setting to keep bluetooth enabled all the time, even when switching on the airplane mode. I was expecting that rooting my Yotaphone 2 would let me get that behavior again (out of the box, the bluetooth gets switched off when enabling airplane mode, which is, after all, the goal of airplane mode, but happens to be a pain when you use an Android Wear watch).
I've googled a bit for a solution, either an utility or customized setting app, and I found a very simple hack that I thought I'd share here in case other Yotaphone 2 users like me want this behavior:
What you need is:
1) a rooted Yotaphone 2
2) an sqlite database editor that can access system databases on rooted phones (I used Sqlite Editor by Speed Software, which is nice but not free, you can certainly find a freeware equivalent).
In your sqlite editor, look for the following file:
/data/data/com.android.providers.settings/databases/settings.db
When you open this file, in the "global" database, you'll find the two fields that we want to look at:
airplane_mode_radios
cell,bluetooth,wifi,nfc,wimax
airplane_mode_toggleable_radios
bluetooth,wifi,nfc
What this means is that by default, switching the airplane mode on/off will switch the cellular, bluetooth, wifi/wimax and nfc radios in the phone (in the airplane_mode_radio field) and that when airplane mode is activated, you can still manually re-enable bluetooth, wifi or nfc (airplane_mode_toggleable_radios field).
I use a nfc sticker on my bedstand, programmed as a shortcut to switch in and out of airplane mode, so in my case I simply modified the airplane_mode_radios field to remove bluetooth and nfc:
Edited airplane_mode_radios
cell,wifi,wimax
Kudos to cdl for the initial post on AndroidForums (http://androidforums.com/threads/ho...when-enabling-disabling-airplane-mode.659825/)

Categories

Resources