2009-03-04 11:32:55 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
#include <cutils/properties.h>
|
|
|
|
|
|
|
|
#include <sys/atomics.h>
|
|
|
|
|
|
|
|
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
|
|
|
|
#include <sys/_system_properties.h>
|
|
|
|
|
|
|
|
typedef struct pwatch pwatch;
|
|
|
|
|
|
|
|
struct pwatch
|
|
|
|
{
|
|
|
|
const prop_info *pi;
|
|
|
|
unsigned serial;
|
|
|
|
};
|
|
|
|
|
|
|
|
static pwatch watchlist[1024];
|
|
|
|
|
|
|
|
static void announce(const prop_info *pi)
|
|
|
|
{
|
|
|
|
char name[PROP_NAME_MAX];
|
|
|
|
char value[PROP_VALUE_MAX];
|
|
|
|
char *x;
|
|
|
|
|
|
|
|
__system_property_read(pi, name, value);
|
|
|
|
|
|
|
|
for(x = value; *x; x++) {
|
|
|
|
if((*x < 32) || (*x > 127)) *x = '.';
|
|
|
|
}
|
|
|
|
|
|
|
|
fprintf(stderr,"%10d %s = '%s'\n", (int) time(0), name, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
int watchprops_main(int argc, char *argv[])
|
|
|
|
{
|
2013-01-29 09:14:04 +08:00
|
|
|
unsigned serial = 0;
|
|
|
|
unsigned count;
|
2009-03-04 11:32:55 +08:00
|
|
|
unsigned n;
|
|
|
|
|
2013-01-29 09:14:04 +08:00
|
|
|
for(n = 0; n < 1024; n++) {
|
2009-03-04 11:32:55 +08:00
|
|
|
watchlist[n].pi = __system_property_find_nth(n);
|
2013-01-29 09:14:04 +08:00
|
|
|
if (watchlist[n].pi == 0)
|
|
|
|
break;
|
|
|
|
watchlist[n].serial = __system_property_serial(watchlist[n].pi);
|
2009-03-04 11:32:55 +08:00
|
|
|
}
|
|
|
|
|
2013-01-29 09:14:04 +08:00
|
|
|
count = n;
|
|
|
|
if (count == 1024)
|
|
|
|
exit(1);
|
2009-03-04 11:32:55 +08:00
|
|
|
|
2013-01-29 09:14:04 +08:00
|
|
|
for(;;) {
|
|
|
|
serial = __system_property_wait_any(serial);
|
|
|
|
while(count < 1024){
|
2009-03-04 11:32:55 +08:00
|
|
|
watchlist[count].pi = __system_property_find_nth(count);
|
2013-01-29 09:14:04 +08:00
|
|
|
if (watchlist[count].pi == 0)
|
|
|
|
break;
|
|
|
|
watchlist[count].serial = __system_property_serial(watchlist[n].pi);
|
2009-03-04 11:32:55 +08:00
|
|
|
announce(watchlist[count].pi);
|
|
|
|
count++;
|
|
|
|
if(count == 1024) exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(n = 0; n < count; n++){
|
2013-01-29 09:14:04 +08:00
|
|
|
unsigned tmp = __system_property_serial(watchlist[n].pi);
|
2009-03-04 11:32:55 +08:00
|
|
|
if(watchlist[n].serial != tmp) {
|
|
|
|
announce(watchlist[n].pi);
|
|
|
|
watchlist[n].serial = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|