Closed Bug 1117137 Opened 9 years ago Closed 3 years ago

Background services should use a wifi lock

Categories

(Firefox for Android Graveyard :: Android Sync, defect, P3)

All
Android
defect

Tracking

(Not tracked)

RESOLVED INCOMPLETE

People

(Reporter: rnewman, Unassigned, Mentored, NeedInfo)

References

Details

(Whiteboard: [good next bug][lang=java])

See Bug 1117095. Every background service should take a wifi lock for the duration of their work, to prevent the radio being powered down during operation.

This might not be necessary... but let's find out!

http://developer.android.com/reference/android/net/wifi/WifiManager.WifiLock.html
Hi Richard ,i read the description and probably understood wifi API functions from surface,now in order to start development i have following queries-

1-Which files have to be looked for changes{some info so i can understand where to start beacuse evrything seems to be linked like wifimanager ,network status and all}I read the code of BackgroundServices.java but only relised that it was returning status that wether background internet is allowed or not.

2-Do we need to make changes to every background service or just the updater and download actions

3-What if any process somehow unables to complete its network related task and stops in middle but not leaving wifi lock.Do we have to give timer to stop after a certain period of time if the application is not utilising network for that period of time.
(In reply to Richard Newman [:rnewman] from comment #0)
> See Bug 1117095. Every background service should take a wifi lock for the
> duration of their work, to prevent the radio being powered down during
> operation.

I don't think this is *every* background service - e.g. I don't believe the HealthReportPruneService accesses the network.
(In reply to Michael Comella (:mcomella) from comment #2)

> I don't think this is *every* background service - e.g. I don't believe the
> HealthReportPruneService accesses the network.

Correct; I was lazy. Every service that accesses the network :D


(In reply to surabhi anand from comment #1)

> 2-Do we need to make changes to every background service or just the updater
> and download actions

Not those; the updater is Bug 1117095, which is already done. (You can copy that code, too.)

In particular, we need to address these --

In android-sync:
* SyncAdapter (Sync 1.1)
* FxAccountSyncAdapter (Sync 1.5)
* HealthReportUploadService

In the Stumbler (ask :garvank if this is actually necessary):
* StumblerService (where it does uploads)

Of all of these, the Sync code is the most prone to harm if the connection drops, so that's the first thing to address.

It's worth bearing in mind that Sync is also the most likely to drain your battery, and a WifiLock is a bigger hammer to do so. We should consider whether to introduce some nuance.


> 3-What if any process somehow unables to complete its network related task
> and stops in middle but not leaving wifi lock.Do we have to give timer to
> stop after a certain period of time if the application is not utilising
> network for that period of time.

WifiLock has a finalizer that automatically releases the lock:

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/1.6_r2/android/net/wifi/WifiManager.java#818

Between a try..finally block, an interrupt handler for the SyncAdapter classes, and the finalizer, there should be no issues.
Is this available for me to take up?
Is this fixed ? If not I would like to try it.
Michael, can you mentor this?
Mentor: rnewman → michael.l.comella
Flags: needinfo?(michael.l.comella)
Hi Tomislav. I'm no longer working on fennec – let me try to get someone else to look over this.

Sebastian, do you think you can redirect?
Flags: needinfo?(michael.l.comella) → needinfo?(s.kaspari)
(In reply to Tomislav Jurin from comment #6)
> Is this fixed ? If not I would like to try it.

Hi Tomislav! Do you have experience with services and wifi locks? I'd be happy to review patches and help you get this fixed. However right now I'm too busy to help you if you need more detailed guidance.

I cc'ed some other Android folks at Mozilla in case anyone else wants to mentor this.
Mentor: michael.l.comella → s.kaspari
Flags: needinfo?(s.kaspari)
Hi Tomislav
You can find me(:nechen) on IRC if I can help :)
Flags: needinfo?(svezauzeto12)
Hi Nevin, sorry for late response I had got sick so I was "out of fight " for 10 days. I will try to contact you on IRC and we can discuss there.

Thank you for help.
No problem!
And please check "Need more information from..." and select me(nechen) so me or others can get notified!
No problem!
And please check "Need more information from..." and select me(nechen) so me or others can get notified!
Component: Core → Android Sync
Product: Android Background Services → Firefox for Android
Mentor: s.kaspari → gkruglov
Priority: -- → P3
We have completed our launch of our new Firefox on Android. The development of the new versions use GitHub for issue tracking. If the bug report still reproduces in a current version of [Firefox on Android nightly](https://play.google.com/store/apps/details?id=org.mozilla.fenix) an issue can be reported at the [Fenix GitHub project](https://github.com/mozilla-mobile/fenix/). If you want to discuss your report please use [Mozilla's chat](https://wiki.mozilla.org/Matrix#Connect_to_Matrix) server https://chat.mozilla.org and join the [#fenix](https://chat.mozilla.org/#/room/#fenix:mozilla.org) channel.
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.