这是indexloc提供的服务,不要输入任何密码
Skip to content
Closed
Show file tree
Hide file tree
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
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
}

defaultConfig {
applicationId "com.termux"
applicationId "pl.sviete.dom"
minSdkVersion 21
targetSdkVersion 28
versionCode 75
Expand Down Expand Up @@ -45,8 +45,17 @@ android {
}
}


repositories {
maven { url "https://jitpack.io" }
mavenCentral()
jcenter()
}

dependencies {
testImplementation 'junit:junit:4.12'
implementation 'com.koushikdutta.async:androidasync:2.1.9'
implementation 'com.google.android.exoplayer:exoplayer-core:2.9.1'
}

task versionName {
Expand Down
25 changes: 24 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.termux"
android:installLocation="internalOnly"
android:sharedUserId="com.termux"
android:sharedUserId="pl.sviete.dom"
android:sharedUserLabel="@string/shared_user_label" >

<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
Expand All @@ -14,6 +14,14 @@
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>

<application
Expand Down Expand Up @@ -114,6 +122,21 @@
android:name="com.termux.app.TermuxService"
android:exported="false" />

<service android:name=".dom.DomAccessibilityService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:label="@string/accessibility_service_label">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" />
</service>
<service
android:name=".dom.FloatingViewService"
android:enabled="true"
android:exported="false">
</service>
<receiver android:name=".app.TermuxOpenReceiver" />

<provider android:authorities="com.termux.files"
Expand Down
Binary file added app/src/main/assets/bootstrap/bootstrap-arm.zip
Binary file not shown.
22 changes: 22 additions & 0 deletions app/src/main/java/com/termux/app/TermuxActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import android.widget.Toast;

import com.termux.R;
import com.termux.dom.FloatingViewService;
import com.termux.terminal.EmulatorDebug;
import com.termux.terminal.TerminalColors;
import com.termux.terminal.TerminalSession;
Expand Down Expand Up @@ -313,6 +314,27 @@ public void onPageSelected(int position) {
checkForFontAndColors();

mBellSoundId = mBellSoundPool.load(this, R.raw.bell, 1);

// ais-dom
// Delay the service start until the app comes to foreground - to the launcher activity's onCreate method.
Intent aisPanelService = new Intent(getApplicationContext(), com.termux.dom.AisPanelService.class);
startService(aisPanelService);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !Settings.canDrawOverlays(getApplicationContext())) {
//If the draw over permission is not available open the settings screen to grant the permission.
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
Uri.parse("package:" + getPackageName()));
int CODE_DRAW_OVER_OTHER_APP_PERMISSION = 2084;
startActivityForResult(intent, CODE_DRAW_OVER_OTHER_APP_PERMISSION);
} else {
Log.i(EmulatorDebug.LOG_TAG, "start FloatingViewService");
startService(new Intent(TermuxActivity.this, FloatingViewService.class));
// go back to home
Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);

}
}

