Skip to content

Commit 4cdb5e1

Browse files
committed
limit some file operations to rooted devices only
1 parent c13bedb commit 4cdb5e1

File tree

25 files changed

+72
-26
lines changed

25 files changed

+72
-26
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/adapters/ItemsAdapter.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import com.simplemobiletools.filemanager.dialogs.CompressAsDialog
3030
import com.simplemobiletools.filemanager.extensions.*
3131
import com.simplemobiletools.filemanager.helpers.RootHelpers
3232
import com.simplemobiletools.filemanager.interfaces.ItemOperationsListener
33+
import com.stericson.RootTools.RootTools
3334
import kotlinx.android.synthetic.main.list_item.view.*
3435
import java.io.Closeable
3536
import java.io.File
@@ -433,6 +434,11 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
433434
val removeFiles = ArrayList<FileDirItem>(selectedPositions.size)
434435
val SAFPath = fileDirItems[selectedPositions.first()].path
435436

437+
if (activity.isPathOnRoot(SAFPath) && !RootTools.isRootAvailable()) {
438+
activity.toast(R.string.rooted_device_only)
439+
return
440+
}
441+
436442
activity.handleSAFDialog(SAFPath) {
437443
selectedPositions.sortedDescending().forEach {
438444
val file = fileDirItems[it]

app/src/main/kotlin/com/simplemobiletools/filemanager/helpers/RootHelpers.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ package com.simplemobiletools.filemanager.helpers
33
import android.app.Activity
44
import com.simplemobiletools.commons.extensions.areDigitsOnly
55
import com.simplemobiletools.commons.extensions.showErrorToast
6+
import com.simplemobiletools.commons.extensions.toast
67
import com.simplemobiletools.commons.helpers.SORT_BY_SIZE
78
import com.simplemobiletools.commons.models.FileDirItem
9+
import com.simplemobiletools.filemanager.R
810
import com.simplemobiletools.filemanager.extensions.config
911
import com.stericson.RootShell.execution.Command
1012
import com.stericson.RootTools.RootTools
@@ -160,6 +162,11 @@ class RootHelpers(val activity: Activity) {
160162
}
161163

162164
fun createFileFolder(path: String, isFile: Boolean, callback: (success: Boolean) -> Unit) {
165+
if (!RootTools.isRootAvailable()) {
166+
activity.toast(R.string.rooted_device_only)
167+
return
168+
}
169+
163170
tryMountAsRW(path) {
164171
val mountPoint = it
165172
val targetPath = path.trim('/')
@@ -239,6 +246,11 @@ class RootHelpers(val activity: Activity) {
239246
}
240247

241248
fun deleteFiles(fileDirItems: ArrayList<FileDirItem>) {
249+
if (!RootTools.isRootAvailable()) {
250+
activity.toast(R.string.rooted_device_only)
251+
return
252+
}
253+
242254
tryMountAsRW(fileDirItems.first().path) {
243255
fileDirItems.forEach {
244256
val targetPath = it.path.trim('/')
@@ -256,6 +268,11 @@ class RootHelpers(val activity: Activity) {
256268
}
257269

258270
fun copyMoveFiles(fileDirItems: ArrayList<FileDirItem>, destination: String, isCopyOperation: Boolean, successes: Int = 0, callback: (Int) -> Unit) {
271+
if (!RootTools.isRootAvailable()) {
272+
activity.toast(R.string.rooted_device_only)
273+
return
274+
}
275+
259276
val fileDirItem = fileDirItems.first()
260277
val mainCommand = if (isCopyOperation) {
261278
if (fileDirItem.isDirectory) "cp -R" else "cp"

app/src/main/res/values-ar/strings.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
<string name="path_copied">تم نسخ المسار</string>
1212
<string name="select_audio_file">الرجاء تحديد ملف صوتي</string>
1313
<string name="search_folder">Search folder</string>
14+
<string name="rooted_device_only">This operation works only on rooted devices</string>
1415

1516
<!-- Compression -->
1617
<string name="compress">ضغط</string>
1718
<string name="decompress">فك الضغط</string>
1819
<string name="compress_as">ضغط كا</string>
1920
<string name="compressing">ضغط…</string>
20-
<string name="decompressing">فك الضغط...</string>
21+
<string name="decompressing">فك الضغط</string>
2122
<string name="compression_successful">نجح الضغط</string>
2223
<string name="decompression_successful">نجح التفكيك</string>
2324
<string name="compressing_failed">أخفق الضغط</string>
@@ -44,7 +45,7 @@
4445
<string name="app_long_description">ويمكن أيضا أن يستخدم لتصفح ملفات الجذر ومحتوى بطاقة الذاكرة. يمكنك بسهولة إعادة تسمية، نسخ، نقل وحذف ومشاركة أي شيء تريده. \n
4546
لا يحتوي على إعلانات أو أذونات لا حاجة لها. مفتوح المصدر بشكل كامل ، ويوفر الألوان للتخصيص. هذا التطبيق هو مجرد قطعة واحدة من سلسلة أكبر من التطبيقات. \n
4647
يمكنك العثور عليها هنا\n
47-
http://www.simplemobiletools.com</string>
48+
https://www.simplemobiletools.com</string>
4849

4950
<!--
5051
Haven't found some strings? There's more at

app/src/main/res/values-cs/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<string name="path_copied">Path copied</string>
1212
<string name="select_audio_file">Please select an audio file</string>
1313
<string name="search_folder">Search folder</string>
14+
<string name="rooted_device_only">This operation works only on rooted devices</string>
1415

1516
<!-- Compression -->
1617
<string name="compress">Compress</string>
@@ -48,7 +49,7 @@
4849

4950
Neobsahuje žádné reklamy a nepotřebná oprávnění. Aplikace je plně opensource a mimo jiné obsahuje také Tmavé téma.
5051

51-
Tato aplikace je pouze jedna část větší série aplikací. Zbytek aplikací můžete nalézt na http://www.simplemobiletools.com
52+
Tato aplikace je pouze jedna část větší série aplikací. Zbytek aplikací můžete nalézt na https://www.simplemobiletools.com
5253
</string>
5354

5455
<!--

app/src/main/res/values-da/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<string name="path_copied">Sti kopieret</string>
1212
<string name="select_audio_file">Vælg en lydfil</string>
1313
<string name="search_folder">Søg mappe</string>
14+
<string name="rooted_device_only">This operation works only on rooted devices</string>
1415

1516
<!-- Compression -->
1617
<string name="compress">Komprimer</string>
@@ -48,7 +49,7 @@
4849

4950
Uden reklamer og unødvendige tilladelser. Den er helt igennem open source, og du kan selv bestemme farverne.
5051

51-
Denne app er en enkelt del af en større serie apps. Du finder dem alle på siden http://www.simplemobiletools.com
52+
Denne app er en enkelt del af en større serie apps. Du finder dem alle på siden https://www.simplemobiletools.com
5253
</string>
5354

5455
<!--

app/src/main/res/values-de/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<string name="path_copied">Pfad kopiert</string>
1212
<string name="select_audio_file">Bitte wähle eine Audiodatei aus</string>
1313
<string name="search_folder">Ordner suchen</string>
14+
<string name="rooted_device_only">This operation works only on rooted devices</string>
1415

1516
<!-- Compression -->
1617
<string name="compress">Komprimieren</string>
@@ -48,7 +49,7 @@
4849

4950
Beinhaltet keine Werbung oder unnötige Berechtigungen. Sie ist komplett Open Source, alle verwendeten Farben sind anpassbar.
5051

51-
Diese App ist nur eine aus einer größeren Serie von schlichten Apps. Der Rest davon findet sich auf http://www.simplemobiletools.com
52+
Diese App ist nur eine aus einer größeren Serie von schlichten Apps. Der Rest davon findet sich auf https://www.simplemobiletools.com
5253
</string>
5354

5455
<!--

app/src/main/res/values-es/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<string name="path_copied">Path copied</string>
1212
<string name="select_audio_file">Please select an audio file</string>
1313
<string name="search_folder">Search folder</string>
14+
<string name="rooted_device_only">This operation works only on rooted devices</string>
1415

1516
<!-- Compression -->
1617
<string name="compress">Compress</string>
@@ -48,7 +49,7 @@
4849

4950
No contiene anuncios ni permisos innecesarios. Es completamente OpenSource y además provee un tema oscuro.
5051

51-
Esta aplicación es tan solo una pequeña parte de una serie de aplicaciones. Puede encontrar el resto en http://www.simplemobiletools.com
52+
Esta aplicación es tan solo una pequeña parte de una serie de aplicaciones. Puede encontrar el resto en https://www.simplemobiletools.com
5253
</string>
5354

5455
<!--

app/src/main/res/values-fr/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<string name="path_copied">Chemin du fichier copié</string>
1212
<string name="select_audio_file">Veuillez sélectionner un fichier audio</string>
1313
<string name="search_folder">Chercher dans le dossier</string>
14+
<string name="rooted_device_only">This operation works only on rooted devices</string>
1415

1516
<!-- Compression -->
1617
<string name="compress">Compresser</string>
@@ -48,7 +49,7 @@
4849

4950
Ne contient pas de pubs ou de permissions inutiles. C\'est un logiciel libre et open-source. Il y a un thème sombre.
5051

51-
Cette app est juste une pièce d\'une plus grande série d\'apps. Vous pouvez trouver le reste à http://www.simplemobiletools.com
52+
Cette app est juste une pièce d\'une plus grande série d\'apps. Vous pouvez trouver le reste à https://www.simplemobiletools.com
5253
</string>
5354

5455
<!--

app/src/main/res/values-hr/strings.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
<string name="path_copied">Putanja kopirana</string>
1212
<string name="select_audio_file">Odaberite audio datoteku</string>
1313
<string name="search_folder">Pretraži mapu</string>
14+
<string name="rooted_device_only">This operation works only on rooted devices</string>
1415

1516
<!-- Compression -->
1617
<string name="compress">Sažmi</string>
1718
<string name="decompress">Otpakiraj</string>
1819
<string name="compress_as">Sažmi kao</string>
19-
<string name="compressing">Sažimanje...</string>
20-
<string name="decompressing">Otpakiravanje...</string>
20+
<string name="compressing">Sažimanje</string>
21+
<string name="decompressing">Otpakiravanje</string>
2122
<string name="compression_successful">Sažimanje uspješno</string>
2223
<string name="decompression_successful">Otpakiravanje uspješno</string>
2324
<string name="compressing_failed">Sažimanje neuspješno</string>
@@ -48,7 +49,7 @@
4849

4950
Ne sadrži oglase ili nepotrebne dozvole. Aplikacije je otvorenog koda, pruža prilagodljive boje.
5051

51-
Ova je aplikacija samo dio većeg broja aplikacija. Možete pronaći ostatak na http://www.simplemobiletools.com
52+
Ova je aplikacija samo dio većeg broja aplikacija. Možete pronaći ostatak na https://www.simplemobiletools.com
5253
</string>
5354

5455
<!--

app/src/main/res/values-hu/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<string name="path_copied">Path copied</string>
1212
<string name="select_audio_file">Please select an audio file</string>
1313
<string name="search_folder">Search folder</string>
14+
<string name="rooted_device_only">This operation works only on rooted devices</string>
1415

1516
<!-- Compression -->
1617
<string name="compress">Compress</string>
@@ -48,7 +49,7 @@
4849

4950
Nincsenek reklámok, sem felesleges engedélykérések. Teljesen nyílt forráskódú. Sötét téma is elérhető.
5051

51-
Ez az alkalmazás egy nagyobb sorozat egyik darabja. A többit is megtalálod itt: http://www.simplemobiletools.com
52+
Ez az alkalmazás egy nagyobb sorozat egyik darabja. A többit is megtalálod itt: https://www.simplemobiletools.com
5253
</string>
5354

5455
<!--

0 commit comments

Comments
 (0)