Added: termux-am-library to integrate am with Termux.

This commit is contained in:
tareksander
2021-12-04 19:28:32 +01:00
committed by agnostic-apollo
parent e597ece75f
commit 4aca16326c
3 changed files with 182 additions and 0 deletions

View File

@@ -25,6 +25,10 @@ android {
implementation project(":terminal-view")
implementation project(":termux-shared")
implementation 'com.github.tareksander:termux-am-library:main-SNAPSHOT'
}
defaultConfig {

View File

@@ -3,13 +3,16 @@ package com.termux.app;
import android.app.Application;
import android.content.Context;
import com.termux.am.Am;
import com.termux.shared.termux.TermuxConstants;
import com.termux.shared.termux.crash.TermuxCrashUtils;
import com.termux.shared.termux.settings.preferences.TermuxAppSharedPreferences;
import com.termux.shared.logger.Logger;
import com.termux.shared.termux.settings.properties.TermuxAppSharedProperties;
import com.termux.shared.termux.theme.TermuxThemeUtils;
import com.termux.shared.shell.LocalSocketListener;
import java.io.IOException;
public class TermuxApplication extends Application {
@@ -31,6 +34,20 @@ public class TermuxApplication extends Application {
// Set NightMode.APP_NIGHT_MODE
TermuxThemeUtils.setAppNightMode(properties.getNightMode());
try {
new LocalSocketListener(this, (args, out, err) -> {
try {
new Am(out, err, this).run(args);
return 0;
} catch (Exception e) {
return 1;
}
}, TermuxConstants.TERMUX_PACKAGE_NAME+"://call-am", 1000);
}
catch (IOException e) {
Logger.logDebug("TermuxApplication", "am socket already in use");
}
}
public static void setLogConfig(Context context) {