Bruno Haible <br...@clisp.org> writes: > I wrote: >> > No, it isn't. The attached file, when compiled and run under Termux (which >> > doesn't have particular permissions), prints e.g.: >> > >> > from clock : 1691616762.476870660 = 2023-08-09 21:32:42.476870660 >> > from sysinfo: 1691616762.329261637 = 2023-08-09 21:32:42.329261637 >> > >> > Note that this uses the kernel's uptime counter, so it will not work well >> > when the user changes the current time manually. But this is rare on >> > Android. > > It works well enough, that I'm adding it to Gnulib, through the attached > patch. > > Po Lu wrote: >> This uses the uptime counter (which also results in an SELinux denial >> for me, but different Android distributions have SELinux policies of >> varying strictness) > > How did you run the program, and which of the two calls (clock_gettime, > sysinfo) > failed for you? Maybe it depends not only on the Android version and device, > but also on the permissions required by the app?
Both clock_gettime (CLOCK_BOOTIME, ... sysinfo fail with AVC denial errors and errno set to EACCESS. I think it is a bit of a stretch to ascribe this to an app's requested permissions, though, since none of the listed permissions available to user programs seems pertinent.