DriveFi: An application to prevent "Drive-by WiFi connections"


#1
Whoa there par’dner! (why the cowboy themed accent? I really don’t know…)

You came here looking for DriveFi, and there really is good info below (including the motivation for writing it) but this blog post has become stale over time. You can find the CURRENT app on the Google Play Store as described in the follow-up blog post here: DriveFi is now available the Google Play Store


Don’t care for long posts?

  • Documentation and Downloads can be found here: DriveFi,
  • A forum comment with change logs can be found here: Updates
  • Link to latest version is available in-app starting with version 1.4
  • Please report bugs either in-app or from your computer here: DriveFi Bug Report

Drive-by WiFi connections:

If you have RW’s Wi-Fi+ app installed on your phone, then your device actively seeks out open WiFi access points everywhere you go. There are other apps available in the Play Store to do something similar. These apps setup open WiFi hotspots as “known” hotspots in your device, to be automatically connected to whenever your device sees the same WiFi again in the future. This is a Good Thing for offloading to WiFi as much as possible, but it can be troublesome.

When driving, especially at slow speed through a commercial area in town, your phone may observe many open WiFi hotspots and try connecting to each one as you pass by. The problem here is that you won’t remain close to any one WiFi hotspot for very long: you are just Driving-by.

When your phone attempts to connect to a WiFi hotspot as you Drive-by, your cellular data is momentarily disconnected and often times your phone will functionally operate in its WiFi-calling mode: an incoming call may be dropped or an outbound call may be difficult to perform during this time.

Drive-by Wifi connections can be frustrating, but they can also be prevented.

Manual Workaround:

The obvious manual workaround is to disable your WiFi radio whenever you will be driving. This is simple enough: Open the Settings app, tap “Wireless & networks”, and finally tap “Wi-Fi” to toggle its state.

While this is simple to perform, it is anything but convenient:

  • You may forget to DISABLE WiFi as you get into your car
  • You may forget to ENABLE WiFi again when you arrive at your destination
  • In either case, your Hybrid Calling experience would be less than optimal
  • Even if you are diligent about en/dis-abling your WiFi, this drudgery should not be required of you!

Google Play Activities API:

At the 2013 Google I/O 2013 developers conference, Google announced new APIs to enable context-aware applications to detect not just your location, but also what sort of location-based activity you are most likely participating in at any given time: Google Announces 3 New Android APIs

The relevant new API, the Activity Recognition API, “[…] uses the accelerometer and machine learning to discern if a user is cycling, walking, or driving”. This Activity Recognition API continually learns from all users and improves over time without requiring any changes to the applications which use it.

Automated Solution:

Using the new Google Play Activities API, an automated solution is possible. Taking advantage of the extremely power efficient Activity Recognition features, this automated solution should be capable of detecting when we are driving or not-driving without significantly affecting our battery life.

The automated solution should request the “current activity” periodically and control the state of the WiFi radio for us. It should also prevent the radio from being turned ON by other apps (as some have reported WiFi+ does), as well as preventing the radio from being turned OFF by other apps (like a poorly configured battery saving app). This way the sate of the WiFi radio should nearly ALWAYS be dictated by whether we are driving or not-driving at any given time.

Such a solution should also be easy to enable and disable itself, and to provide notifications to users when the state of the WiFi radio is toggled for us so we always know what is happening with our devices.

Tasker and Third Party Plugins:

There is an application in the Play Store called Tasker which provides an easy method to develop automation scripts for Android devices. These scripts may be exported as proper Android Apps and may be freely distributed by the script author.

Tasker does not provide access to the new Activity Recognition API, though third party plugins exist which do provide access to this API. Unfortunately these third party plugins are not free.

When a Tasker script is export as a proper App, it includes hints that the App requires any third party plugins that were used to create it. The exported app cannot include the plugin directly, and of course plugins must be installed (and purchased, if not free) by anyone who wishes to run a Tasker-based app which utilizes that plugin.

Introducing DriveFi:

