Created
February 26, 2020 19:53
-
-
Save EmilAlipiev/7867c2fe79e2510a3e2a8c6811f191f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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