mirror of
https://github.com/awfixers-stuff/OwnDroid.git
synced 2026-03-23 11:05:59 +00:00
automation: unsuspend app
This commit is contained in:
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@@ -4,6 +4,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '**.md'
|
- '**.md'
|
||||||
|
branches: [ "master" ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
|
|||||||
@@ -11,28 +11,16 @@ import androidx.activity.ComponentActivity
|
|||||||
|
|
||||||
class TaskReceiver: BroadcastReceiver() {
|
class TaskReceiver: BroadcastReceiver() {
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
Log.d("OwnDroid", ("TaskReceiver: pkgName: " + intent.component?.packageName))
|
|
||||||
Log.d("OwnDroid", ("TaskReceiver: pkg: " + intent.`package`))
|
|
||||||
val sharedPref = context.getSharedPreferences("data", Context.MODE_PRIVATE)
|
|
||||||
if(sharedPref.getString("AutomationApp", "") != intent.component?.packageName) return
|
|
||||||
val category = intent.getStringExtra("category")
|
|
||||||
if(category == "app") {
|
|
||||||
val action = intent.getStringExtra("action")
|
val action = intent.getStringExtra("action")
|
||||||
if(action == "suspend") {
|
|
||||||
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
val dpm = context.getSystemService(ComponentActivity.DEVICE_POLICY_SERVICE) as DevicePolicyManager
|
||||||
val receiver = ComponentName(context,Receiver::class.java)
|
val receiver = ComponentName(context,Receiver::class.java)
|
||||||
val app = intent.getStringExtra("app")
|
val app = intent.getStringExtra("app")
|
||||||
val mode = intent.getBooleanExtra("mode", false)
|
if(action == "suspend") {
|
||||||
if(VERSION.SDK_INT >= 24) {
|
dpm.setPackagesSuspended(receiver, arrayOf(app), true)
|
||||||
dpm.setPackagesSuspended(receiver, arrayOf(app), mode)
|
} else if(action == "unsuspend") {
|
||||||
} else {
|
dpm.setPackagesSuspended(receiver, arrayOf(app), false)
|
||||||
Log.d("OwnDroid", "unsupported")
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
Log.d("OwnDroid", "unknown action")
|
Log.d("OwnDroid", "unknown action")
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
Log.d("OwnDroid", "unknown category")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user