Skip to content

Commit

Permalink
export saved patches and keystore
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminHalko committed Sep 25, 2023
1 parent 2a89ef7 commit 99c9206
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 30 deletions.
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

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

0 comments on commit 99c9206

Please sign in to comment.