replace common qcom sources with samsung ones

This commit is contained in:
SaschaNes
2025-08-12 22:13:00 +02:00
parent ba24dcded9
commit 6f7753de11
5682 changed files with 2450203 additions and 103634 deletions

View File

@@ -0,0 +1,10 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libnlp_api_headers
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/inc
include $(BUILD_HEADER_LIBRARY)
include $(CLEAR_VARS)

View File

@@ -0,0 +1,66 @@
/* Copyright (c) 2021 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted 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 The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
*/
#ifndef ALT_REC_H
#define ALT_REC_H
#include <DBCommon.h>
/******************************************************************************
AltitudeReceiver
******************************************************************************/
typedef struct {
NlpLocation loc;
uint64_t elapsedRealTimeInMs;
} LocationExt;
/** @brief
All the memory pointers received will be never freed internally.
Caller shall manage the memory before and after calling these functions.
If altitude is valid, ALTITUDE_BIT must set in loc.locationFlagsMask.
elapsedRealTimeInMs must be set correctly using boottime of system.
*/
typedef struct {
void (*pushAltitude)(const LocationExt* location);
} AltitudeReceiver;
/******************************************************************************
ResponseListener
******************************************************************************/
/** @brief
All the memory pointers returned in these callbacks will be freed after call returns.
Implementation of these callbacks shall copy the needed data before returning.
*/
typedef struct {
void (*onAltitudeLookupRequest)(const LocationExt* location, bool is_emergency,
const void* clientData);
} AltitudeReceiverResponseListener;
#endif

View File

@@ -0,0 +1,115 @@
/* Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted 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 The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
*/
#ifndef WIFI_DB_COMMON_H
#define WIFI_DB_COMMON_H
#include <stdint.h>
/** @brief
All the memory pointers received will be never freed internally.
Caller shall manage the memory before and after calling these functions.
*/
typedef enum {
STD_CONT = 0,
STD_FINAL = 1,
SCAN_FINAL = 2,
} ApBsListStatus;
typedef enum {
GSM = 0,
WCDMA = 1,
CDMA = 2,
LTE = 3,
} CellType;
typedef struct {
CellType cellType;
uint16_t regionId1;
uint16_t regionId2;
uint16_t regionId3;
uint16_t regionId4;
uint32_t timestamp;
} CellInfo;
typedef enum LocationPositionSource : uint8_t {
GPS = (1<<0),
HYBRID = (1<<1),
} LocationPositionSource;
typedef enum NlpLocationFlagsBits : uint16_t {
LAT_LONG_BIT = (1<<0), // location has valid latitude and longitude
ALTITUDE_BIT = (1<<1), // location has valid altitude
SPEED_BIT = (1<<2), // location has valid speed
BEARING_BIT = (1<<3), // location has valid bearing
ACCURACY_BIT = (1<<4), // location has valid accuracy
VERTICAL_ACCURACY_BIT = (1<<5), // location has valid vertical accuracy
SPEED_ACCURACY_BIT = (1<<6), // location has valid speed accuracy
BEARING_ACCURACY_BIT = (1<<7), // location has valid bearing accuracy
} NlpLocationFlagsBits;
typedef struct {
LocationPositionSource positionSource;
NlpLocationFlagsBits locationFlagsMask;
uint64_t timestamp;
double latitude;
double longitude;
double altitude;
float speed;
float bearing;
float accuracy;
float verticalAccuracy;
float speedAccuracy;
float bearingAccuracy;
} NlpLocation;
typedef enum {
OPT_OUT = 0,
OPT_IN = 1,
} OptInStatus;
typedef enum {
TYPE_MOBILE = 0,
TYPE_WIFI,
TYPE_ETHERNET,
TYPE_BLUETOOTH,
TYPE_MMS,
TYPE_SUPL,
TYPE_DUN,
TYPE_HIPRI,
TYPE_WIMAX,
TYPE_PROXY,
TYPE_UNKNOWN,
} NetworkType;
typedef struct {
NetworkType networkType;
uint64_t networkHandle;
} NlpNetwork;
#endif /* WIFI_DB_COMMON_H */

View File

