File tree 1 file changed +10
-3
lines changed
library/src/main/java/ashell 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 22
22
23
23
public class ShellFactory {
24
24
25
+ private boolean isRoot = false ;
25
26
private AShell shell ;
26
27
27
- private ShellFactory (AShell shell ) {
28
+ public ShellFactory (AShell shell , boolean isRoot ) {
28
29
this .shell = shell ;
30
+ this .isRoot = isRoot ;
29
31
}
30
32
31
33
public AShell getShell () {
32
34
return shell ;
33
35
}
34
36
37
+ public boolean isRoot () {
38
+ return isRoot ;
39
+ }
40
+
35
41
@ SuppressWarnings ("unchecked" ) // Single-interface proxy creation guarded by parameter safety.
36
42
public <T > T create (final Class <T > shellModel ) {
37
43
//Utils.validateServiceInterface(service);
@@ -97,12 +103,13 @@ public ShellFactory build() throws IOException {
97
103
}
98
104
99
105
public ShellFactory build (boolean runAsSuperuser ) throws IOException {
100
-
106
+ boolean isRoot = false ;
101
107
if (processBuilder == null ) {
102
108
processBuilder = ProcessUtils .getDefaultProcessBuilder ("sh" );
103
109
if (runAsSuperuser ) {
104
110
try {
105
111
processBuilder = ProcessUtils .getDefaultProcessBuilder ("su" );
112
+ isRoot = true ;
106
113
} catch (Exception e ) {
107
114
e .printStackTrace ();
108
115
}
@@ -134,7 +141,7 @@ public ShellFactory build(boolean runAsSuperuser) throws IOException {
134
141
135
142
shell .start ();
136
143
137
- return new ShellFactory (shell );
144
+ return new ShellFactory (shell , isRoot );
138
145
}
139
146
}
140
147
}
You can’t perform that action at this time.
0 commit comments