Compare commits
13 Commits
winboll
...
v0.119.0-b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c5992d379 | ||
|
|
2cfbfcd79f | ||
|
|
afe22941ce | ||
|
|
e85d078f04 | ||
|
|
8cdeb55271 | ||
|
|
3ae0d601db | ||
|
|
3f6ebd33cd | ||
|
|
f12697a0f8 | ||
|
|
b466e9c88d | ||
|
|
bf33a54fe9 | ||
|
|
57e4ef456b | ||
|
|
d90be9cd50 | ||
|
|
062c9771a9 |
@@ -71,14 +71,13 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Attaching APKs to github release"
|
echo "Attaching APKs to github release"
|
||||||
if ! hub release edit \
|
if ! gh release upload "$RELEASE_VERSION_NAME" \
|
||||||
-m "" \
|
"$APK_DIR_PATH/${APK_BASENAME_PREFIX}_universal.apk" \
|
||||||
-a "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_universal.apk" \
|
"$APK_DIR_PATH/${APK_BASENAME_PREFIX}_arm64-v8a.apk" \
|
||||||
-a "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_arm64-v8a.apk" \
|
"$APK_DIR_PATH/${APK_BASENAME_PREFIX}_armeabi-v7a.apk" \
|
||||||
-a "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_armeabi-v7a.apk" \
|
"$APK_DIR_PATH/${APK_BASENAME_PREFIX}_x86_64.apk" \
|
||||||
-a "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_x86_64.apk" \
|
"$APK_DIR_PATH/${APK_BASENAME_PREFIX}_x86.apk" \
|
||||||
-a "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_x86.apk" \
|
"$APK_DIR_PATH/${APK_BASENAME_PREFIX}_sha256sums" \
|
||||||
-a "$APK_DIR_PATH/${APK_BASENAME_PREFIX}_sha256sums" \
|
; then
|
||||||
"$RELEASE_VERSION_NAME"; then
|
|
||||||
exit_on_error "Attach APKs to release failed for '$APK_VERSION_TAG' release."
|
exit_on_error "Attach APKs to release failed for '$APK_VERSION_TAG' release."
|
||||||
fi
|
fi
|
||||||
|
|||||||
1
.github/workflows/debug_build.yml
vendored
1
.github/workflows/debug_build.yml
vendored
@@ -4,6 +4,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- 'github-releases/**'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
|||||||
42
README.md
42
README.md
@@ -51,7 +51,7 @@ The core [Termux](https://github.com/termux/termux-app) app comes with the follo
|
|||||||
|
|
||||||
Latest version is `v0.118.0`.
|
Latest version is `v0.118.0`.
|
||||||
|
|
||||||
**NOTICE: It is highly recommended that you update to `v0.118.0` or higher ASAP for various bug fixes, including a critical world-readable vulnerability reported [here](https://termux.github.io/general/2022/02/15/termux-apps-vulnerability-disclosures.html). Also reminding [again](https://www.reddit.com/r/termux/comments/pkujfa/important_deprecation_notice_for_google_play) to users who have installed termux apps from google playstore that playstore builds are [deprecated](#google-play-store-deprecated) and no longer supported. It is recommended that you shift to F-Droid or GitHub releases.**
|
**NOTICE: It is highly recommended that you update to `v0.118.0` or higher ASAP for various bug fixes, including a critical world-readable vulnerability reported [here](https://termux.github.io/general/2022/02/15/termux-apps-vulnerability-disclosures.html). See [below](#google-play-store-experimental-branch) for information regarding Termux on Google Play.**
|
||||||
|
|
||||||
Termux can be obtained through various sources listed below for **only** Android `>= 7` with full support for apps and packages.
|
Termux can be obtained through various sources listed below for **only** Android `>= 7` with full support for apps and packages.
|
||||||
|
|
||||||
@@ -114,45 +114,13 @@ Version: 3
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### Google Play Store **(Deprecated)**
|
### Google Play Store **(Experimental branch)**
|
||||||
|
|
||||||
**Termux and its plugins are no longer updated on [Google Play Store](https://play.google.com/store/apps/details?id=com.termux) due to [android 10 issues](https://github.com/termux/termux-packages/wiki/Termux-and-Android-10) and have been deprecated.** The last version released for Android `>= 7` was `v0.101`. **It is highly recommended to not install Termux apps from Play Store any more.**
|
There is currently a build of Termux available on Google Play for Android 11+ devices, with extensive adjustments in order to pass policy requirements there. This is under development and has missing functionality and bugs (see [here](https://github.com/termux-play-store/) for status updates) compared to the stable F-Droid build, which is why most users who can should still use F-Droid or GitHub build as mentioned above.
|
||||||
|
|
||||||
**Termux developers do not have access to Play Store Console account where Termux is published and therefore can't remove the app.** You are encouraged to move to `F-Droid` or `GitHub` builds as soon as possible and suggest doing so for other users via social media.
|
|
||||||
|
|
||||||
You **will not need to buy plugins again** if you bought them on Play Store. All plugins are free on `F-Droid` and `GitHub`.
|
|
||||||
|
|
||||||
You can backup all your data under `$HOME/` and `$PREFIX/` before changing installation source, and then restore it afterwards, by following instructions at [Backing up Termux](https://wiki.termux.com/wiki/Backing_up_Termux) before the uninstallation.
|
|
||||||
|
|
||||||
There is currently no work being done to solve android `10` issues and *working* updates will not be resumed on Google Play Store any time soon. We will continue targeting sdk `28` for now. So there is not much point in staying on Play Store builds and waiting for updates to be resumed. If for some reason you don't want to move to `F-Droid` or `GitHub` sources for now, then at least check [Package Management](https://github.com/termux/termux-packages/wiki/Package-Management) to **change your mirror**, otherwise, you will get **`repository is under maintenance or down`** errors when running `apt` or `pkg` commands. After that, it is also **highly advisable** to run `pkg upgrade` command to update all packages to the latest available versions, or at least update `termux-tools` package with `pkg install termux-tools` command.
|
|
||||||
|
|
||||||
Note that by upgrading old packages to latest versions, like that of `python` may break your setups/scripts since they may not be compatible anymore. Moreover, you will not be able to downgrade the package versions since termux repos only keep the latest version and you will have to manually rebuild the old versions of the packages if required as per [Building packages](https://github.com/termux/termux-packages/wiki/Building-packages).
|
|
||||||
|
|
||||||
If you plan on staying on Play Store sources in future as well, then you may want to **disable automatic updates in Play Store** for Termux apps, since if and when updates to disable Termux apps are released, then **you will not be able to downgrade** and **will be forced** to move since apps won't work anymore. Only a way to backup `termux-app` data may be provided. The `termux-tools` [version `>= 0.135`](https://github.com/termux/termux-packages/pull/7493) will also show a banner at the top of the terminal saying `You are likely using a very old version of Termux, probably installed from the Google Play Store.`, you can remove it by running `rm -f /data/data/com.termux/files/usr/etc/motd-playstore` and restarting the app.
|
|
||||||
|
|
||||||
#### Why Disable?
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary></summary>
|
|
||||||
|
|
||||||
- Play store apps have multiple critical vulnerabilities as reported at https://termux.github.io/general/2022/02/15/termux-apps-vulnerability-disclosures.html and since they cannot be updated with fixes, any users using older versions would be vulnerable.
|
|
||||||
|
|
||||||
- They should be disabled because deprecated things get removed and are not supported after some time, its the standard practice. It has been many months now since deprecation was announced and updates have not been released on Play Store since after `29 September 2020`.
|
|
||||||
|
|
||||||
- The new versions have lots of **new features and fixes** which you can mostly check out in the Changelog of [`GitHub Releases`](https://github.com/termux/termux-app/releases) that you may be missing out. Extra detail is usually provided in [commit messages](https://github.com/termux/termux-app/commits/master).
|
|
||||||
|
|
||||||
- Users on old versions are quite often reporting issues in multiple repositories and support forums that were **fixed months ago**, which we then have to deal with. The maintainers of @termux work in their free time, majorly for free, to work on development and provide support and having to re-re-deal with old issues takes away the already limited time from current work and is not possible to continue doing. Play Store page of `termux-app` has been filled with bad reviews of *"broken app"*, even though its clearly mentioned on the page that app is not being updated, yet users don't read and still install and report issues.
|
|
||||||
|
|
||||||
- Asking people to pay for plugins when the `termux-app` at installation time is broken due to repository issues and has bugs is unethical.
|
|
||||||
|
|
||||||
- Old versions don't have proper logging/debugging and crash report support. Reporting bugs without logs or detailed info is not helpful in solving them.
|
|
||||||
|
|
||||||
- It's also easier for us to solve package related issues and provide custom functionality with app updates, which can't be done if users continue using old versions. For example, the [bintray shutdown](https://github.com/termux/termux-packages/wiki/Package-Management) causing package install/update failures for new Play Store users is/was not an issue for F-Droid users since it is being shipped with updated bootstrap and repo info, hence no reported issues from new F-Droid users.
|
|
||||||
</details>
|
|
||||||
|
|
||||||
##
|
|
||||||
|
|
||||||
|
Currently, Google Play will try to update installations away from F-Droid ones. Updating will still fail as [sharedUserId](https://developer.android.com/guide/topics/manifest/manifest-element#uid) has been removed. A planned 0.118.1 F-Droid release will fix this by setting a higher version code than used for the PlayStore app. Meanwhile, to prevent Google Play from attempting to download and then fail to install the Google Play releases over existing installations, you can open the Termux apps pages on Google Play and then click on the 3 dots options button in the top right and then disable the Enable auto update toggle. However, the Termux apps updates will still show in the PlayStore app updates list.
|
||||||
|
|
||||||
|
If you want to help out with testing the Google Play build (or cannot install Termux from other sources), be aware that it's built from a separate repository (https://github.com/termux-play-store/) - be sure to report issues [there](https://github.com/termux-play-store/termux-issues/issues/new/choose), as any issues encountered might very well be specific to that repository.
|
||||||
|
|
||||||
## Uninstallation
|
## Uninstallation
|
||||||
|
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ android {
|
|||||||
applicationId "com.termux"
|
applicationId "com.termux"
|
||||||
minSdkVersion project.properties.minSdkVersion.toInteger()
|
minSdkVersion project.properties.minSdkVersion.toInteger()
|
||||||
targetSdkVersion project.properties.targetSdkVersion.toInteger()
|
targetSdkVersion project.properties.targetSdkVersion.toInteger()
|
||||||
versionCode 118
|
versionCode 1020
|
||||||
versionName "0.118.0"
|
versionName "0.119.0-beta.1"
|
||||||
|
|
||||||
if (appVersionName) versionName = appVersionName
|
if (appVersionName) versionName = appVersionName
|
||||||
validateVersionName(versionName)
|
validateVersionName(versionName)
|
||||||
@@ -214,11 +214,11 @@ task downloadBootstraps() {
|
|||||||
doLast {
|
doLast {
|
||||||
def packageVariant = project.ext.packageVariant
|
def packageVariant = project.ext.packageVariant
|
||||||
if (packageVariant == "apt-android-7") {
|
if (packageVariant == "apt-android-7") {
|
||||||
def version = "2022.04.28-r5" + "+" + packageVariant
|
def version = "2024.06.17-r1" + "+" + packageVariant
|
||||||
downloadBootstrap("aarch64", "4a51a7eb209fe82efc24d52e3cccc13165f27377290687cb82038cbd8e948430", version)
|
downloadBootstrap("aarch64", "91a90661597fe14bb3c3563f5f65b243c0baaec42f2bc3d2243ff459e3942fb6", version)
|
||||||
downloadBootstrap("arm", "6459a786acbae50d4c8a36fa1c3de6a4dd2d482572f6d54f73274709bd627325", version)
|
downloadBootstrap("arm", "d54b5eb2a305d72f267f9704deaca721b2bebbd3d4cca134aec31da719707997", version)
|
||||||
downloadBootstrap("i686", "919d212b2f19e08600938db4079e794e947365022dbfd50ac342c50fcedcd7be", version)
|
downloadBootstrap("i686", "06a51ac1c679d68d52045509f1a705622c8f41748ef753660e31e3b6a846eba2", version)
|
||||||
downloadBootstrap("x86_64", "61b02fdc03ea4f5d9da8d8cf018013fdc6659e6da6cbf44e9b24d1c623580b89", version)
|
downloadBootstrap("x86_64", "4c8e43474c8d9543e01d4cbf3c4d7f59bbe4d696c38f6dece2b6ab3ba8881f2e", version)
|
||||||
} else if (packageVariant == "apt-android-5") {
|
} else if (packageVariant == "apt-android-5") {
|
||||||
def version = "2022.04.28-r6" + "+" + packageVariant
|
def version = "2022.04.28-r6" + "+" + packageVariant
|
||||||
downloadBootstrap("aarch64", "913609d439415c828c5640be1b0561467e539cb1c7080662decaaca2fb4820e7", version)
|
downloadBootstrap("aarch64", "913609d439415c828c5640be1b0561467e539cb1c7080662decaaca2fb4820e7", version)
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions" />
|
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions" />
|
||||||
|
<uses-permission android:name="com.android.alarm.permission.SET_ALARM" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".app.TermuxApplication"
|
android:name=".app.TermuxApplication"
|
||||||
|
|||||||
@@ -785,7 +785,7 @@ public final class TermuxActivity extends AppCompatActivity implements ServiceCo
|
|||||||
|
|
||||||
// If permission is granted, then also setup storage symlinks.
|
// If permission is granted, then also setup storage symlinks.
|
||||||
if(PermissionUtils.checkAndRequestLegacyOrManageExternalStoragePermission(
|
if(PermissionUtils.checkAndRequestLegacyOrManageExternalStoragePermission(
|
||||||
TermuxActivity.this, requestCode, !isPermissionCallback)) {
|
TermuxActivity.this, requestCode, true, !isPermissionCallback)) {
|
||||||
if (isPermissionCallback)
|
if (isPermissionCallback)
|
||||||
Logger.logInfoAndShowToast(TermuxActivity.this, LOG_TAG,
|
Logger.logInfoAndShowToast(TermuxActivity.this, LOG_TAG,
|
||||||
getString(com.termux.shared.R.string.msg_storage_permission_granted_on_request));
|
getString(com.termux.shared.R.string.msg_storage_permission_granted_on_request));
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class TermuxApplication extends Application {
|
|||||||
boolean isTermuxFilesDirectoryAccessible = error == null;
|
boolean isTermuxFilesDirectoryAccessible = error == null;
|
||||||
if (isTermuxFilesDirectoryAccessible) {
|
if (isTermuxFilesDirectoryAccessible) {
|
||||||
Logger.logInfo(LOG_TAG, "Termux files directory is accessible");
|
Logger.logInfo(LOG_TAG, "Termux files directory is accessible");
|
||||||
|
/*
|
||||||
error = TermuxFileUtils.isAppsTermuxAppDirectoryAccessible(true, true);
|
error = TermuxFileUtils.isAppsTermuxAppDirectoryAccessible(true, true);
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
Logger.logErrorExtended(LOG_TAG, "Create apps/termux-app directory failed\n" + error);
|
Logger.logErrorExtended(LOG_TAG, "Create apps/termux-app directory failed\n" + error);
|
||||||
@@ -61,6 +61,7 @@ public class TermuxApplication extends Application {
|
|||||||
|
|
||||||
// Setup termux-am-socket server
|
// Setup termux-am-socket server
|
||||||
TermuxAmSocketServer.setupTermuxAmSocketServer(context);
|
TermuxAmSocketServer.setupTermuxAmSocketServer(context);
|
||||||
|
*/
|
||||||
} else {
|
} else {
|
||||||
Logger.logErrorExtended(LOG_TAG, "Termux files directory is not accessible\n" + error);
|
Logger.logErrorExtended(LOG_TAG, "Termux files directory is not accessible\n" + error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import android.view.WindowManager;
|
|||||||
|
|
||||||
import com.termux.R;
|
import com.termux.R;
|
||||||
import com.termux.shared.file.FileUtils;
|
import com.termux.shared.file.FileUtils;
|
||||||
|
import com.termux.shared.shell.command.ExecutionCommand;
|
||||||
|
import com.termux.shared.shell.command.runner.app.AppShell;
|
||||||
import com.termux.shared.termux.crash.TermuxCrashUtils;
|
import com.termux.shared.termux.crash.TermuxCrashUtils;
|
||||||
import com.termux.shared.termux.file.TermuxFileUtils;
|
import com.termux.shared.termux.file.TermuxFileUtils;
|
||||||
import com.termux.shared.interact.MessageDialogUtils;
|
import com.termux.shared.interact.MessageDialogUtils;
|
||||||
@@ -195,7 +197,8 @@ final class TermuxInstaller {
|
|||||||
outStream.write(buffer, 0, readBytes);
|
outStream.write(buffer, 0, readBytes);
|
||||||
}
|
}
|
||||||
if (zipEntryName.startsWith("bin/") || zipEntryName.startsWith("libexec") ||
|
if (zipEntryName.startsWith("bin/") || zipEntryName.startsWith("libexec") ||
|
||||||
zipEntryName.startsWith("lib/apt/apt-helper") || zipEntryName.startsWith("lib/apt/methods")) {
|
zipEntryName.startsWith("lib/apt/apt-helper") || zipEntryName.startsWith("lib/apt/methods") ||
|
||||||
|
zipEntryName.equals("etc/termux/bootstrap/termux-bootstrap-second-stage.sh")) {
|
||||||
//noinspection OctalInteger
|
//noinspection OctalInteger
|
||||||
Os.chmod(targetFile.getAbsolutePath(), 0700);
|
Os.chmod(targetFile.getAbsolutePath(), 0700);
|
||||||
}
|
}
|
||||||
@@ -216,6 +219,28 @@ final class TermuxInstaller {
|
|||||||
throw new RuntimeException("Moving termux prefix staging to prefix directory failed");
|
throw new RuntimeException("Moving termux prefix staging to prefix directory failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Run Termux bootstrap second stage
|
||||||
|
Logger.logInfo(LOG_TAG, "Running Termux bootstrap second stage.");
|
||||||
|
String termuxBootstrapSecondStageFile = TERMUX_PREFIX_DIR_PATH + "/etc/termux/bootstrap/termux-bootstrap-second-stage.sh";
|
||||||
|
if (FileUtils.fileExists(termuxBootstrapSecondStageFile, false)) {
|
||||||
|
ExecutionCommand executionCommand = new ExecutionCommand(-1,
|
||||||
|
termuxBootstrapSecondStageFile, null, null,
|
||||||
|
null, ExecutionCommand.Runner.APP_SHELL.getName(), false);
|
||||||
|
executionCommand.commandLabel = "Termux Bootstrap Second Stage Command";
|
||||||
|
executionCommand.backgroundCustomLogLevel = Logger.LOG_LEVEL_NORMAL;
|
||||||
|
AppShell appShell = AppShell.execute(activity, executionCommand, null, new TermuxShellEnvironment(), null, true);
|
||||||
|
boolean stderrSet = !executionCommand.resultData.stderr.toString().isEmpty();
|
||||||
|
if (appShell == null || !executionCommand.isSuccessful() || executionCommand.resultData.exitCode != 0 || stderrSet) {
|
||||||
|
// Delete prefix directory as otherwise when app is restarted, the broken prefix directory would be used and logged into
|
||||||
|
error = FileUtils.deleteFile("termux prefix directory", TERMUX_PREFIX_DIR_PATH, true);
|
||||||
|
if (error != null)
|
||||||
|
Logger.logErrorExtended(LOG_TAG, error.toString());
|
||||||
|
|
||||||
|
showBootstrapErrorDialog(activity, whenDone, MarkdownUtils.getMarkdownCodeForString(executionCommand.toString(), true));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Logger.logInfo(LOG_TAG, "Bootstrap packages installed successfully.");
|
Logger.logInfo(LOG_TAG, "Bootstrap packages installed successfully.");
|
||||||
|
|
||||||
// Recreate env file since termux prefix was wiped earlier
|
// Recreate env file since termux prefix was wiped earlier
|
||||||
|
|||||||
@@ -209,31 +209,44 @@ public class PermissionUtils {
|
|||||||
|
|
||||||
/** If path is under primary external storage directory and storage permission is missing,
|
/** If path is under primary external storage directory and storage permission is missing,
|
||||||
* then legacy or manage external storage permission will be requested from the user via a call
|
* then legacy or manage external storage permission will be requested from the user via a call
|
||||||
* to {@link #checkAndRequestLegacyOrManageExternalStoragePermission(Context, int, boolean)}.
|
* to {@link #checkAndRequestLegacyOrManageExternalStoragePermission(Context, int, boolean, boolean)}.
|
||||||
*
|
*
|
||||||
* @param context The context for operations.
|
* @param context The context for operations.
|
||||||
* @param filePath The path to check.
|
* @param filePath The path to check.
|
||||||
* @param requestCode The request code to use while asking for permission.
|
* @param requestCode The request code to use while asking for permission.
|
||||||
|
* @param prioritizeManageExternalStoragePermission If {@link Manifest.permission#MANAGE_EXTERNAL_STORAGE}
|
||||||
|
* permission should be requested if on
|
||||||
|
* Android `>= 11` instead of getting legacy
|
||||||
|
* storage permission.
|
||||||
* @param showErrorMessage If an error message toast should be shown if permission is not granted.
|
* @param showErrorMessage If an error message toast should be shown if permission is not granted.
|
||||||
* @return Returns {@code true} if permission is granted, otherwise {@code false}.
|
* @return Returns {@code true} if permission is granted, otherwise {@code false}.
|
||||||
*/
|
*/
|
||||||
@SuppressLint("SdCardPath")
|
@SuppressLint("SdCardPath")
|
||||||
public static boolean checkAndRequestLegacyOrManageExternalStoragePermissionIfPathOnPrimaryExternalStorage(
|
public static boolean checkAndRequestLegacyOrManageExternalStoragePermissionIfPathOnPrimaryExternalStorage(
|
||||||
@NonNull Context context, String filePath, int requestCode, boolean showErrorMessage) {
|
@NonNull Context context, String filePath, int requestCode,
|
||||||
|
boolean prioritizeManageExternalStoragePermission, boolean showErrorMessage) {
|
||||||
// If path is under primary external storage directory, then check for missing permissions.
|
// If path is under primary external storage directory, then check for missing permissions.
|
||||||
if (!FileUtils.isPathInDirPaths(filePath,
|
if (!FileUtils.isPathInDirPaths(filePath,
|
||||||
Arrays.asList(Environment.getExternalStorageDirectory().getAbsolutePath(), "/sdcard"), true))
|
Arrays.asList(Environment.getExternalStorageDirectory().getAbsolutePath(), "/sdcard"), true))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return checkAndRequestLegacyOrManageExternalStoragePermission(context, requestCode, showErrorMessage);
|
return checkAndRequestLegacyOrManageExternalStoragePermission(context, requestCode, prioritizeManageExternalStoragePermission, showErrorMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if legacy or manage external storage permissions has been granted. If
|
* Check if legacy or manage external storage permissions has been granted.
|
||||||
* {@link #isLegacyExternalStoragePossible(Context)} returns {@code true}, them it will be
|
*
|
||||||
* checked if app has has been granted {@link Manifest.permission#READ_EXTERNAL_STORAGE} and
|
* - If `prioritizeManageExternalStoragePermission` is `true and running on Android `>= 11`, then
|
||||||
* {@link Manifest.permission#WRITE_EXTERNAL_STORAGE} permissions, otherwise it will be checked
|
* it will be checked if app has been granted the
|
||||||
* if app has been granted the {@link Manifest.permission#MANAGE_EXTERNAL_STORAGE} permission.
|
* {@link Manifest.permission#MANAGE_EXTERNAL_STORAGE}.
|
||||||
|
* - If `prioritizeManageExternalStoragePermission` is `false` and running on Android `>= 11`, then
|
||||||
|
* if {@link #isLegacyExternalStoragePossible(Context)} returns `true`, them it will be
|
||||||
|
* checked if app has has been granted {@link Manifest.permission#READ_EXTERNAL_STORAGE} and
|
||||||
|
* {@link Manifest.permission#WRITE_EXTERNAL_STORAGE} permissions, otherwise it will be checked
|
||||||
|
* if app has been granted the {@link Manifest.permission#MANAGE_EXTERNAL_STORAGE} permission.
|
||||||
|
* - If running on Android `< 11`, then it will only be checked if app has been granted
|
||||||
|
* {@link Manifest.permission#READ_EXTERNAL_STORAGE} and
|
||||||
|
* {@link Manifest.permission#WRITE_EXTERNAL_STORAGE} permissions.
|
||||||
*
|
*
|
||||||
* If storage permission is missing, it will be requested from the user if {@code context} is an
|
* If storage permission is missing, it will be requested from the user if {@code context} is an
|
||||||
* instance of {@link Activity} or {@link AppCompatActivity} and {@code requestCode}
|
* instance of {@link Activity} or {@link AppCompatActivity} and {@code requestCode}
|
||||||
@@ -256,16 +269,34 @@ public class PermissionUtils {
|
|||||||
*}
|
*}
|
||||||
* @param context The context for operations.
|
* @param context The context for operations.
|
||||||
* @param requestCode The request code to use while asking for permission.
|
* @param requestCode The request code to use while asking for permission.
|
||||||
|
* @param prioritizeManageExternalStoragePermission If {@link Manifest.permission#MANAGE_EXTERNAL_STORAGE}
|
||||||
|
* permission should be requested if on
|
||||||
|
* Android `>= 11` instead of getting legacy
|
||||||
|
* storage permission.
|
||||||
* @param showErrorMessage If an error message toast should be shown if permission is not granted.
|
* @param showErrorMessage If an error message toast should be shown if permission is not granted.
|
||||||
* @return Returns {@code true} if permission is granted, otherwise {@code false}.
|
* @return Returns {@code true} if permission is granted, otherwise {@code false}.
|
||||||
*/
|
*/
|
||||||
public static boolean checkAndRequestLegacyOrManageExternalStoragePermission(@NonNull Context context,
|
public static boolean checkAndRequestLegacyOrManageExternalStoragePermission(@NonNull Context context,
|
||||||
int requestCode,
|
int requestCode,
|
||||||
|
boolean prioritizeManageExternalStoragePermission,
|
||||||
boolean showErrorMessage) {
|
boolean showErrorMessage) {
|
||||||
|
Logger.logVerbose(LOG_TAG, "Checking storage permission");
|
||||||
|
|
||||||
String errmsg;
|
String errmsg;
|
||||||
boolean requestLegacyStoragePermission = isLegacyExternalStoragePossible(context);
|
Boolean requestLegacyStoragePermission = null;
|
||||||
|
|
||||||
|
if (prioritizeManageExternalStoragePermission && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
|
||||||
|
requestLegacyStoragePermission = false;
|
||||||
|
|
||||||
|
if (requestLegacyStoragePermission == null)
|
||||||
|
requestLegacyStoragePermission = isLegacyExternalStoragePossible(context);
|
||||||
|
|
||||||
boolean checkIfHasRequestedLegacyExternalStorage = checkIfHasRequestedLegacyExternalStorage(context);
|
boolean checkIfHasRequestedLegacyExternalStorage = checkIfHasRequestedLegacyExternalStorage(context);
|
||||||
|
|
||||||
|
Logger.logVerbose(LOG_TAG, "prioritizeManageExternalStoragePermission=" + prioritizeManageExternalStoragePermission +
|
||||||
|
", requestLegacyStoragePermission=" + requestLegacyStoragePermission +
|
||||||
|
", checkIfHasRequestedLegacyExternalStorage=" + checkIfHasRequestedLegacyExternalStorage);
|
||||||
|
|
||||||
if (requestLegacyStoragePermission && checkIfHasRequestedLegacyExternalStorage) {
|
if (requestLegacyStoragePermission && checkIfHasRequestedLegacyExternalStorage) {
|
||||||
// Check if requestLegacyExternalStorage is set to true in app manifest
|
// Check if requestLegacyExternalStorage is set to true in app manifest
|
||||||
if (!hasRequestedLegacyExternalStorage(context, showErrorMessage))
|
if (!hasRequestedLegacyExternalStorage(context, showErrorMessage))
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ public class ShellCommandShellEnvironment {
|
|||||||
public static final String ENV_SHELL_CMD__APP_SHELL_NUMBER_SINCE_BOOT = SHELL_CMD_ENV_PREFIX + "APP_SHELL_NUMBER_SINCE_BOOT";
|
public static final String ENV_SHELL_CMD__APP_SHELL_NUMBER_SINCE_BOOT = SHELL_CMD_ENV_PREFIX + "APP_SHELL_NUMBER_SINCE_BOOT";
|
||||||
|
|
||||||
/** Environment variable for the {{@link ExecutionCommand.Runner#TERMINAL_SESSION} number since boot. */
|
/** Environment variable for the {{@link ExecutionCommand.Runner#TERMINAL_SESSION} number since boot. */
|
||||||
public static final String ENV_SHELL_CMD__TERMINAL_SESSION_NUMBER_SINCE_BOOT = SHELL_CMD_ENV_PREFIX + "TERMINAL_SESSION_NUMBER_SINCE_BOOT";
|
public static final String ENV_SHELL_CMD__APP_TERMINAL_SESSION_NUMBER_SINCE_BOOT = SHELL_CMD_ENV_PREFIX + "APP_TERMINAL_SESSION_NUMBER_SINCE_BOOT";
|
||||||
|
|
||||||
/** Environment variable for the {@link ExecutionCommand.Runner#APP_SHELL} number since app start. */
|
/** Environment variable for the {@link ExecutionCommand.Runner#APP_SHELL} number since app start. */
|
||||||
public static final String ENV_SHELL_CMD__APP_SHELL_NUMBER_SINCE_APP_START = SHELL_CMD_ENV_PREFIX + "APP_SHELL_NUMBER_SINCE_APP_START";
|
public static final String ENV_SHELL_CMD__APP_SHELL_NUMBER_SINCE_APP_START = SHELL_CMD_ENV_PREFIX + "APP_SHELL_NUMBER_SINCE_APP_START";
|
||||||
|
|
||||||
/** Environment variable for the {@link ExecutionCommand.Runner#TERMINAL_SESSION} number since app start. */
|
/** Environment variable for the {@link ExecutionCommand.Runner#TERMINAL_SESSION} number since app start. */
|
||||||
public static final String ENV_SHELL_CMD__TERMINAL_SESSION_NUMBER_SINCE_APP_START = SHELL_CMD_ENV_PREFIX + "TERMINAL_SESSION_NUMBER_SINCE_APP_START";
|
public static final String ENV_SHELL_CMD__APP_TERMINAL_SESSION_NUMBER_SINCE_APP_START = SHELL_CMD_ENV_PREFIX + "APP_TERMINAL_SESSION_NUMBER_SINCE_APP_START";
|
||||||
|
|
||||||
|
|
||||||
/** Get shell environment containing info for {@link ExecutionCommand}. */
|
/** Get shell environment containing info for {@link ExecutionCommand}. */
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ public final class TermuxPropertyConstants {
|
|||||||
/** Defines the key for extra keys */
|
/** Defines the key for extra keys */
|
||||||
public static final String KEY_EXTRA_KEYS = "extra-keys"; // Default: "extra-keys"
|
public static final String KEY_EXTRA_KEYS = "extra-keys"; // Default: "extra-keys"
|
||||||
//public static final String DEFAULT_IVALUE_EXTRA_KEYS = "[[ESC, TAB, CTRL, ALT, {key: '-', popup: '|'}, DOWN, UP]]"; // Single row
|
//public static final String DEFAULT_IVALUE_EXTRA_KEYS = "[[ESC, TAB, CTRL, ALT, {key: '-', popup: '|'}, DOWN, UP]]"; // Single row
|
||||||
public static final String DEFAULT_IVALUE_EXTRA_KEYS = "[['ESC','/',{key: '-', popup: '|'},'HOME','UP','END','PGUP'], ['TAB','CTRL','ALT','LEFT','DOWN','RIGHT','PGDN']]"; // Double row
|
public static final String DEFAULT_IVALUE_EXTRA_KEYS = "[['ESC',{key: 'DRAWER', popup: 'PASTE'},'SCROLL','HOME','UP','END','PGUP'], ['TAB','CTRL','ALT','LEFT','DOWN','RIGHT','PGDN']]"; // Double row
|
||||||
|
|
||||||
/** Defines the key for extra keys style */
|
/** Defines the key for extra keys style */
|
||||||
public static final String KEY_EXTRA_KEYS_STYLE = "extra-keys-style"; // Default: "extra-keys-style"
|
public static final String KEY_EXTRA_KEYS_STYLE = "extra-keys-style"; // Default: "extra-keys-style"
|
||||||
|
|||||||
@@ -27,6 +27,12 @@ public class TermuxAppShellEnvironment {
|
|||||||
/** Termux app environment variables. */
|
/** Termux app environment variables. */
|
||||||
public static HashMap<String, String> termuxAppEnvironment;
|
public static HashMap<String, String> termuxAppEnvironment;
|
||||||
|
|
||||||
|
/** Environment variable root scope. */
|
||||||
|
public static final String TERMUX_ENV__S_ROOT = "TERMUX_"; // Default: "TERMUX_"
|
||||||
|
|
||||||
|
/** Environment variable scope for Termux. */
|
||||||
|
public static final String TERMUX_ENV__S_TERMUX = TERMUX_ENV__S_ROOT + "_"; // Default: "TERMUX__"
|
||||||
|
|
||||||
/** Environment variable for the Termux app version. */
|
/** Environment variable for the Termux app version. */
|
||||||
public static final String ENV_TERMUX_VERSION = TermuxConstants.TERMUX_ENV_PREFIX_ROOT + "_VERSION";
|
public static final String ENV_TERMUX_VERSION = TermuxConstants.TERMUX_ENV_PREFIX_ROOT + "_VERSION";
|
||||||
|
|
||||||
@@ -34,15 +40,15 @@ public class TermuxAppShellEnvironment {
|
|||||||
public static final String TERMUX_APP_ENV_PREFIX = TermuxConstants.TERMUX_ENV_PREFIX_ROOT + "_APP__";
|
public static final String TERMUX_APP_ENV_PREFIX = TermuxConstants.TERMUX_ENV_PREFIX_ROOT + "_APP__";
|
||||||
|
|
||||||
/** Environment variable for the Termux app version name. */
|
/** Environment variable for the Termux app version name. */
|
||||||
public static final String ENV_TERMUX_APP__VERSION_NAME = TERMUX_APP_ENV_PREFIX + "VERSION_NAME";
|
public static final String ENV_TERMUX_APP__APP_VERSION_NAME = TERMUX_APP_ENV_PREFIX + "APP_VERSION_NAME";
|
||||||
/** Environment variable for the Termux app version code. */
|
/** Environment variable for the Termux app version code. */
|
||||||
public static final String ENV_TERMUX_APP__VERSION_CODE = TERMUX_APP_ENV_PREFIX + "VERSION_CODE";
|
public static final String ENV_TERMUX_APP__APP_VERSION_CODE = TERMUX_APP_ENV_PREFIX + "APP_VERSION_CODE";
|
||||||
/** Environment variable for the Termux app package name. */
|
/** Environment variable for the Termux app package name. */
|
||||||
public static final String ENV_TERMUX_APP__PACKAGE_NAME = TERMUX_APP_ENV_PREFIX + "PACKAGE_NAME";
|
public static final String ENV_TERMUX_APP__PACKAGE_NAME = TERMUX_APP_ENV_PREFIX + "PACKAGE_NAME";
|
||||||
/** Environment variable for the Termux app process id. */
|
/** Environment variable for the Termux app process id. */
|
||||||
public static final String ENV_TERMUX_APP__PID = TERMUX_APP_ENV_PREFIX + "PID";
|
public static final String ENV_TERMUX_APP__PID = TERMUX_APP_ENV_PREFIX + "PID";
|
||||||
/** Environment variable for the Termux app uid. */
|
/** Environment variable for the Termux app uid. */
|
||||||
public static final String ENV_TERMUX_APP__UID = TERMUX_APP_ENV_PREFIX + "UID";
|
public static final String ENV_TERMUX__UID = TERMUX_ENV__S_TERMUX + "UID";
|
||||||
/** Environment variable for the Termux app targetSdkVersion. */
|
/** Environment variable for the Termux app targetSdkVersion. */
|
||||||
public static final String ENV_TERMUX_APP__TARGET_SDK = TERMUX_APP_ENV_PREFIX + "TARGET_SDK";
|
public static final String ENV_TERMUX_APP__TARGET_SDK = TERMUX_APP_ENV_PREFIX + "TARGET_SDK";
|
||||||
/** Environment variable for the Termux app is debuggable apk build. */
|
/** Environment variable for the Termux app is debuggable apk build. */
|
||||||
@@ -50,27 +56,27 @@ public class TermuxAppShellEnvironment {
|
|||||||
/** Environment variable for the Termux app {@link TermuxConstants} APK_RELEASE_*. */
|
/** Environment variable for the Termux app {@link TermuxConstants} APK_RELEASE_*. */
|
||||||
public static final String ENV_TERMUX_APP__APK_RELEASE = TERMUX_APP_ENV_PREFIX + "APK_RELEASE";
|
public static final String ENV_TERMUX_APP__APK_RELEASE = TERMUX_APP_ENV_PREFIX + "APK_RELEASE";
|
||||||
/** Environment variable for the Termux app install path. */
|
/** Environment variable for the Termux app install path. */
|
||||||
public static final String ENV_TERMUX_APP__APK_PATH = TERMUX_APP_ENV_PREFIX + "APK_PATH";
|
public static final String ENV_TERMUX_APP__APK_FILE = TERMUX_APP_ENV_PREFIX + "APK_FILE";
|
||||||
/** Environment variable for the Termux app is installed on external/portable storage. */
|
/** Environment variable for the Termux app is installed on external/portable storage. */
|
||||||
public static final String ENV_TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE = TERMUX_APP_ENV_PREFIX + "IS_INSTALLED_ON_EXTERNAL_STORAGE";
|
public static final String ENV_TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE = TERMUX_APP_ENV_PREFIX + "IS_INSTALLED_ON_EXTERNAL_STORAGE";
|
||||||
|
|
||||||
/** Environment variable for the Termux app process selinux context. */
|
/** Environment variable for the Termux app process selinux context. */
|
||||||
public static final String ENV_TERMUX_APP__SE_PROCESS_CONTEXT = TERMUX_APP_ENV_PREFIX + "SE_PROCESS_CONTEXT";
|
public static final String ENV_TERMUX__SE_PROCESS_CONTEXT = TERMUX_ENV__S_TERMUX + "SE_PROCESS_CONTEXT";
|
||||||
/** Environment variable for the Termux app data files selinux context. */
|
/** Environment variable for the Termux app data files selinux context. */
|
||||||
public static final String ENV_TERMUX_APP__SE_FILE_CONTEXT = TERMUX_APP_ENV_PREFIX + "SE_FILE_CONTEXT";
|
public static final String ENV_TERMUX__SE_FILE_CONTEXT = TERMUX_ENV__S_TERMUX + "SE_FILE_CONTEXT";
|
||||||
/** Environment variable for the Termux app seInfo tag found in selinux policy used to set app process and app data files selinux context. */
|
/** Environment variable for the Termux app seInfo tag found in selinux policy used to set app process and app data files selinux context. */
|
||||||
public static final String ENV_TERMUX_APP__SE_INFO = TERMUX_APP_ENV_PREFIX + "SE_INFO";
|
public static final String ENV_TERMUX__SE_INFO = TERMUX_ENV__S_TERMUX + "SE_INFO";
|
||||||
/** Environment variable for the Termux app user id. */
|
/** Environment variable for the Termux app user id. */
|
||||||
public static final String ENV_TERMUX_APP__USER_ID = TERMUX_APP_ENV_PREFIX + "USER_ID";
|
public static final String ENV_TERMUX__USER_ID = TERMUX_ENV__S_TERMUX + "USER_ID";
|
||||||
/** Environment variable for the Termux app profile owner. */
|
/** Environment variable for the Termux app profile owner. */
|
||||||
public static final String ENV_TERMUX_APP__PROFILE_OWNER = TERMUX_APP_ENV_PREFIX + "PROFILE_OWNER";
|
public static final String ENV_TERMUX__PROFILE_OWNER = TERMUX_ENV__S_TERMUX + "PROFILE_OWNER";
|
||||||
|
|
||||||
/** Environment variable for the Termux app {@link TermuxBootstrap#TERMUX_APP_PACKAGE_MANAGER}. */
|
/** Environment variable for the Termux app {@link TermuxBootstrap#TERMUX_APP_PACKAGE_MANAGER}. */
|
||||||
public static final String ENV_TERMUX_APP__PACKAGE_MANAGER = TERMUX_APP_ENV_PREFIX + "PACKAGE_MANAGER";
|
public static final String ENV_TERMUX_APP__PACKAGE_MANAGER = TERMUX_APP_ENV_PREFIX + "PACKAGE_MANAGER";
|
||||||
/** Environment variable for the Termux app {@link TermuxBootstrap#TERMUX_APP_PACKAGE_VARIANT}. */
|
/** Environment variable for the Termux app {@link TermuxBootstrap#TERMUX_APP_PACKAGE_VARIANT}. */
|
||||||
public static final String ENV_TERMUX_APP__PACKAGE_VARIANT = TERMUX_APP_ENV_PREFIX + "PACKAGE_VARIANT";
|
public static final String ENV_TERMUX_APP__PACKAGE_VARIANT = TERMUX_APP_ENV_PREFIX + "PACKAGE_VARIANT";
|
||||||
/** Environment variable for the Termux app files directory. */
|
/** Environment variable for the Termux app files directory. */
|
||||||
public static final String ENV_TERMUX_APP__FILES_DIR = TERMUX_APP_ENV_PREFIX + "FILES_DIR";
|
public static final String ENV_TERMUX_APP__DATA_DIR = TERMUX_APP_ENV_PREFIX + "DATA_DIR";
|
||||||
|
|
||||||
|
|
||||||
/** Environment variable for the Termux app {@link TermuxAmSocketServer#getTermuxAppAMSocketServerEnabled(Context)}. */
|
/** Environment variable for the Termux app {@link TermuxAmSocketServer#getTermuxAppAMSocketServerEnabled(Context)}. */
|
||||||
@@ -105,21 +111,22 @@ public class TermuxAppShellEnvironment {
|
|||||||
HashMap<String, String> environment = new HashMap<>();
|
HashMap<String, String> environment = new HashMap<>();
|
||||||
|
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_VERSION, PackageUtils.getVersionNameForPackage(packageInfo));
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_VERSION, PackageUtils.getVersionNameForPackage(packageInfo));
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__VERSION_NAME, PackageUtils.getVersionNameForPackage(packageInfo));
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__APP_VERSION_NAME, PackageUtils.getVersionNameForPackage(packageInfo));
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__VERSION_CODE, String.valueOf(PackageUtils.getVersionCodeForPackage(packageInfo)));
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__APP_VERSION_CODE, String.valueOf(PackageUtils.getVersionCodeForPackage(packageInfo)));
|
||||||
|
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__PACKAGE_NAME, packageName);
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__PACKAGE_NAME, packageName);
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__PID, TermuxUtils.getTermuxAppPID(currentPackageContext));
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__PID, TermuxUtils.getTermuxAppPID(currentPackageContext));
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__UID, String.valueOf(PackageUtils.getUidForPackage(applicationInfo)));
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX__UID, String.valueOf(PackageUtils.getUidForPackage(applicationInfo)));
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__TARGET_SDK, String.valueOf(PackageUtils.getTargetSDKForPackage(applicationInfo)));
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__TARGET_SDK, String.valueOf(PackageUtils.getTargetSDKForPackage(applicationInfo)));
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__IS_DEBUGGABLE_BUILD, PackageUtils.isAppForPackageADebuggableBuild(applicationInfo));
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__IS_DEBUGGABLE_BUILD, PackageUtils.isAppForPackageADebuggableBuild(applicationInfo));
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__APK_PATH, PackageUtils.getBaseAPKPathForPackage(applicationInfo));
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__APK_FILE, PackageUtils.getBaseAPKPathForPackage(applicationInfo));
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE, PackageUtils.isAppInstalledOnExternalStorage(applicationInfo));
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE, PackageUtils.isAppInstalledOnExternalStorage(applicationInfo));
|
||||||
|
|
||||||
putTermuxAPKSignature(currentPackageContext, environment);
|
putTermuxAPKSignature(currentPackageContext, environment);
|
||||||
|
|
||||||
Context termuxPackageContext = TermuxUtils.getTermuxPackageContext(currentPackageContext);
|
Context termuxPackageContext = TermuxUtils.getTermuxPackageContext(currentPackageContext);
|
||||||
if (termuxPackageContext != null) {
|
if (termuxPackageContext != null) {
|
||||||
|
/*
|
||||||
// An app that does not have the same sharedUserId as termux app will not be able to get
|
// An app that does not have the same sharedUserId as termux app will not be able to get
|
||||||
// get termux context's classloader to get BuildConfig.TERMUX_PACKAGE_VARIANT via reflection.
|
// get termux context's classloader to get BuildConfig.TERMUX_PACKAGE_VARIANT via reflection.
|
||||||
// Check TermuxBootstrap.setTermuxPackageManagerAndVariantFromTermuxApp()
|
// Check TermuxBootstrap.setTermuxPackageManagerAndVariantFromTermuxApp()
|
||||||
@@ -127,24 +134,26 @@ public class TermuxAppShellEnvironment {
|
|||||||
environment.put(ENV_TERMUX_APP__PACKAGE_MANAGER, TermuxBootstrap.TERMUX_APP_PACKAGE_MANAGER.getName());
|
environment.put(ENV_TERMUX_APP__PACKAGE_MANAGER, TermuxBootstrap.TERMUX_APP_PACKAGE_MANAGER.getName());
|
||||||
if (TermuxBootstrap.TERMUX_APP_PACKAGE_VARIANT != null)
|
if (TermuxBootstrap.TERMUX_APP_PACKAGE_VARIANT != null)
|
||||||
environment.put(ENV_TERMUX_APP__PACKAGE_VARIANT, TermuxBootstrap.TERMUX_APP_PACKAGE_VARIANT.getName());
|
environment.put(ENV_TERMUX_APP__PACKAGE_VARIANT, TermuxBootstrap.TERMUX_APP_PACKAGE_VARIANT.getName());
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
// Will not be set for plugins
|
// Will not be set for plugins
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__AM_SOCKET_SERVER_ENABLED,
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__AM_SOCKET_SERVER_ENABLED,
|
||||||
TermuxAmSocketServer.getTermuxAppAMSocketServerEnabled(currentPackageContext));
|
TermuxAmSocketServer.getTermuxAppAMSocketServerEnabled(currentPackageContext));
|
||||||
|
*/
|
||||||
|
|
||||||
String filesDirPath = currentPackageContext.getFilesDir().getAbsolutePath();
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__DATA_DIR, applicationInfo.dataDir);
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__FILES_DIR, filesDirPath);
|
|
||||||
|
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__SE_PROCESS_CONTEXT, SELinuxUtils.getContext());
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX__SE_PROCESS_CONTEXT, SELinuxUtils.getContext());
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__SE_FILE_CONTEXT, SELinuxUtils.getFileContext(filesDirPath));
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX__SE_FILE_CONTEXT, SELinuxUtils.getFileContext(applicationInfo.dataDir));
|
||||||
|
|
||||||
String seInfoUser = PackageUtils.getApplicationInfoSeInfoUserForPackage(applicationInfo);
|
String seInfoUser = PackageUtils.getApplicationInfoSeInfoUserForPackage(applicationInfo);
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__SE_INFO, PackageUtils.getApplicationInfoSeInfoForPackage(applicationInfo) +
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX__SE_INFO, PackageUtils.getApplicationInfoSeInfoForPackage(applicationInfo) +
|
||||||
(DataUtils.isNullOrEmpty(seInfoUser) ? "" : seInfoUser));
|
(DataUtils.isNullOrEmpty(seInfoUser) ? "" : seInfoUser));
|
||||||
|
|
||||||
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__USER_ID, String.valueOf(PackageUtils.getUserIdForPackage(currentPackageContext)));
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX__USER_ID, String.valueOf(PackageUtils.getUserIdForPackage(currentPackageContext)));
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX_APP__PROFILE_OWNER, PackageUtils.getProfileOwnerPackageNameForUser(currentPackageContext));
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_TERMUX__PROFILE_OWNER, PackageUtils.getProfileOwnerPackageNameForUser(currentPackageContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
termuxAppEnvironment = environment;
|
termuxAppEnvironment = environment;
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ public class TermuxShellCommandShellEnvironment extends ShellCommandShellEnviron
|
|||||||
String.valueOf(TermuxShellManager.getAndIncrementAppShellNumberSinceAppStart()));
|
String.valueOf(TermuxShellManager.getAndIncrementAppShellNumberSinceAppStart()));
|
||||||
|
|
||||||
} else if (ExecutionCommand.Runner.TERMINAL_SESSION.equalsRunner(executionCommand.runner)) {
|
} else if (ExecutionCommand.Runner.TERMINAL_SESSION.equalsRunner(executionCommand.runner)) {
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_SHELL_CMD__TERMINAL_SESSION_NUMBER_SINCE_BOOT,
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_SHELL_CMD__APP_TERMINAL_SESSION_NUMBER_SINCE_BOOT,
|
||||||
String.valueOf(preferences.getAndIncrementTerminalSessionNumberSinceBoot()));
|
String.valueOf(preferences.getAndIncrementTerminalSessionNumberSinceBoot()));
|
||||||
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_SHELL_CMD__TERMINAL_SESSION_NUMBER_SINCE_APP_START,
|
ShellEnvironmentUtils.putToEnvIfSet(environment, ENV_SHELL_CMD__APP_TERMINAL_SESSION_NUMBER_SINCE_APP_START,
|
||||||
String.valueOf(TermuxShellManager.getAndIncrementTerminalSessionNumberSinceAppStart()));
|
String.valueOf(TermuxShellManager.getAndIncrementTerminalSessionNumberSinceAppStart()));
|
||||||
} else {
|
} else {
|
||||||
return environment;
|
return environment;
|
||||||
|
|||||||
@@ -71,9 +71,11 @@ public class TermuxShellEnvironment extends AndroidShellEnvironment {
|
|||||||
if (termuxAppEnvironment != null)
|
if (termuxAppEnvironment != null)
|
||||||
environment.putAll(termuxAppEnvironment);
|
environment.putAll(termuxAppEnvironment);
|
||||||
|
|
||||||
|
/*
|
||||||
HashMap<String, String> termuxApiAppEnvironment = TermuxAPIShellEnvironment.getEnvironment(currentPackageContext);
|
HashMap<String, String> termuxApiAppEnvironment = TermuxAPIShellEnvironment.getEnvironment(currentPackageContext);
|
||||||
if (termuxApiAppEnvironment != null)
|
if (termuxApiAppEnvironment != null)
|
||||||
environment.putAll(termuxApiAppEnvironment);
|
environment.putAll(termuxApiAppEnvironment);
|
||||||
|
*/
|
||||||
|
|
||||||
environment.put(ENV_HOME, TermuxConstants.TERMUX_HOME_DIR_PATH);
|
environment.put(ENV_HOME, TermuxConstants.TERMUX_HOME_DIR_PATH);
|
||||||
environment.put(ENV_PREFIX, TermuxConstants.TERMUX_PREFIX_DIR_PATH);
|
environment.put(ENV_PREFIX, TermuxConstants.TERMUX_PREFIX_DIR_PATH);
|
||||||
|
|||||||
Reference in New Issue
Block a user