@@ -0,0 +1,230 @@
/* Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted 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 The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
*/
#ifndef NLP_API_H
#define NLP_API_H
#include <dlfcn.h>
#include <stddef.h>
#include <stdbool.h>
#include <WiFiDBReceiver.h>
#include <WiFiDBProvider.h>
#include <AltitudeReceiver.h>
#ifdef __cplusplus
extern "C" {
#endif
#define CURRENT_VERSION 4
/**
API VERSION 1: Initial release
API VERSION 2: Changed return value of connectToSystemStatus
from bool to const SystemRequester*
API VERSION 3: Added clientData as an argument to all *connect calls.
Changed return value of connectToSystemStatus to SystemStatusListener*.
Added multiple-client support to connectToSystemStatus.
API VERSION 4: Added passive location listener in SystemStatus.
Added AltitudeReceiver APIs.
*/
/** @brief
Table of calls clients to implement for service to provide system level updates
*/
typedef struct {
void (*onLocationOptInUpdate)(OptInStatus optInStatus, const void* clientData);
void (*onNetworkStatusUpdate)(bool isConected, const NlpNetwork* networksAvailable,
uint8_t networksAvailableCount, const void* clientData);
void (*onLocationChange)(const NlpLocation* location, const void* clientData);
} SystemStatusListener;
/** @brief
Table calls for client to make system level requests
All calls must be made with listenerAsID registered to
the service via connectToSystemStatus() call. Calls with
unregistered listenerAsID would receirve false return.
*/
typedef struct {
bool (*requestDataConnection)(const SystemStatusListener* listenerAsID);
bool (*releaseDataConnection)(const SystemStatusListener* listenerAsID);
} SystemRequester;
typedef struct {
/** @brief
Provides an instance of SystemRequester object with
the specified listener and clientData. The registered
SystemStatusListener will get updates on changes, with
clientData being passed back to the client. Support
multiple clients identified by listener, pertaining to
calls maked to SystemRequester calls.
@param
listener: instance of SystemStatusListener,
implementing the required callback functions.
Should be valid until disconnect function is called.
@param
clientData: opaque client data bundle, will be passed
back to client with all listener callbacks.
*/
const SystemRequester* (*connectToSystemStatus)(
const SystemStatusListener* listener, const void* clientData);
/** @brief
Provides an instance of WiFiDBReceiver object with
the specified listener and clientData. Only one valid
registration at a given time.
@param
listener: instance of WiFiDBReceiverResponseListener,
implementing the required callback functions.
Should be valid until disconnect function is called.
@param
clientData: opaque client data bundle, will be passed
back to client with all listener callbacks.
@return WiFiDBReceiver*. Nullptr if listener is nullptr;
or if one instance has already registered.
*/
const WiFiDBReceiver* (*connectToWiFiDBReceiver)(
const WiFiDBReceiverResponseListener* listener, const void* clientData);
/** @brief
Provides an instance of WiFiDBProvider object with
the specified listener and clientData. Only one valid
registration at a given time.
@param
listener: instance of WiFiDBProviderResponseListener,
implementing the required callback functions.
Should be valid until disconnect function is called.
@param
clientData: opaque client data bundle, will be passed
back to client with all the callbacks.
@return WiFiDBProvider*. False if listener is nullptr;
or if one instance has already registered.
*/
const WiFiDBProvider* (*connectToWiFiDBProvider)(
const WiFiDBProviderResponseListener* listener,
const void* clientData);
/** @brief
Provides an instance of AltitudeReceiver object with
the specified priority listener.
@param
listener: instance of AltitudeReceiverResponseListener,
implementing the required callback functions.
Should not be freed until disconnect function is called.
@param
clientData: opaque client data bundle, will be passed
back to client with all the callbacks.
@return AltitudeReceiver
*/
const AltitudeReceiver* (*connectToAltitudeReceiver)(
const AltitudeReceiverResponseListener* listener, const void* clientData);
/** @brief
Disconnect the SystemStatusListener. Indicates that client process is not
available for any reason. {listener, clientData} must match the pair given
to the connectToSystemStatus call.
@param
listener: instance of SystemStatusListener, previously provided
in the connectToSystemStatus call.
@param
clientData: opaque client data bundle, previously provided
in the connectToSystemStatus call.
*/
void (*disconnectFromSystemStatus)(const SystemStatusListener* listener);
/** @brief
Disconnect the WiFiDBReceiver associated with the provided listener.
{listener, clientData} must match the pair given to the connectToSystemStatus call
@param
listener: instance of WiFiDBReceiverResponseListener, previously provided
in the connectToWiFiDBReceiver call.
@param
clientData: opaque client data bundle, previously provided
in the connectToWiFiDBReceiver call.
*/
void (*disconnectFromWiFiDBReceiver)(const WiFiDBReceiverResponseListener* listener);
/** @brief
Disconnect the WiFiDBProvider associated with the provided listener.
{listener, clientData} must match the pair given to the connectToSystemStatus call
@param
listener: instance of WiFiDBProviderResponseListener, previously provided
in the connectToWiFiDBProvider call.
@param
clientData: opaque client data bundle, previously provided
in the connectToWiFiDBProvider call.
*/
void (*disconnectFromWiFiDBProvider)(const WiFiDBProviderResponseListener* listene);
/** @brief
Disconnect the AltitudeReceiver associated with the provided listener.
@param
listener: instance of AltitudeReceiverResponseListener, previously provided
in the connectToAltitudeReceiver call.
*/
void (*disconnectFromAltitudeReceiver)(
const AltitudeReceiverResponseListener* listener);
} NLPApi;
/** @brief
Provides a C pointer to an instance of NLPApi struct after dynamic linking to lobnlp_api.so.
*/
inline const NLPApi* linkGetNLPApi() {
typedef const void* (getNLPApi)(uint32_t);
getNLPApi* getter = nullptr;
void *handle = dlopen("libnlp_client_api.so", RTLD_NOW);
if (nullptr != handle) {
getter = (getNLPApi*)dlsym(handle, "getNLPApiByVersion");
}
// increment this version number when aboe NLPApi changes
return (const NLPApi*)(nullptr != getter) ? (NLPApi*)(*getter)(CURRENT_VERSION) : nullptr;
}
#ifdef __cplusplus
}
#endif
#endif /* NLP_API_H */

