Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ abstract class RootInstaller internal constructor(
CREATE_INSTALLATION_PATH().waitFor()
MOUNT_APK(packageName)().waitFor()

// Install and run.
// Install mount script.
TMP_FILE_PATH.write(MOUNT_SCRIPT(packageName))
INSTALL_MOUNT_SCRIPT(packageName)().waitFor()
MOUNT_SCRIPT_PATH(packageName)().waitFor()

// Mount and restart.
mount(packageName)
RESTART(packageName)()

DELETE(TMP_FILE_PATH)()
Expand All @@ -73,7 +75,7 @@ abstract class RootInstaller internal constructor(
override suspend fun uninstall(packageName: String): RootInstallerResult {
logger.info("Uninstalling $packageName by unmounting")

UMOUNT(packageName)()
unmount(packageName)

DELETE(MOUNTED_APK_PATH)(packageName)()
DELETE(MOUNT_SCRIPT_PATH)(packageName)()
Expand All @@ -93,10 +95,31 @@ abstract class RootInstaller internal constructor(
return RootInstallation(
INSTALLED_APK_PATH(packageName)().output.ifEmpty { null },
patchedApkPath,
MOUNT_GREP(patchedApkPath)().exitCode == 0,
isMounted(packageName),
)
}

suspend fun mount(packageName: String): RootInstallerResult {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Granular mount and unmount control should never be needed. Callsite should ever need to either install, or uninstall, which the current APIs already provide.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have seen a few users use the control to their advantage, most recent one I saw was where their mounted app was crashing, instead of repatching they unmounted, updated the unpatched app then remounted

This could be achieved by proxy by switching to magisk modules, users can simply disable or enable the module if they want

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of repatching they unmounted, updated the unpatched app then remounted

This is possible without unmounting. They can simply update the unpatched app. However, a desync in the installation is not something that is intended to be something that the user should take care of. It is an edge case that should be handled by the installer. E.g. it should detect that the app is updated/correct version installed and mount or similiar, so once again the correct solution is not to shift the responsibility to the user with granular control.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be achieved by proxy by switching to magisk modules, users can simply disable or enable the module if they want

We intend to keep this method of installation as a legacy version, the magisk installation will only work on magisk so other root solutions would have to rely on the legacy/"agnostic" root installation

logger.info("Mounting $packageName")

MOUNT_SCRIPT_PATH(packageName)().waitFor()

return RootInstallerResult.SUCCESS
}

suspend fun unmount(packageName: String): RootInstallerResult {
logger.info("Unmounting $packageName")

UMOUNT(packageName)()

return RootInstallerResult.SUCCESS
}

suspend fun isMounted(packageName: String): Boolean {
val patchedApkPath = MOUNTED_APK_PATH(packageName)
return MOUNT_GREP(patchedApkPath)().exitCode == 0
}

/**
* Runs a command on the device.
*/
Expand Down
Loading