Search code examples
c#websockettizentizen-wearable-sdk

Tizen .NET Wearable Screen Wakeup


We are currently developing an application for smartwatches. We originally built the apps as a Web Application using HTML, JS and CSS. Since the development went rather rough for us, we switched to .NET.

Everything works fine after the port. The only exception is, that our application has to continue in the background. We originally forced this, by manually waking up the screen, whenever it wanted to go to sleep (similar to this post: Is it possible to keep Tizen application alive non stop). Within .NET we do not have this exact functionality now. After searching for hours we didn't find a proper solution, the screen is always shutting down and sooner or later the application gets killed by the OS.

Why shouldn't the app be killed? We have a WebSocket connection. This WebSocket communicates with the watch. If the app gets killed, obviously the server can not communicate anymore. Therefore the WebSocket has to run constantly for at least 10 hours.

I hope somebody can help. Thank you!


Solution

  • Thanks to @Lunch Basketball I've gotten a nice input.

    You can import the specific DLLs from the native methods and call them within the project. E.g. if you want to lock and release the CPU (which means that your application will not be killed).

    internal static class NativeMethods
    {
        [DllImport("libcapi-system-device.so.0", EntryPoint = "device_power_request_lock", CallingConvention = CallingConvention.Cdecl)]
        internal static extern int DevicePowerRequestLock(int type, int timeoutMs);
    
        [DllImport("libcapi-system-device.so.0", EntryPoint = "device_power_release_lock", CallingConvention = CallingConvention.Cdecl)]
        internal static extern int DevicePowerReleaseLock(int type);
    }