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" />
|
android:resource="@xml/file_paths" />
|
||||||
</provider>
|
</provider>
|
||||||
<provider
|
<provider
|
||||||
android:name=".utils.share.ShareProvider"
|
android:name=".utils.share.LegacySettingsProvider"
|
||||||
android:authorities="app.revanced.manager.flutter.provider"
|
android:authorities="app.revanced.manager.flutter.provider"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
</provider>
|
</provider>
|
||||||
|
@ -27,13 +27,6 @@ import java.io.StringWriter
|
|||||||
import java.util.logging.LogRecord
|
import java.util.logging.LogRecord
|
||||||
import java.util.logging.Logger
|
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() {
|
class MainActivity : FlutterActivity() {
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
private val handler = Handler(Looper.getMainLooper())
|
||||||
private lateinit var installerChannel: MethodChannel
|
private lateinit var installerChannel: MethodChannel
|
||||||
@ -46,21 +39,6 @@ class MainActivity : FlutterActivity() {
|
|||||||
val patcherChannel = "app.revanced.manager.flutter/patcher"
|
val patcherChannel = "app.revanced.manager.flutter/patcher"
|
||||||
val installerChannel = "app.revanced.manager.flutter/installer"
|
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 =
|
val mainChannel =
|
||||||
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, patcherChannel)
|
MethodChannel(flutterEngine.dartExecutor.binaryMessenger, patcherChannel)
|
||||||
|
|
||||||
|
@ -7,11 +7,11 @@ import android.content.UriMatcher
|
|||||||
import android.database.Cursor
|
import android.database.Cursor
|
||||||
import android.database.MatrixCursor
|
import android.database.MatrixCursor
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.util.Base64
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
import java.io.File
|
||||||
|
|
||||||
import android.util.Log
|
class LegacySettingsProvider : ContentProvider() {
|
||||||
|
|
||||||
class ShareProvider : ContentProvider() {
|
|
||||||
private val authority = "app.revanced.manager.flutter.provider"
|
private val authority = "app.revanced.manager.flutter.provider"
|
||||||
private val URI_CODE_SETTINGS = 1
|
private val URI_CODE_SETTINGS = 1
|
||||||
|
|
||||||
@ -27,18 +27,30 @@ class ShareProvider : ContentProvider() {
|
|||||||
val json = JSONObject()
|
val json = JSONObject()
|
||||||
|
|
||||||
// Default Data
|
// Default Data
|
||||||
|
json.put("keystorePassword", "s3cur3p@ssw0rd")
|
||||||
// TODO: load default data
|
|
||||||
|
|
||||||
// Load Shared Preferences
|
// Load Shared Preferences
|
||||||
val sharedPreferences = context!!.getSharedPreferences("FlutterSharedPreferences", Context.MODE_PRIVATE)
|
val sharedPreferences = context!!.getSharedPreferences("FlutterSharedPreferences", Context.MODE_PRIVATE)
|
||||||
val allEntries: Map<String, *> = sharedPreferences.getAll()
|
val allEntries: Map<String, *> = sharedPreferences.getAll()
|
||||||
for ((key, value) in allEntries.entries) {
|
for ((key, value) in allEntries.entries) {
|
||||||
Log.d("map values", key + ": " + value.toString())
|
|
||||||
json.put(key.replace("flutter.", ""), value)
|
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()
|
return json.toString()
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user