mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-30 06:47:53 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
23 lines
524 B
Objective-C
23 lines
524 B
Objective-C
#import <MonotonicTime/DeviceUptime.h>
|
|
|
|
#include <sys/sysctl.h>
|
|
|
|
int32_t getDeviceUptimeSeconds(int32_t *bootTime) {
|
|
struct timeval boottime;
|
|
int mib[2] = {CTL_KERN, KERN_BOOTTIME};
|
|
size_t size = sizeof(boottime);
|
|
time_t now;
|
|
time_t uptime = -1;
|
|
|
|
(void)time(&now);
|
|
|
|
if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && boottime.tv_sec != 0) {
|
|
uptime = now - boottime.tv_sec;
|
|
if (bootTime != NULL) {
|
|
*bootTime = boottime.tv_sec;
|
|
}
|
|
}
|
|
|
|
return uptime;
|
|
}
|