Add setter/getter tool for upgrade type 03/314203/1 accepted/tizen/8.0/unified/20240710.161341
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Fri, 28 Jun 2024 14:16:34 +0000 (16:16 +0200)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Mon, 8 Jul 2024 11:56:27 +0000 (13:56 +0200)
To make upgrade type settable and gettable, corresponding tools are
added:
 * device_board_get_upgrade_type
 * device_board_set_upgrade_type

Change-Id: Ie86d474e2e23d9d894cab49ae4c0efea74ec056a

packaging/deviced.spec
tools/board/CMakeLists.txt
tools/board/get-upgrade-type.c [new file with mode: 0644]
tools/board/set-upgrade-type.c [new file with mode: 0644]

index 4720036407b1ecaa944fbb18d4057ead2613491b..bdb1807193aac9c6cd43d822600bd4184b7ab7c7 100644 (file)
@@ -352,6 +352,8 @@ mv %{_libdir}/tv-display.so %{_libdir}/deviced/display.so
 %attr(0555,system_fw,system_fw) %{_bindir}/device_board_get_upgrade_progress_status
 %attr(0554,system_fw,system_fw) %{_bindir}/device_board_set_upgrade_state
 %attr(0555,system_fw,system_fw) %{_bindir}/device_board_get_upgrade_state
+%attr(0554,system_fw,system_fw) %{_bindir}/device_board_set_upgrade_type
+%attr(0555,system_fw,system_fw) %{_bindir}/device_board_get_upgrade_type
 
 %files auto-test
 %manifest deviced.manifest
index 334fb54036fe121f35c6f361a8f58ed615fd22be..4afbb4a41c9aff33f71598afaefb106caf36270b 100644 (file)
@@ -32,3 +32,6 @@ ADD_BOOT_EXECUTABLE(device_board_get_upgrade_progress_status get-upgrade-progres
 
 ADD_BOOT_EXECUTABLE(device_board_set_upgrade_state set-upgrade-state.c)
 ADD_BOOT_EXECUTABLE(device_board_get_upgrade_state get-upgrade-state.c)
+
+ADD_BOOT_EXECUTABLE(device_board_set_upgrade_type set-upgrade-type.c)
+ADD_BOOT_EXECUTABLE(device_board_get_upgrade_type get-upgrade-type.c)
diff --git a/tools/board/get-upgrade-type.c b/tools/board/get-upgrade-type.c
new file mode 100644 (file)
index 0000000..498b7dc
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * device-board-get-upgrade-state
+ *
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <hal/device/hal-board.h>
+
+#define BUFFER_LEN 1024
+
+int main(int argc, char *argv[])
+{
+       char state_buffer[BUFFER_LEN];
+       int ret;
+
+       ret = hal_device_board_get_upgrade_type(state_buffer, BUFFER_LEN);
+       if(ret < 0) {
+               printf("FAILURE\n");
+               return 1;
+       }
+
+       printf("%s\n", state_buffer);
+       return 0;
+}
diff --git a/tools/board/set-upgrade-type.c b/tools/board/set-upgrade-type.c
new file mode 100644 (file)
index 0000000..03969c1
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * device-board-set-upgrade-state
+ *
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <limits.h>
+
+#include <hal/device/hal-board.h>
+
+#define UPGRADE_TYPE_ONLINE "online"
+#define UPGRADE_TYPE_OFFLINE "offline"
+
+int main(int argc, char *argv[])
+{
+       char *type = NULL;
+       int ret = 0;
+
+       if(argc < 2)
+               goto error;
+
+       type = argv[1];
+       if (strcmp(type, UPGRADE_TYPE_ONLINE) != 0 &&
+           strcmp(type, UPGRADE_TYPE_OFFLINE) != 0) {
+               goto error;
+       }
+
+       ret = hal_device_board_set_upgrade_type(type);
+       if(ret < 0)
+               goto error;
+
+       printf("SUCCESS\n");
+       return 0;
+
+error:
+       printf("FAILURE\n");
+       return 1;
+}