Skip to content

Commit 9dfd5c2

Browse files
committed
Update timezone setting on miyoo flip to match what miyoo stock os expects
1 parent 48ea4cc commit 9dfd5c2

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

main-ui/devices/miyoo/flip/miyoo_flip.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import inspect
22
from pathlib import Path
33
import re
4+
import shutil
45
import subprocess
56
import threading
67
import time
@@ -138,7 +139,6 @@ def startup_init(self, include_wifi=True):
138139
self.start_wifi_services()
139140

140141
self.init_bluetooth()
141-
self.apply_timezone(self.system_config.get_timezone())
142142

143143
def init_bluetooth(self):
144144
if(self.system_config.is_bluetooth_enabled()):
@@ -360,11 +360,32 @@ def prompt_timezone_update(self):
360360
self.system_config.set_timezone(tz)
361361
self.apply_timezone(tz)
362362

363+
363364
def apply_timezone(self, timezone):
364-
os.environ['TZ'] = timezone
365-
time.tzset()
366-
#If we set the time be sure to
367-
#export TZ='{timezone}'
365+
zoneinfo_path = f"/usr/share/zoneinfo/{timezone}"
366+
localtime_path = "/userdata/localtime"
367+
timezone_path = "/userdata/timezone"
368+
369+
if not os.path.isfile(zoneinfo_path):
370+
Display.write_message_multiline([f"Error getting timezone file",
371+
f"Does not appear to be a file",f"{timezone}"
372+
],3_000)
373+
return
374+
375+
def safe_delete(path):
376+
if os.path.lexists(path):
377+
if os.path.isdir(path) and not os.path.islink(path):
378+
shutil.rmtree(path)
379+
else:
380+
os.remove(path)
381+
382+
safe_delete(localtime_path)
383+
safe_delete(timezone_path)
384+
385+
shutil.copyfile(zoneinfo_path, localtime_path)
386+
shutil.copyfile(localtime_path, timezone_path)
387+
388+
Display.display_message("May need to reboot to apply timezone setting",3_000)
368389

369390
def set_theme(self, theme_path: str):
370391
MiyooTrimCommon.set_theme(MiyooFlip.MIYOO_STOCK_CONFIG_LOCATION, theme_path)

0 commit comments

Comments
 (0)