Skip to content

Commit 9084e38

Browse files
committed
Restrict data/obb on Android 11+
1 parent 445d12a commit 9084e38

1 file changed

Lines changed: 3 additions & 30 deletions

File tree

  • commons/src/main/kotlin/org/fossify/commons/extensions

commons/src/main/kotlin/org/fossify/commons/extensions/Activity.kt

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ fun BaseSimpleActivity.isShowingAndroidSAFDialog(path: String, openInSystemAppAl
230230
return if (isRestrictedSAFOnlyRoot(path) && (getAndroidTreeUri(path).isEmpty() || !hasProperStoredAndroidTreeUri(path))) {
231231
runOnUiThread {
232232
if (!isDestroyed && !isFinishing) {
233-
if (isUpsideDownCakePlus() && !openInSystemAppAllowed) {
233+
if (!openInSystemAppAllowed) {
234234
ConfirmationDialog(
235235
this,
236236
"",
@@ -243,42 +243,15 @@ fun BaseSimpleActivity.isShowingAndroidSAFDialog(path: String, openInSystemAppAl
243243
this,
244244
"",
245245
R.string.confirm_storage_access_restricted_text,
246-
if (isUpsideDownCakePlus()) {
247-
R.string.confirm_storage_access_restricted_text_open_system
248-
} else {
249-
R.string.confirm_storage_access_restricted_text_request_access
250-
},
246+
R.string.confirm_storage_access_restricted_text_open_system,
251247
R.string.cancel
252248
) { success ->
253249
if (success) {
254250
val uri = createAndroidDataOrObbUri(path)
255251

256252
// On Android 14+, there is no longer any workaround to access the data/ and obb/ folders
257253
// Open the system app instead
258-
if (isUpsideDownCakePlus()) {
259-
launchSystemFileManager(uri)
260-
} else {
261-
Intent(Intent.ACTION_OPEN_DOCUMENT_TREE).apply {
262-
putExtra(EXTRA_SHOW_ADVANCED, true)
263-
putExtra(DocumentsContract.EXTRA_INITIAL_URI, uri)
264-
try {
265-
startActivityForResult(this, OPEN_DOCUMENT_TREE_FOR_ANDROID_DATA_OR_OBB)
266-
checkedDocumentPath = path
267-
return@apply
268-
} catch (e: Exception) {
269-
type = "*/*"
270-
}
271-
272-
try {
273-
startActivityForResult(this, OPEN_DOCUMENT_TREE_FOR_ANDROID_DATA_OR_OBB)
274-
checkedDocumentPath = path
275-
} catch (e: ActivityNotFoundException) {
276-
toast(R.string.system_service_disabled, Toast.LENGTH_LONG)
277-
} catch (e: Exception) {
278-
toast(R.string.unknown_error_occurred)
279-
}
280-
}
281-
}
254+
launchSystemFileManager(uri)
282255
}
283256
}
284257
}

0 commit comments

Comments
 (0)