Skip to content

Commit b079391

Browse files
feat: inherit timezone from host
1 parent 51a4d4a commit b079391

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/plugins/terminal/scripts/init-alpine.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,10 @@ fi
3333
if [ "$1" = "--installing" ]; then
3434
echo "Configuring timezone..."
3535

36-
# Fetch timezone using wget
37-
TZ=$(wget -qO- https://ipapi.co/timezone)
38-
39-
if [ -n "$TZ" ] && [ -f "/usr/share/zoneinfo/$TZ" ]; then
36+
if [ -n "$ANDROID_TZ" ] && [ -f "/usr/share/zoneinfo/$ANDROID_TZ" ]; then
4037
ln -sf "/usr/share/zoneinfo/$TZ" /etc/localtime
41-
echo "$TZ" > /etc/timezone
42-
echo "Timezone set to: $TZ"
38+
echo "$ANDROID_TZ" > /etc/timezone
39+
echo "Timezone set to: $ANDROID_TZ"
4340
else
4441
echo "Failed to detect timezone"
4542
fi

src/plugins/terminal/src/android/TerminalService.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
import java.util.concurrent.Executors;
2727
import java.lang.reflect.Field;
2828

29+
import java.util.TimeZone;
30+
import java.util.Map;
31+
import java.util.HashMap;
32+
33+
2934

3035
public class TerminalService extends Service {
3136

@@ -141,6 +146,9 @@ private void startProcess(String pid, String cmd, String alpine) {
141146
Map<String, String> env = builder.environment();
142147
env.put("PREFIX", getFilesDir().getAbsolutePath());
143148
env.put("NATIVE_DIR", getApplicationInfo().nativeLibraryDir);
149+
TimeZone tz = TimeZone.getDefault();
150+
String timezoneId = tz.getID();
151+
env.put("ANDROID_TZ", timezoneId);
144152

145153
try {
146154
int target = getPackageManager().getPackageInfo(getPackageName(), 0).applicationInfo.targetSdkVersion;
@@ -180,6 +188,9 @@ private void exec(String execId, String cmd, String alpine) {
180188
Map<String, String> env = builder.environment();
181189
env.put("PREFIX", getFilesDir().getAbsolutePath());
182190
env.put("NATIVE_DIR", getApplicationInfo().nativeLibraryDir);
191+
TimeZone tz = TimeZone.getDefault();
192+
String timezoneId = tz.getID();
193+
env.put("ANDROID_TZ", timezoneId);
183194

184195
try {
185196
int target = getPackageManager().getPackageInfo(getPackageName(), 0).applicationInfo.targetSdkVersion;

0 commit comments

Comments
 (0)