这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions app/src/main/java/com/termux/app/TermuxActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
TermuxInstaller.setupIfNeeded(TermuxActivity.this, () -> {
if (mTermService == null) return; // Activity might have been destroyed.
try {
clearTemporaryDirectory();
addNewSession(false, null);
} catch (WindowManager.BadTokenException e) {
// Activity finished - ignore.
Expand All @@ -478,6 +479,7 @@ public View getView(int position, View convertView, @NonNull ViewGroup parent) {
Intent i = getIntent();
if (i != null && Intent.ACTION_RUN.equals(i.getAction())) {
// Android 7.1 app shortcut from res/xml/shortcuts.xml.
clearTemporaryDirectory();
addNewSession(false, null);
} else {
switchToSession(getStoredCurrentSessionOrLast());
Expand Down Expand Up @@ -572,18 +574,6 @@ void addNewSession(boolean failSafe, String sessionName) {
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) {
Expand Down Expand Up @@ -828,4 +818,18 @@ public void removeFinishedSession(TerminalSession finishedSession) {
}
}

private void clearTemporaryDirectory() {
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();
}
}
}
}