msm8976-common: ril: add squash of OSS libsecnativefeature

msm8976-common: ril: add open-sourced libsecnativefeature, used by libsec-ril

 Change-Id: I2f487db23b31c63ba919863f393ca37cc9a81191

 libsecnativefeature: fix build with clang

 Change-Id: Ibda3234af2b1184e094913e35cb919a75f972c87

Change-Id: Iaaa06fa527cedce6609a95b21d787c13dda6a30a
lineage-17.1
Ziyan 8 years ago committed by LuK1337
parent 2ff56657dd
commit 61a4c37735

@ -0,0 +1,20 @@
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional
LOCAL_SRC_FILES := \
SecNativeFeatureCIf.cpp \
SecNativeFeatureCppIf.cpp
LOCAL_C_INCLUDES += \
external/expat/lib
LOCAL_SHARED_LIBRARIES := \
libexpat
LOCAL_CFLAGS := -Wall -Werror
LOCAL_MODULE := libsecnativefeature
include $(BUILD_SHARED_LIBRARY)

@ -0,0 +1,31 @@
#ifndef SEC_NATIVE_FEATURE_H
#define SEC_NATIVE_FEATURE_H
#include "SecNativeFeatureTagAll.h"
// define TAG for default value
/*
#define Str_NoTag ""
#define Bool_NoTag false
#define Int_NoTag (0)
#define TAG_BOOLEAN_TEST_TRUE "CscFeature_BooleanTestTrue"
#define TAG_BOOLEAN_TEST_FALSE "CscFeature_BooleanTestFalse"
#define TAG_BOOLEAN_TEST_NULL "CscFeature_BooleanTestNull"
#define TAG_STRING_TEST "CscFeature_StringTest"
#define TAG_STRING_TEST_NULL "CscFeature_StringTestNull"
#define TAG_INTEGER_TEST "CscFeature_IntegerTest"
#define TAG_INTEGER_TEST_NULL "CscFeature_IntegerTestNull"
#define TAG_FMRADIO_RTPLUS "CscFeature_FMRadioRTPlus"
#define TAG_FMRADIO_SEASETTING "CscFeature_FMRadioSEASetting"
*/
#ifdef __cplusplus
#include "SecNativeFeatureCppIf.h"
#else
#include "SecNativeFeatureCIf.h"
#endif
#endif // SEC_NATIVE_FEATURE_H

@ -0,0 +1,85 @@
#include <string>
#include <iostream>
#include "SecNativeFeatureCppIf.h"
#include "SecNativeFeatureCIf.h"
#include <expat.h>
#include <stdlib.h>
int
SecNativeFeature_getEnableStatus(const char* tag)
{
SecNativeFeature* instance = SecNativeFeature::getInstance();
if (instance)
{
return instance->getEnableStatus(tag);
}
return 0;
}
int
SecNativeFeature_getEnableStatusWithDefault(const char* tag, int defaultValue)
{
SecNativeFeature* instance = SecNativeFeature::getInstance();
if (instance)
{
return instance->getEnableStatus(tag, defaultValue);
}
return defaultValue;
}
int
SecNativeFeature_getInteger(const char* tag)
{
SecNativeFeature* instance = SecNativeFeature::getInstance();
if (instance)
{
return instance->getInteger(tag);
}
return -1;
}
int
SecNativeFeature_getIntegerWithDefault(const char* tag, int defaultValue)
{
SecNativeFeature* instance = SecNativeFeature::getInstance();
if (instance)
{
return instance->getInteger(tag, defaultValue);
}
return defaultValue;
}
const char*
SecNativeFeature_getString(const char* tag)
{
SecNativeFeature* instance = SecNativeFeature::getInstance();
if (instance)
{
return instance->getString(tag);
}
return NULL;
}
const char*
SecNativeFeature_getStringWithDefault(const char* tag, char* defaultValue)
{
SecNativeFeature* instance = SecNativeFeature::getInstance();
if (instance)
{
return instance->getString(tag, defaultValue);
}
return defaultValue;
}

