Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af95a99854 | ||
|
|
25523ae224 | ||
|
|
665adb6895 | ||
|
|
eb7fda28df | ||
|
|
7063a3a9da | ||
|
|
6e02b99ff6 | ||
|
|
9aae665bfc | ||
|
|
52ce6cc94b | ||
|
|
f91168eff4 | ||
|
|
8faa5b2151 | ||
|
|
216cc10f3c |
@@ -17,8 +17,8 @@ android {
|
||||
applicationId "com.termux"
|
||||
minSdkVersion project.properties.minSdkVersion.toInteger()
|
||||
targetSdkVersion project.properties.targetSdkVersion.toInteger()
|
||||
versionCode 99
|
||||
versionName "0.99"
|
||||
versionCode 100
|
||||
versionName "0.100"
|
||||
|
||||
externalNativeBuild {
|
||||
ndkBuild {
|
||||
@@ -133,11 +133,11 @@ clean {
|
||||
|
||||
task downloadBootstraps(){
|
||||
doLast {
|
||||
def version = 28
|
||||
downloadBootstrap("aarch64", "8f8c8af1d6c50bd0d6ecd5a1df8d5b0c3122a945b6febd0de0308504b4075ed0", version)
|
||||
downloadBootstrap("arm", "179465f403a73fec6534363b11cb38eed3b6b3d8e9d922d8e55dc8a06813240d", version)
|
||||
downloadBootstrap("i686", "2100ebf36befde73b08efaa7e3ccc9c218a8b5e7d69db06e16e364ab8b7dfbd5", version)
|
||||
downloadBootstrap("x86_64", "3f5192f63595426370aa69f102fac07ae00c12154878eddec24e8406e640a67f", version)
|
||||
def version = 29
|
||||
downloadBootstrap("aarch64", "1b67ba2302efc20952c00d607a3a169e86cf8ecb66b0c6e16bee9997289119e1", version)
|
||||
downloadBootstrap("arm", "dd87a5902b6b7ee4d4499a10da99a3ea605ba020ad1cc77cad16b3267ac13c2", version)
|
||||
downloadBootstrap("i686", "66cf79273a2ee87730010febe258bec02abf4c4d4c6f89b1b174619baa3c5a0e", version)
|
||||
downloadBootstrap("x86_64", "e9541c02e4e7df4860d76098e4f477e09952ae65323216f692d668425842bf00", version)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||
|
||||
<application
|
||||
android:extractNativeLibs="true"
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.termux.app;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.Service;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Binder;
|
||||
@@ -8,6 +12,8 @@ import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import com.termux.R;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
@@ -20,9 +26,21 @@ import java.util.Properties;
|
||||
*
|
||||
* Third-party program must declare com.termux.permission.RUN_COMMAND permission and it should be
|
||||
* granted by user.
|
||||
* Full path of command or script must be given in "RUN_COMMAND_PATH" extra.
|
||||
*
|
||||
* Absolute path of command or script must be given in "RUN_COMMAND_PATH" extra.
|
||||
* The "RUN_COMMAND_ARGUMENTS", "RUN_COMMAND_WORKDIR" and "RUN_COMMAND_BACKGROUND" extras are
|
||||
* optional. The background mode defaults to false.
|
||||
* optional. The workdir defaults to termux home. The background mode defaults to "false".
|
||||
* The command path and workdir can optionally be prefixed with "$PREFIX/" or "~/" if an absolute
|
||||
* path is not to be given.
|
||||
*
|
||||
* To automatically bring to foreground and start termux commands that were started with
|
||||
* background mode "false" in android >= 10 without user having to click the notification manually,
|
||||
* requires termux to be granted draw over apps permission due to new restrictions
|
||||
* of starting activities from the background, this also applies to Termux:Tasker plugin.
|
||||
*
|
||||
* To reduce the chance of termux being killed by android even further due to violation of not
|
||||
* being able to call startForeground() within ~5s of service start in android >= 8, the user
|
||||
* may disable battery optimizations for termux.
|
||||
*
|
||||
* Sample code to run command "top" with java:
|
||||
* Intent intent = new Intent();
|
||||
@@ -50,6 +68,9 @@ public class RunCommandService extends Service {
|
||||
public static final String RUN_COMMAND_WORKDIR = "com.termux.RUN_COMMAND_WORKDIR";
|
||||
public static final String RUN_COMMAND_BACKGROUND = "com.termux.RUN_COMMAND_BACKGROUND";
|
||||
|
||||
private static final String NOTIFICATION_CHANNEL_ID = "termux_run_command_notification_channel";
|
||||
private static final int NOTIFICATION_ID = 1338;
|
||||
|
||||
class LocalBinder extends Binder {
|
||||
public final RunCommandService service = RunCommandService.this;
|
||||
}
|
||||
@@ -61,14 +82,23 @@ public class RunCommandService extends Service {
|
||||
return mBinder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
runStartForeground();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
// Run again in case service is already started and onCreate() is not called
|
||||
runStartForeground();
|
||||
|
||||
if (allowExternalApps() && RUN_COMMAND_ACTION.equals(intent.getAction())) {
|
||||
Uri programUri = new Uri.Builder().scheme("com.termux.file").path(intent.getStringExtra(RUN_COMMAND_PATH)).build();
|
||||
Uri programUri = new Uri.Builder().scheme("com.termux.file").path(parsePath(intent.getStringExtra(RUN_COMMAND_PATH))).build();
|
||||
|
||||
Intent execIntent = new Intent(TermuxService.ACTION_EXECUTE, programUri);
|
||||
execIntent.setClass(this, TermuxService.class);
|
||||
execIntent.putExtra(TermuxService.EXTRA_ARGUMENTS, intent.getStringArrayExtra(RUN_COMMAND_ARGUMENTS));
|
||||
execIntent.putExtra(TermuxService.EXTRA_CURRENT_WORKING_DIRECTORY, intent.getStringExtra(RUN_COMMAND_WORKDIR));
|
||||
execIntent.putExtra(TermuxService.EXTRA_CURRENT_WORKING_DIRECTORY, parsePath(intent.getStringExtra(RUN_COMMAND_WORKDIR)));
|
||||
execIntent.putExtra(TermuxService.EXTRA_EXECUTE_IN_BACKGROUND, intent.getBooleanExtra(RUN_COMMAND_BACKGROUND, false));
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
@@ -78,9 +108,56 @@ public class RunCommandService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
runStopForeground();
|
||||
|
||||
return Service.START_NOT_STICKY;
|
||||
}
|
||||
|
||||
private void runStartForeground() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
setupNotificationChannel();
|
||||
startForeground(NOTIFICATION_ID, buildNotification());
|
||||
}
|
||||
}
|
||||
|
||||
private void runStopForeground() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
stopForeground(true);
|
||||
}
|
||||
}
|
||||
|
||||
private Notification buildNotification() {
|
||||
Notification.Builder builder = new Notification.Builder(this);
|
||||
builder.setContentTitle(getText(R.string.application_name) + " Run Command");
|
||||
builder.setSmallIcon(R.drawable.ic_service_notification);
|
||||
|
||||
// Use a low priority:
|
||||
builder.setPriority(Notification.PRIORITY_LOW);
|
||||
|
||||
// No need to show a timestamp:
|
||||
builder.setShowWhen(false);
|
||||
|
||||
// Background color for small notification icon:
|
||||
builder.setColor(0xFF607D8B);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
builder.setChannelId(NOTIFICATION_CHANNEL_ID);
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private void setupNotificationChannel() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return;
|
||||
|
||||
String channelName = "Termux Run Command";
|
||||
int importance = NotificationManager.IMPORTANCE_LOW;
|
||||
|
||||
NotificationChannel channel = new NotificationChannel(NOTIFICATION_CHANNEL_ID, channelName, importance);
|
||||
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
manager.createNotificationChannel(channel);
|
||||
}
|
||||
|
||||
private boolean allowExternalApps() {
|
||||
File propsFile = new File(TermuxService.HOME_PATH + "/.termux/termux.properties");
|
||||
if (!propsFile.exists())
|
||||
@@ -99,4 +176,14 @@ public class RunCommandService extends Service {
|
||||
|
||||
return props.getProperty("allow-external-apps", "false").equals("true");
|
||||
}
|
||||
|
||||
/** Replace "$PREFIX/" or "~/" prefix with termux absolute paths */
|
||||
private String parsePath(String path) {
|
||||
if(path != null && !path.isEmpty()) {
|
||||
path = path.replaceAll("^\\$PREFIX\\/", TermuxService.PREFIX_PATH + "/");
|
||||
path = path.replaceAll("^~\\/", TermuxService.HOME_PATH + "/");
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
1
gradle/wrapper/gradle-wrapper.properties
vendored
1
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
|
||||
distributionSha256Sum=7873ed5287f47ca03549ab8dcb6dc877ac7f0e3d7b1eb12685161d10080910ac
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -748,7 +748,7 @@ public final class TerminalEmulator {
|
||||
value = (mScreen == mAltBuffer) ? 1 : 2;
|
||||
} else {
|
||||
int internalBit = mapDecSetBitToInternalBit(mode);
|
||||
if (internalBit == -1) {
|
||||
if (internalBit != -1) {
|
||||
value = isDecsetInternalBitSet(internalBit) ? 1 : 2; // 1=set, 2=reset.
|
||||
} else {
|
||||
Log.e(EmulatorDebug.LOG_TAG, "Got DECRQM for unrecognized private DEC mode=" + mode);
|
||||
|
||||
Reference in New Issue
Block a user