Skip to content

Commit 1206926

Browse files
authored
XIONE-18661 : Added support for IBackupProvider in UserSettings plugin. (#6463)
* XIONE-18661 : Added Account and BackupManager plugins. * Added interfaces for Account and BackupManager for L2 tests. * Added PrivacyMode read to SetAndGetMethodsUsingComRpcConnectionSuccessCase. * L2 test fix. * Removed Account and BackupManager plugins. * Updated version and changelog. * Updated patch with Account-BackupManager interfaces for L2 tests.
1 parent 12cf882 commit 1206926

8 files changed

Lines changed: 515 additions & 11 deletions

File tree

.github/workflows/L2-tests-R4-4-1.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ jobs:
147147
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/Use_Legact_Alt_In_ThunderInterfaces_Based_On_ThunderTools_R4.4.3.patch
148148
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/RDK-51362-System-Mode-Thunder-Plugin.patch
149149
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/0001-Add-IAnalytics-interface-R4.4.patch
150+
patch -p1 < ${{github.workspace}}/rdkservices/Tests/L2Tests/patches/0003-XIONE-18661-Account-BackupManager-plugins.patch
150151
cd ..
151152
152153
- name: Build ThunderInterfaces

Tests/L2Tests/L2TestsPlugin/tests/UserSettings_L2Test.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,6 +2472,26 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase)
24722472
TEST_LOG("Err: %s", errorMsg.c_str());
24732473
}
24742474

2475+
TEST_LOG("Setting and Getting PrivacyMode Values");
2476+
status = m_usersettingsplugin->SetPrivacyMode("SHARE");
2477+
EXPECT_EQ(status,Core::ERROR_NONE);
2478+
if (status != Core::ERROR_NONE)
2479+
{
2480+
std::string errorMsg = "COM-RPC returned error " + std::to_string(status) + " (" + std::string(Core::ErrorToString(status)) + ")";
2481+
TEST_LOG("Err: %s", errorMsg.c_str());
2482+
}
2483+
status = m_usersettingsplugin->GetPrivacyMode(getStringValue);
2484+
EXPECT_EQ(status,Core::ERROR_NONE);
2485+
if (status != Core::ERROR_NONE)
2486+
{
2487+
std::string errorMsg = "COM-RPC returned error " + std::to_string(status) + " (" + std::string(Core::ErrorToString(status)) + ")";
2488+
TEST_LOG("Err: %s", errorMsg.c_str());
2489+
}
2490+
else
2491+
{
2492+
EXPECT_EQ(getStringValue, "SHARE");
2493+
}
2494+
24752495

24762496
TEST_LOG("Testing getMigrationState after migrating properties");
24772497

@@ -2637,6 +2657,15 @@ TEST_F(UserSettingTest,SetAndGetMethodsUsingComRpcConnectionSuccessCase)
26372657
TEST_LOG("Err: %s", errorMsg.c_str());
26382658
}
26392659