@ -0,0 +1,24 @@
#ifndef SEC_NATIVE_FEATURE_CIF_H
#define SEC_NATIVE_FEATURE_CIF_H
#ifdef __cplusplus
#define DECLARE_BEGIN_C extern "C" {
#define DECLARE_END_C }
#else
#define DECLARE_BEGIN_C
#define DECLARE_END_C
#endif
DECLARE_BEGIN_C
int SecNativeFeature_getEnableStatus(const char* tag);
int SecNativeFeature_getEnableStatusWithDefault(const char* tag, int defaultValue);
int SecNativeFeature_getInteger(const char* tag);
int SecNativeFeature_getIntegerWithDefault(const char* tag, int defaultValue);
const char* SecNativeFeature_getString(const char* tag);
const char* SecNativeFeature_getStringWithDefault(const char* tag, char* defaultValue);
DECLARE_END_C
#endif // SEC_NATIVE_FEATURE_CIF_H

@ -0,0 +1,187 @@
#include <string>
#include <iostream>
#include "SecNativeFeatureCppIf.h"
#include <expat.h>
#include <stdlib.h>
// feature file location (which should be "/system/csc/feature.xml")
#define FEATURE_FILE "/system/csc/feature.xml"
// feature file location (which should be "/system/csc/others.xml")
#define MPS_FEATURE_FILE "/system/csc/others.xml"
// XML parsing using expat lib - handlers
typedef struct{
std::string curr_name;
std::map<std::string,std::string> *pFeatures;
int depth;
} ParserUserData;
static void XMLCALL
charDataHandler(void *userData, const char *s, int len){
ParserUserData* pData = (ParserUserData*)userData;
std::string value(s, len);
std::string curr_name = pData->curr_name;
if(!curr_name.empty()){
std::map<std::string,std::string>::iterator result = (*pData->pFeatures).find(curr_name);
if (result != (*pData->pFeatures).end()) {
value = result->second + value;
(*pData->pFeatures).erase(curr_name);
}
std::map<std::string,std::string>::iterator begin;
begin = (*pData->pFeatures).begin();
std::pair<std::string,std::string> feature(curr_name,value);
(*pData->pFeatures).insert(begin, feature);
}
// else{
// // printf("no name\n");
// }
}
static void XMLCALL
startElement(void *userData, const char *name, const char **atts __unused)
{
ParserUserData* pData = (ParserUserData*)userData;
pData->curr_name.assign(name);
pData->depth += 1;
}
static void XMLCALL
endElement(void *userData, const char *name __unused)
{
ParserUserData* pData = (ParserUserData*)userData;
pData->curr_name.clear();
pData->depth -= 1;
}
// SecNativeFeture class implementation
SecNativeFeature* SecNativeFeature::_instance = NULL;
SecNativeFeature::SecNativeFeature() {
int load_result = 0;
_features.clear();
load_result = _loadFeature();
if (load_result == -1){
// todo : handle _loadFeature errors here.
}
}
SecNativeFeature::~SecNativeFeature() {
delete _instance;
}
SecNativeFeature* SecNativeFeature::getInstance() {
if(_instance == NULL) {
_instance = new SecNativeFeature();
}
return _instance;
}
bool SecNativeFeature::getEnableStatus(const char* tag) {
std::map<std::string,std::string>::iterator found;
found = _features.find(tag);
if(found == _features.end()) {
return false;
}
if(found->second.compare("true") == 0 || found->second.compare("TRUE") == 0) {
return true;
}
return false;
}
bool SecNativeFeature::getEnableStatus(const char* tag, bool defaultValue) {
std::map<std::string,std::string>::iterator found;
found = _features.find(tag);
if(found == _features.end()) {
return defaultValue;
}
if(found->second.compare("true") == 0 || found->second.compare("TRUE") == 0) {
return true;
}
return defaultValue;
}
const char* SecNativeFeature::getString(const char* tag) {
std::map<std::string,std::string>::iterator found;
found = _features.find(tag);
if(found == _features.end()) {
return "";
}
return found->second.c_str();
}
const char* SecNativeFeature::getString(const char* tag, char* defaultValue) {
std::map<std::string,std::string>::iterator found;
found = _features.find(tag);
if(found == _features.end()) {
return defaultValue;
}
return found->second.c_str();
}
int SecNativeFeature::getInteger(const char* tag) {
std::map<std::string,std::string>::iterator found;
found = _features.find(tag);
if(found == _features.end()) {
return -1;
}
std::string raw_value = _features.find(tag)->second;
return atoi(raw_value.c_str());
}
int SecNativeFeature::getInteger(const char* tag, int defaultValue) {
std::map<std::string,std::string>::iterator found;
found = _features.find(tag);
if(found == _features.end()) {
return defaultValue;
}
std::string raw_value = _features.find(tag)->second;
return atoi(raw_value.c_str());
}
int SecNativeFeature::_loadFeature(){
char buf[BUFSIZ];
XML_Parser parser = XML_ParserCreate(NULL);
int done;
FILE * pFeatureFile = NULL;
ParserUserData userData;
userData.curr_name = std::string ();
userData.pFeatures = &_features;
userData.depth = 0;
pFeatureFile = fopen(FEATURE_FILE, "r");
if (pFeatureFile == NULL) {
pFeatureFile = fopen(MPS_FEATURE_FILE, "r");
if (pFeatureFile == NULL) {
return -1;
}
}
XML_SetUserData(parser, &userData);
XML_SetElementHandler(parser, startElement, endElement);
XML_SetCharacterDataHandler(parser, charDataHandler);
do {
size_t len = fread(buf, 1, sizeof(buf), pFeatureFile);
if ((len != sizeof(buf)) && (ferror(pFeatureFile))){
fclose(pFeatureFile);
return -1;
}
done = len < sizeof(buf);
if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) {
if(pFeatureFile) {
fclose(pFeatureFile);
}
return -1;
}
} while (!done);
XML_ParserFree(parser);
fclose(pFeatureFile);
return 0;
}

