inotify in android
来源:互联网 发布:怀化广电网络 编辑:程序博客网 时间:2024/05/17 00:09
android_util_FileObserver.cpp uses inotify to notice the changes of appointed files , and report these changes to FileObserver.
android_os_fileobserver_init() call inotify_init to create an inotify instance. a file descriptor is returned to the caller,
the caller will pass it in android_os_fileobserver_startWatching, android_os_fileobserver_stopWatching etc. functions.
static jint android_os_fileobserver_startWatching(JNIEnv* env, jobject object, jint fd, jstring pathString, jint mask):
The function call inotify _add_watch(fd, pathname, mask) to watch the inode pointed to by pathname.
inotify _add_watch returns a unique watch descriptor to the inode pointed by the pathname.
notes: the parameter fd is a file descriptor created by android_os_fileobserver_init, inotify instance.
static void android_os_fileobserver_stopWatching(JNIEnv* env, jobject object, jint fd, jint wfd):
the function call inotify_rm_watch to cancel a watch on the watch descriptor wfd in an inotify instance appointed by fd .
static void android_os_fileobserver_observe(JNIEnv* env, jobject object, jint fd):
This function enters into a dead loop, it continously read event information from the inotify instance appointed by fd.
The function do not return unless encounter an error when reading and the error is not EINTR.
after read events, the events is splited to single event, then call method_onEvent( it is a global variant be metioned later) to send the event to FileObserver.
int register_android_os_FileObserver(JNIEnv* env):
this funtion will get method id of "android/os/FileObserver$ObserverThread/onEvent",
and save the method id in method_onEvent,
and register all methods to androidruntime metioned above .
from what the function do , we should guess the function is called very early,
in fact the function's address is declared in array gRegJNI[] (static const RegJNIRec ),
each gRegJNI's element is called at androidRuntime's startup. (in function startreg)
- inotify in android
- Inotify
- inotify
- Inotify
- inotify
- inotify
- inotify
- Inotify
- inotify
- inotify
- inotify
- inotify
- Android Studio Inotify Watches Limit
- Inotify与Android文件监控FileObserver原理
- Inotify与Android文件监控FileObserver原理
- 解决Android Studio提示inotify大小不足的问题
- Android FileObserver–The Underlying inotify Mechanism and an Example
- inotify 笔记
- 如何禁止IPV6
- VC下使用命令行重定向输出
- Linux常见问题
- MFC获得当前应用程序目录GetCurrentDirectory()和GetModuleFileName()函数
- sizeof的用法
- inotify in android
- UPnP 协议概述
- 全自动安装微软雅黑字体- Ubuntu
- xcode 4.2下怎么添加framework?
- 郎咸平:中国人正上的四个大当 房产排第一
- svg webtopo原型8 -拖曳
- 一位码农的人生自述(十)------得失
- Cortex-M3 (NXP LPC1788)之ADC数模转换器的应用
- UPNP协议细节(转)