54
54
#define T2_PERSISTENT_FOLDER " /opt/.t2reportprofiles/"
55
55
#define DEFAULT_PROFILES_FILE " /etc/t2profiles/default.json"
56
56
57
- #define SYSTEMSERVICES_CALLSIGN " org.rdk.System "
57
+ #define USERSETTINGS_CALLSIGN " org.rdk.UserSettings "
58
58
59
59
#define API_VERSION_NUMBER_MAJOR 1
60
- #define API_VERSION_NUMBER_MINOR 3
60
+ #define API_VERSION_NUMBER_MINOR 4
61
61
#define API_VERSION_NUMBER_PATCH 0
62
62
63
63
#ifdef HAS_RBUS
@@ -96,6 +96,10 @@ namespace WPEFramework
96
96
97
97
Telemetry::Telemetry ()
98
98
: PluginHost::JSONRPC()
99
+ #ifdef HAS_RBUS
100
+ , _userSettingsPlugin(nullptr )
101
+ , _userSettingsNotification(*this )
102
+ #endif
99
103
{
100
104
Telemetry::_instance = this ;
101
105
@@ -117,43 +121,22 @@ namespace WPEFramework
117
121
118
122
#ifdef HAS_RBUS
119
123
PluginHost::IShell::state state;
120
- if ((Utils::getServiceState (service, SYSTEMSERVICES_CALLSIGN, state) == Core::ERROR_NONE) && (state != PluginHost::IShell::state::ACTIVATED))
121
- Utils::activatePlugin (service, SYSTEMSERVICES_CALLSIGN);
122
124
123
- if ((Utils::getServiceState (service, SYSTEMSERVICES_CALLSIGN, state) == Core::ERROR_NONE) && (state == PluginHost::IShell::state::ACTIVATED))
125
+ if ((Utils::getServiceState (service, USERSETTINGS_CALLSIGN, state) == Core::ERROR_NONE) && (state != PluginHost::IShell::state::ACTIVATED))
126
+ Utils::activatePlugin (service, USERSETTINGS_CALLSIGN);
127
+
128
+ if ((Utils::getServiceState (service, USERSETTINGS_CALLSIGN, state) == Core::ERROR_NONE) && (state == PluginHost::IShell::state::ACTIVATED))
124
129
{
125
- m_systemServiceConnection = Utils::getThunderControllerClient (SYSTEMSERVICES_CALLSIGN );
130
+ ASSERT (service != nullptr );
126
131
127
- if (!m_systemServiceConnection)
128
- {
129
- LOGERR (" %s plugin initialisation failed" , SYSTEMSERVICES_CALLSIGN);
130
- }
131
- else
132
+ _userSettingsPlugin = service->QueryInterfaceByCallsign <WPEFramework::Exchange::IUserSettings>(USERSETTINGS_CALLSIGN);
133
+ if (_userSettingsPlugin)
132
134
{
133
- uint32_t err = m_systemServiceConnection->Subscribe <JsonObject>(2000 , " onPrivacyModeChanged" , [this ](const JsonObject& parameters) {
134
-
135
- if (parameters.HasLabel (" privacyMode" ))
136
- {
137
- std::string privacyMode = parameters[" privacyMode" ].String ();
138
- notifyT2PrivacyMode (privacyMode);
139
- }
140
- else
141
- {
142
- LOGERR (" No 'privacyMode' parameter" );
143
- }
144
- });
145
-
146
- if (err != Core::ERROR_NONE)
147
- {
148
- LOGERR (" Failed to subscribe to onPrivacyModeChanged: %d" , err);
149
- }
135
+ _userSettingsPlugin->Register (&_userSettingsNotification);
150
136
151
- JsonObject params;
152
- JsonObject res;
153
- m_systemServiceConnection->Invoke <JsonObject, JsonObject>(2000 , " getPrivacyMode" , params, res);
154
- if (res[" success" ].Boolean ())
137
+ std::string privacyMode;
138
+ if (_userSettingsPlugin->GetPrivacyMode (privacyMode) == Core::ERROR_NONE)
155
139
{
156
- std::string privacyMode = res[" privacyMode" ].String ();
157
140
notifyT2PrivacyMode (privacyMode);
158
141
}
159
142
else
@@ -164,7 +147,7 @@ namespace WPEFramework
164
147
}
165
148
else
166
149
{
167
- LOGERR (" %s plugin is not activated " , SYSTEMSERVICES_CALLSIGN );
150
+ LOGERR (" Failed to activate %s " , USERSETTINGS_CALLSIGN );
168
151
}
169
152
#endif
170
153
@@ -258,6 +241,12 @@ namespace WPEFramework
258
241
rbus_close (rbusHandle);
259
242
rbusHandleStatus = RBUS_ERROR_NOT_INITIALIZED;
260
243
}
244
+
245
+ if (_userSettingsPlugin) {
246
+ _userSettingsPlugin->Unregister (&_userSettingsNotification);
247
+ _userSettingsPlugin->Release ();
248
+ _userSettingsPlugin = nullptr ;
249
+ }
261
250
#endif
262
251
}
263
252
0 commit comments