0
点赞
收藏
分享

微信扫一扫

android 恢复出厂设置之后如何将时间变为初始值

杰森wang 2023-04-04 阅读 52

Recovery.c (bootable\recovery):

 #include <linux/rtc.h> 

 #include <sys/ioctl.h>

  void set_rtc(void) { 

  struct tm tm; 

  int fd; 

  tm.tm_sec = 0; 

  tm.tm_min = 0; 

  tm.tm_hour = 0; 

  tm.tm_mday = 1; 

  tm.tm_mon = 0; 

  tm.tm_year = 2012-1900;

  

 fd = open("/dev/rtc0", O_WRONLY);

  

 if (fd != -1) { 

  ioctl(fd, RTC_SET_TIME, &tm); 

  close(fd); 

  } 

 }

  

 int 

 main(int argc, char **argv) {

  

 ... 

 中的

  

 } else if (wipe_data) {

  

 .... 

  // 

 /*该else if代码最后 新增代码如下*/

  

 set_rtc(); 

 }

举报

相关推荐

0 条评论