mirror of
https://github.com/fankes/termux-app.git
synced 2025-09-06 10:45:23 +08:00
Added: Add TERMUX_APPS_DIR_PATH
and TERMUX_APP.APPS_DIR_PATH
and create them at application startup.
The termux files directory will also be checked and created if required at startup and code related to it will only be run if it is accessible. This can later also be used for init execution commands. The `TERMUX_APP.APPS_DIR_PATH` will act as app specific directory for `termux-app` app related files. Other plugin apps will have their own directories under `TERMUX_APPS_DIR_PATH` if required.
This commit is contained in:
@@ -11,7 +11,7 @@ import java.util.Formatter;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* Version: v0.39.0
|
||||
* Version: v0.40.0
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
* Changelog
|
||||
@@ -216,10 +216,10 @@ import java.util.List;
|
||||
* - Added `TERMUX_PROPERTIES_FILE_PATHS_LIST` and `TERMUX_FLOAT_PROPERTIES_FILE_PATHS_LIST`.
|
||||
*
|
||||
* - 0.34.0 (2021-10-26)
|
||||
* - Move `RESULT_SENDER` to `com.termux.shared.shell.command.ShellCommandConstants`.
|
||||
* - Move `RESULT_SENDER` to `com.termux.shared.shell.command.ShellCommandConstants`.
|
||||
*
|
||||
* - 0.35.0 (2022-01-28)
|
||||
* - Add `TERMUX_APP.TERMUX_ACTIVITY.EXTRA_RECREATE_ACTIVITY`.
|
||||
* - Add `TERMUX_APP.TERMUX_ACTIVITY.EXTRA_RECREATE_ACTIVITY`.
|
||||
*
|
||||
* - 0.36.0 (2022-03-10)
|
||||
* - Added `TERMUX_APP.TERMUX_SERVICE.EXTRA_RUNNER` and `TERMUX_APP.RUN_COMMAND_SERVICE.EXTRA_RUNNER`
|
||||
@@ -233,6 +233,9 @@ import java.util.List;
|
||||
* - 0.39.0 (2022-03-18)
|
||||
* - Added `TERMUX_APP.TERMUX_SERVICE.EXTRA_SESSION_NAME`, `TERMUX_APP.RUN_COMMAND_SERVICE.EXTRA_SESSION_NAME`,
|
||||
* `TERMUX_APP.TERMUX_SERVICE.EXTRA_SESSION_CREATE_MODE` and `TERMUX_APP.RUN_COMMAND_SERVICE.EXTRA_SESSION_CREATE_MODE`.
|
||||
*
|
||||
* - 0.40.0 (2022-04-17)
|
||||
* - Added `TERMUX_APPS_DIR_PATH` and `TERMUX_APP.APPS_DIR_PATH`.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -657,6 +660,11 @@ public final class TermuxConstants {
|
||||
|
||||
|
||||
|
||||
/** Termux and plugin apps directory path */
|
||||
public static final String TERMUX_APPS_DIR_PATH = TERMUX_FILES_DIR_PATH + "/apps"; // Default: "/data/data/com.termux/files/apps"
|
||||
/** Termux and plugin apps directory */
|
||||
public static final File TERMUX_APPS_DIR = new File(TERMUX_APPS_DIR_PATH);
|
||||
|
||||
|
||||
|
||||
/*
|
||||
@@ -872,6 +880,10 @@ public final class TermuxConstants {
|
||||
*/
|
||||
public static final class TERMUX_APP {
|
||||
|
||||
/** Termux apps directory path */
|
||||
public static final String APPS_DIR_PATH = TERMUX_APPS_DIR_PATH + "/termux-app"; // Default: "/data/data/com.termux/files/apps/termux-app"
|
||||
|
||||
|
||||
/** Termux app core activity name. */
|
||||
public static final String TERMUX_ACTIVITY_NAME = TERMUX_PACKAGE_NAME + ".app.TermuxActivity"; // Default: "com.termux.app.TermuxActivity"
|
||||
|
||||
|
@@ -307,6 +307,24 @@ public class TermuxFileUtils {
|
||||
false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate if {@link TermuxConstants.TERMUX_APP#APPS_DIR_PATH} exists and has
|
||||
* {@link FileUtils#APP_WORKING_DIRECTORY_PERMISSIONS} permissions.
|
||||
*
|
||||
* @param createDirectoryIfMissing The {@code boolean} that decides if directory file
|
||||
* should be created if its missing.
|
||||
* @param setMissingPermissions The {@code boolean} that decides if permissions are to be
|
||||
* automatically set.
|
||||
* @return Returns the {@code error} if path is not a directory file, failed to create it,
|
||||
* or validating permissions failed, otherwise {@code null}.
|
||||
*/
|
||||
public static Error isAppsTermuxAppDirectoryAccessible(boolean createDirectoryIfMissing, boolean setMissingPermissions) {
|
||||
return FileUtils.validateDirectoryFileExistenceAndPermissions("apps/termux-app directory", TermuxConstants.TERMUX_APP.APPS_DIR_PATH,
|
||||
null, createDirectoryIfMissing,
|
||||
FileUtils.APP_WORKING_DIRECTORY_PERMISSIONS, setMissingPermissions, true,
|
||||
false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a markdown {@link String} for stat output for various Termux app files paths.
|
||||
*
|
||||
|
Reference in New Issue
Block a user