Skip to content

Generalized android polling

Bob Evans edited this page Oct 9, 2013 · 1 revision

Polling can be useful in two ways:

  1. Periodically observing a variable to detect a threshold as a triggering mechanism
  2. A passive data input to sample

Polling of trigger variables

This is checking an input or set of inputs values at a certain frequency for a certain duration at a certain resolution combined with the evaluation of a rule for creating a Notification.

Polling for passive data collection

This is checking an input or set of inputs values at a certain frequency for a certain duration at a certain resolution and recording that sample.

Polling parameters

  • The input to poll
  • The frequency of polling
  • The duration of the polling window
  • The number of samples to take in the polling window.

Possibly,

  • The trigger rules to evaluate at some interval of polling to determine the need for a Notification.

    • This is most likely a threshold value or boolean function that says yes, fire now.
  • Possibly a schedule parameter for the trigger rule evaluation if not at every polling point. At first, just evaluate the rule at every polling.

Possible mechanism

The current alarm mechanism is used to schedule work at some point in the future. Currently we do two types of work based on alarms. We create notifications and we cancel notifications.

We could just as well sample an input and store the sample in the datastore.

This could be as simple as scheduling the experiment with a polling component according to its polling schedule. This may create a lot of activity in the BeeperService due to alarms constantly waking the phone to poll. If the frequency of polling is very high this seems like an abuse of alarms.

The wakeup alarm, instead of creating a notification, starts a polling worker service that is responsible for the polling. It would be started and would run for the 'duration' parameter. It would sample at the sampling rate until it is done.

Clone this wiki locally