bool ResourceMonitorAndroid::run() { Watch w; HAGGLE_DBG("Running resource monitor\n"); if (uevent_init() == -1) { HAGGLE_ERR("Could not open uevent socket\n"); return false; } while (!shouldExit()) { int ret; w.reset(); int ueventIndex = w.add(uevent_fd); ret = w.wait(); if (ret == Watch::ABANDONED) { break; } else if (ret == Watch::FAILED) { HAGGLE_ERR("Wait on objects failed\n"); break; } if (w.isSet(ueventIndex)) { uevent_read(); } } return false; }
ECode UEventObserver::NativeSetup() { if (!uevent_init()) { //jniThrowException(env, "java/lang/RuntimeException", "Unable to open socket for UEventObserver"); return E_RUNTIME_EXCEPTION; } return NOERROR; }
static void android_os_UEventObserver_native_setup(JNIEnv *env, jclass clazz) { if (!uevent_init()) { jniThrowException(env, "java/lang/RuntimeException", "Unable to open socket for UEventObserver"); } }
int main() { ALOGI("usb 3g monitor v0.1 start"); uevent_init(); coldboot("/sys/devices"); uevent_next_event(on_uevent); return 0; }
int main() { SLOGI("-------------------------------------------------------------------"); SLOGI("USB3G Monitor ver. 0.1f fixed by lolet -- built on %s, %s",__DATE__, __TIME__); SLOGI("-------------------------------------------------------------------"); uevent_init(); coldboot("/sys/devices"); uevent_next_event(on_uevent); return 0; }
int main() { int ret; klog_set_level(KLOG_LEVEL); ret = uevent_init(); if (ret == 0) ret = chargeled_mainloop(); return ret; }
static void event_loop(void) { int len = 0; static char udata[4096]; memset(udata, 0, sizeof(udata)); uevent_init(); while (1) { len = uevent_next_event(udata, sizeof(udata) - 2); handle_uevent(udata); } }
static void *uevent_loop(void *param) { int len = 0; static char udata[PAGE_SIZE]; hwc_context_t * ctx = reinterpret_cast<hwc_context_t *>(param); setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); uevent_init(); while(1) { len = uevent_next_event(udata, sizeof(udata) - 2); handle_uevent(ctx, udata, len); } return NULL; }
static void *uevent_loop(void *param) { int len = 0; static char udata[PAGE_SIZE]; hwc_context_t * ctx = reinterpret_cast<hwc_context_t *>(param); char thread_name[64] = HWC_UEVENT_THREAD_NAME; prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0); setpriority(PRIO_PROCESS, 0, HAL_PRIORITY_URGENT_DISPLAY); uevent_init(); while(1) { len = uevent_next_event(udata, sizeof(udata) - 2); handle_uevent(ctx, udata, len); } return NULL; }
void UEventWatcher::run() { if (uevent_init()) { char msg[UEVENT_MSG_LEN+2]; int n; while ((n = uevent_next_event(msg, UEVENT_MSG_LEN)) > 0) { if (n >= UEVENT_MSG_LEN) continue; msg[n] = 0; msg[n+1] = 0; struct uevent uevent; parse_event(msg, &uevent); if (strcmp(uevent.subsystem,"power_supply") == 0) { emit activity(); } } } }
void EnableBatteryNotifications() { if (!sUEventInitialized) sUEventInitialized = uevent_init(); if (!sUEventInitialized) { NS_WARNING("uevent_init() failed!"); return; } if (!sWatcher) sWatcher = new UEventWatcher(); NS_ADDREF(sWatcher); sWatcher->mRunning = true; nsresult rv = NS_NewThread(&sWatcherThread, sWatcher); if (NS_FAILED(rv)) NS_WARNING("Failed to get new thread for uevent watching"); }
int main(int argc, char *argv[]) { int ret; struct uevent_desc udesc; ret = uevent_init(&udesc); if (ret < 0) { error_msg("uevent_init"); return ret; } while (1) { char devpath[1024]; ret = get_partition_add_uevent(&udesc); if (ret < 0) { error_msg("get_partition_add_uevent"); break; } if (uevent_get_propery_devname(&udesc, devpath) == NULL) { continue; } if (file_test(devpath, "b") < 0) { continue; } println("partition \"%s\" added", devpath); mount_main(devpath, NULL, NULL, NULL); } uevent_deinit(&udesc); return 0; }
static void *uevent_loop(void *param) { int len = 0; static char udata[PAGE_SIZE]; hwc_context_t * ctx = reinterpret_cast<hwc_context_t *>(param); char thread_name[64] = HWC_UEVENT_THREAD_NAME; prctl(PR_SET_NAME, (unsigned long) &thread_name, 0, 0, 0); androidSetThreadPriority(0, HAL_PRIORITY_URGENT_DISPLAY); if(!uevent_init()) { ALOGE("%s: failed to init uevent ",__FUNCTION__); return NULL; } while(1) { len = uevent_next_event(udata, (int)sizeof(udata) - 2); handle_uevent(ctx, udata, len); } return NULL; }
int uevent_add(char *action, char *subsystem, uevent_func_t func, void *user_data) { #ifdef HAKIT_UEVENT_ENABLED uevent_hook_t *hook; /* Init uevent gears. This will have no effect if init was already done before */ uevent_init(); log_debug(2, "uevent_add: action='%s' subsystem='%s'", action, subsystem); /* Allocate new hook */ uevent_nhooks++; uevent_hooks = realloc(uevent_hooks, uevent_nhooks * sizeof(uevent_hook_t)); hook = &uevent_hooks[uevent_nhooks-1]; hook->func = func; hook->user_data = user_data; if (action != NULL) { hook->action = strdup(action); } else { hook->action = NULL; } if (subsystem != NULL) { hook->subsystem = strdup(subsystem); } else { hook->subsystem = NULL; } return 0; #else return -1; #endif /* HAKIT_UEVENT_ENABLED */ }
int main (int argc, char **argv) { UpgradeNotifier *un; GError *error = NULL; // init if(!gtk_init_with_args (&argc, &argv, _("- inform about updates"), entries, "update-notifier", &error) ) { fprintf(stderr, _("Failed to init the UI: %s\n"), error ? error->message : _("unknown error")); exit(1); } notify_init("update-notifier"); bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); if (HOOK_DEBUG || UPDATE_DEBUG || INOTIFY_DEBUG || UEVENT_DEBUG || RELEASE_DEBUG || MISC_DEBUG) g_setenv ("G_MESSAGES_DEBUG", "all", TRUE); // setup a custom debug log handler g_log_set_handler ("inotify", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler ("hooks", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler ("update", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler ("uevent", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler ("release", G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, NULL); g_set_application_name (_("update-notifier")); gtk_window_set_default_icon_name ("update-notifier"); //g_print("starting update-notifier\n"); /* Create the UpgradeNotifier object */ un = g_new0 (UpgradeNotifier, 1); un->settings = g_settings_new(SETTINGS_SCHEMA); // do not run as system user (e.g. guest user) if (system_user(un) && !FORCE_START) { g_warning("not starting for system user"); exit(0); } // do not run as system user (e.g. guest user) if (FORCE_RELEASE_CHECK) g_settings_reset(un->settings, SETTINGS_KEY_LAST_RELEASE_CHECK); // check if it is running already if (!up_get_clipboard ()) { g_warning ("already running?"); return 1; } // check for update-notifier dir and create if needed gchar *dirname = g_strdup_printf("%s/update-notifier", g_get_user_config_dir()); if(!g_file_test(dirname, G_FILE_TEST_IS_DIR)) g_mkdir(dirname, 0700); g_free(dirname); // delay icon creation for 30s so that the desktop // login is not slowed down by update-notifier g_timeout_add_seconds(STARTUP_DELAY, (GSourceFunc)(tray_icons_init), un); // initial check for avahi avahi_disabled_check(); /* setup inserted-cdroms checker */ if(!cdroms_init(un)) { g_warning("initializing cdroms failed"); } // init release checker release_checker_init(un); // init uevent monitoring (missing firmware, etc.) uevent_init(); // init gio file monitoring monitor_init (un); /* Start the main gtk loop */ g_unix_signal_add_full (G_PRIORITY_DEFAULT, SIGINT, sigint_cb, NULL, NULL); gtk_main (); return 0; }
int ExtDisplayObserver::readyToRun() { //Initialize the uevent uevent_init(); ALOGD_IF(EXT_OBSERVER_DEBUG, "%s: success", __FUNCTION__); return android::NO_ERROR; }