2660+
status = m_usersettings_inspe_plugin->GetMigrationState(Exchange::IUserSettingsInspector::SettingsKey::PRIVACY_MODE, requiresMigration);
2661+
EXPECT_EQ(requiresMigration, false);
2662+
EXPECT_EQ(status,Core::ERROR_NONE);
2663+
if (status != Core::ERROR_NONE)
2664+
{
2665+
std::string errorMsg = "COM-RPC returned error " + std::to_string(status) + " (" + std::string(Core::ErrorToString(status)) + ")";
2666+
TEST_LOG("Err: %s", errorMsg.c_str());
2667+
}
2668+
26402669
status = m_usersettings_inspe_plugin->GetMigrationStates(states);
26412670
EXPECT_EQ(status,Core::ERROR_NONE);
26422671
if (status != Core::ERROR_NONE)
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
diff -uprN a/interfaces/IAccount.h b/interfaces/IAccount.h
2+
--- a/interfaces/IAccount.h 1970-01-01 03:00:00.000000000 +0300
3+
+++ b/interfaces/IAccount.h 2026-04-29 19:09:36.495820909 +0300
4+
@@ -0,0 +1,50 @@
5+
+/*
6+
+ * If not stated otherwise in this file or this component's LICENSE file the
7+
+ * following copyright and licenses apply:
8+
+ *
9+
+ * Copyright 2026 RDK Management
10+
+ *
11+
+ * Licensed under the Apache License, Version 2.0 (the "License");
12+
+ * you may not use this file except in compliance with the License.
13+
+ * You may obtain a copy of the License at
14+
+ *
15+
+ * http://www.apache.org/licenses/LICENSE-2.0
16+
+ *
17+
+ * Unless required by applicable law or agreed to in writing, software
18+
+ * distributed under the License is distributed on an "AS IS" BASIS,
19+
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
+ * See the License for the specific language governing permissions and
21+
+ * limitations under the License.
22+
+ */
23+
+
24+
+#pragma once
25+
+#include "Module.h"
26+
+
27+
+
28+
+namespace WPEFramework {
29+
+namespace Exchange {
30+
+ // Account Plugin provides various operations that can be made at account level
31+
+ // @json 1.0.0 @text:keep
32+
+ struct EXTERNAL IAccount : virtual public Core::IUnknown {
33+
+ enum { ID = ID_ACCOUNT };
34+
+
35+
+ virtual ~IAccount() = default;
36+
+
37+
+ struct GetLastCheckoutResetTimeResult {
38+
+ uint64_t resetTime; // @text resetTime
39+
+ };
40+
+
41+
+ // @text getLastCheckoutResetTime
42+
+ // @brief Gets the last reset time for Hotel Checkout.
43+
+ // @param resetTime: Time in UTC. Returns 0, if time is not available.
44+
+ // @retval Core::ERROR_NONE Last Checkout reset time is successfully retrieved
45+
+ virtual Core::hresult GetLastCheckoutResetTime(GetLastCheckoutResetTimeResult& resetTime /* @out */) const = 0;
46+
+
47+
+ // @text setLastCheckoutResetTime
48+
+ // @brief Sets the last reset time for Hotel Checkout.
49+
+ // @param resetTime: Time in UTC.
50+
+ // @retval Core::ERROR_NONE Last Checkout reset time is successfully set
51+
+ virtual Core::hresult SetLastCheckoutResetTime(const uint64_t resetTime) = 0;
52+
+ };
53+
+}
54+
+}
55+
diff -uprN a/interfaces/IBackup.h b/interfaces/IBackup.h
56+
--- a/interfaces/IBackup.h 1970-01-01 03:00:00.000000000 +0300
57+
+++ b/interfaces/IBackup.h 2026-04-29 19:09:28.417616523 +0300
58+
@@ -0,0 +1,109 @@
59+
+/*
60+
+ * If not stated otherwise in this file or this component's LICENSE file the
61+
+ * following copyright and licenses apply:
62+
+ *
63+
+ * Copyright 2026 RDK Management
64+
+ *
65+
+ * Licensed under the Apache License, Version 2.0 (the "License");
66+
+ * you may not use this file except in compliance with the License.
67+
+ * You may obtain a copy of the License at
68+
+ *
69+
+ * http://www.apache.org/licenses/LICENSE-2.0
70+
+ *
71+
+ * Unless required by applicable law or agreed to in writing, software
72+
+ * distributed under the License is distributed on an "AS IS" BASIS,
73+
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74+
+ * See the License for the specific language governing permissions and
75+
+ * limitations under the License.
76+
+ */
77+
+
78+
+#pragma once
79+
+#include "Module.h"
80+
+
81+
+namespace WPEFramework
82+
+{
83+
+ namespace Exchange
84+
+ {
85+
+ enum Scenario : uint8_t
86+
+ {
87+
+ HOSPITALITY_RESET /* @text HOSPITALITY_RESET */
88+
+ };
89+
+
90+
+ struct EXTERNAL BackupContext
91+
+ {
92+
+ Scenario scenario /* @text scenario */
93+
+ /* @brief The scenario for which the backup operations are done */;
94+
+ string variant /* @text variant */
95+
+ /* @brief Variant label for the backup context (for example, user profile for which the backup operations are done) */
96+
+ /* @default:"generic" */;
97+
+ string persistentPath /* @text persistentPath */
98+
+ /* @brief Filesystem path where backup data is stored persistently */
99+
+ /* @default:"/opt/secure/persistent/settings_backup/" */;
100+
+ };
101+
+
102+
+ /*
103+
+ * Manages "backup and restore" operations for various settings in the system
104+
+ * by working with other plugins in the system
105+
+ */
106+
+ // @json 1.0.0 @text:keep
107+
+ struct EXTERNAL IBackupManager : virtual public Core::IUnknown
108+
+ {
109+
+ enum
110+
+ {
111+
+ ID = ID_BACKUP_MANAGER
112+
+ };
113+
+
114+
+ virtual ~IBackupManager() = default;
115+
+
116+
+ // @text backupSettings
117+
+ // @brief Backup settings across the system
118+
+ // @param context: Context for which the backup to happen
119+
+ // @retval Core::ERROR_NONE Successfully backed up the settings
120+
+ virtual Core::hresult BackupSettings(const BackupContext& context) = 0;
121+
+
122+
+ // @text restoreSettings
123+
+ // @brief Restore settings across the system
124+
+ // @param context: Context for which the restore to happen
125+
+ // @retval Core::ERROR_NONE Successfully restored the settings
126+
+ virtual Core::hresult RestoreSettings(const BackupContext& context) = 0;
127+
+
128+
+ // @text deleteBackup
129+
+ // @brief Deletes the previously backed up settings across the system
130+
+ // @param context: Context for which the backup to be deleted
131+
+ // @retval Core::ERROR_NONE Successfully deleted the backup
132+
+ virtual Core::hresult DeleteBackup(const BackupContext& context) = 0;
133+
+ };
134+
+
135+
+ /*
136+
+ * Provides APIs to "backup" and "restore" the settings the plugin owns.
137+
+ * Exact list of settings that gets backed up and restored are internal to the implementation.
138+
+ */
139+
+ struct EXTERNAL IBackupProvider : virtual public Core::IUnknown
140+
+ {
141+
+ enum
142+
+ {
143+
+ ID = ID_BACKUP_PROVIDER
144+
+ };
145+
+
146+
+ virtual ~IBackupProvider() = default;
147+
+
148+
+ // @text backup
149+
+ // @brief Backup settings that belong to this component.
150+
+ // @param context: Context for which the backup to happen
151+
+ // @retval Core::ERROR_NONE Successfully backed up
152+
+ virtual Core::hresult Backup(const BackupContext& context) = 0;
153+
+
154+
+ // @text restore
155+
+ // @brief Restore settings that belong to this component.
156+
+ // @param context: Context for which the restore to happen
157+
+ // @retval Core::ERROR_NONE Successfully restored
158+
+ virtual Core::hresult Restore(const BackupContext& context) = 0;
159+
+
160+
+ // @text delete
161+
+ // @brief Deletes the previously backed up settings that belong to this component.
162+
+ // @param context: Context for which the backup to be deleted
163+
+ // @retval Core::ERROR_NONE Successfully deleted the backup
164+
+ virtual Core::hresult Delete(const BackupContext& context) = 0;
165+
+ };
166+
+ }
167+
+}
168+
diff -uprN a/interfaces/Ids.h b/interfaces/Ids.h
169+
--- a/interfaces/Ids.h 2025-11-20 09:23:01.475783701 +0200
170+
+++ b/interfaces/Ids.h 2026-04-27 22:53:44.989463335 +0300
171+
@@ -356,6 +356,11 @@ namespace Exchange {
172+
173+
ID_WATCHDOG = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x4A0,
174+
175+
+ ID_ACCOUNT = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x4A1,
176+
+
177+
+ ID_BACKUP_MANAGER = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x4A2,
178+
+ ID_BACKUP_PROVIDER = ID_BACKUP_MANAGER + 1,
179+
+
180+
ID_SCRIPT_ENGINE = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x4B0,
181+
ID_SCRIPT_ENGINE_NOTIFICATION = ID_SCRIPT_ENGINE + 1,
182+
183+
diff -uprN a/interfaces/IUserSettings.h b/interfaces/IUserSettings.h
184+
--- a/interfaces/IUserSettings.h 2025-11-20 09:23:00.076754010 +0200
185+
+++ b/interfaces/IUserSettings.h 2026-04-25 06:12:36.406852094 +0300
186+
@@ -229,12 +229,12 @@ struct EXTERNAL IUserSettings : virtual
187+
// @details The setting should be honored by the Telemetry.
188+
// If privacyMode is "DO_NOT_SHARE", logs and crash report should not be uploaded.
189+
// @param privacyMode: "SHARE", "DO_NOT_SHARE"
190+
- virtual uint32_t SetPrivacyMode(const string& privacyMode /* @in @text privacyMode*/) = 0;
191+
+ virtual Core::hresult SetPrivacyMode(const string& privacyMode /* @in @text privacyMode*/) = 0;
192+
193+
// @text getPrivacyMode
194+
// @brief Gets the current PrivacyMode setting.
195+
// @param privacyMode e.g "SHARE"
196+
- virtual uint32_t GetPrivacyMode(string &privacyMode /* @out @text privacyMode */) const = 0;
197+
+ virtual Core::hresult GetPrivacyMode(string &privacyMode /* @out @text privacyMode */) const = 0;
198+
199+
// @text setPinControl
200+
// @brief Sets PinControl ON/OFF. Parental Control as a whole is enabled or disabled.
201+
@@ -401,7 +401,8 @@ struct EXTERNAL IUserSettingsInspector :
202+
VOICE_GUIDANCE = 15,
203+
VOICE_GUIDANCE_RATE = 16,
204+
VOICE_GUIDANCE_HINTS = 17,
205+
- CONTENT_PIN = 18
206+
+ CONTENT_PIN = 18,
207+
+ PRIVACY_MODE = 19
208+
};
209+
210+
struct SettingsMigrationState

