From 2f83043c6894f1b88aec37551e1431df629abece Mon Sep 17 00:00:00 2001 From: Tad Date: Sun, 9 Aug 2020 12:14:29 -0400 Subject: [PATCH] 14.1+15.1: GPS week rollover fix 16.0: 279492 17.1: 278135 also switch to alternate Xtra servers https://developer.gemalto.com/threads/gps-time-info-error --- .../0001-rollover.patch | 105 ++++++++++++++++++ .../0001-rollover.patch | 89 +++++++++++++++ Scripts/Common/Functions.sh | 6 + Scripts/LineageOS-14.1/Patch.sh | 3 + Scripts/LineageOS-15.1/Patch.sh | 3 + 5 files changed, 206 insertions(+) create mode 100644 Patches/Common/android_hardware_qcom_gps/0001-rollover.patch create mode 100644 Patches/LineageOS-14.1/android_harware_qcom_gps/0001-rollover.patch diff --git a/Patches/Common/android_hardware_qcom_gps/0001-rollover.patch b/Patches/Common/android_hardware_qcom_gps/0001-rollover.patch new file mode 100644 index 00000000..01e8b956 --- /dev/null +++ b/Patches/Common/android_hardware_qcom_gps/0001-rollover.patch @@ -0,0 +1,105 @@ +From 67a2a14cf94f41a11d73cd76aac01fb02f4b6399 Mon Sep 17 00:00:00 2001 +From: jlask +Date: Tue, 19 May 2020 10:04:37 -0500 +Subject: [PATCH] gps: Correct week rollover timestamps + +This adjustment will help with applications checking the time coming from gps. +Some applictions will consider times in the far past as an error. + +Change-Id: I69d6971249c4898ac3895f725e46f268cdb2b00d +--- + core/LocApiBase.cpp | 7 +++++++ + msm8084/core/LocApiBase.cpp | 7 +++++++ + msm8909/core/LocApiBase.cpp | 7 +++++++ + msm8960/core/LocApiBase.cpp | 6 ++++++ + msm8974/core/LocApiBase.cpp | 6 ++++++ + 5 files changed, 33 insertions(+) + +diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp +index f56694e..a284080 100644 +--- a/core/LocApiBase.cpp ++++ b/core/LocApiBase.cpp +@@ -243,6 +243,13 @@ void LocApiBase::reportPosition(UlpLocation &location, + location.gpsLocation.bearing, location.gpsLocation.accuracy, + location.gpsLocation.timestamp, location.rawDataSize, + location.rawData, status, loc_technology_mask); ++ ++ if (location.gpsLocation.timestamp > 0 && ++ location.gpsLocation.timestamp <1580000000000) { ++ location.gpsLocation.timestamp = location.gpsLocation.timestamp + 619315200000; ++ LOC_LOGV("week rollover fixed, timestamp: %lld.", location.gpsLocation.timestamp); ++ } ++ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS( + mLocAdapters[i]->reportPosition(location, +diff --git a/msm8084/core/LocApiBase.cpp b/msm8084/core/LocApiBase.cpp +index 152243f..aed4cdd 100644 +--- a/msm8084/core/LocApiBase.cpp ++++ b/msm8084/core/LocApiBase.cpp +@@ -237,6 +237,13 @@ void LocApiBase::reportPosition(UlpLocation &location, + location.gpsLocation.bearing, location.gpsLocation.accuracy, + location.gpsLocation.timestamp, location.rawDataSize, + location.rawData, status, loc_technology_mask); ++ ++ if (location.gpsLocation.timestamp > 0 && ++ location.gpsLocation.timestamp <1580000000000) { ++ location.gpsLocation.timestamp = location.gpsLocation.timestamp + 619315200000; ++ LOC_LOGV("week rollover fixed, timestamp: %lld.", location.gpsLocation.timestamp); ++ } ++ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS( + mLocAdapters[i]->reportPosition(location, +diff --git a/msm8909/core/LocApiBase.cpp b/msm8909/core/LocApiBase.cpp +index 01aba47..a0315aa 100644 +--- a/msm8909/core/LocApiBase.cpp ++++ b/msm8909/core/LocApiBase.cpp +@@ -243,6 +243,13 @@ void LocApiBase::reportPosition(UlpLocation &location, + location.gpsLocation.bearing, location.gpsLocation.accuracy, + location.gpsLocation.timestamp, location.rawDataSize, + location.rawData, status, loc_technology_mask); ++ ++ if (location.gpsLocation.timestamp > 0 && ++ location.gpsLocation.timestamp <1580000000000) { ++ location.gpsLocation.timestamp = location.gpsLocation.timestamp + 619315200000; ++ LOC_LOGV("week rollover fixed, timestamp: %lld.", location.gpsLocation.timestamp); ++ } ++ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS( + mLocAdapters[i]->reportPosition(location, +diff --git a/msm8960/core/LocApiBase.cpp b/msm8960/core/LocApiBase.cpp +index 82c7692..ad384d2 100644 +--- a/msm8960/core/LocApiBase.cpp ++++ b/msm8960/core/LocApiBase.cpp +@@ -197,6 +197,12 @@ void LocApiBase::reportPosition(UlpLocation &location, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask) + { ++ if (location.gpsLocation.timestamp > 0 && ++ location.gpsLocation.timestamp <1580000000000) { ++ location.gpsLocation.timestamp = location.gpsLocation.timestamp + 619315200000; ++ LOC_LOGV("week rollover fixed, timestamp: %lld.", location.gpsLocation.timestamp); ++ } ++ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS( + mLocAdapters[i]->reportPosition(location, +diff --git a/msm8974/core/LocApiBase.cpp b/msm8974/core/LocApiBase.cpp +index 6969fe5..9367012 100644 +--- a/msm8974/core/LocApiBase.cpp ++++ b/msm8974/core/LocApiBase.cpp +@@ -226,6 +226,12 @@ void LocApiBase::reportPosition(UlpLocation &location, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask) + { ++ if (location.gpsLocation.timestamp > 0 && ++ location.gpsLocation.timestamp <1580000000000) { ++ location.gpsLocation.timestamp = location.gpsLocation.timestamp + 619315200000; ++ LOC_LOGV("week rollover fixed, timestamp: %lld.", location.gpsLocation.timestamp); ++ } ++ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS( + mLocAdapters[i]->reportPosition(location, diff --git a/Patches/LineageOS-14.1/android_harware_qcom_gps/0001-rollover.patch b/Patches/LineageOS-14.1/android_harware_qcom_gps/0001-rollover.patch new file mode 100644 index 00000000..a41fb770 --- /dev/null +++ b/Patches/LineageOS-14.1/android_harware_qcom_gps/0001-rollover.patch @@ -0,0 +1,89 @@ +From 895557ea85e34d3f969955f234186c5a0afab0a9 Mon Sep 17 00:00:00 2001 +From: jlask +Date: Tue, 19 May 2020 10:04:37 -0500 +Subject: [PATCH] gps: Correct week rollover timestamps + +This adjustment will help with applications checking the time coming from gps. +Some applictions will consider times in the far past as an error. + +Change-Id: I69d6971249c4898ac3895f725e46f268cdb2b00d +--- + core/LocApiBase.cpp | 7 +++++++ + msm8909/core/LocApiBase.cpp | 7 +++++++ + msm8960/core/LocApiBase.cpp | 6 ++++++ + msm8974/core/LocApiBase.cpp | 6 ++++++ + 4 files changed, 26 insertions(+) + +diff --git a/core/LocApiBase.cpp b/core/LocApiBase.cpp +index f56694e..a284080 100644 +--- a/core/LocApiBase.cpp ++++ b/core/LocApiBase.cpp +@@ -243,6 +243,13 @@ void LocApiBase::reportPosition(UlpLocation &location, + location.gpsLocation.bearing, location.gpsLocation.accuracy, + location.gpsLocation.timestamp, location.rawDataSize, + location.rawData, status, loc_technology_mask); ++ ++ if (location.gpsLocation.timestamp > 0 && ++ location.gpsLocation.timestamp <1580000000000) { ++ location.gpsLocation.timestamp = location.gpsLocation.timestamp + 619315200000; ++ LOC_LOGV("week rollover fixed, timestamp: %lld.", location.gpsLocation.timestamp); ++ } ++ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS( + mLocAdapters[i]->reportPosition(location, +diff --git a/msm8909/core/LocApiBase.cpp b/msm8909/core/LocApiBase.cpp +index 01aba47..a0315aa 100644 +--- a/msm8909/core/LocApiBase.cpp ++++ b/msm8909/core/LocApiBase.cpp +@@ -243,6 +243,13 @@ void LocApiBase::reportPosition(UlpLocation &location, + location.gpsLocation.bearing, location.gpsLocation.accuracy, + location.gpsLocation.timestamp, location.rawDataSize, + location.rawData, status, loc_technology_mask); ++ ++ if (location.gpsLocation.timestamp > 0 && ++ location.gpsLocation.timestamp <1580000000000) { ++ location.gpsLocation.timestamp = location.gpsLocation.timestamp + 619315200000; ++ LOC_LOGV("week rollover fixed, timestamp: %lld.", location.gpsLocation.timestamp); ++ } ++ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS( + mLocAdapters[i]->reportPosition(location, +diff --git a/msm8960/core/LocApiBase.cpp b/msm8960/core/LocApiBase.cpp +index f50d3e1..e6fb8cb 100644 +--- a/msm8960/core/LocApiBase.cpp ++++ b/msm8960/core/LocApiBase.cpp +@@ -196,6 +196,12 @@ void LocApiBase::reportPosition(UlpLocation &location, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask) + { ++ if (location.gpsLocation.timestamp > 0 && ++ location.gpsLocation.timestamp <1580000000000) { ++ location.gpsLocation.timestamp = location.gpsLocation.timestamp + 619315200000; ++ LOC_LOGV("week rollover fixed, timestamp: %lld.", location.gpsLocation.timestamp); ++ } ++ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS( + mLocAdapters[i]->reportPosition(location, +diff --git a/msm8974/core/LocApiBase.cpp b/msm8974/core/LocApiBase.cpp +index 6969fe5..9367012 100644 +--- a/msm8974/core/LocApiBase.cpp ++++ b/msm8974/core/LocApiBase.cpp +@@ -226,6 +226,12 @@ void LocApiBase::reportPosition(UlpLocation &location, + enum loc_sess_status status, + LocPosTechMask loc_technology_mask) + { ++ if (location.gpsLocation.timestamp > 0 && ++ location.gpsLocation.timestamp <1580000000000) { ++ location.gpsLocation.timestamp = location.gpsLocation.timestamp + 619315200000; ++ LOC_LOGV("week rollover fixed, timestamp: %lld.", location.gpsLocation.timestamp); ++ } ++ + // loop through adapters, and deliver to all adapters. + TO_ALL_LOCADAPTERS( + mLocAdapters[i]->reportPosition(location, +-- +2.26.2 + diff --git a/Scripts/Common/Functions.sh b/Scripts/Common/Functions.sh index 1a10890c..702a543a 100644 --- a/Scripts/Common/Functions.sh +++ b/Scripts/Common/Functions.sh @@ -395,6 +395,9 @@ hardenLocationConf() { #Switch gpsOneXtra to IZatCloud (invalid certificate) sed -i '/xtrapath/!s|://xtra|://xtrapath|' "$gpsConfig" &>/dev/null || true; sed -i 's|gpsonextra.net|izatcloud.net|' "$gpsConfig" &>/dev/null || true; + sed -i 's|xtrapath1|xtrapath4|' "$gpsConfig" &>/dev/null || true; + sed -i 's|xtrapath2|xtrapath5|' "$gpsConfig" &>/dev/null || true; + sed -i 's|xtrapath3|xtrapath6|' "$gpsConfig" &>/dev/null || true; #Enable HTTPS (IZatCloud supports HTTPS) sed -i 's|http://xtrapath|https://xtrapath|' "$gpsConfig" &>/dev/null || true; #sed -i 's|http://gllto|https://gllto|' "$gpsConfig" &>/dev/null || true; XXX: GLPals has an invaid certificate @@ -431,6 +434,9 @@ hardenLocationFWB() { #Switch gpsOneXtra to IZatCloud (invalid certificate) sed -i '/xtrapath/!s|://xtra|://xtrapath|' "$dir"/frameworks/base/core/res/res/values*/*.xml &>/dev/null || true; sed -i 's|gpsonextra.net|izatcloud.net|' "$dir"/frameworks/base/core/res/res/values*/*.xml &>/dev/null || true; + sed -i 's|xtrapath1|xtrapath4|' "$dir"/frameworks/base/core/res/res/values*/*.xml &>/dev/null || true; + sed -i 's|xtrapath2|xtrapath5|' "$dir"/frameworks/base/core/res/res/values*/*.xml &>/dev/null || true; + sed -i 's|xtrapath3|xtrapath6|' "$dir"/frameworks/base/core/res/res/values*/*.xml &>/dev/null || true; #Enable HTTPS (IZatCloud supports HTTPS) sed -i 's|http://xtrapath|https://xtrapath|' "$dir"/frameworks/base/core/res/res/values*/*.xml &>/dev/null || true; #sed -i 's|http://gllto|https://gllto|' "$dir"/frameworks/base/core/res/res/values*/*.xml &>/dev/null || true; XXX: GLPals has an invaid certificate diff --git a/Scripts/LineageOS-14.1/Patch.sh b/Scripts/LineageOS-14.1/Patch.sh index f38f660c..82c3d86e 100644 --- a/Scripts/LineageOS-14.1/Patch.sh +++ b/Scripts/LineageOS-14.1/Patch.sh @@ -121,6 +121,9 @@ enterAndClear "hardware/ti/wlan"; git apply "$DOS_PATCHES/android_hardware_ti_wlan/209209.patch"; #wl12xx: Update SR and MR firmwares versions git apply "$DOS_PATCHES/android_hardware_ti_wlan/209210.patch"; #wl12xx: Update SR PLT firmwares +enterAndClear "hardware/qcom/gps"; +git apply "$DOS_PATCHES/android_hardware_qcom_gps/0001-rollover.patch"; #fix week rollover + if enter "kernel/wireguard"; then if [ "$DOS_WIREGUARD_INCLUDED" = false ]; then rm Android.mk; fi; #Remove system information from HTTP requests diff --git a/Scripts/LineageOS-15.1/Patch.sh b/Scripts/LineageOS-15.1/Patch.sh index dad73645..831fe01c 100644 --- a/Scripts/LineageOS-15.1/Patch.sh +++ b/Scripts/LineageOS-15.1/Patch.sh @@ -115,6 +115,9 @@ awk -i inplace '!/mPermissionReviewRequired = Build.PERMISSIONS_REVIEW_REQUIRED/ awk -i inplace '!/\|\| context.getResources\(\).getBoolean\(/' service/java/com/android/server/wifi/WifiServiceImpl.java; awk -i inplace '!/com.android.internal.R.bool.config_permissionReviewRequired/' service/java/com/android/server/wifi/WifiServiceImpl.java; +enterAndClear "hardware/qcom/gps"; +git apply "$DOS_PATCHES_COMMON/android_hardware_qcom_gps/0001-rollover.patch"; #fix week rollover + if enter "kernel/wireguard"; then if [ "$DOS_WIREGUARD_INCLUDED" = false ]; then rm Android.mk; fi; #Remove system information from HTTP requests