Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public static class ScreenSettings
{
public static void MakeScreenOn()
{
int ret = DevicePowerRequestLock(1, 0); // type : CPU:0, DisplayNormal:1, DisplayDim:2
//if (ret != 0)
//{
// Exception exp;
// switch (ret)
// {
// case -22:// invalid parameter
// exp = new InvalidOperationException("[device_power_request_lock] invalid parameter.");
// break;
// case -13: // permission denied
// exp = new UnauthorizedAccessException("[device_power_request_lock] permission denied.");
// break;
// case -0x01140000 | 0x01: // operation failed
// exp = new InvalidOperationException("[device_power_request_lock] Operation Failed");
// break;
// default:
// exp = new InvalidOperationException("[device_power_request_lock] The unknown error occurs.");
// break;
// }
// throw exp;
//}
}
public static void MakeScreenOff()
{
int ret = DevicePowerReleaseLock(1); // type : CPU:0, DisplayNormal:1, DisplayDim:2
//if (ret != 0)
//{
// Exception exp;
// switch (ret)
// {
// case -22:// invalid parameter
// exp = new InvalidOperationException("[device_power_release_lock] invalid parameter.");
// break;
// case -13: // permission denied
// exp = new UnauthorizedAccessException("[device_power_release_lock] permission denied.");
// break;
// case -0x01140000 | 0x01: // operation failed
// exp = new InvalidOperationException("[device_power_release_lock] Operation Failed");
// break;
// default:
// exp = new InvalidOperationException("[device_power_release_lock] The unknown error occurs.");
// break;
// }
// throw exp;
//}
}
[DllImport("libcapi-system-device.so.0", EntryPoint = "device_power_request_lock", CallingConvention = CallingConvention.Cdecl)]
internal static extern int DevicePowerRequestLock(int type, int timeout_ms);
[DllImport("libcapi-system-device.so.0", EntryPoint = "device_power_release_lock", CallingConvention = CallingConvention.Cdecl)]
internal static extern int DevicePowerReleaseLock(int type);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.