I have developed an application to automate en/dis-abling the WiFi radio as described above. The app polls the Activity Recognition API every ~30 seconds to detect when you are Driving or Not-Driving. When driving, your WiFi radio is disabled; when not-driving the WiFi radio is re-enabled. I used Tasker to create this application (note: you DO NOT need to own a copy of Tasker to use DriveFi) and the non-free 3rd party plugin AutoLocation to connect to the Activity Recognition API (note: you DO need to own a copy of AutoLocation to use DriveFi beyond a 7 day trial period).

  • DriveFi is FREE; I have no intention of seeking profit from this app, it is free to download, install and use (If you would like to share the app with others, I would appreciate you doing so only by providing others with a LINK to the file so that they download it directly from me).
  • It requires a NON-FREE plugin to provide access to the Activity Recognition API; if a FREE alternative becomes available I would eagerly consider switching to it to make this app 100% free for all users. If you spot a viable candidate for this, please let me know.
  • The NON-FREE plugin I used provides a 7 day trial period so you can test this app for a week completely free of charge.
  • I am not affiliated AT ALL with the developer of the NON-FREE plugin; I don’t see a penny of the money if you buy it.

The DriveFi app was written specifically with RW members in mind: its functionality is meant to maintain the best Hybrid Calling experience with the least manual effort. I hope you like it!

Documentation and downloads are available here: [DriveFi

](https://app.box.com/drivefi)

To pique your interest, here’s a screenshot of the Setup Screen for DriveFi v1.1 (it looks a little prettier by now)):

screen1.1.png

**
**

**
**

Please feel free to post comments, questions, bug reports, (bug reports should go here instead) or feature requests as comments to this post.

**
**

I hope you enjoy using DriveFi!

-bit


Connecting to various wifi places...a question about one of the RW articles
Delay needed before connecting to Wifi
#2

Good job @bitflung!


#3

Good App. The app is not published on the play store. So I am a little hesitant to install it but good to know that there is an option now.


#4

Updates will be posted here:

Updated 20/July

Version 1.5: Download

  • BUG FIX: added code to workaround a bug in the AutoLocation plugin
  • Identified a bug in AutoLocation: activity triggers were being called by the plugin even when they don’t match the configured activity
  • Added a pop-up on first use to direct users to the online help for bug reports and user survey
  • Added version info to main setup screen
  • Reverted back to 2 activity detection loops as the single loop did not maintain the same level of functional correctness

Updated 19/July

Version 1.4: Download

This version is the result of a significant rewrite, due to:

  • Errant WiFi toggles were traced back to a misunderstanding of how Tasker handles control of Settings (like the wifi radio state)
  • The original UI logic could fail if the user hit buttons to rapidly
    The new version differs greatly, despite looking almost identical:
  • Reduced number of activity detection loops from 2 to 1
  • WiFi settings should no longer toggle at wrong time (at least not for the same reason as before)
  • Efficiency of UI graphics has been improved
  • Sensitivity of activity detection has been increased
    I’ve introduced a neumber of new features as well:
  • Landscape support
  • Yup, the UI now supports landscape orientation.
  • Online Help
  • A button in the Setup Screen opens in in-app Help document
  • The help document is dynamic and re-loads every time you press the Help button
  • The help document itself is a work in progress; updates to the document will show in your app automatically
  • User Survey
  • The Help document includes a link to a user survey
  • Survey responses will be PUBLIC, please don’t share info you’d like to remain private
  • Bug Report
  • The Help document also includes a link to a bug report form
  • Ideally bugs should be reported as often as they occur

Update [18/July]: Version 1.3 uploaded

  • BUG FIX: I finally figured out the source of the spurious wifi toggles:
  • Tasker automatically restores settings like WiFi state in some circumstances.
  • I’ve re-coded the detection profiles to avoid these circumstances
  • I left the old mitigation methods in place so as to introduce less change to this version to be tested - these will be removed once the new solution is well tested.
  • ERRATA: Automatic wifi toggle is NO LONGER paused while the setup screen is displayed
  • Note though, that the description (Driving/Not Driving) is not updated until the setup screen is reloaded
  • FEATURE: as requested in the RW community, I’ve chaged the ‘Service’ button name to ‘DriveFi’

Update: Version 1.2 uploaded

