webOS-ports / luneos-testing

Public testing images for LuneOS
4 stars 0 forks source link

Incorrect timezone is being chosen in FirstUse #2

Open Herrie82 opened 2 years ago

Herrie82 commented 2 years ago

Describe the bug The timezone chosen in FirstUse is incorrect, probably due to a change in the timezone data provided.

To Reproduce In FirstUse select your country, when you come to the timezone page you'll notice it doesn't show or select the correct timezone.

Expected behavior The correct timezone should be automatically selected based on country or available MCC/MNC when a SIM is present.

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

Herrie82 commented 2 years ago

It seems that no offset is being populated for the countries anymore. Need to check luna-init to see if something needs updating in the timeZone files etc

Herrie82 commented 10 months ago

@Tofee It seems that "offsetFromUTC" ends up being 0 in all cases, causing the code in FirstUse not to work.

I guess the issue might be in here somehow?

https://github.com/webosose/luna-sysservice/blob/16eca0bf1b09bbbfeabbbb06c782b3167ea7979f/Src/TimePrefsHandler.cpp#L248-L251 which used to be:

https://github.com/openwebos/luna-sysservice/blob/c59b806a70bc1489a45f22454f07718bce51d350/Src/TimePrefsHandler.cpp#L1236-L1241

Which uses this file as source: https://github.com/webosose/luna-init/blob/master/src/ext-timezones.json

Tofee commented 10 months ago

Mmh both the new and the old code look good... It would need a pass in a debugger I think, to see more clearly what happens there.

Herrie82 commented 10 months ago

A bit weird here... The value is shown correctly in another call:

root@qemux86-64:/var/luna/preferences# luna-send -f -n 1 luna://com.palm.systemservice/time/getSystemTime '{}'
{
    "returnValue": true,
    "timezone": "Europe/Amsterdam",
    "localtime": {
        "month": 1,
        "day": 2,
        "hour": 15,
        "year": 2024,
        "minute": 15,
        "second": 21
    },
    "TZ": "CET",
    "offset": 60,
    "systemTimeSource": "ntp",
    "utc": 1704204921,
    "isDST": false,
    "timeZoneFile": "/var/luna/preferences/localtime",
    "timestamp": {
        "source": "monotonic",
        "sec": 14824,
        "nsec": 287385799
    }
}
root@qemux86-64:/var/luna/preferences# luna-send -f -n 1 luna://com.palm.systemservice/getPreferences '{"keys": ["region", "timeZone", "timeFormat", "locale"]}'
{
    "timeZone": {
        "ZoneID": "Europe/Amsterdam",
        "Country": "Netherlands",
        "supportsDST": 0,
        "offsetFromUTC": 0,
        "CountryCode": "NL",
        "Description": "Central European Time",
        "City": "Amsterdam"
    },
    "subscribed": false,
    "timeFormat": "HH12",
    "returnValue": true,
    "locale": {
        "languageCode": "en",
        "countryCode": "us",
        "phoneRegion": {
            "countryCode": "us",
            "countryName": "United States"
        }
    },
    "region": {
        "countryCode": "nl",
        "countryName": "Netherlands"
    }
}
Herrie82 commented 10 months ago

luna-send -n 1 luna://com.palm.systemservice/getPreferenceValues '{"key": "timeZone"}' also shows the incorrect value

Herrie82 commented 10 months ago

Ok seems issue might be in https://github.com/webosose/luna-init/blob/master/src/gen-ext-timezones.py

The generated ext-timezones.json doesn't contain the correct offsetFromUTC. Culprit is likely https://github.com/webosose/luna-init/blob/master/src/gen-ext-timezones.py#L121

Herrie82 commented 10 months ago

OK seems we need a new syntax in Python3: https://stackoverflow.com/questions/15940280/how-to-get-utc-time-in-python

I'll prepare a fix

Herrie82 commented 10 months ago

Seems I have a rebased and patched luna-init from OSE already in the works. Will test that first and add it to that PR

Herrie82 commented 9 months ago

Mostly solved now, just the selection of the correct timezone based on the country isn't working (anymore). Need to debug it a bit further:

https://github.com/webOS-ports/org.webosports.app.firstuse/blob/master/qml/TimeZonePage.qml#L169