@ -0,0 +1,27 @@
#ifndef SEC_NATIVE_FEATURE_CPPIF_H
#define SEC_NATIVE_FEATURE_CPPIF_H
#include <string>
#include <map>
class SecNativeFeature {
public:
bool getEnableStatus(const char* tag);
bool getEnableStatus(const char* tag, bool defaultValue);
const char* getString(const char* tag);
const char* getString(const char* tag, char* defaultValue);
int getInteger(const char* tag);
int getInteger(const char* tag, int defaultValue);
static SecNativeFeature* getInstance();
private:
static SecNativeFeature* _instance;
SecNativeFeature();
~SecNativeFeature();
int _loadFeature();
int _loadDefault();
std::map<std::string,std::string> _features;
};
#endif // SEC_NATIVE_FEATURE_CPPIF_H

@ -0,0 +1,20 @@
/*
* CSC Features
* Auto generated by gen_cscfeaturetag_ih.pl
* DO NOT EDIT THIS FILE
*/
/*
#include "SecNativeFeatureTagGMS.h"
#include "SecNativeFeatureTagIMS.h"
#include "SecNativeFeatureTagMediaProvider.h"
#include "SecNativeFeatureTagNFC.h"
#include "SecNativeFeatureTagRIL.h"
#include "SecNativeFeatureTagStreaming.h"
#include "SecNativeFeatureTagWiFi.h"
#include "SecNativeFeatureTagBT.h"
*/
#include "SecNativeFeatureTagFramework.h"
#include "SecNativeFeatureTagCommon.h"
#include "SecNativeFeatureTagWeb.h"

@ -0,0 +1,9 @@
#ifndef SEC_NATIVE_FEATURE_TAG_COMMON_H
#define SEC_NATIVE_FEATURE_TAG_COMMON_H
// Note
// The string must be same as the string in CSCFeatureTagCommon.java
// Because one feature coulde be implemented both in java layer and in native layer
#define TAG_CSCFEATURE_COMMON_USECHAMELEON "CscFeature_Common_UseChameleon"
#endif // SEC_NATIVE_FEATURE_TAG_COMMON_H

@ -0,0 +1,16 @@
#ifndef SEC_NATIVE_FEATURE_TAG_FRAMEWORK_H
#define SEC_NATIVE_FEATURE_TAG_FRAMEWORK_H
// Note
// The string must be same as the string in CSCFeatureTagFramework.java
// Because one feature coulde be implemented both in java layer and in native layer
#define TAG_CSCFEATURE_FRAMEWORK_ENABLEBIDIRECTION "CscFeature_Framework_EnableBidirection"
#define TAG_CSCFEATURE_FRAMEWORK_ENABLEHARFBUZZ "CscFeature_Framework_EnableHarfbuzz"
#define TAG_CSCFEATURE_FRAMEWORK_ENABLETHAIVIETRESHAPING "CscFeature_Framework_EnableThaiVietReshaping"
#endif // SEC_NATIVE_FEATURE_TAG_FRAMEWORK_H

