Cell Tower Location doesn't work well

Post your questions and help other users.

Moderator: Martin

Post Reply
kholdstayr
Posts: 6
Joined: 24 Oct 2017 01:57

Cell Tower Location doesn't work well

Post by kholdstayr » 28 Oct 2017 16:54

I really like Automagic but I was wondering if it would be possible to improve cell tower detection in future updates? Compared to Tasker and Automate for instance, the cell tower triggering is not as good.

First I'll mention Tasker. Tasker has workaround options just like Automagic does, since newer Android versions don't always allow constant cell tower updates when the screen is off. I wanted to mention a couple things I've noticed about Tasker that I haven't been able to get to work in Automagic. On my phone, which is a Samsung Galaxy J7 with Android 7.0, the modern method to query cell towers DOES work in Tasker. However, with Automagic, if I try to use the modern cell tower method, it DOES NOT work. I'm wondering if there may be a bug with the implementation of it in Automagic?

In addition, with Tasker I've found that using cell tower triggering does not work well when the screen is off, despite the work arounds that Tasker provides. However, I did find one method that works 100% of the time so far in my own personal testing. In Tasker, besides normal profile triggering from cell tower location changes, you can trigger off of the %CELLID variable being updated. I don't know how Tasker implements this internally vs the cell tower trigger, but I found that triggering via the %CELLID variable works all the time. In Tasker when the screen is off, it will only poll this variable via the main "screen off" timer which by default is set to 10 minutes. I find that if I drive to or from work, every 10 minutes Tasker will trigger with this variable updating showing that the cell tower connection has changed. If I just do a normal cell tower location trigger with Tasker I don't get these updates with the screen off. So somehow Tasker is doing a different polling method with the %CELLID variable monitoring that still lets it work with the screen off.

I also wanted to briefly mention the Automate app. Automate does something interesting that I haven't seen yet in other automation apps. In Automate, even with GPS/location off, wifi off, and mobile internet off, Automate is able to show me multiple cell tower locations when I query local cell towers. I have no idea how it does that since Tasker will only find 1 tower at a given time. If I query Automate from my home it will show 4 nearby towers at any given time. if I drive around then those towers will update to new ones. The only problem with this is that Automate is still poor at triggering on these updates if the screen is off.

In conclusion, the only truly reilable method I have found for cell tower location updates so far is to monitor the %CELLID variable changing in Tasker, which by default occurs every 10 minutes if the screen is off. That level of timing is good enough for me and hasn't been bad on the battery so far.

In Automagic I haven't been able to get it to update when the screen is off with the "wake device" and "force updates" option checked. I haven't tried the "screen on" workaround because I don't want my screen to come on in order to get the updates. I am wondering if there is a way to implement Tasker's CELLID polling in Automagic? I tried to use a 10 minute wake device timer in Automagic along with a decision block that checks cell location, and in parallel to that I had a sleep block with the keep device awake flag set. That still won't provide updates when the screen is off. I found that the decision block is able to poll the tower, but the connected cell tower information doesn't change until I turn my screen on. It will just show the same cell phone being connected until I turn the screen on. I have the cell tower locations being logged to a text file so I can check them and compare them all.

** EDIT **

I've now found a way to get reliable updates from Automate as well. In Automate, there is a "Cell Tower Near" block. You can set the block to "When changed" or "immediately". The "When Changed" trigger is the part that does not work well in Automate when the screen is off. If you set it to immediately, and then regularly poll it at certain intervals (10 minutes for instance) it will update reliably, even when the screen is off. I am just mentioning this because I think improvements are possible to be made with the cell tower detection in Automagic. I like how Automagic works compared to other automation tools, and one of the only issues I've seen with it so far is the cell detection when the screen is off. Thank you.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Cell Tower Location doesn't work well

Post by Martin » 29 Oct 2017 19:33

Hi,

Likely the device does not inform other apps when the cells change and the screen is off. Unfortunately this is the case on most modern devices. Turning the screen on temporarily usually works on such devices but drains the battery quite fast.
You could try to see if periodically checking condition Phone Cell GSM works better. This condition also provides a variable with a list of the neighboring cells. So far my test devices usually did not provide anything meaningful in this variable but you might be lucky and Samsung actually provides values.

Please let me know if polling the condition works on your device.

Regards,
Martin

kholdstayr
Posts: 6
Joined: 24 Oct 2017 01:57

Re: Cell Tower Location doesn't work well

Post by kholdstayr » 29 Oct 2017 21:46

Martin wrote:Hi,

Likely the device does not inform other apps when the cells change and the screen is off. Unfortunately this is the case on most modern devices. Turning the screen on temporarily usually works on such devices but drains the battery quite fast.
You could try to see if periodically checking condition Phone Cell GSM works better. This condition also provides a variable with a list of the neighboring cells. So far my test devices usually did not provide anything meaningful in this variable but you might be lucky and Samsung actually provides values.

