Explorar o código

sm8450-common: gps: HAL: Location compilation bringup for wearables

Enable few more important compilation flags which will consider
warnings as errors. Most of these flags were configured to be
only warning for mobile SPs, but for wearable SPs some of them
are configured to be errors. So configure these as in common
GNSS flags so that same set of flags could be applied to mobile
SPs too.
Fix compilation errors which were showing up, when these flags
were enabled.

Change-Id: I62ef74419d4416252dfc8b25251ba3a51d522bfd
CRs-Fixed: 3292623
Vamana Murthi %!s(int64=2) %!d(string=hai) anos
pai
achega
cd7a05c656

+ 7 - 0
gps/Android.bp

@@ -1,5 +1,12 @@
 GNSS_CFLAGS = [
     "-Werror",
+    "-Wformat",
+    "-Wformat-extra-args",
+    "-Wunused-label",
+    "-Wunused-variable",
+    "-Wunused-function",
+    "-Wimplicit-fallthrough",
+    "-Wno-unused-parameter",
     "-Wno-error=unused-parameter",
     "-Wno-error=macro-redefined",
     "-Wno-error=reorder",

+ 7 - 0
gps/Android.mk

@@ -3,6 +3,13 @@ ifneq ($(BOARD_VENDOR_QCOM_GPS_LOC_API_HARDWARE),)
 # Set required flags
 GNSS_CFLAGS := \
     -Werror \
+    -Wformat \
+    -Wformat-extra-args \
+    -Wunused-label \
+    -Wunused-variable \
+    -Wunused-function \
+    -Wimplicit-fallthrough \
+    -Wno-unused-parameter \
     -Wno-error=unused-parameter \
     -Wno-error=macro-redefined \
     -Wno-error=reorder \

+ 12 - 2
gps/android/aidl-impl/Android.mk

@@ -29,13 +29,18 @@ LOCAL_SHARED_LIBRARIES := \
     android.hardware.gnss-V1-ndk \
     liblog \
     libcutils \
-    libqti_vndfwk_detect_vendor \
     libutils \
     libloc_core \
     libgps.utils \
     libdl \
     liblocation_api
 
+ifneq ($(TARGET_SUPPORTS_WEARABLES),true)
+    LOCAL_SHARED_LIBRARIES += libqti_vndfwk_detect_vendor
+else
+    LOCAL_SHARED_LIBRARIES += libqti_vndfwk_detect
+endif
+
 LOCAL_CFLAGS += $(GNSS_CFLAGS)
 
 include $(BUILD_SHARED_LIBRARY)
@@ -65,9 +70,14 @@ LOCAL_SHARED_LIBRARIES := \
     libutils \
     libgps.utils \
     liblocation_api \
-    libqti_vndfwk_detect_vendor \
     libbinder_ndk
 
+ifneq ($(TARGET_SUPPORTS_WEARABLES),true)
+    LOCAL_SHARED_LIBRARIES += libqti_vndfwk_detect_vendor
+else
+    LOCAL_SHARED_LIBRARIES += libqti_vndfwk_detect
+endif
+
 LOCAL_SHARED_LIBRARIES += \
     libhidlbase \
     [email protected] \

+ 1 - 1
gps/android/aidl-impl/GnssConfiguration.cpp

@@ -255,7 +255,7 @@ bool GnssConfiguration::setBlocklistedSource(GnssSvIdSource& copyToSource,
         break;
     default:
         copyToSource.constellation = GNSS_SV_TYPE_UNKNOWN;
-        LOC_LOGe("Invalid constellation %hhu", copyFromSource.constellation);
+        LOC_LOGe("Invalid constellation %d", copyFromSource.constellation);
         retVal = false;
         break;
     }

+ 1 - 1
gps/android/aidl-impl/GnssMeasurementInterface.cpp

@@ -538,7 +538,7 @@ void GnssMeasurementInterface::convertElapsedRealtimeNanos(
         elapsedRealtime.flags |= elapsedRealtime.HAS_TIME_UNCERTAINTY_NS;
         elapsedRealtime.timeUncertaintyNs = in.clock.elapsedRealTimeUnc;
         LOC_LOGd("elapsedRealtime.timestampNs=%" PRIi64 ""
-                 " elapsedRealtime.timeUncertaintyNs=%" PRIi64 " elapsedRealtime.flags=0x%X",
+                 " elapsedRealtime.timeUncertaintyNs=%lf elapsedRealtime.flags=0x%X",
                  elapsedRealtime.timestampNs,
                  elapsedRealtime.timeUncertaintyNs, elapsedRealtime.flags);
     }

+ 1 - 1
gps/android/aidl-impl/location_api/GnssAPIClient.cpp

@@ -145,7 +145,7 @@ void GnssAPIClient::gnssConfigurationUpdate(const GnssConfig& gnssConfig) {
 
 // callbacks
 void GnssAPIClient::onCapabilitiesCb(LocationCapabilitiesMask capabilitiesMask) {
-    LOC_LOGD("%s]: (%02x)", __FUNCTION__, capabilitiesMask);
+    LOC_LOGD("%s]: (0x%" PRIx64 ")", __FUNCTION__, capabilitiesMask);
     mLocationCapabilitiesMask = capabilitiesMask;
     mLocationCapabilitiesCached = true;
     mMutex.lock();

+ 6 - 2
gps/core/data-items/DataItemConcreteTypes.cpp

@@ -237,7 +237,9 @@ void TimeZoneChangeDataItem::stringify(string& valueStr) {
         valueStr.clear ();
         valueStr = TIMEZONECHANGE_FIELD_ENABLED;
         valueStr += ": ";
-        valueStr += "true";
+        char time [30];
+        snprintf (time, 30, "%" PRIi64, d->mCurrTimeMillis);
+        valueStr += string (time);
     } while (0);
     EXIT_LOG_WITH_ERROR("%d", result);
 }
@@ -249,7 +251,9 @@ void TimeChangeDataItem::stringify(string& valueStr) {
         valueStr.clear ();
         valueStr = TIMECHANGE_FIELD_ENABLED;
         valueStr += ": ";
-        valueStr += "true";
+        char time [30];
+        snprintf (time, 30, "%" PRIi64, d->mCurrTimeMillis);
+        valueStr += string (time);
     } while (0);
     EXIT_LOG_WITH_ERROR("%d", result);
 }

+ 0 - 2
gps/geofence/GeofenceAdapter.cpp

@@ -919,8 +919,6 @@ GeofenceAdapter::updateSystemPowerStateCommand(PowerStateType powerState)
 void
 GeofenceAdapter::pauseOrResumeGeofences(bool pauseOrResume /*false - pause, true - resume*/)
 {
-    LocationError error;
-
     for (auto it = mGeofenceIds.begin(); it != mGeofenceIds.end(); ++it) {
 
         uint32_t hwId = it->second;

+ 0 - 1
gps/gnss/GnssAdapter.cpp

@@ -1157,7 +1157,6 @@ GnssAdapter::setConfig()
 std::vector<LocationError> GnssAdapter::gnssUpdateConfig(const std::string& oldMoServerUrl,
         const std::string& moServerUrl, const std::string& serverUrl,
         GnssConfig& gnssConfigRequested, GnssConfig& gnssConfigNeedEngineUpdate, size_t count) {
-    loc_gps_cfg_s gpsConf = ContextBase::mGps_conf;
     size_t index = 0;
     LocationError err = LOCATION_ERROR_SUCCESS;
     std::vector<LocationError> errsList = {err};

+ 37 - 1
gps/gnss/NativeAgpsHandler.cpp

@@ -26,6 +26,43 @@
  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  */
+
+/*
+Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted (subject to the limitations in the
+disclaimer below) provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+    * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
 #define LOG_TAG "LocSvc_NativeAgpsHandler"
 
 #include <LocAdapterBase.h>
@@ -50,7 +87,6 @@ void NativeAgpsHandler::notify(const unordered_set<IDataItemCore*>& dlist) {
             case NETWORKINFO_DATA_ITEM_ID: {
                 NetworkInfoDataItem* networkInfo = static_cast<NetworkInfoDataItem*>(each);
                 uint64_t mobileBit = (uint64_t )1 << loc_core::TYPE_MOBILE;
-                uint64_t allTypes = networkInfo->mAllTypes;
                 mConnected = ((networkInfo->mAllTypes & mobileBit) == mobileBit);
                 /**
                  * mApn Telephony preferred Access Point Name to use for

+ 0 - 1
gps/gnss/location_gnss.cpp

@@ -87,7 +87,6 @@ static uint32_t setConstrainedTunc (bool enable, float tuncConstraint,
 static uint32_t setPositionAssistedClockEstimator(bool enable);
 static uint32_t gnssUpdateSvConfig(const GnssSvTypeConfig& constellationEnablementConfig,
                                    const GnssSvIdConfig& blacklistSvConfig);
-static uint32_t gnssResetSvConfig();
 static uint32_t configLeverArm(const LeverArmConfigInfo& configInfo);
 static uint32_t configRobustLocation(bool enable, bool enableForE911);
 static uint32_t configMinGpsWeek(uint16_t minGpsWeek);

+ 0 - 11
gps/location/LocationAPI.cpp

@@ -131,17 +131,6 @@ static void loadLibGeofencing() {
     }
 }
 
-static bool needsGnssTrackingInfo(LocationCallbacks& locationCallbacks)
-{
-    return (locationCallbacks.gnssLocationInfoCb != nullptr ||
-            locationCallbacks.engineLocationsInfoCb != nullptr ||
-            locationCallbacks.gnssSvCb != nullptr ||
-            locationCallbacks.gnssNmeaCb != nullptr ||
-            locationCallbacks.gnssDataCb != nullptr ||
-            locationCallbacks.gnssMeasurementsCb != nullptr ||
-            locationCallbacks.gnssNHzMeasurementsCb != nullptr);
-}
-
 static bool isGnssClient(LocationCallbacks& locationCallbacks)
 {
     return (locationCallbacks.gnssNiCb != nullptr ||

+ 1 - 3
gps/utils/loc_cfg.cpp

@@ -584,11 +584,10 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p
     loc_process_info_s_type *child_proc = nullptr;
     volatile int i=0;
     unsigned int j=0;
-    gid_t gid_list[LOC_PROCESS_MAX_NUM_GROUPS];
     char *split_strings[MAX_NUM_STRINGS];
     int name_length=0, group_list_length=0, platform_length=0, baseband_length=0, ngroups=0, ret=0;
     int auto_platform_length = 0, soc_id_list_length=0;
-    int group_index=0, nstrings=0, status_length=0;
+    int nstrings=0, status_length=0;
     FILE* conf_fp = nullptr;
     char platform_name[PROPERTY_VALUE_MAX], baseband_name[PROPERTY_VALUE_MAX];
     int low_ram_target=0;
@@ -596,7 +595,6 @@ int loc_read_process_conf(const char* conf_file_name, uint32_t * process_count_p
     unsigned int loc_service_mask=0;
     unsigned char config_mask = 0;
     unsigned char proc_list_length=0;
-    int gtp_cell_ap_enabled = 0;
     char arg_gtp_waa[LOC_PROCESS_MAX_ARG_STR_LENGTH] = "--";
     char arg_gtp_modem_cell[LOC_PROCESS_MAX_ARG_STR_LENGTH] = "--";
     char arg_gtp_wifi[LOC_PROCESS_MAX_ARG_STR_LENGTH] = "--";

+ 0 - 1
gps/utils/loc_log.cpp

@@ -141,7 +141,6 @@ RETURN VALUE
 ===========================================================================*/
 const char *loc_get_target_name(unsigned int target)
 {
-    int64_t index = 0;
     static char ret[BUFFER_SIZE];
 
     snprintf(ret, sizeof(ret), " %s with%s SSC",

+ 1 - 1
gps/utils/loc_misc_utils.cpp

@@ -175,7 +175,7 @@ uint64_t getQTimerDeltaNanos()
     char qtimer_val_string[100];
     char *temp;
     uint64_t local_qtimer = 0, remote_qtimer = 0;
-    int mdm_fd = -1, wlan_fd = -1, ret = 0;
+    int mdm_fd = -1, ret = 0;
     uint64_t delta = 0;
 
     memset(qtimer_val_string, '\0', sizeof(qtimer_val_string));

+ 36 - 1
gps/utils/loc_target.cpp

@@ -27,6 +27,42 @@
  *
  */
 
+/*
+Changes from Qualcomm Innovation Center are provided under the following license:
+
+Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted (subject to the limitations in the
+disclaimer below) provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+    * Neither the name of Qualcomm Innovation Center, Inc. nor the names of its
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -142,7 +178,6 @@ void loc_get_auto_platform_name(char *platform_name, int array_length)
 */
 int loc_identify_low_ram_target()
 {
-    int ret = 0;
     char low_ram_target[PROPERTY_VALUE_MAX];
     property_get("ro.config.low_ram", low_ram_target, "");
     LOC_LOGd("low ram target: %s\n", low_ram_target);