void toggleShowExtraKeys() {
Expand Down
11 changes: 8 additions & 3 deletions app/src/main/java/com/termux/app/TermuxInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
Expand Down Expand Up @@ -82,8 +83,8 @@ public void run() {
final byte[] buffer = new byte[8096];
final List<Pair<String, String>> symlinks = new ArrayList<>(50);

final URL zipUrl = determineZipUrl();
try (ZipInputStream zipInput = new ZipInputStream(zipUrl.openStream())) {
InputStream inputStream = activity.getAssets().open("bootstrap/bootstrap-arm.zip");
try (ZipInputStream zipInput = new ZipInputStream(inputStream)) {
ZipEntry zipEntry;
while ((zipEntry = zipInput.getNextEntry()) != null) {
if (zipEntry.getName().equals("SYMLINKS.txt")) {
Expand Down Expand Up @@ -124,7 +125,11 @@ public void run() {
if (symlinks.isEmpty())
throw new RuntimeException("No SYMLINKS.txt encountered");
for (Pair<String, String> symlink : symlinks) {
Os.symlink(symlink.first, symlink.second);
try {
Os.symlink(symlink.first, symlink.second);
} catch(Exception e){
Log.e(EmulatorDebug.LOG_TAG, "symlink.first " + symlink.first + " symlink.second " + symlink.second);
}
}

if (!STAGING_PREFIX_FILE.renameTo(PREFIX_FILE)) {
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/com/termux/app/TermuxService.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@ public final class TermuxService extends Service implements SessionChangedCallba

/** Note that this is a symlink on the Android M preview. */
@SuppressLint("SdCardPath")
public static final String FILES_PATH = "/data/data/com.termux/files";
public static final String FILES_PATH = "/data/data/pl.sviete.dom/files";
public static final String PREFIX_PATH = FILES_PATH + "/usr";
public static final String HOME_PATH = FILES_PATH + "/home";

private static final int NOTIFICATION_ID = 1337;

private static final String ACTION_STOP_SERVICE = "com.termux.service_stop";
private static final String ACTION_LOCK_WAKE = "com.termux.service_wake_lock";
private static final String ACTION_UNLOCK_WAKE = "com.termux.service_wake_unlock";
public static final String ACTION_LOCK_WAKE = "com.termux.service_wake_lock";
public static final String ACTION_UNLOCK_WAKE = "com.termux.service_wake_unlock";
/** Intent action to launch a new terminal session. Executed from TermuxWidgetProvider. */
public static final String ACTION_EXECUTE = "com.termux.service_execute";

Expand Down
46 changes: 46 additions & 0 deletions app/src/main/java/com/termux/dom/AisCommandLog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.termux.dom;

import android.content.Context;
import android.util.Log;

/**
* Created by andrzej on 26.01.18.
*/


public class AisCommandLog {
public static final String TYPE_IN = "TYPE_IN";
public static final String TYPE_OUT = "TYPE_OUT";
public static final String TYPE_ERROR = "TYPE_ERROR";
public static final String TAG = AisCommandLog.class.getName();

public static void show(Context context, String text, String type) {
Log.i(TAG, "AisCommandLog -> show, type: " + type + ", text: " + text);

// TODO style the text
//Spannable spannable = new SpannableString(text);
//spannable.setSpan(new ForegroundColorSpan(Color.BLUE), 0, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);


// if (type == TYPE_IN) {
// BrowserActivity.chatTextSpeak.append("Ty: " + text +"\n");
// }
// else if (type == TYPE_OUT) {
// BrowserActivity.chatTextSpeak.append("Asystent: " +text +"\n");
// }
// else if (type == TYPE_ERROR) {
// BrowserActivity.chatTextSpeak.append("System: " +text +"\n");
// }
//
//
// // autoscroll
// final int scrollAmount = BrowserActivity.chatTextSpeak.getLayout().getLineTop(BrowserActivity.chatTextSpeak.getLineCount())
// - BrowserActivity.chatTextSpeak.getHeight();
// // if there is no need to scroll, scrollAmount will be <=0
// if (scrollAmount > 0)
// BrowserActivity.chatTextSpeak.scrollTo(0, scrollAmount);
// else
// BrowserActivity.chatTextSpeak.scrollTo(0, 0);

}
}
46 changes: 46 additions & 0 deletions app/src/main/java/com/termux/dom/AisCoreUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.termux.dom;

import java.io.File;

import static com.termux.app.TermuxService.HOME_PATH;

public class AisCoreUtils {
private static String AIS_DOM_URL = "http://192.168.1.54:8180";

// STT
public static final String BROADCAST_ON_START_SPEECH_TO_TEXT = "BROADCAST_ON_START_SPEECH_TO_TEXT";
public static final String BROADCAST_ON_END_SPEECH_TO_TEXT = "BROADCAST_ON_END_SPEECH_TO_TEXT";
public static final String BROADCAST_ON_SPEECH_TO_TEXT_ERROR = "BROADCAST_ON_SPEECH_TO_TEXT_ERROR";
public static final String SPEECH_TO_TEXT_ERROR_VALUE = "SPEECH_TO_TEXT_ERROR_VALUE";
public static final String BROADCAST_EVENT_ON_SPEECH_COMMAND = "BROADCAST_EVENT_ON_SPEECH_COMMAND";
public static final String BROADCAST_EVENT_ON_SPEECH_COMMAND_TEXT = "BROADCAST_EVENT_ON_SPEECH_COMMAND_TEXT";
//
// TTS
public static final String BROADCAST_ON_END_TEXT_TO_SPEECH = "BROADCAST_ON_END_TEXT_TO_SPEECH";
public static final String BROADCAST_ON_START_TEXT_TO_SPEECH = "BROADCAST_ON_START_TEXT_TO_SPEECH";
public static final String COMMAND_LOG_TEXT = "COMMAND_LOG_TEXT";
public static final String COMMAND_LOG_TYPE = "COMMAND_LOG_TYPE";

public static String getAisDomUrl(){
return AIS_DOM_URL;
}

public static Boolean getAppPreventSleep(){
return true;
}

public static boolean onBox() {
// default for box and phone
File conf = new File(HOME_PATH + "/AIS/configuration.yaml");
// during the first start on box only bootstrap exists
File bootstrap = new File("/data/data/pl.sviete.dom/files.tar.7z");
// during the first start on box the bootstrap can be on /sdcard
File sd_bootstrap = new File("/sdcard/files.tar.7z");
if (conf.exists() || bootstrap.exists() || sd_bootstrap.exists()) {
return true;
} else {
return false;
}

}
}
Loading