Skip to content

Instantly share code, notes, and snippets.

@aeroevan
Created October 17, 2014 03:47
Show Gist options
  • Save aeroevan/526f24622a1da95e8e37 to your computer and use it in GitHub Desktop.
Save aeroevan/526f24622a1da95e8e37 to your computer and use it in GitHub Desktop.
Set Privacy Stuff?
diff --git a/gps/core/LocApiBase.cpp b/gps/core/LocApiBase.cpp
index 8b6713c..b08e416 100644
--- a/gps/core/LocApiBase.cpp
+++ b/gps/core/LocApiBase.cpp
@@ -473,4 +473,8 @@ DEFAULT_IMPL(-1)
int LocApiBase::
getGpsLock()
DEFAULT_IMPL(-1)
+
+enum loc_api_adapter_err LocApiBase::
+ setPrivacy(int8_t privacy_setting)
+DEFAULT_IMPL(LOC_API_ADAPTER_ERR_SUCCESS)
} // namespace loc_core
diff --git a/gps/core/LocApiBase.h b/gps/core/LocApiBase.h
index 1603e6b..c6b0560 100644
--- a/gps/core/LocApiBase.h
+++ b/gps/core/LocApiBase.h
@@ -212,6 +212,14 @@ public:
-1 on failure
*/
virtual int getGpsLock(void);
+
+private:
+ inline virtual void unknownVirtualMethod29() {}
+ inline virtual void unknownVirtualMethod30() {}
+
+public:
+ inline virtual enum loc_api_adapter_err
+ setPrivacy(int8_t privacy_setting);
};
typedef LocApiBase* (getLocApi_t)(const MsgTask* msgTask,
diff --git a/gps/etc/gps.conf b/gps/etc/gps.conf
index 2f4f33e..1cb533d 100644
--- a/gps/etc/gps.conf
+++ b/gps/etc/gps.conf
@@ -13,7 +13,7 @@ XTRA_SERVER_3=http://xtra3.gpsonextra.net/xtra2.bin
# DEBUG LEVELS: 0 - none, 1 - Error, 2 - Warning, 3 - Info
# 4 - Debug, 5 - Verbose
-DEBUG_LEVEL = 2
+DEBUG_LEVEL = 5
# Intermediate position report, 1=enable, 0=disable
INTERMEDIATE_POS=0
diff --git a/gps/loc_api/libloc_api_50001/LocEngAdapter.h b/gps/loc_api/libloc_api_50001/LocEngAdapter.h
index 932fea1..e5ea06f 100644
--- a/gps/loc_api/libloc_api_50001/LocEngAdapter.h
+++ b/gps/loc_api/libloc_api_50001/LocEngAdapter.h
@@ -298,6 +298,11 @@ public:
{
return mLocApi->getGpsLock();
}
+
+ inline virtual enum loc_api_adapter_err setPrivacy(int8_t privacy_setting)
+ {
+ return mLocApi->setPrivacy(privacy_setting);
+ }
};
#endif //LOC_API_ENG_ADAPTER_H
diff --git a/gps/loc_api/libloc_api_50001/loc_eng.cpp b/gps/loc_api/libloc_api_50001/loc_eng.cpp
index 2c92d46..52c3e00 100644
--- a/gps/loc_api/libloc_api_50001/loc_eng.cpp
+++ b/gps/loc_api/libloc_api_50001/loc_eng.cpp
@@ -183,7 +183,8 @@ static void loc_eng_process_conn_request(loc_eng_data_s_type &loc_eng_data,
static void loc_eng_agps_close_status(loc_eng_data_s_type &loc_eng_data, int is_succ);
static void loc_eng_handle_engine_down(loc_eng_data_s_type &loc_eng_data) ;
static void loc_eng_handle_engine_up(loc_eng_data_s_type &loc_eng_data) ;
-
+static int loc_eng_set_privacy(loc_eng_data_s_type &loc_eng_data,
+ int8_t privacy_setting);
static int loc_eng_start_handler(loc_eng_data_s_type &loc_eng_data);
static int loc_eng_stop_handler(loc_eng_data_s_type &loc_eng_data);
static int loc_eng_get_zpp_handler(loc_eng_data_s_type &loc_eng_data);
@@ -497,6 +498,27 @@ struct LocEngLppConfig : public LocMsg {
}
};
+// case LOC_ENG_MSG_PRIVACY:
+struct LocEngPrivacy : public LocMsg {
+ LocEngAdapter* mAdapter;
+ const int8_t mPrivacySetting;
+ inline LocEngPrivacy(LocEngAdapter* adapter,
+ int8_t privacySetting) :
+ LocMsg(), mAdapter(adapter), mPrivacySetting(privacySetting)
+ {
+ locallog();
+ }
+ inline virtual void proc() const {
+ mAdapter->setPrivacy(mPrivacySetting);
+ }
+ inline void locallog() const {
+ LOC_LOGV("privacySetting: %d", mPrivacySetting);
+ }
+ inline virtual void log() const {
+ locallog();
+ }
+};
+
// case LOC_ENG_MSG_SET_SENSOR_CONTROL_CONFIG:
struct LocEngSensorControlConfig : public LocMsg {
LocEngAdapter* mAdapter;
@@ -1502,6 +1524,12 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks,
return ret_val;
}
+ if (NULL != loc_eng_data.adapter) {
+ // Current loc_eng_cleanup keeps context initialized, so must enable
+ // here too.
+ loc_eng_set_privacy(loc_eng_data, 1);
+ }
+
STATE_CHECK((NULL == loc_eng_data.adapter),
"instance already initialized", return 0);
@@ -1548,6 +1576,8 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks,
loc_eng_data.adapter);
loc_eng_data.adapter->sendMsg(new LocEngInit(&loc_eng_data));
+ loc_eng_set_privacy(loc_eng_data, 1);
+
EXIT_LOG(%d, ret_val);
return ret_val;
}
@@ -1647,6 +1677,8 @@ void loc_eng_cleanup(loc_eng_data_s_type &loc_eng_data)
loc_eng_stop(loc_eng_data);
}
+ loc_eng_set_privacy(loc_eng_data, 0);
+
#if 0 // can't afford to actually clean up, for many reason.
LOC_LOGD("loc_eng_init: client opened. close it now.");
@@ -2607,3 +2639,30 @@ int loc_eng_read_config(void)
EXIT_LOG(%d, 0);
return 0;
}
+
+/*===========================================================================
+FUNCTION loc_eng_set_privacy
+
+DESCRIPTION
+ Sets the privacy lock setting (1. GPS on, 0. GPS off).
+
+DEPENDENCIES
+ None
+
+RETURN VALUE
+ 0: success
+
+SIDE EFFECTS
+ N/A
+
+===========================================================================*/
+static int loc_eng_set_privacy(loc_eng_data_s_type &loc_eng_data,
+ int8_t privacy_setting)
+{
+ ENTRY_LOG();
+ INIT_CHECK(loc_eng_data.adapter, return -1);
+ LocEngAdapter* adapter = loc_eng_data.adapter;
+ adapter->sendMsg(new LocEngPrivacy(adapter, privacy_setting));
+ EXIT_LOG(%d, 0);
+ return 0;
+}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment