mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 02:35:19 +08:00
clean /tmp directory on cold start
This commit is contained in:
committed by
Fredrik Fornwall
parent
3693e3c1b6
commit
beb8a004e6
@@ -69,6 +69,7 @@ import com.termux.view.TerminalView;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -612,6 +613,18 @@ public final class TermuxActivity extends Activity implements ServiceConnection
|
||||
new AlertDialog.Builder(this).setTitle(R.string.max_terminals_reached_title).setMessage(R.string.max_terminals_reached_message)
|
||||
.setPositiveButton(android.R.string.ok, null).show();
|
||||
} else {
|
||||
if (mTermService.getSessions().size() == 0 && !mTermService.isWakelockEnabled()) {
|
||||
File termuxTmpDir = new File(TermuxService.PREFIX_PATH + "/tmp");
|
||||
if (termuxTmpDir.exists()) {
|
||||
try {
|
||||
TermuxInstaller.deleteFolder(termuxTmpDir);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
termuxTmpDir.mkdirs();
|
||||
}
|
||||
}
|
||||
String executablePath = (failSafe ? "/system/bin/sh" : null);
|
||||
TerminalSession newSession = mTermService.createTermSession(executablePath, null, null, failSafe);
|
||||
if (sessionName != null) {
|
||||
|
@@ -250,6 +250,14 @@ public final class TermuxService extends Service implements SessionChangedCallba
|
||||
return mTerminalSessions;
|
||||
}
|
||||
|
||||
public boolean isWakelockEnabled() {
|
||||
if (mWakeLock == null) {
|
||||
return false;
|
||||
} else {
|
||||
return mWakeLock.isHeld();
|
||||
}
|
||||
}
|
||||
|
||||
TerminalSession createTermSession(String executablePath, String[] arguments, String cwd, boolean failSafe) {
|
||||
new File(HOME_PATH).mkdirs();
|
||||
|
||||
|
Reference in New Issue
Block a user