File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed
app/src/main/java/com/appcontrolx Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -15,11 +15,12 @@ class App : Application() {
1515 private const val TAG = " AppControlX"
1616
1717 init {
18+ // Configure libsu
1819 Shell .enableVerboseLogging = BuildConfig .DEBUG
1920 Shell .setDefaultBuilder(
2021 Shell .Builder .create()
21- .setFlags(Shell .FLAG_MOUNT_MASTER )
22- .setTimeout(10 )
22+ .setFlags(Shell .FLAG_REDIRECT_STDERR )
23+ .setTimeout(30 ) // Increase timeout for slow devices
2324 )
2425 }
2526 }
Original file line number Diff line number Diff line change @@ -58,11 +58,18 @@ class RootExecutor : CommandExecutor {
5858 }
5959
6060 return try {
61+ // Ensure shell is ready
62+ val shell = Shell .getShell()
63+ if (! shell.isRoot) {
64+ return Result .failure(Exception (" Root access not available" ))
65+ }
66+
6167 val result = Shell .cmd(command).exec()
6268 if (result.isSuccess) {
6369 Result .success(result.out .joinToString(" \n " ))
6470 } else {
65- Result .failure(Exception (result.err.joinToString(" \n " )))
71+ val error = result.err.joinToString(" \n " ).ifEmpty { " Command failed" }
72+ Result .failure(Exception (error))
6673 }
6774 } catch (e: Exception ) {
6875 Result .failure(e)
Original file line number Diff line number Diff line change @@ -65,11 +65,17 @@ class PermissionBridge(private val context: Context? = null) {
6565 fun checkRootNow (): Boolean {
6666 return try {
6767 // Get shell instance - this will trigger root request if needed
68- Shell .getShell()
68+ val shell = Shell .getShell()
6969
70- // Check if root was granted
70+ // Check if shell is root
71+ if (shell.isRoot) {
72+ return true
73+ }
74+
75+ // Fallback check
7176 Shell .isAppGrantedRoot() == true
7277 } catch (e: Exception ) {
78+ android.util.Log .e(" PermissionBridge" , " Root check failed" , e)
7379 false
7480 }
7581 }
You can’t perform that action at this time.
0 commit comments