Skip to content

Commit c066095

Browse files
committed
use singleton pattern with lazy loading for toolbox
1 parent 2120685 commit c066095

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

cSploit/src/org/csploit/android/core/System.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public class System
121121
private static ArrayList<Plugin> mPlugins = null;
122122
private static Plugin mCurrentPlugin = null;
123123
// toolbox singleton
124-
private static ToolBox mTools = new ToolBox();
124+
private static ToolBox mTools = null;
125125

126126
private static HTTPSRedirector mRedirector = null;
127127
private static Proxy mProxy = null;
@@ -212,9 +212,7 @@ public static void init(Context context) throws Exception{
212212
}
213213

214214
public static void reloadTools() {
215-
if(mTools == null)
216-
mTools = new ToolBox();
217-
mTools.reload();
215+
getTools().reload();
218216
}
219217

220218
public static class SuException extends Exception {
@@ -833,7 +831,11 @@ public static void loadSession(String filename) throws Exception{
833831
}
834832

835833
public static ToolBox getTools() {
836-
return mTools;
834+
synchronized (System.class) {
835+
if(mTools == null)
836+
mTools = new ToolBox();
837+
return mTools;
838+
}
837839
}
838840

839841
public static RPCClient getMsfRpc() {
@@ -1190,7 +1192,7 @@ public static void setForwarding(boolean enabled){
11901192
cmd = "echo " + status + " > " + IPV4_FORWARD_FILEPATH;
11911193

11921194
try{
1193-
mTools.shell.run(cmd);
1195+
getTools().shell.run(cmd);
11941196
}
11951197
catch(Exception e){
11961198
Logger.error(e.getMessage());

0 commit comments

Comments
 (0)