Skip to content

Commit 2dfec0c

Browse files
committed
Merge branch 'timezone-fix' into release-v4.48.5
2 parents 1b46949 + 89674db commit 2dfec0c

6 files changed

Lines changed: 125 additions & 28 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
## v4.48.5
6+
- Bundle BitBox02 firmware version v9.23.2
7+
- iOS: fix wrong timezone when confirming time on BitBox02 (it would always show the time in UTC)
8+
59
## v4.48.4
610
- macOS: fix potential USB communication issue with BitBox02 bootloaders <v1.1.2 and firmwares <v9.23.1
711

backend/mobileserver/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ build-android:
55
# androidapi version should match minSdkVersion in frontends/android/BitBoxApp/app/build.gradle
66
ANDROID_HOME=${ANDROID_SDK_ROOT} gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target android -androidapi 24 .
77
build-ios:
8-
gomobile bind -x -a -glflags="-mod=readonly" -ldflags="-s -w" -target ios,iossimulator .
8+
gomobile bind -x -a -glflags="-mod=readonly" -tags="timetzdata" -ldflags="-s -w" -target ios,iossimulator .
99
clean:
1010
rm -f mobileserver.aar mobileserver-sources.jar
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2025 Shift Crypto AG
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
//go:build android
16+
17+
package mobileserver
18+
19+
import (
20+
"os/exec"
21+
"strings"
22+
"time"
23+
)
24+
25+
// fixTimezone sets the local timezone on Android. This is a workaround to the bug that on Android,
26+
// time.Local is hard-coded to UTC. See https://github.com/golang/go/issues/20455.
27+
//
28+
// We need the correct timezone to be able to send the `time.Now().Zone()` offset to the BitBox02.
29+
// Without it, the BitBox02 will always display UTC time instad of local time.
30+
//
31+
// This fix is copied from https://github.com/golang/go/issues/20455#issuecomment-342287698.
32+
func fixTimezone() {
33+
out, err := exec.Command("/system/bin/getprop", "persist.sys.timezone").Output()
34+
if err != nil {
35+
return
36+
}
37+
z, err := time.LoadLocation(strings.TrimSpace(string(out)))
38+
if err != nil {
39+
return
40+
}
41+
time.Local = z
42+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2025 Shift Crypto AG
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
//go:build ios
16+
17+
package mobileserver
18+
19+
/*
20+
#cgo CFLAGS: -x objective-c
21+
#cgo LDFLAGS: -framework Foundation
22+
#import <Foundation/Foundation.h>
23+
const char* getSystemTimeZone() {
24+
NSTimeZone *timeZone = [NSTimeZone systemTimeZone];
25+
NSString *timeZoneName = [timeZone name];
26+
return [timeZoneName UTF8String];
27+
}
28+
*/
29+
import "C"
30+
31+
import (
32+
"strings"
33+
"time"
34+
)
35+
36+
func getSystemTimeZone() string {
37+
tz := C.getSystemTimeZone()
38+
return C.GoString(tz)
39+
}
40+
41+
// fixTimezone sets the local timezone on iOS. This is a workaround to the bug that on iOS,
42+
// time.Local is hard-coded to UTC. See https://github.com/golang/go/issues/20797.
43+
//
44+
// We need the correct timezone to be able to send the `time.Now().Zone()` offset to the BitBox02.
45+
// Without it, the BitBox02 will always display UTC time instead of local time.
46+
//
47+
// This fix is copied from https://github.com/anyproto/anytype-heart/pull/775/ (referenced in the
48+
// above issue).
49+
func fixTimezone() {
50+
tzName := strings.TrimSpace(getSystemTimeZone())
51+
if len(tzName) == 0 {
52+
return
53+
}
54+
z, err := time.LoadLocation(tzName)
55+
if err != nil {
56+
return
57+
}
58+
time.Local = z
59+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2025 Shift Crypto AG
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
//go:build !ios && !android
16+
17+
package mobileserver
18+
19+
func fixTimezone() {}

backend/mobileserver/mobileserver.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@ package mobileserver
1717
import (
1818
"io"
1919
"log"
20-
"os/exec"
21-
"runtime"
22-
"strings"
2320
"sync"
24-
"time"
2521

2622
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/bridgecommon"
2723
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/devices/usb"
@@ -34,29 +30,6 @@ var (
3430
once sync.Once
3531
)
3632

37-
// fixTimezone sets the local timezone on Android. This is a workaround to the bug that on Android,
38-
// time.Local is hard-coded to UTC. See https://github.com/golang/go/issues/20455.
39-
//
40-
// We need the correct timezone to be able to send the `time.Now().Zone()` offset to the BitBox02.
41-
// Without it, the BitBox02 will always display UTC time instad of local time.
42-
//
43-
// This fix is copied from https://github.com/golang/go/issues/20455#issuecomment-342287698.
44-
func fixTimezone() {
45-
if runtime.GOOS != "android" {
46-
// Only run the fix on Android.
47-
return
48-
}
49-
out, err := exec.Command("/system/bin/getprop", "persist.sys.timezone").Output()
50-
if err != nil {
51-
return
52-
}
53-
z, err := time.LoadLocation(strings.TrimSpace(string(out)))
54-
if err != nil {
55-
return
56-
}
57-
time.Local = z
58-
}
59-
6033
func init() {
6134
fixTimezone()
6235
}

0 commit comments

Comments
 (0)