forked from seedvault-app/seedvault
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow launching restore through a dialer code
* We don't show Restore in menu by default since it's not the best idea to restore a running system * However, at the same time, it's good to have a way to do that for those who'd like to restore anyway, and the only current way is adb, which is not ideal * Dialing "*#*#RESTORE#*#*" will launch the restore activity Change-Id: I258fead82f7e916a4de0b314e1840d7aa4b3746c
- Loading branch information
1 parent
a5a3a85
commit 38f0176
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/stevesoltys/seedvault/SecretCodeReceiver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.stevesoltys.seedvault | ||
|
||
import android.content.BroadcastReceiver | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK | ||
import android.util.Log | ||
import com.stevesoltys.seedvault.restore.RestoreActivity | ||
|
||
private val TAG = BroadcastReceiver::class.java.simpleName | ||
private val RESTORE_SECRET_CODE = "7378673" | ||
|
||
class SecretCodeReceiver : BroadcastReceiver() { | ||
|
||
override fun onReceive(context: Context, intent: Intent) { | ||
val host = intent.data.host | ||
if (!RESTORE_SECRET_CODE.equals(host)) return | ||
Log.d(TAG, "Restore secret code received.") | ||
val i = Intent(context, RestoreActivity::class.java).apply { | ||
flags = FLAG_ACTIVITY_NEW_TASK | ||
} | ||
context.startActivity(i) | ||
} | ||
} |