Version 1.2 adds code to force only one of the detection scripts to be active at a time. Note that previous versions used a logical gate to trigger only one of the detection scripts per activity report, but it is possible that delays in script execution may have created a race condition responsible for spurious wifi state toggles. This version seeks to remedy a rarely observed bug which causes wifi to be disabled when it should remain enabled.

-bit


#5

mahesh wrote:

Good App. The app is not published on the play store. So I am a little hesitant to install it but good to know that there is an option now.

That’s a good point.

To publish app in the Play Store, developers must pay a $25 fee (https://play.google.com/apps/publish/signup/). This is my first Android app* and so haven’t had need to register already. Since I am not selling this app, I didn’t want to pay $ just to share it with the RW community.

How do others feel? Are folks unwilling to install this because it isn’t in the Play Store, but otherwise wish to install/use it?

  • While this is my first Android app, I’d like to point out that I am not inexperienced in development (to put the less optimistic at ease). I am a professional computer engineer and develop both hardware and software for a living (primarily hardware). I’ve been working as an engineer in this regard for nearly a decade. This is my first ANDROID app, not my first application in general.

#6

Thanks Bitflung for all your energy on our behalf. I purchased the add-on and downloaded and installed your free app, DriveFi. I have only had it for a short time today, but it seems to be working perfectly.I went to the store and back home and heard…wifi disabled a block away from my home…and heard wifi enabled about 2 minutes or less after I was in the house. It is super!!! Thank you very much… Congratulations to you for your new lil’bit!!


#7

I installed, and have only been out for one test run…Found problem in MY installation (I did not activateAutoLocation properly … will retest

  • I use Gravity Screen to manage my display turning off/on and it appears to conflict.
    • When parked and out of car for 5 mins I was still driving
    • When sitting on desk and turned off by Gravity Screen it would flash and turn the screen back on every few mins
    • I will remove Gravity screen and retest
  • I would rename Service ‘DriveFi’ (some of us confuse easily)
    Anyone who is aware of your contribution to the community should not be concerned about downloading your app … check his Bio … with a son that cute and wears a RW T-shirt could not be a bad guy

#8

If this is a good app and everyone likes it why don’t we just get a few people to chip in and pay the $25 so he can list it in Google Play. I don’t have my phone yet so I haven’t got a chance to test it but I would be willing to through a $1 his way sight unseen.

The added benefit of having it listed in Google Play is that we could receive any updates he might decide to do.


#9

I’ve made two round trips of about 5 miles each since installing this app. It works very well. Thank you for doing this Jared. It partially solves the problem introduced by WiFi+ but not entirely. I was walking around in a shopping mall a few weeks back. It seems every store has their own WiFi so a bunch were added to my list during that visit.


#10

Neat fix for the most part, but even with WiFi turned off, WiFi+ will toggle it on periodically, unless this behavior has changed. For me, this behavior was only slightly less destructive to battery life than leaving WiFi running full time.

What we really need is some way that the user can have final control over the behavior of WiFi+. If I have WiFi turned off, that is the end of the matter, I know far better than anyone else how my WiFi usability pattern works.

The only way WiFi+ would not be a deal-killer for me is if any phone using it has a battery of about triple normal capacity. Yes, I’m using your thread to vent again.

Good job on the app, it will help some people, and that is enough for it to be worth it.


#11
  • I use Gravity Screen to manage my display turning off/on and it appears to conflict.

    • When parked and out of car for 5 mins I was still driving
    • When sitting on desk and turned off by Gravity Screen it would flash and turn the screen back on every few mins
    • I will remove Gravity screen and retest
      interesting. I’m not familiar with Gravity Screen - hopefully we can find a resolution to this conflict. i didn’t write any code to control the screen behavior in this app, but it’s possible that Tasker has some conflicting base-code.
  • I would rename Service ‘DriveFi’ (some of us confuse easily)
    the ‘service’ button? DONE. (will be changed in version 1.3, which has a bug fix for spurious wifi toggles and will be released later today)

Anyone who is aware of your contribution to the community should not be concerned about downloading your app … check his Bio … with a son that cute and wears a RW T-shirt could not be a bad guy

aww, shucks!

thanks for the feedback!


#12

wendyw.8863c6 wrote:

Thanks […] it seems to be working perfectly.[…] Thank you very much… Congratulations to you for your new lil’bit!!

you’re welcome - glad to hear it is working well for you!

and thanks for the shout-out for lil’bit - my world is definitely revolving around him these days

  • bit

#13

billg wrote:

I’ve made two round trips of about 5 miles each since installing this app. It works very well. Thank you for doing this Jared. It partially solves the problem introduced by WiFi+ but not entirely. I was walking around in a shopping mall a few weeks back. It seems every store has their own WiFi so a bunch were added to my list during that visit.

interesting. perhaps I could add a feature to disable wifi when walking… obviously it would still refrain from disabling wifi if there is an active connection. in this case, wifi would turn on when you sit still for a while, then remain on no matter what you do so long as the wifi remains connected, and finally would turn off the radio when walking OR driving so long as there is no active wifi connection.

one issue i see with this is that the NEXT wifi connection might come up faster than the detection loop in my app would realize that you’ve walked away from the first. i don’t want to poll much more frequently (minimize battery drain) but would have to poll very fast to handle this reliably (what’s the nyquist rate for wifi thrashing? maybe 6Hz? polling six times per second would surely affect the battery)

perhaps I could start a rapid poll only when walking and connected to wifi, then go back to a slow poll once you stop walking and/or have the wifi radio off. this would constrain the battery over-use to just those times you’re walking around AND connected to wifi. you’d have to manually enable this fancy feature when you go to the mall (i wouldn’t make it the default else walking around your home would consume more battery) but i’ll add this to my future feature list if you like.

any other thoughts on how to control it better at the mall?


#14

giqcass wrote:

If this is a good app and everyone likes it why don’t we just get a few people to chip in and pay the $25 so he can list it in Google Play. I don’t have my phone yet so I haven’t got a chance to test it but I would be willing to through a $1 his way sight unseen.

that’s a very generous thought, thanks

The added benefit of having it listed in Google Play is that we could receive any updates he might decide to do.

this is a good point. i already have a new version to release today (am testing it right now before uploading) and i wonder how many folks who install it will diligently come back here to check for updates. i COULD put an update checker in the app, but adding that would take time away from improving the core features of the app.


#15

Just a random thought while reading about the Monday night Bitcoin exchange NYC

How about we finance it with our own ‘bitcoin’?

  • Republic could very simply institute a 1 time additional charge against our monthly cell cost (after we authorize it via an email or an update to a specific thread)
  • When the $$ amount = $12.50 Republic would match it and credit @bitflung with the development dollars!!

#16

Thanks @jben (and @giqcass), it’s a really nice thought but I’m not sure that i’d be comfortable accepting the money. Having a members-wide collection fund for my Google Play publishers fee would feel a little odd to me.

it’s really not much money, i think i’d be more comfortable just paying the fee myself. it might be a few days before i get around to it - my wife is in heavy budgeting-mode at the moment and i’ll just have to wait for her to finish making herself feel OK with the finances (i’m sure we ALL know that feeling!)

Till then I hope this blog post and my updates will suffice.

-bit


#17

Well shatter my dreams of being a Venture Capitalist


#18

Jared, I just don’t see how the walking issue can be handled. People might get disconnected while, for example, pacing around their home during an argument with the IRS. What we really need is a fix for WiFi+ to prevent it from spontaneously turning WiFi back on after we have manually turned it off. Hmm. I wonder if it spontaneously turns it on after your app has shut if off???

Bill


#19

What we really need is a fix for WiFi+ to prevent it from spontaneously turning WiFi back on after we have manually turned it off. Hmm. I wonder if it spontaneously turns it on after your app has shut if off???

i’m sure it doesn’t know who or what turned of wifi previously - so it should turn wifi back on after DriveFi turns it off. the two apps would get into a control-war, with one turning wifi on periodically and the other turning it off. (DriveFi should reassert the ‘proper’ wifi state every ~30 seconds)


#20

Is there any way of DriveFi having hooks into WiFi+ so that DriveFi would gain priority when ‘driving’ and eliminate the contention/race condition? Asking @brandon.smith for comment/help