add notification trigger
|
@ -17,7 +17,7 @@ Lock a device and wipe its data on panic trigger.
|
||||||
height="30%">
|
height="30%">
|
||||||
|
|
||||||
You can use [PanicKit](https://guardianproject.info/code/panickit/), tile, shortcut or send a
|
You can use [PanicKit](https://guardianproject.info/code/panickit/), tile, shortcut or send a
|
||||||
broadcast with authentication code. On trigger, using
|
message with authentication code. On trigger, using
|
||||||
[Device Administration API](https://developer.android.com/guide/topics/admin/device-admin), it
|
[Device Administration API](https://developer.android.com/guide/topics/admin/device-admin), it
|
||||||
locks a device and optionally runs wipe.
|
locks a device and optionally runs wipe.
|
||||||
|
|
||||||
|
|
|
@ -122,5 +122,17 @@
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<service
|
||||||
|
android:name=".NotificationListenerService"
|
||||||
|
android:label="@string/notification_listener_service_name"
|
||||||
|
android:description="@string/notification_listener_service_description"
|
||||||
|
android:enabled="false"
|
||||||
|
android:exported="true"
|
||||||
|
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.service.notification.NotificationListenerService" />
|
||||||
|
</intent-filter>
|
||||||
|
</service>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
|
@ -216,11 +216,13 @@ open class MainActivity : AppCompatActivity() {
|
||||||
setTileState(launchers.and(Launcher.TILE.flag) != 0)
|
setTileState(launchers.and(Launcher.TILE.flag) != 0)
|
||||||
shortcut.setState(launchers.and(Launcher.SHORTCUT.flag) != 0)
|
shortcut.setState(launchers.and(Launcher.SHORTCUT.flag) != 0)
|
||||||
setCodeReceiverState(launchers.and(Launcher.BROADCAST.flag) != 0)
|
setCodeReceiverState(launchers.and(Launcher.BROADCAST.flag) != 0)
|
||||||
|
setNotificationState(launchers.and(Launcher.NOTIFICATION.flag) != 0)
|
||||||
} else {
|
} else {
|
||||||
setPanicKitState(false)
|
setPanicKitState(false)
|
||||||
setTileState(false)
|
setTileState(false)
|
||||||
shortcut.setState(false)
|
shortcut.setState(false)
|
||||||
setCodeReceiverState(false)
|
setCodeReceiverState(false)
|
||||||
|
setNotificationState(false)
|
||||||
}
|
}
|
||||||
updateCodeColorState()
|
updateCodeColorState()
|
||||||
}
|
}
|
||||||
|
@ -248,6 +250,8 @@ open class MainActivity : AppCompatActivity() {
|
||||||
setComponentState(RestartReceiver::class.java, value)
|
setComponentState(RestartReceiver::class.java, value)
|
||||||
private fun setTileState(value: Boolean) =
|
private fun setTileState(value: Boolean) =
|
||||||
setComponentState(QSTileService::class.java, value)
|
setComponentState(QSTileService::class.java, value)
|
||||||
|
private fun setNotificationState(value: Boolean) =
|
||||||
|
setComponentState(NotificationListenerService::class.java, value)
|
||||||
|
|
||||||
private fun setPanicKitState(value: Boolean) {
|
private fun setPanicKitState(value: Boolean) {
|
||||||
setComponentState(PanicConnectionActivity::class.java, value)
|
setComponentState(PanicConnectionActivity::class.java, value)
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package me.lucky.wasted
|
||||||
|
|
||||||
|
import android.app.Notification
|
||||||
|
import android.os.Build
|
||||||
|
import android.service.notification.NotificationListenerService
|
||||||
|
import android.service.notification.StatusBarNotification
|
||||||
|
|
||||||
|
class NotificationListenerService : NotificationListenerService() {
|
||||||
|
private lateinit var prefs: Preferences
|
||||||
|
private lateinit var admin: DeviceAdminManager
|
||||||
|
|
||||||
|
override fun onCreate() {
|
||||||
|
super.onCreate()
|
||||||
|
init()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun init() {
|
||||||
|
prefs = Preferences(this)
|
||||||
|
admin = DeviceAdminManager(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onNotificationPosted(sbn: StatusBarNotification?) {
|
||||||
|
super.onNotificationPosted(sbn)
|
||||||
|
if (sbn == null) return
|
||||||
|
val code = prefs.code
|
||||||
|
if (!prefs.isServiceEnabled ||
|
||||||
|
code == "" ||
|
||||||
|
sbn.notification.extras.getString(Notification.EXTRA_TEXT) != code) return
|
||||||
|
cancelAllNotifications()
|
||||||
|
try {
|
||||||
|
admin.lockNow()
|
||||||
|
if (prefs.isWipeData) admin.wipeData()
|
||||||
|
} catch (exc: SecurityException) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onListenerConnected() {
|
||||||
|
super.onListenerConnected()
|
||||||
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.S) return
|
||||||
|
migrateNotificationFilter(0, null)
|
||||||
|
}
|
||||||
|
}
|
|
@ -83,4 +83,5 @@ enum class Launcher(val flag: Int) {
|
||||||
TILE(1 shl 1),
|
TILE(1 shl 1),
|
||||||
SHORTCUT(1 shl 2),
|
SHORTCUT(1 shl 2),
|
||||||
BROADCAST(1 shl 3),
|
BROADCAST(1 shl 3),
|
||||||
|
NOTIFICATION(1 shl 4),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Потрачено</string>
|
<string name="app_name">Потрачено</string>
|
||||||
<string name="description">Включите Потрачено чтобы заблокировать устройство при получении тревожного сигнала. Вы можете использовать PanicKit, плитку быстрых настроек, ярлык или отправить широковещательное сообщение с этим кодом аутентификации.</string>
|
<string name="description">Включите Потрачено чтобы заблокировать устройство при получении тревожного сигнала. Вы можете использовать PanicKit, плитку быстрых настроек, ярлык или отправить сообщение с этим кодом аутентификации.</string>
|
||||||
<string name="device_admin_label">Потрачено</string>
|
<string name="device_admin_label">Потрачено</string>
|
||||||
<string name="device_admin_description">Разрешите Потрачено блокировать устройство и опционально стирать его данные при получении тревожного сигнала</string>
|
<string name="device_admin_description">Разрешите Потрачено блокировать устройство и опционально стирать его данные при получении тревожного сигнала</string>
|
||||||
<string name="service_unavailable_popup">Администратор устройства недоступен</string>
|
<string name="service_unavailable_popup">Администратор устройства недоступен</string>
|
||||||
|
@ -32,4 +32,7 @@
|
||||||
<string name="launchers_array_1">Плитка</string>
|
<string name="launchers_array_1">Плитка</string>
|
||||||
<string name="launchers_array_2">Ярлык</string>
|
<string name="launchers_array_2">Ярлык</string>
|
||||||
<string name="launchers_array_3">Широковещательное сообщение</string>
|
<string name="launchers_array_3">Широковещательное сообщение</string>
|
||||||
|
<string name="launchers_array_4">Уведомление</string>
|
||||||
|
<string name="notification_listener_service_name">Вайпер</string>
|
||||||
|
<string name="notification_listener_service_description">Сканирует уведомления на наличие кода аутентификации</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -5,5 +5,6 @@
|
||||||
<item>@string/launchers_array_1</item>
|
<item>@string/launchers_array_1</item>
|
||||||
<item>@string/launchers_array_2</item>
|
<item>@string/launchers_array_2</item>
|
||||||
<item>@string/launchers_array_3</item>
|
<item>@string/launchers_array_3</item>
|
||||||
|
<item>@string/launchers_array_4</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
</resources>
|
</resources>
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">Wasted</string>
|
<string name="app_name">Wasted</string>
|
||||||
<string name="description">Turn on Wasted to lock a device on panic trigger. You can use PanicKit, tile, shortcut or send a broadcast with this authentication code.</string>
|
<string name="description">Turn on Wasted to lock a device on panic trigger. You can use PanicKit, tile, shortcut or send a message with this authentication code.</string>
|
||||||
<string name="device_admin_label">Wasted</string>
|
<string name="device_admin_label">Wasted</string>
|
||||||
<string name="device_admin_description">Allow Wasted to lock a device and optionally wipe its data on panic trigger</string>
|
<string name="device_admin_description">Allow Wasted to lock a device and optionally wipe its data on panic trigger</string>
|
||||||
<string name="service_unavailable_popup">Device admin unavailable</string>
|
<string name="service_unavailable_popup">Device admin unavailable</string>
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
<string name="notification_channel_default_name">Default</string>
|
<string name="notification_channel_default_name">Default</string>
|
||||||
<string name="ok">OK</string>
|
<string name="ok">OK</string>
|
||||||
<string name="wipe_job_description">Wipe a device on inactivity</string>
|
<string name="wipe_job_description">Wipe a device on inactivity</string>
|
||||||
<string name="wipe_job_schedule_failed_popup">Failed to schedule a wipe service</string>
|
<string name="wipe_job_schedule_failed_popup">Failed to schedule a wipe job</string>
|
||||||
<string name="unlock_service_description">Receive unlock events</string>
|
<string name="unlock_service_description">Receive unlock events</string>
|
||||||
<string name="unlock_service_notification_title">Unlock Service</string>
|
<string name="unlock_service_notification_title">Unlock Service</string>
|
||||||
<string name="dialog_confirm_panic_title">Activate panic\?</string>
|
<string name="dialog_confirm_panic_title">Activate panic\?</string>
|
||||||
|
@ -32,4 +32,7 @@
|
||||||
<string name="launchers_array_1">Tile</string>
|
<string name="launchers_array_1">Tile</string>
|
||||||
<string name="launchers_array_2">Shortcut</string>
|
<string name="launchers_array_2">Shortcut</string>
|
||||||
<string name="launchers_array_3">Broadcast</string>
|
<string name="launchers_array_3">Broadcast</string>
|
||||||
|
<string name="launchers_array_4">Notification</string>
|
||||||
|
<string name="notification_listener_service_name">Viper</string>
|
||||||
|
<string name="notification_listener_service_description">Scan notifications for authentication code</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Lock a device and wipe its data on panic trigger.
|
Lock a device and wipe its data on panic trigger.
|
||||||
|
|
||||||
You can use PanicKit, tile, shortcut or send a broadcast with authentication code. On trigger,
|
You can use PanicKit, tile, shortcut or send a message with authentication code. On trigger, using
|
||||||
using Device Administration API, it locks a device and optionally runs wipe.
|
Device Administration API, it locks a device and optionally runs wipe.
|
||||||
|
|
||||||
Also you can:
|
Also you can:
|
||||||
* limit the maximum number of failed password attempts
|
* limit the maximum number of failed password attempts
|
||||||
|
|
Before Width: | Height: | Size: 117 KiB After Width: | Height: | Size: 117 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 104 KiB |
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 93 KiB |
Before Width: | Height: | Size: 114 KiB After Width: | Height: | Size: 114 KiB |
|
@ -1,8 +1,8 @@
|
||||||
Блокировка устройства и удаление его данных при получении тревожного сигнала.
|
Блокировка устройства и удаление его данных при получении тревожного сигнала.
|
||||||
|
|
||||||
Вы можете использовать PanicKit, плитку быстрых настроек, ярлык или отправить широковещательное
|
Вы можете использовать PanicKit, плитку быстрых настроек, ярлык или отправить сообщение с кодом
|
||||||
сообщение с кодом аутентификации. При получении тревожного сигнала, используя API Администратора
|
аутентификации. При получении тревожного сигнала, используя API Администратора Устройства,
|
||||||
Устройства, программа заблокирует устройство и опционально запустит стирание данных.
|
программа заблокирует устройство и опционально запустит стирание данных.
|
||||||
|
|
||||||
Также Вы можете:
|
Также Вы можете:
|
||||||
* установить лимит на максимальное количество неудачных попыток ввода пароля
|
* установить лимит на максимальное количество неудачных попыток ввода пароля
|
||||||
|
|