UserSettings/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ All notable changes to this RDK Service will be documented in this file.
1616

1717
* For more details, refer to [versioning](https://github.com/rdkcentral/rdkservices#versioning) section under Main README.
1818

19+
## [2.5.0] - 2026-04-29
20+
### Added
21+
- Added support for IBackupProvider interface.
22+
1923
## [2.4.0] - 2025-06-24
2024
### Added
2125
- Add "contentPin" parameter in User Settings.

UserSettings/UserSettings.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include "UserSettings.h"
2121

2222
#define API_VERSION_NUMBER_MAJOR 2
23-
#define API_VERSION_NUMBER_MINOR 4
23+
#define API_VERSION_NUMBER_MINOR 5
2424
#define API_VERSION_NUMBER_PATCH 0
2525

2626
namespace WPEFramework
@@ -48,7 +48,7 @@ namespace WPEFramework
4848
**/
4949
SERVICE_REGISTRATION(UserSettings, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH);
5050

51-
UserSettings::UserSettings() : _service(nullptr), _connectionId(0), _userSetting(nullptr), _userSettingsInspector(nullptr), _usersettingsNotification(this)
51+
UserSettings::UserSettings() : _service(nullptr), _connectionId(0), _userSetting(nullptr), _userSettingsInspector(nullptr), _usersettingsNotification(this), configure(nullptr), _backupProvider(nullptr)
5252
{
5353
SYSLOG(Logging::Startup, (_T("UserSettings Constructor")));
5454
}
@@ -76,7 +76,6 @@ namespace WPEFramework
7676

7777
if(nullptr != _userSetting)
7878
{
79-
8079
configure = _userSetting->QueryInterface<Exchange::IConfiguration>();
8180
if (configure != nullptr)
8281
{
@@ -91,6 +90,13 @@ namespace WPEFramework
9190
message = _T("UserSettings implementation did not provide a configuration interface");
9291
}
9392

93+
_backupProvider = _userSetting->QueryInterface<Exchange::IBackupProvider>();
94+
if (_backupProvider == nullptr)
95+
{
96+
LOGERR("UserSettings implementation did not provide a IBackupProvider interface");
97+
message = _T("UserSettings implementation did not provide a IBackupProvider interface");
98+
}
99+
94100
// Register for notifications
95101
_userSetting->Register(&_usersettingsNotification);
96102
// Invoking Plugin API register to wpeframework
@@ -135,11 +141,20 @@ namespace WPEFramework
135141
Exchange::JUserSettings::Unregister(*this);
136142
Exchange::JUserSettingsInspector::Unregister(*this);
137143

138-
configure->Release();
139-
_userSettingsInspector->Release();
144+
if (configure != nullptr) {
145+
configure->Release();
146+
configure = nullptr;
147+
}
148+
149+
if (_userSettingsInspector != nullptr) {
150+
_userSettingsInspector->Release();
151+
_userSettingsInspector = nullptr;
152+
}
140153

141-
configure = nullptr;
142-
_userSettingsInspector = nullptr;
154+
if (_backupProvider != nullptr) {
155+
_backupProvider->Release();
156+
_backupProvider = nullptr;
157+
}
143158

144159
// Stop processing:
145160
RPC::IRemoteConnection* connection = service->RemoteConnection(_connectionId);

UserSettings/UserSettings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <interfaces/json/JsonData_UserSettingsInspector.h>
2727
#include <interfaces/IUserSettings.h>
2828
#include <interfaces/IConfiguration.h>
29+
#include <interfaces/IBackup.h>
2930
#include "UtilsLogging.h"
3031
#include "tracing/Logging.h"
3132
#include <mutex>
@@ -203,6 +204,7 @@ namespace Plugin {
203204
INTERFACE_ENTRY(PluginHost::IDispatcher)
204205
INTERFACE_AGGREGATE(Exchange::IUserSettings, _userSetting)
205206
INTERFACE_AGGREGATE(Exchange::IUserSettingsInspector, _userSettingsInspector)
207+
INTERFACE_AGGREGATE(Exchange::IBackupProvider, _backupProvider)
206208
END_INTERFACE_MAP
207209

208210
// IPlugin methods
@@ -221,6 +223,7 @@ namespace Plugin {
221223
Exchange::IUserSettingsInspector* _userSettingsInspector{};
222224
Core::Sink<Notification> _usersettingsNotification;
223225
Exchange::IConfiguration* configure;
226+
Exchange::IBackupProvider* _backupProvider{};
224227
};
225228

226229
} // namespace Plugin

0 commit comments

Comments
 (0)