Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 6418 [details]
FileObserver implementation and sample usage
I'm having a few issues using the native FileObserver
- FileObserverEvents is not marked as [Flags]. Not a major issue, as you can still do the binary operations, but a bit annoying.
- The FileObserver does not recognize the flags I'm passing, and returns significantly different values.
Example: the following mask FileObserverEvents.Create | FileObserverEvents.Delete | FileObserverEvents.MovedFrom | FileObserverEvents.MovedTo returns 960 which looks correct, but the FileObserver doesn't show anything. When I look at the return values without using the mask I'm seeing values like 1073741840, 1073741856, 1073741840. The last 3 figures look correct, but everything else doesn't make any sense to me.
I have added [Flags] attribute on FileObserverEvents enum for monodroid 4.14. Thanks for the report.
Those returned values do make sense. You have to use logical calculation with the returned values.
1073741840 = 40000010 means FileObserver.CLOSE_NOWRITE (0x10)
1073741856 = 40000020 means FileObserver.OPEN (0x20)
I found some example usage on this API here:
Thanks, I didn't think that the values were in hex...
Thanks for the link.
After further investigation, I found this link http://rswiki.csie.org/lxr/http/source/include/linux/inotify.h?a=m68k#L45 , which shows a few additional flags.
The interesting one is
#define IN_ISDIR 0x40000000 /* event occurred against dir */
which is not exposed by the Android docs, but it's actually been used by Android.
The values I got (0x40000020) where against a folder, which now makes sense.
How would you manage this? Should I implement this check in my library, or is something that Xamarin.Android could pick up?
That seems to be non-public API, so we wouldn't bind it. There should be reason that Google does not expose it i.e. it is not supposed by developers in their code. You should be able to write code without it, like using logical operations mentioned earlier.
To verify this issue I have checked the "Assemble Browser" and observed that a [Flags] attribute is added on FileObserverEvents enum. But I am not sure how to verify the values of following mask FileObserverEvents.Create |
FileObserverEvents.Delete | FileObserverEvents.MovedFrom |
Screencast : http://www.screencast.com/t/EI1MawskXN
Environment Info :
=== Xamarin Studio ===
Version 4.2.5 (build 0)
Installation UUID: 312d4e9a-339c-433f-a27b-88ce0777af8f
Microsoft .NET 4.0.30319.34014
GTK+ 2.24.22 (MS-Windows theme)
=== Xamarin.Android ===
Version: 4.15.0 (Enterprise Edition)
Android SDK: D:\SDK\AndroidSDK
Supported Android versions:
2.1 (API level 7)
2.2 (API level 8)
2.3 (API level 10)
3.1 (API level 12)
3.2 (API level 13)
4.0 (API level 14)
4.0.3 (API level 15)
4.1 (API level 16)
4.2 (API level 17)
4.3 (API level 18)
4.4 (API level 19)
Java SDK: C:\Program Files (x86)\Java\jdk1.6.0_31
java version "1.6.0_31"
Java(TM) SE Runtime Environment (build 1.6.0_31-b05)
Java HotSpot(TM) Client VM (build 20.6-b01, mixed mode)
=== Build Information ===
Release ID: 402050000
Git revision: 95ac543f224a70960a9ab71e24ce341eb87de06f
Build date: 2014-05-02 12:59:15-04
Xamarin addins: b81285ac0156281956135adb96685f98922893a1
=== Operating System ===
Windows 6.2.9200.0 (64-bit)