export saved patches and keystore

This commit is contained in:
Benjamin Halko 2023-09-25 08:43:10 -07:00
parent 2a89ef797f
commit 99c92069b9
No known key found for this signature in database
GPG key ID: 790C70040EB331A0
3 changed files with 20 additions and 30 deletions

View file

@ -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>

View file

@ -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)

View file

@ -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()
}