display: add dummy display for iot-headless 44/281644/2 accepted/tizen_7.0_unified_hotfix tizen_7.0_hotfix accepted/tizen/7.0/unified/hotfix/20221116.105704 accepted/tizen/unified/20220921.091815 tizen_7.0_m2_release
authorYoungjae Cho <y0.cho@samsung.com>
Tue, 20 Sep 2022 06:45:26 +0000 (15:45 +0900)
committerYoungjae Cho <y0.cho@samsung.com>
Tue, 20 Sep 2022 08:43:32 +0000 (17:43 +0900)
For who want cpulock directly via dbus API, not device API on headless
target, add dummy dbus object that receives those request not to emit
error.

Such a weird call, request for display function on headless profile,
is basically because display module provides state locking including
sleep state(cpulock), which should have been handled by power module.
Therefore in the future, moving cpulock from display to power module
should be followed by removing this dummy.

Change-Id: If8f0b449f65832ddf705b9e7ad4e461c20f6a102
Signed-off-by: Youngjae Cho <y0.cho@samsung.com>
CMakeLists.txt
packaging/deviced.spec
plugins/iot-headless/display/CMakeLists.txt [new file with mode: 0644]
plugins/iot-headless/display/core.c [new file with mode: 0644]

index ba0c0c8..8aca3d1 100644 (file)
@@ -337,6 +337,7 @@ ADD_SUBDIRECTORY(plugins/tv/display)
 ADD_SUBDIRECTORY(plugins/iot-headed/display)
 ADD_SUBDIRECTORY(plugins/iot-headless/input)
 ADD_SUBDIRECTORY(plugins/iot-headless/battery)
+ADD_SUBDIRECTORY(plugins/iot-headless/display)
 IF(BATTERY_MODULE STREQUAL on)
        ADD_SUBDIRECTORY(plugins/mobile/battery)
        ADD_SUBDIRECTORY(plugins/wearable/battery)
index caa06af..a963293 100644 (file)
@@ -258,6 +258,7 @@ mv %{_sysconfdir}/deviced/power-profile-iot-headless.conf %{_sysconfdir}/deviced
 mkdir -p %{_libdir}/deviced
 mv %{_libdir}/iot-headless-input-handler.so %{_libdir}/deviced/input-handler.so
 mv %{_libdir}/iot-headless-battery.so %{_libdir}/deviced/battery.so
+mv %{_libdir}/iot-headless-display.so %{_libdir}/deviced/display.so
 
 %files
 %manifest %{name}.manifest
@@ -393,5 +394,6 @@ mv %{_libdir}/iot-headless-battery.so %{_libdir}/deviced/battery.so
 %config %{_sysconfdir}/deviced/power-profile-iot-headless.conf
 %{_libdir}/iot-headless-input-handler.so
 %{_libdir}/iot-headless-battery.so
+%{_libdir}/iot-headless-display.so
 %{_unitdir}/rndis.service
 %{_bindir}/rndis.sh
diff --git a/plugins/iot-headless/display/CMakeLists.txt b/plugins/iot-headless/display/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3d0a186
--- /dev/null
@@ -0,0 +1,21 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(iot-headless-display C)
+
+FILE(GLOB SRCS "*.c")
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(libpkgs REQUIRED
+       libsyscommon)
+
+FOREACH(flag ${libpkgs_CFLAGS})
+       SET(EXTRA_LIB_CFLAGS "${EXTRA_LIB_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LIB_CFLAGS}")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS})
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${libpkgs_LDFLAGS} deviced-common-private)
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES PREFIX "")
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES OUTPUT_NAME iot-headless-display)
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
diff --git a/plugins/iot-headless/display/core.c b/plugins/iot-headless/display/core.c
new file mode 100644 (file)
index 0000000..fc642eb
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * deviced
+ *
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * 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 <shared/common.h>
+#include <shared/devices.h>
+#include <libsyscommon/libgdbus.h>
+
+static GVariant *dbus_lockstate(GDBusConnection *conn,
+       const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
+       GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
+{
+       return g_variant_new("(i)", 0);
+}
+
+static GVariant *dbus_unlockstate(GDBusConnection *conn,
+       const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
+       GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
+{
+       return g_variant_new("(i)", 0);
+}
+
+static const dbus_method_s dbus_methods[] = {
+       { "lockstate",     "sssi",   "i", dbus_lockstate },
+       { "unlockstate",     "ss",   "i", dbus_unlockstate },
+};
+
+static const dbus_interface_u dbus_interface = {
+       .oh = NULL,
+       .name = DEVICED_INTERFACE_DISPLAY,
+       .methods = dbus_methods,
+       .nr_methods = ARRAY_SIZE(dbus_methods),
+};
+
+static void display_init(void *data)
+{
+       gdbus_add_object(NULL, DEVICED_PATH_DISPLAY, &dbus_interface);
+}
+
+static const struct device_ops display_device_ops = {
+       .priority = DEVICE_PRIORITY_HIGH,
+       DECLARE_NAME_LEN("display"),
+       .init     = display_init,
+};
+
+DEVICE_OPS_REGISTER(&display_device_ops)