Merge pull request #729 from Heap-Hop/master

Android screen wakeup
This commit is contained in:
RustDesk 2022-06-08 21:11:49 +08:00 committed by GitHub
commit 3740a0b730
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 3 deletions

1
.gitignore vendored
View File

@ -11,7 +11,6 @@ src/version.rs
*tgz *tgz
*lib *lib
cert.pfx cert.pfx
flutter_hbb
*.bak *.bak
*png *png
*svg *svg

View File

@ -9,6 +9,7 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<!--<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />--> <!--<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />-->
<application <application

View File

@ -206,7 +206,6 @@ class InputService : AccessibilityService() {
} }
} }
@RequiresApi(Build.VERSION_CODES.O)
override fun onServiceConnected() { override fun onServiceConnected() {
super.onServiceConnected() super.onServiceConnected()
ctx = this ctx = this

View File

@ -75,7 +75,17 @@ class MainService : Service() {
@Keep @Keep
@RequiresApi(Build.VERSION_CODES.N) @RequiresApi(Build.VERSION_CODES.N)
fun rustMouseInput(mask: Int, x: Int, y: Int) { fun rustMouseInput(mask: Int, x: Int, y: Int) {
InputService.ctx?.onMouseInput(mask,x,y) // turn on screen with LIFT_DOWN when screen off
if (!powerManager.isInteractive && mask == LIFT_DOWN) {
if (wakeLock.isHeld) {
Log.d(logTag,"Turn on Screen, WakeLock release")
wakeLock.release()
}
Log.d(logTag,"Turn on Screen")
wakeLock.acquire(5000)
} else {
InputService.ctx?.onMouseInput(mask,x,y)
}
} }
@Keep @Keep
@ -145,6 +155,9 @@ class MainService : Service() {
private var serviceLooper: Looper? = null private var serviceLooper: Looper? = null
private var serviceHandler: Handler? = null private var serviceHandler: Handler? = null
private val powerManager: PowerManager by lazy { applicationContext.getSystemService(Context.POWER_SERVICE) as PowerManager }
private val wakeLock: PowerManager.WakeLock by lazy { powerManager.newWakeLock(PowerManager.ACQUIRE_CAUSES_WAKEUP or PowerManager.SCREEN_BRIGHT_WAKE_LOCK, "rustdesk:wakelock")}
// jvm call rust // jvm call rust
private external fun init(ctx: Context) private external fun init(ctx: Context)
private external fun startServer() private external fun startServer()