View File

@@ -0,0 +1,71 @@
/* Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted 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 The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
*/
#ifndef WIFI_DB_PROV_H
#define WIFI_DB_PROV_H
#include <DBCommon.h>
/******************************************************************************
WiFiDBReceiver
******************************************************************************/
typedef struct {
void (*requestAPObsLocData)();
} WiFiDBProvider;
/******************************************************************************
ResponseListener
******************************************************************************/
typedef struct {
uint8_t macAddress[6];
float rssi;
uint64_t deltaTime;
char ssid[8];
uint16_t channelNumber;
} ApScan;
typedef struct {
NlpLocation location;
CellInfo cellInfo;
uint64_t scanTimestamp;
ApScan* ap_scan_list;
uint16_t ap_scan_list_count;
} APObsLocData;
/** @brief
All the memory pointers returned in these callbacks will be freed after call returns.
Implementation of these callbacks shall copy the needed data before returning.
*/
typedef struct {
void (*onApObsLocDataAvailable)(const APObsLocData* ap_obs_list, uint16_t ap_obs_list_count,
ApBsListStatus ap_status, const void* clientData);
void (*onServiceRequest)(const void* clientData);
} WiFiDBProviderResponseListener;
#endif /* WIFI_DB_PROV_H */

View File

@@ -0,0 +1,114 @@
/* Copyright (c) 2020-2021 The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted 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 The Linux Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 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.
*/
#ifndef WIFI_DB_REC_H
#define WIFI_DB_REC_H
#include <DBCommon.h>
/******************************************************************************
WiFiDBReceiver
******************************************************************************/
typedef enum ReliabilityTypes : uint8_t {
VERY_LOW = 0,
LOW = 1,
MEDIUM = 2,
HIGH = 3,
VERY_HIGH = 4,
} ReliabilityTypes;
typedef struct {
uint8_t macAddress[6];
double latitude;
double longitude;
float max_antenna_range;
float horizontal_error;
ReliabilityTypes reliability;
} APLocationData;
typedef enum APSpecialInfoType : uint8_t {
NO_INFO_AVAILABLE = 0,
MOVING_AP = 1,
} APSpecialInfoType;
typedef struct {
uint8_t macAddress[6];
APSpecialInfoType specialInfoType;
} APSpecialInfo;
/** @brief
All the memory pointers received will be never freed internally.
Caller shall manage the memory before and after calling these functions.
*/
typedef struct {
void (*requestAPList)(int expire_in_days);
void (*requestScanList)();
void (*pushWiFiDB)(const APLocationData* location_data, uint16_t location_data_count,
const APSpecialInfo* special_info, uint16_t special_info_count, int days_valid);
void (*pushLookupResult)(const APLocationData* location_data, uint16_t location_data_count,
const APSpecialInfo* special_info, uint16_t special_info_count);
} WiFiDBReceiver;
/******************************************************************************
ResponseListener
******************************************************************************/
typedef enum FdalStatus : uint8_t {
NOT_IN_FDAL = 0,
IN_FDAL = 1,
BLACKLISTED = 2,
NA = 3,
} FdalStatus;
typedef struct {
char ssid[8];
CellInfo cellInfo;
} NlpAPInfoExtra;
typedef struct {
uint8_t macAddress[6];
uint64_t timestamp;
FdalStatus fdalStatus;
NlpAPInfoExtra extra;
} NlpAPInfo;
/** @brief
All the memory pointers returned in these callbacks will be freed after call returns.
Implementation of these callbacks shall copy the needed data before returning.
*/
typedef struct {
void (*onAPListAvailable)(const NlpAPInfo* ap_list, uint16_t ap_list_count,
ApBsListStatus ap_status, NlpLocation location, const void* clientData);
void (*onLookupRequest)(const NlpAPInfo* ap_list, uint16_t ap_list_count, NlpLocation location,
bool is_emergency, const void* clientData);
void (*onStatusUpdate)(bool is_success, const char* error, const void* clientData);
void (*onServiceRequest)(bool is_emergency, const void* clientData);
} WiFiDBReceiverResponseListener;
#endif /* WIFI_DB_REC_H */