Efficient context monitoring
Disclosed are systems, methods, and non-transitory computer-readable storage media for efficiently monitoring the operating context of a computing device. In some implementations, the context daemon and/or the context client can be terminated to conserve system resources. For example, if the context daemon and/or the context client are idle, they can be shutdown to conserve battery power or free other system resources (e.g., memory). When an event occurs (e.g., a change in current context) that requires the context daemon and/or the context client to be running, the context daemon and/or the context client can be restarted to handle the event. Thus, system resources can be conserved while still providing relevant context information collection and callback notification features.
1. A method comprising:
receiving, by a context daemon executing on a computing device, values corresponding to a first context item monitored by a context monitor;
generating, by the context daemon, a historical event stream corresponding to the first context item based on the received values;
determining, by the context daemon, a short-term probability of a particular value of the first context item based on the historical event stream;
determining, by the context daemon, a long-term probability of the particular value of the first context item based on the historical event stream; and
predicting, by the context daemon, a future occurrence of the particular value of the first context item based on a combination of the short-term probability and the long-term probability.
2. The method as recited in claim 1 , further comprising, prior to receiving the values corresponding to the first context item:
receiving, by the context daemon from a context client process, a context information request corresponding to the first context item;
determining, by the context daemon, that the first context item is not currently monitored by any context monitor; and
initializing, by the context daemon, the context monitor corresponding to the first context item.
3. The method as recited in claim 2 , wherein initializing the context monitor comprises dynamically loading a software package corresponding to the context monitor into the context daemon.
4. The method as recited in claim 2 , wherein initializing the context monitor comprises invoking a new context monitor process separate from the context daemon, the new context monitor process corresponding to the context monitor.
5. The method as recited in claim 1 , further comprising receiving, by the context demon, a plurality of values corresponding to more than one context item monitored by a plurality of context monitors.
6. The method as recited in claim 1 , wherein the short-term probability indicates, for each first period of time over a predetermined number of preceding days, a first likelihood of occurrence of the particular value of the first context item, and wherein the long-term probability indicates, for the each first period of time of a same day of the week over a predetermined number of weeks, a second likelihood of occurrence of the particular value of the first context item.
7. The method as recited in claim 1 , wherein the received values for the first context item describe a current state of one or more components selected from a group comprising: hardware components of the computing device and software components of the computing device.
8. The method as recited in claim 1 , wherein the context monitor generates historical event stream objects that identify a start time, a duration, and a context item value that describes an event in the historical event stream.
9. A non-transitory computer-readable medium comprising instructions that, when executed by a computing device, cause a context daemon of the computing device to:
receive values corresponding to a first context item monitored by a context monitor;
generate a historical event stream corresponding to the first context item based on the received values;
determine a short-term probability of a particular value of the first context item based on the historical event stream;
determine a long-term probability of the particular value of the first context item based on the historical event stream; and
predict a future occurrence of the particular value of the first context item based on a combination of the short-term probability and the long-term probability.
10. The non-transitory computer-readable medium as recited in claim 9 , further comprising instructions, which when executed, cause the context daemon to, prior to receiving the values corresponding to the first context item:
receive, from a context client process, a context information request corresponding to the first context item;
determine that the first context item is not currently monitored by any context monitor; and
initialize the context monitor corresponding to the first context item.
11. The non-transitory computer-readable medium as recited in claim 10 , wherein initializing the context monitor comprises dynamically loading a software package corresponding to the context monitor into the context daemon.
12. The non-transitory computer-readable medium as recited in claim 10 , wherein initializing the context monitor comprises invoking a new context monitor process separate from the context daemon, the new context monitor process corresponding to the context monitor.
13. The non-transitory computer-readable medium as recited in claim 9 , further comprising instructions, which when executed, cause the context daemon to receive a plurality of values corresponding to more than one context item monitored by a plurality of context monitors.
14. The non-transitory computer-readable medium as recited in claim 9 , wherein the short-term probability indicates, for each first period of time over a predetermined number of preceding days, a first likelihood of occurrence of the particular value of the first context item, and wherein the long-term probability indicates, for the each first period of time of a same day of the week over a predetermined number of weeks, a second likelihood of occurrence of the particular value of the first context item.
15. The non-transitory computer-readable medium as recited in claim 9 , wherein the received values for the first context item describe a current state of one or more components selected from a group comprising: hardware components of the computing device and software components of the computing device.
16. The non-transitory computer-readable medium as recited in claim 9 , wherein the context monitor generates historical event stream objects that identify a start time, a duration, and a context item value that describes an event in the historical event stream.
17. A computing device comprising:
one or more hardware processors; and
a non-transitory computer-readable medium comprising instructions that, when executed by the one or more hardware processors on the computing device, cause a context daemon to:
receive values corresponding to a first context item monitored by a context monitor;
generate a historical event stream corresponding to the first context item based on the received values;
determine a short-term probability of a particular value of the first context item based on the historical event stream;
determine a long-term probability of the particular value of the first context item based on the historical event stream; and
predict a future occurrence of the particular value of the first context item based on a combination of the short-term probability and the long-term probability.
18. The computing device as recited in claim 17 , wherein the non-transitory computer-readable medium further comprises instructions, which when executed, cause the context daemon to, prior to receiving the values corresponding to the first context item:
receive, from a context client process, a context information request corresponding to the first context item;
determine that the first context item is not currently monitored by any context monitor; and
initialize the context monitor corresponding to the first context item.
19. The computing device as recited in claim 17 , wherein the context monitor generates historical event stream objects that identify a start time, a duration, and a context item value that describes an event in the historical event stream.
20. The computing device as recited in claim 17 , wherein the received values for the first context item describe a current state of one or more components selected from a group comprising: hardware components of the computing device and software components of the computing device.