@ -0,0 +1,150 @@
#ifndef SEC_NATIVE_FEATURE_TAG_WEB_H
#define SEC_NATIVE_FEATURE_TAG_WEB_H
// Note
// The string must be same as the string in CSCFeatureTagWeb.java
// Because one feature coulde be implemented both in java layer and in native layer
// The default values for each types
// This means the specified TAG is not defined
#define CSCFeatureTagWeb_Str_NoTag ""
#define CSCFeatureTagWeb_Bool_NoTag false
#define CSCFeatureTagWeb_Int_NoTag 0
// To define custom UserAgent string
// If this value is not defined, the default Android UserAgent will be sent to server
#define CSCFeatureTagWeb_SetUserAgent "CscFeature_Web_SetUserAgent"
// To define UAProfile string
// If this value is not defined, UAProfile will not be sent to server
#define CSCFeatureTagWeb_SetUAProfile "CscFeature_Web_SetUAProfile"
// Change homepage_base regardless language and APN
#define CscFeatureTagWeb_SetHomepageURL "CscFeature_Web_SetHomepageURL"
// Disable RSS button on the url bar
#define CscFeatureTagWeb_DisableRSS "CscFeature_Web_DisableRSS"
// Remove voicesearch button on the url bar
#define CscFeatureTagWeb_DisableVoiceSearch "CscFeature_Web_DisableVoiceSearch"
// Disable showing activity chooser on redirecting in case when 3rd party browser also installed
#define CscFeatureTagWeb_DisableRedirectionChooser "CscFeature_Web_DisableRedirectionChooser"
// Enable UAProfile in Header
#define CscFeatureTagWeb_Bool_EnableUAProfile "CscFeature_Web_Bool_EnableUAProfile"
// To Enable the GateConfig Logs(USA STA requirement for stability test)
#define CscFeatureTagWeb_Bool_EnableGateConfig "CscFeature_Web_EnableLogStabililtyTest"
//add for Handling Operator UA
#define CscFeature_Web_OverrideUserAgent "CscFeature_Web_OverrideUserAgent"
// add menu clear today history
#define CscFeatureTagWeb_EnableDeletingTodayHistory "CscFeature_Web_EnableDeletingTodayHistory"
// To enable bookmark overwrite
#define CscFeatureTagWeb_EnableOverwritingBookmark "CscFeature_Web_EnableOverwritingBookmark"
// To enable downloaded folder notification
#define CscFeatureTagWeb_EnableDownloadedFolderInNotificationBar "CscFeature_Web_EnableDownloadedFolderInNotificationBar"
//Enable DeviceID at Header(USA ATT Requirement)
#define CscFeatureTag_Web_Bool_DeviceID "CscFeature_Web_UseDeviceIdInHeader"
// support uploading contacts in VCard format (China-Telecom requirement)
#define CscFeatureTagWeb_SupportVcfUpload "CscFeature_Web_SupportVcfUpload"
//Parse XHTML document as HTML (ignore parse error. China-Telecom requirement)
#define CscFeatureTagWeb_ParseXHtmlToHtml "CscFeature_Web_ParseXHtmlToHtml"
//Block SD & CD download ( NAGSM common requirement)
#define CscFeatureTag_Web_Bool_BlockSDCDDownload "CscFeature_Web_BlockSDCDDownload"
// display download progress on notification bar (China-Telecom requirement)
#define CscFeatureTagWeb_ShowDownloadProgressOnNotification "CscFeature_Web_ShowDownloadProgressOnNotification"
// show browser version in browser settings (China-Telecom requirement)
#define CscFeatureTagWeb_ShowVersionInSetting "CscFeature_Web_ShowVersionInSetting"
// support "exit browser" option (China-Telecom requirement)
#define CscFeatureTagWeb_AddOptionToTerminate "CscFeature_Web_AddOptionToTerminate"
// Add "Delete-all" function at Download list (China-Telecom requirement)
#define CscFeatureTagWeb_EnableDeleteAllOnDownloadList "CscFeature_Web_EnableDeleteAllOnDownloadList"
// Support save-as function and default folder by mime-type (China-Telecom requirement)
#define CscFeatureTagWeb_SupportDownloadSaveAs "CscFeature_Web_SupportDownloadSaveAs"
// support delete-all option in bookmarks page (China-Telecom requirement)
#define CscFeatureTagWeb_EnableDeleteAllBookmarks "CscFeature_Web_EnableDeleteAllBookmarks"
// Add "FullHandwriting IME issue "(China-Common requirement)
#define CscFeatureTagWeb_EnableOptionEditTextDuringFullHwr "CscFeature_Web_EnableOptionEditTextDuringFullHwr"
// support offline-startup page includes bookmarks, history, search dialog (China-Telecom requirement)
#define CscFeatureTagWeb_SupportOfflineStartupPage "CscFeature_Web_SupportOfflineStartupPage"
// support not to set factory-reset-homepage to PREF_HOMEPAGE
#define CscFeatureTagWeb_Bool_DisableSetFactoryResetHomeToPrefHome "CscFeature_Web_Bool_DisableSetFactoryResetHomeToPrefHome"
// Show roaming dialog (ATT Requirement)
#define CscFeatureTagWeb_Bool_ShowRoamingDialog "CscFeature_Web_EnableRoamingDialog"
// set download folder by mime-type for China-Telecom requirement
#define CscFeatureTagWeb_SetDownloadFolderNameByMimeType "CscFeature_Web_SetDownloadFolderNameByMimeType"
// Disable showing activity chooser for defined string
#define CscFeature_Web_DisableChooser4 "CscFeature_Web_DisableChooser4"
// Enable download hebrew filename
#define CscFeature_Web_SupportHebrewFileName "CscFeature_Web_SupportHebrewFileName"
// remove google in search engine list
#define CscFeatureTagWeb_DisableGoogleInBrowserSearchEngine "CscFeature_Web_DisableGoogleInBrowserSearchEngine"
// set off overview mode as default (CTC Requirement)
#define CscFeatureTagWeb_SetOffOverviewModeAsDefault "CscFeature_Web_SetOffOverviewModeAsDefault"
// Disable setting homepage as it is set in APN when SIM changed
#define CscFeature_Web_EnableAutoSimHomeUrlInProfile "CscFeature_Web_EnableAutoSimHomeUrlInProfile"
// Add download file name decode feature for China region
#define CscFeatureTagWeb_SupportDownloadedFileNameInChineseChar "CscFeature_Web_SupportDownloadedFileNameInChineseChar"
// support multiAPN (CMCC Requirement)
#define CscFeatureTagWeb_EnableMultipleApn4 "CscFeature_Web_EnableMultipleApn4"
// Enable Ask to exit on back (CMCC Requirement)
#define CscFeatureTagWeb_EnablePromptToExit "CscFeature_Web_EnablePromptToExit"
// Enable EMOJI for JPN
#define CscFeatureTagWeb_EnableEmoji "CscFeature_Web_Bool_EnableEmoji"
// Show Wifi AP List when WIFI switch is on (CMCC Requirement)
#define CscFeatureTagWeb_ShowWifiAPList "CscFeature_Web_ShowWifiAPList"
// Enable Operator's toolbar (ATT Requirement)
#define CscFeatureTagWeb_EnableOperatorToolbar "CscFeature_Web_EnableOperatorToolbar"
// Set TCP Connection timout (China Requirement)
#define CscFeatureTagWeb_SetTcpConnTimeoutAs "CscFeature_Web_SetTcpConnTimeoutAs"
// Add WML mime type to Accept Header (CMCC Requirement)
#define CscFeatureTagWeb_AddWmlToHttpAcceptHeader4 "CscFeature_Web_AddWmlToHttpAcceptHeader4"
// change block zoom method to position based touch block zoom (Australia Requirement)
#define CscFeature_Web_BlockZoomBaseOnTouchPosition "CscFeature_Web_BlockZoomBaseOnTouchPosition"
// Remove Partial View During Horizontal Scroll in Nav Screen (Australia Requirement)
#define CscFeature_Web_RemovePartialViewDuringHorizontalScroll "CscFeature_Web_RemovePartialViewDuringHorizontalScroll"
// Show Popup for MaxLength reached during Url input (CMCC Requirement)
#define CscFeatureTagWeb_EnablePopup4MaxLengthReachedDuringUrlInput "CscFeature_Web_EnablePopup4MaxLengthReachedDuringUrlInput"
// Support Tel Number in the page to go to dialing app (KOR Requirement)
#define CscFeature_Web_RecognizeTelNumber "CscFeature_Web_RecognizeTelNumber"
// Large file transfer in Internet download (VZW Requirement)
#define CscFeature_Web_EnableWifiOption4LargeFileDownload "CscFeature_Web_EnableWifiOption4LargeFileDownload"
// Add additional accept charset to Accept Header (CTC Requirement)
#define CscFeature_Web_AddCharSetToHttpHeader "CscFeature_Web_AddCharSetToHttpHeader"
// max connection per host for performance
#define CscFeature_Web_MaxConnectionPerHost "CscFeature_Web_MaxConnectionPerHost"
#endif // SEC_NATIVE_FEATURE_TAG_WEB_H
Loading…
Cancel
Save