-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Users affected by recent Files app patches can now use PF Tool using Shizuku * added an option to switch between SAF (Scoped storage) and Shizuku file management methods * app now guides you through all the SAF workarounds and eventually enables Shizuku if none of the workarounds work (Android 11+) * it is now harder to select a random path for maps folder * selecting exported maps recommended directory is now more optional * small improvements
- Loading branch information
1 parent
443b4c5
commit 6341d1e
Showing
47 changed files
with
1,424 additions
and
390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.aliernfrog.pftool; | ||
|
||
import com.aliernfrog.pftool.data.ServiceFile; | ||
|
||
interface IFileService { | ||
void destroy() = 16777114; // Destroy method defined by Shizuku server | ||
|
||
void exit() = 1; | ||
|
||
void copy(String sourcePath, String targetPath) = 2; | ||
|
||
void delete(String path) = 3; | ||
|
||
boolean exists(String path) = 4; | ||
|
||
byte[] getByteArray(String path) = 5; | ||
|
||
ServiceFile getFile(String path) = 6; | ||
|
||
ServiceFile[] listFiles(String path) = 7; | ||
|
||
void renameFile(String oldPath, String newPath) = 8; | ||
|
||
void unzipMap(String path, String targetPath) = 9; | ||
|
||
void zipMap(String path, String targetPath) = 10; | ||
} |
3 changes: 3 additions & 0 deletions
3
app/src/main/aidl/com/aliernfrog/pftool/data/ServiceFile.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.aliernfrog.pftool.data; | ||
|
||
parcelable ServiceFile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
app/src/main/java/com/aliernfrog/pftool/data/PermissionData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/src/main/java/com/aliernfrog/pftool/data/ServiceFile.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.aliernfrog.pftool.data | ||
|
||
import android.os.Parcelable | ||
import com.aliernfrog.pftool.ui.viewmodel.ShizukuViewModel | ||
import com.aliernfrog.pftool.util.getKoinInstance | ||
import com.aliernfrog.pftool.util.staticutil.FileUtil | ||
import kotlinx.parcelize.Parcelize | ||
|
||
@Parcelize | ||
data class ServiceFile( | ||
val name: String, | ||
val path: String, | ||
val parentPath: String?, | ||
val size: Long, | ||
val lastModified: Long, | ||
val isFile: Boolean | ||
): Parcelable | ||
|
||
val ServiceFile.nameWithoutExtension | ||
get() = FileUtil.removeExtension(this.name) | ||
|
||
fun ServiceFile.delete() { | ||
val shizukuViewModel = getKoinInstance<ShizukuViewModel>() | ||
return shizukuViewModel.fileService!!.delete(path) | ||
} | ||
|
||
fun ServiceFile.exists(): Boolean { | ||
val shizukuViewModel = getKoinInstance<ShizukuViewModel>() | ||
return shizukuViewModel.fileService!!.exists(path) | ||
} | ||
|
||
fun ServiceFile.getByteArray(): ByteArray { | ||
val shizukuViewModel = getKoinInstance<ShizukuViewModel>() | ||
return shizukuViewModel.fileService!!.getByteArray(path) | ||
} | ||
|
||
fun ServiceFile.listFiles(): Array<ServiceFile>? { | ||
val shizukuViewModel = getKoinInstance<ShizukuViewModel>() | ||
return shizukuViewModel.fileService!!.listFiles(path) | ||
} | ||
|
||
fun ServiceFile.renameTo(newPath: String) { | ||
val shizukuViewModel = getKoinInstance<ShizukuViewModel>() | ||
shizukuViewModel.fileService!!.renameFile(path, newPath) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
app/src/main/java/com/aliernfrog/pftool/enum/FileManagementMethod.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.aliernfrog.pftool.enum | ||
|
||
import androidx.annotation.StringRes | ||
import com.aliernfrog.pftool.ConfigKey | ||
import com.aliernfrog.pftool.R | ||
import com.aliernfrog.pftool.util.manager.PreferenceManager | ||
import com.aliernfrog.pftool.util.staticutil.FileUtil | ||
|
||
enum class FileManagementMethod( | ||
@StringRes val label: Int, | ||
val enable: (PreferenceManager) -> Unit | ||
) { | ||
SAF( | ||
label = R.string.settings_general_fileManagementService_saf, | ||
enable = { | ||
it.fileManagementMethod = SAF.ordinal | ||
it.pfMapsDir = FileUtil.getTreeUriForPath(it.pfMapsDir).toString() | ||
it.exportedMapsDir = FileUtil.getTreeUriForPath(it.exportedMapsDir).toString() | ||
} | ||
), | ||
|
||
SHIZUKU( | ||
label = R.string.settings_general_fileManagementService_shizuku, | ||
enable = { | ||
it.fileManagementMethod = SHIZUKU.ordinal | ||
it.pfMapsDir = FileUtil.getFilePath(it.pfMapsDir) ?: ConfigKey.RECOMMENDED_MAPS_DIR | ||
it.exportedMapsDir = FileUtil.getFilePath(it.exportedMapsDir) ?: ConfigKey.RECOMMENDED_EXPORTED_MAPS_DIR | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
app/src/main/java/com/aliernfrog/pftool/enum/SAFWorkaroundLevel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.aliernfrog.pftool.enum | ||
|
||
import android.content.Intent | ||
import android.net.Uri | ||
import android.provider.Settings | ||
import android.widget.Toast | ||
import androidx.annotation.StringRes | ||
import androidx.compose.material3.Button | ||
import androidx.compose.material3.Text | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.res.stringResource | ||
import com.aliernfrog.pftool.R | ||
|
||
enum class SAFWorkaroundLevel( | ||
@StringRes val title: Int? = null, | ||
@StringRes val description: Int? = null, | ||
val button: (@Composable () -> Unit)? = null | ||
) { | ||
/** | ||
* Telling the user to make sure the folder exists. | ||
*/ | ||
MAKE_SURE_FOLDER_EXISTS, | ||
|
||
/** | ||
* Telling the user to uninstall updates of Files app. | ||
*/ | ||
UNINSTALL_FILES_APP_UPDATES( | ||
title = R.string.permissions_uninstallFilesAppUpdates, | ||
description = R.string.permissions_uninstallFilesAppUpdates_description, | ||
button = { | ||
val context = LocalContext.current | ||
Button( | ||
onClick = { | ||
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { | ||
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
data = Uri.parse("package:com.google.android.documentsui") | ||
context.startActivity(this) | ||
} | ||
Toast.makeText(context, context.getString(R.string.permissions_uninstallFilesAppUpdates_guide), Toast.LENGTH_SHORT).show() | ||
} | ||
) { | ||
Text(stringResource(R.string.permissions_uninstallFilesAppUpdates_uninstall)) | ||
} | ||
} | ||
), | ||
|
||
/** | ||
* No workarounds anymore. | ||
*/ | ||
SETUP_SHIZUKU( | ||
title = R.string.permissions_setupShizuku, | ||
description = R.string.permissions_setupShizuku_description | ||
) | ||
} |
9 changes: 9 additions & 0 deletions
9
app/src/main/java/com/aliernfrog/pftool/enum/ShizukuStatus.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.aliernfrog.pftool.enum | ||
|
||
enum class ShizukuStatus { | ||
NOT_INSTALLED, | ||
WAITING_FOR_BINDER, | ||
UNAUTHORIZED, | ||
AVAILABLE, | ||
UNKNOWN | ||
} |
Oops, something went wrong.