also looking at this
feat(android): setKeepAwake through the trampoline — ratchet 70 → 69
#174
7 files
+140
-13
| @@ -128,6 +128,7 @@ object CraftNative { | ||
| 128 | 128 | private external fun nativeRunTask(activity: Activity, token: Long) |
| 129 | 129 | private external fun nativeLockOrientation(activity: Activity, orientation: String): Boolean |
| 130 | 130 | private external fun nativeUnlockOrientation(activity: Activity): Boolean |
| 131 | private external fun nativeSetKeepAwake(activity: Activity, enabled: Boolean): Boolean | |
| 131 | 132 | |
| 132 | 133 | /** |
| 133 | 134 | * `getDeviceInfo`, or null to use the Kotlin implementation. |
| @@ -619,4 +620,13 @@ object CraftNative { | ||
| 619 | 620 | false |
| 620 | 621 | } |
| 621 | 622 | } |
| 623 | ||
| 624 | fun setKeepAwake(activity: Activity, enabled: Boolean): Boolean { | |
| 625 | if (!isAvailable) return false | |
| 626 | return try { | |
| 627 | nativeSetKeepAwake(activity, enabled) | |
| 628 | } catch (e: UnsatisfiedLinkError) { | |
| 629 | false | |
| 630 | } | |
| 631 | } | |
| 622 | 632 | } |