manager: fix zip not flashing from content:// uri

This commit is contained in:
Rifat Azad
2025-06-15 12:09:32 +06:00
parent 14ec1194e4
commit 8c9728df95

View File

@@ -74,13 +74,29 @@ class MainActivity : ComponentActivity() {
val isManager = Natives.becomeManager(ksuApp.packageName) val isManager = Natives.becomeManager(ksuApp.packageName)
if (isManager) install() if (isManager) install()
// Check if launched with a ZIP file
val zipUri: Uri? = when (intent?.action) { val zipUri: Uri? = when (intent?.action) {
Intent.ACTION_VIEW, Intent.ACTION_SEND -> { Intent.ACTION_VIEW, Intent.ACTION_SEND -> {
intent.data ?: intent.getParcelableExtra(Intent.EXTRA_STREAM) val uri = intent.data ?: intent.getParcelableExtra<Uri>(Intent.EXTRA_STREAM)
uri?.let {
val name = when (it.scheme) {
"file" -> it.lastPathSegment ?: ""
"content" -> {
contentResolver.query(it, null, null, null, null)?.use { cursor ->
val nameIndex = cursor.getColumnIndex(android.provider.OpenableColumns.DISPLAY_NAME)
if (cursor.moveToFirst() && nameIndex != -1) {
cursor.getString(nameIndex)
} else {
it.lastPathSegment ?: ""
}
} ?: (it.lastPathSegment ?: "")
}
else -> it.lastPathSegment ?: ""
}
if (name.lowercase().endsWith(".zip")) it else null
}
} }
else -> null else -> null
}?.takeIf { it.toString().endsWith(".zip", ignoreCase = true) } }
setContent { setContent {
// Read AMOLED mode preference // Read AMOLED mode preference