C Android上的settimeofday()会导致错误-只读文件系统
我正在尝试用C语言的NDK本机代码设置设备时间。据我所知,最好的解决方案是使用settimeofday() 导致C Android上的settimeofday()会导致错误-只读文件系统,c,linux,time,android-ndk,C,Linux,Time,Android Ndk,我正在尝试用C语言的NDK本机代码设置设备时间。据我所知,最好的解决方案是使用settimeofday() 导致 settimeofday() failed: Read-only file system 在native中是否有其他方法来设置时间?有可能吗?我看了只读文件系统部分的问题,但我没有根设备 提前谢谢 如果没有足够的权限,您无法设置设备时间,应用程序将无法在非根设备上获得该权限。从手册页: EPERM The calling process has insufficient p
settimeofday() failed: Read-only file system
在native中是否有其他方法来设置时间?有可能吗?我看了只读文件系统部分的问题,但我没有根设备
提前谢谢 如果没有足够的权限,您无法设置设备时间,应用程序将无法在非根设备上获得该权限。从手册页:
EPERM The calling process has insufficient privilege to call settime-
ofday(); under Linux the CAP_SYS_TIME capability is required.
即使您成功地设置了它,下次设备通过网络获得时间更新时,它也可能被覆盖
有点奇怪,你得到的是EROFS而不是EPERM。Android系统时钟映射到“/dev/alarm”,它只对非系统应用程序具有读取权限。所以,如果你想改变一个股票设备的时间,那你就倒霉了。你必须使用其中一种-
希望这能有所帮助。因此,只有在使用Java API的应用程序上下文中才能设置时间:)?
EPERM The calling process has insufficient privilege to call settime-
ofday(); under Linux the CAP_SYS_TIME capability is required.