mirror of https://github.com/x13a/Wasted.git
add PanicKit
This commit is contained in:
parent
5b50da436a
commit
5858aeeaf7
|
@ -8,7 +8,7 @@ Lock device and wipe data on panic trigger.
|
|||
|
||||
<img src="https://user-images.githubusercontent.com/53379023/146620711-e8675350-3634-4e45-825a-1661c8018b38.png" width="30%" height="30%">
|
||||
|
||||
The app will listen for broadcast message with authentication code. On receive, using
|
||||
You can use PanicKit or send broadcast message with authentication code. On trigger, using
|
||||
[Device Administration API](https://developer.android.com/guide/topics/admin/device-admin), it
|
||||
locks device and runs wipe.
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 1.0.x | :white_check_mark: |
|
||||
| < 1.0 | :x: |
|
||||
| 1.1.x | :white_check_mark: |
|
||||
| < 1.1 | :x: |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
applicationId "me.lucky.wasted"
|
||||
minSdk 25
|
||||
minSdk 23
|
||||
targetSdk 31
|
||||
versionCode 6
|
||||
versionName "1.0.5"
|
||||
versionCode 7
|
||||
versionName "1.1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
@ -45,4 +45,5 @@ dependencies {
|
|||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
|
||||
implementation 'androidx.security:security-crypto:1.0.0'
|
||||
implementation 'info.guardianproject.panic:panic:1.0'
|
||||
}
|
|
@ -4,24 +4,24 @@
|
|||
package="me.lucky.wasted">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:fullBackupContent="true"
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Wasted">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<receiver android:name=".DeviceAdminReceiver"
|
||||
<receiver
|
||||
android:name=".DeviceAdminReceiver"
|
||||
android:label="@string/device_admin_label"
|
||||
android:description="@string/device_admin_description"
|
||||
android:permission="android.permission.BIND_DEVICE_ADMIN"
|
||||
|
@ -42,6 +42,29 @@
|
|||
<action android:name="me.lucky.wasted.action.TRIGGER" />
|
||||
</intent-filter>
|
||||
</receiver>
|
||||
|
||||
<activity
|
||||
android:name=".PanicResponderActivity"
|
||||
android:noHistory="true"
|
||||
android:exported="true"
|
||||
android:theme="@android:style/Theme.NoDisplay">
|
||||
<intent-filter>
|
||||
<action android:name="info.guardianproject.panic.action.TRIGGER" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".PanicConnectionActivity"
|
||||
android:noHistory="true"
|
||||
android:exported="true">
|
||||
<intent-filter>
|
||||
<action android:name="info.guardianproject.panic.action.CONNECT" />
|
||||
<action android:name="info.guardianproject.panic.action.DISCONNECT" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package me.lucky.wasted
|
||||
|
||||
import android.app.admin.DevicePolicyManager
|
||||
import android.app.Activity
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
|
@ -15,7 +14,7 @@ import java.util.*
|
|||
|
||||
import me.lucky.wasted.databinding.ActivityMainBinding
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
open class MainActivity : AppCompatActivity() {
|
||||
private lateinit var binding: ActivityMainBinding
|
||||
|
||||
private val prefs by lazy { Preferences(this) }
|
||||
|
@ -26,7 +25,7 @@ class MainActivity : AppCompatActivity() {
|
|||
private val requestAdminPolicy =
|
||||
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { result ->
|
||||
when (result.resultCode) {
|
||||
Activity.RESULT_OK -> setOn()
|
||||
RESULT_OK -> setOn()
|
||||
else -> binding.toggle.isChecked = false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package me.lucky.wasted
|
||||
|
||||
import android.content.pm.PackageManager
|
||||
import android.os.Bundle
|
||||
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
|
||||
import info.guardianproject.panic.PanicResponder
|
||||
|
||||
class PanicConnectionActivity : MainActivity() {
|
||||
|
||||
private val pm by lazy { packageManager }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
if (PanicResponder.checkForDisconnectIntent(this)) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
val sender = PanicResponder.getConnectIntentSender(this)
|
||||
val packageName = PanicResponder.getTriggerPackageName(this)
|
||||
if (sender != "" && sender != packageName) {
|
||||
showOptInDialog()
|
||||
}
|
||||
}
|
||||
|
||||
private fun showOptInDialog() {
|
||||
var app: CharSequence = getString(R.string.panic_app_unknown_app)
|
||||
val packageName = callingActivity?.packageName
|
||||
if (packageName != null) {
|
||||
try {
|
||||
app = pm.getApplicationLabel(pm.getApplicationInfo(packageName, 0))
|
||||
} catch (exc: PackageManager.NameNotFoundException) {}
|
||||
}
|
||||
|
||||
AlertDialog.Builder(this).apply {
|
||||
setTitle(getString(R.string.panic_app_dialog_title))
|
||||
setMessage(String.format(getString(R.string.panic_app_dialog_message), app))
|
||||
setNegativeButton(R.string.allow) { _, _ ->
|
||||
PanicResponder.setTriggerPackageName(this@PanicConnectionActivity)
|
||||
setResult(RESULT_OK)
|
||||
}
|
||||
setPositiveButton(R.string.cancel) { _, _ ->
|
||||
setResult(RESULT_CANCELED)
|
||||
finish()
|
||||
}
|
||||
show()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package me.lucky.wasted
|
||||
|
||||
import android.app.admin.DevicePolicyManager
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
||||
import info.guardianproject.panic.Panic
|
||||
import info.guardianproject.panic.PanicResponder
|
||||
|
||||
class PanicResponderActivity : AppCompatActivity() {
|
||||
private val prefs by lazy { Preferences(this) }
|
||||
private val dpm by lazy {
|
||||
getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager }
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
if (!Panic.isTriggerIntent(intent) || !prefs.isServiceEnabled) {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
try {
|
||||
dpm.lockNow()
|
||||
if (PanicResponder.receivedTriggerFromConnectedApp(this) &&
|
||||
prefs.doWipe) dpm.wipeData(0)
|
||||
} catch (exc: SecurityException) {}
|
||||
finish()
|
||||
}
|
||||
}
|
|
@ -1,8 +1,13 @@
|
|||
<resources>
|
||||
<string name="app_name">Wasted</string>
|
||||
<string name="description">Turn on Wasted to lock device on panic trigger. The app will listen for broadcast message with this authentication code.</string>
|
||||
<string name="description">Turn on Wasted to lock device on panic trigger. You can use PanicKit or send broadcast message with this authentication code.</string>
|
||||
<string name="device_admin_label">Wasted</string>
|
||||
<string name="device_admin_description">Allow Wasted to lock device and wipe data on panic trigger</string>
|
||||
<string name="service_unavailable_toast">Admin service unavailable</string>
|
||||
<string name="wipe_data_check_box">Wipe data</string>
|
||||
<string name="panic_app_dialog_title">Confirm Panic App</string>
|
||||
<string name="panic_app_dialog_message">Are you sure that you want to allow %1$s to trigger destructive panic actions?</string>
|
||||
<string name="panic_app_unknown_app">an unknown app</string>
|
||||
<string name="allow">Allow</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
</resources>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
add PanicKit
|
|
@ -1,4 +1,4 @@
|
|||
Lock device and wipe data on panic trigger.
|
||||
|
||||
The app will listen for broadcast message with authentication code.
|
||||
On receive, using Device Administration API, it locks device and runs wipe.
|
||||
You can use PanicKit or send broadcast message with authentication code.
|
||||
On trigger, using Device Administration API, it locks device and runs wipe.
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 74 KiB |
Loading…
Reference in New Issue