mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
export saved patches and keystore
This commit is contained in:
parent
2a89ef797f
commit
99c92069b9
@ -55,7 +55,7 @@
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
<provider
|
||||
android:name=".utils.share.ShareProvider"
|
||||
android:name=".utils.share.LegacySettingsProvider"
|
||||
android:authorities="app.revanced.manager.flutter.provider"
|
||||
android:exported="true">
|
||||
</provider>
|
||||
|
@ -27,13 +27,6 @@ import java.io.StringWriter
|
||||
import java.util.logging.LogRecord
|
||||
import java.util.logging.Logger
|
||||
|
||||
import android.content.ContentResolver
|
||||
import android.content.Context
|
||||
import android.database.Cursor
|
||||
import android.net.Uri
|
||||
|
||||
import android.util.Log
|
||||
|
||||
class MainActivity : FlutterActivity() {
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private lateinit var installerChannel: MethodChannel
|
||||
@ -46,21 +39,6 @@ class MainActivity : FlutterActivity() {
|
||||
val patcherChannel = "app.revanced.manager.flutter/patcher"
|
||||
val installerChannel = "app.revanced.manager.flutter/installer"
|
||||
|
||||
val contentProviderUri = Uri.parse("content://app.revanced.manager.flutter.provider/settings")
|
||||
val contentResolver: ContentResolver = context.contentResolver
|
||||
val cursor: Cursor? = contentResolver.query(contentProviderUri, null, null, null, null)
|
||||
|
||||
Log.d("app.revanced.manager.flutter.debug", "byhithere")
|
||||
if (cursor != null) {
|
||||
Log.d("app.revanced.manager.flutter.debug", "test2")
|
||||
if (cursor.moveToFirst()) {
|
||||
val helloValue = cursor.getString(cursor.getColumnIndex("settings"))
|
||||
// Process the retrieved "hello" value
|
||||
Log.d("testing2", helloValue)
|
||||
}
|
||||
cursor.close()
|
||||
}
|
||||
|
||||
val mainChannel =
|
||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, patcherChannel)
|
||||
|
||||
|
@ -7,11 +7,11 @@ import android.content.UriMatcher
|
||||
import android.database.Cursor
|
||||
import android.database.MatrixCursor
|
||||
import android.net.Uri
|
||||
import android.util.Base64
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
import android.util.Log
|
||||
|
||||
class ShareProvider : ContentProvider() {
|
||||
class LegacySettingsProvider : ContentProvider() {
|
||||
private val authority = "app.revanced.manager.flutter.provider"
|
||||
private val URI_CODE_SETTINGS = 1
|
||||
|
||||
@ -27,18 +27,30 @@ class ShareProvider : ContentProvider() {
|
||||
val json = JSONObject()
|
||||
|
||||
// Default Data
|
||||
|
||||
// TODO: load default data
|
||||
json.put("keystorePassword", "s3cur3p@ssw0rd")
|
||||
|
||||
// Load Shared Preferences
|
||||
val sharedPreferences = context!!.getSharedPreferences("FlutterSharedPreferences", Context.MODE_PRIVATE)
|
||||
val allEntries: Map<String, *> = sharedPreferences.getAll()
|
||||
for ((key, value) in allEntries.entries) {
|
||||
Log.d("map values", key + ": " + value.toString())
|
||||
json.put(key.replace("flutter.", ""), value)
|
||||
}
|
||||
|
||||
// TODO: Load keystore
|
||||
// Load keystore
|
||||
val keystoreFile = File(context!!.getExternalFilesDir(null), "/revanced-manager.keystore")
|
||||
if (keystoreFile.exists()) {
|
||||
val keystoreBytes = keystoreFile.readBytes()
|
||||
val keystoreBase64 = Base64.encodeToString(keystoreBytes, Base64.DEFAULT)
|
||||
json.put("keystore", keystoreBase64)
|
||||
}
|
||||
|
||||
// Load saved patches
|
||||
val storedPatchesFile = File(context!!.filesDir.parentFile.absolutePath, "/app_flutter/selected-patches.json")
|
||||
if (storedPatchesFile.exists()) {
|
||||
val patchesBytes = storedPatchesFile.readBytes()
|
||||
val patches = String(patchesBytes, Charsets.UTF_8)
|
||||
json.put("savedPatches", patches)
|
||||
}
|
||||
|
||||
return json.toString()
|
||||
}
|
Loading…
Reference in New Issue
Block a user