Please let me know if polling the condition works on your device.

Regards,
Martin
Hello again,

I'm sorry I was not clear in the original post. I did try polling the condition, in my case it is CDMA. I found that it is able to poll it, but unless the screen is on, the cell_id variable does not change from one poll to the next. I've set it up so that every time it polls it stores the cell_id in a separate text file on my system so I can track it. While the screen is off, it will update the text file with every poll using the condition, but the cell_id is the same every time. It does not change and always has the exact same value as last time. Once the screen is on and the poll occurs, the cell_id does update and changes (if I'm driving around while testing it).

In Tasker I can poll the %CELLID and I've found that it will update even with the screen off. One difference is that Tasker supports the "new" API for cell tower polling though. If I try the new API with Automagic it will never find a single tower. Maybe this is the difference as to why Tasker will update if I poll the CELLID variable and Automagic does not? For instance, in Tasker, if I check the cell tower location right now, I get "LTE:311.480.58483478". If I poll using Automagic I get "0.0.58483478" . If I enable the old polling method in Tasker I get "CDMA:58331424".

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Cell Tower Location doesn't work well

Post by Martin » 31 Oct 2017 20:26

That's strange, the API seems to report the base station ID which is part of the same set of data returned by the API that also returns the networkID and systemID as zero.
Maybe it's some kind of permission issue. Could you please try to enable all permissions in system settings->Apps->Automagic->Permissions and also ensure that location mode is set to 'High Accuracy'. Android sometimes adds new behavior for apps that target a newer Android version which could affect this area. Automagic has to target a newer Android version since Automagic supports the runtime permissions of Android 6+. Tasker does not support runtime permissions yet (to my knowledge) which might explain the difference.

Regards,
Martin

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Cell Tower Location doesn't work well

Post by Martin » 01 Nov 2017 20:51

Maybe I found a problem on CDMA devices. Could you please create an action Script with following script:

Code: Select all

tm=callJavaMethod(getContext(), "android.content.Context", "getSystemService(java.lang.String)", "phone");
cis=callJavaMethod(tm, "android.telephony.TelephonyManager", "getAllCellInfo()");
for(ci in cis)
  log(ci);
While still in the editing screen of the action use menu->Execute and then menu->Log, menu->Send Log to send the log file to me so I can check if there are cells that are not considered by the trigger.

Thanks & Regards,
Martin

kholdstayr
Posts: 6
Joined: 24 Oct 2017 01:57

Re: Cell Tower Location doesn't work well

Post by kholdstayr » 01 Nov 2017 23:49

Martin wrote:Maybe I found a problem on CDMA devices. Could you please create an action Script with following script:

Code: Select all

tm=callJavaMethod(getContext(), "android.content.Context", "getSystemService(java.lang.String)", "phone");
cis=callJavaMethod(tm, "android.telephony.TelephonyManager", "getAllCellInfo()");
for(ci in cis)
  log(ci);
While still in the editing screen of the action use menu->Execute and then menu->Log, menu->Send Log to send the log file to me so I can check if there are cells that are not considered by the trigger.

Thanks & Regards,
Martin
Hello Martin,

Thanks for the replies. I did try your first suggestion, which was to make sure that all the necessary permissions were enabled in Automagic, and then make sure that Location was turned on to full accuracy. I tried that and it did not make a difference.

I just ran the script you provided, and I attached the log file here for you. Please let me know if this helps you. Thanks!
Attachments
flow_Flow4_20171101_194037.xml
flow script
(1.2 KiB) Downloaded 820 times
log_mail.txt
log from script
(1.59 KiB) Downloaded 827 times

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Cell Tower Location doesn't work well

Post by Martin » 03 Nov 2017 20:33

Thanks for the log!
The log looks very promising. CDMA devices return a cell type I did not expect so it's ignored. The next update will also handle this cell type which should likely fix this issue.
Would be great if you could use the EAP version 1.35 that will be provided in the EAP forum in a few weeks and report back if the fix actually works on your device (unfortunately there's no way for me to test CDMA devices in my country).

Regards,
Martin

kholdstayr
Posts: 6
Joined: 24 Oct 2017 01:57

Re: Cell Tower Location doesn't work well

Post by kholdstayr » 04 Nov 2017 14:34

I'm glad that I could help. Yes I understand that CDMA is primarily used in the United States and i understand why you wouldn't be able to test it. Unfortunately, the carrier with the best availability in the U.S. (Verizon) still uses CDMA, so it will still be around for a long time.

I will wait for the new EAP version to appear and then test it out for you.

Post Reply