Added: Init TermuxShellEnvironment at app startup

This will currently cache `TermuxAppShellEnvironment` so that its not regenerated for each shell started since it contains some slightly expensive operations.
This commit is contained in:
agnostic-apollo
2022-06-12 00:37:09 +05:00
parent 150b1ff99c
commit f76c20d036
2 changed files with 8 additions and 0 deletions

View File

@@ -60,6 +60,9 @@ public class TermuxApplication extends Application {
} }
TermuxAmSocketServer.setupTermuxAmSocketServer(context); TermuxAmSocketServer.setupTermuxAmSocketServer(context);
// Init TermuxShellEnvironment constants and caches after everything has been setup including termux-am-socket server
TermuxShellEnvironment.init(this);
} }
} }

View File

@@ -28,6 +28,11 @@ public class TermuxShellEnvironment extends AndroidShellEnvironment {
shellCommandShellEnvironment = new TermuxShellCommandShellEnvironment(); shellCommandShellEnvironment = new TermuxShellCommandShellEnvironment();
} }
/** Init {@link TermuxShellEnvironment} constants and caches. */
public synchronized static void init(@NonNull Context currentPackageContext) {
TermuxAppShellEnvironment.setTermuxAppEnvironment(currentPackageContext);
}
/** Get shell environment for Termux. */ /** Get shell environment for Termux. */
@NonNull @NonNull
@Override @Override