Import sources from code.google.com/p/androidterm

This commit is contained in:
Jack Palevich 2010-09-04 06:57:29 -07:00
parent 560cbf9d17
commit f45c3a228c
24 changed files with 4737 additions and 0 deletions

7
.gitignore vendored Normal file
View File

@ -0,0 +1,7 @@
bin/
gen/
libs/
obj/
.classpath
.project
.settings/

21
AndroidManifest.xml Normal file
View File

@ -0,0 +1,21 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jackpal.androidterm"
android:versionName="1.0.14" android:versionCode="15">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application android:icon="@drawable/app_terminal"
android:label="@string/application_terminal">
<activity android:name="Term"
android:theme="@style/Theme"
android:launchMode="singleInstance"
android:configChanges="keyboard|keyboardHidden|orientation"
android:windowSoftInputMode="adjustResize|stateVisible">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="TermPreferences"/>
</application>
<uses-sdk android:minSdkVersion="4" />
</manifest>

0
MODULE_LICENSE_APACHE2 Normal file
View File

190
NOTICE Normal file
View File

@ -0,0 +1,190 @@
Copyright (c) 2005-2008, The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

35
README.txt Normal file
View File

@ -0,0 +1,35 @@
This is an Android Terminal emulator. It enables you to access your Android
device's built-in command-line shell.
This terminal emulator emulates Digital Equipment Corporation VT-100 terminal
escape codes. It is designed to be used with command-line programs and
curses-based applications like vi, emacs, nethack, and dropbear ssh.
Features:
+ Connects to your Android device's built-in command-line shell.
+ Comprehensive VT100 terminal emulation.
+ Supports a range of font sizes
+ Supports several choices of text and background color.
+ 1000-line transcript buffer.
+ Can send transcript as an email message.
FAQ:
+ What can I do with this?
A you can run and control command-line applications on your Android device.
+ Why would I want to do that?
For fun! There are a wealth of Linux utility programs that can be made to work
on Android, and this terminal emulator provides a good way of interacting with
them.
+ Does this application give me "root" access?
No, it doesn't. It runs as an ordinary application, with no special access
rights.
+ How can I build this?
Build instructions can be found in the docs directory.

11
default.properties Normal file
View File

@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-4

68
docs/Building.txt Normal file
View File

@ -0,0 +1,68 @@
Obtain the Software Needed to Build Android Term
------------------------------------------------
Android is built using the Android SDK 1.6 or newer and the Android NDK r4 or newer.
You can downlaod them from:
http://developer.android.com/sdk
You will also need Eclipse 3.4 or newer, Java version, available from:
http://eclipse.org
After you install the SDK and the NDK, please build some of the samples that
come with the NDK in order to get a feel for using the SDK and the NDK.
Building Android Term
---------------------
There are three parts to building Android Term:
1) Build the shared library
2) Create the Eclipse Project for the Application
3) Build the Java apk.
Build the shared library:
cd <the-app-where-androidterm-is>
<path-to-the-android-ndk>/ndk-build
(Be sure to use the actual pathnames from your system. For example,
on my system I actually type the following:
cd ~/code/androidterm
../android-ndk-r4/ndk-build
This should chug away for a while and ultimately produce the file
libs/armeabi/libterm.so
Create the Eclipse project:
Start Eclipse
From the menu choose File : New Project
Choose Android:Android Project as a project type
Press Next
Set Project Name: AndroidTerm
Choose "Create project from existing source"
Browse to the location of the AndroidTerm source directory.
Make sure the "Android 1.6" Target Name is checked.
Make sure the Min SDK Version is 4
Press Finish
NOTE: When you Press Finish you may get the following error
Invalid project description.
<path-to-your-project> overlaps the location of another
project: '<project>'
This seems to be due to a bug in the Android SDK, where it
can't import projects that are located in the Eclipse "workspace"
directory. The work-around is to move the androidterm project
directory to a different location on your file system, so
that it is _not_ in the Eclipse "workspace" directory.
Build the Java apk:
This should happen automatically once you've created the Eclipse project.

32
jni/Android.mk Normal file
View File

@ -0,0 +1,32 @@
#
# Copyright (C) 2008 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This makefile supplies the rules for building a library of JNI code for
# use by our example of how to bundle a shared library with an APK.
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
# This is the target being built.
LOCAL_MODULE:= libandroidterm
# All of the source files that we will compile.
LOCAL_SRC_FILES:= \
termExec.cpp
LOCAL_LDLIBS := -ldl -llog
include $(BUILD_SHARED_LIBRARY)

350
jni/termExec.cpp Normal file
View File

@ -0,0 +1,350 @@
/*
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "Exec"
#include "jni.h"
#include <android/log.h>
#define LOGI(...) do { __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__); } while(0)
#define LOGW(...) do { __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__); } while(0)
#define LOGE(...) do { __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__); } while(0)
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <termios.h>
static jclass class_fileDescriptor;
static jfieldID field_fileDescriptor_descriptor;
static jmethodID method_fileDescriptor_init;
typedef unsigned short char16_t;
class String8 {
public:
String8() {
mString = 0;
}
~String8() {
if (mString) {
free(mString);
}
}
void set(const char16_t* o, size_t numChars) {
mString = (char*) malloc(numChars + 1);
for (size_t i = 0; i < numChars; i++) {
mString[i] = (char) o[i];
}
mString[numChars] = '\0';
}
const char* string() {
return mString;
}
private:
char* mString;
};
static int create_subprocess(const char *cmd, const char *arg0, const char *arg1,
int* pProcessId)
{
char *devname;
int ptm;
pid_t pid;
ptm = open("/dev/ptmx", O_RDWR); // | O_NOCTTY);
if(ptm < 0){
LOGE("[ cannot open /dev/ptmx - %s ]\n",strerror(errno));
return -1;
}
fcntl(ptm, F_SETFD, FD_CLOEXEC);
if(grantpt(ptm) || unlockpt(ptm) ||
((devname = (char*) ptsname(ptm)) == 0)){
LOGE("[ trouble with /dev/ptmx - %s ]\n", strerror(errno));
return -1;
}
pid = fork();
if(pid < 0) {
LOGE("- fork failed: %s -\n", strerror(errno));
return -1;
}
if(pid == 0){
close(ptm);
int pts;
setsid();
pts = open(devname, O_RDWR);
if(pts < 0) exit(-1);
dup2(pts, 0);
dup2(pts, 1);
dup2(pts, 2);
execl(cmd, cmd, arg0, arg1, NULL);
exit(-1);
} else {
*pProcessId = (int) pid;
return ptm;
}
}
static jobject android_os_Exec_createSubProcess(JNIEnv *env, jobject clazz,
jstring cmd, jstring arg0, jstring arg1, jintArray processIdArray)
{
const jchar* str = cmd ? env->GetStringCritical(cmd, 0) : 0;
String8 cmd_8;
if (str) {
cmd_8.set(str, env->GetStringLength(cmd));
env->ReleaseStringCritical(cmd, str);
}
str = arg0 ? env->GetStringCritical(arg0, 0) : 0;
const char* arg0Str = 0;
String8 arg0_8;
if (str) {
arg0_8.set(str, env->GetStringLength(arg0));
env->ReleaseStringCritical(arg0, str);
arg0Str = arg0_8.string();
}
str = arg1 ? env->GetStringCritical(arg1, 0) : 0;
const char* arg1Str = 0;
String8 arg1_8;
if (str) {
arg1_8.set(str, env->GetStringLength(arg1));
env->ReleaseStringCritical(arg1, str);
arg1Str = arg1_8.string();
}
int procId;
int ptm = create_subprocess(cmd_8.string(), arg0Str, arg1Str, &procId);
if (processIdArray) {
int procIdLen = env->GetArrayLength(processIdArray);
if (procIdLen > 0) {
jboolean isCopy;
int* pProcId = (int*) env->GetPrimitiveArrayCritical(processIdArray, &isCopy);
if (pProcId) {
*pProcId = procId;
env->ReleasePrimitiveArrayCritical(processIdArray, pProcId, 0);
}
}
}
jobject result = env->NewObject(class_fileDescriptor, method_fileDescriptor_init);
if (!result) {
LOGE("Couldn't create a FileDescriptor.");
}
else {
env->SetIntField(result, field_fileDescriptor_descriptor, ptm);
}
return result;
}
static void android_os_Exec_setPtyWindowSize(JNIEnv *env, jobject clazz,
jobject fileDescriptor, jint row, jint col, jint xpixel, jint ypixel)
{
int fd;
struct winsize sz;
fd = env->GetIntField(fileDescriptor, field_fileDescriptor_descriptor);
if (env->ExceptionOccurred() != NULL) {
return;
}
sz.ws_row = row;
sz.ws_col = col;
sz.ws_xpixel = xpixel;
sz.ws_ypixel = ypixel;
ioctl(fd, TIOCSWINSZ, &sz);
}
static int android_os_Exec_waitFor(JNIEnv *env, jobject clazz,
jint procId) {
int status;
waitpid(procId, &status, 0);
int result = 0;
if (WIFEXITED(status)) {
result = WEXITSTATUS(status);
}
return result;
}
static void android_os_Exec_close(JNIEnv *env, jobject clazz, jobject fileDescriptor)
{
int fd;
struct winsize sz;
fd = env->GetIntField(fileDescriptor, field_fileDescriptor_descriptor);
if (env->ExceptionOccurred() != NULL) {
return;
}
close(fd);
}
static int register_FileDescriptor(JNIEnv *env)
{
class_fileDescriptor = env->FindClass("java/io/FileDescriptor");
if (class_fileDescriptor == NULL) {
LOGE("Can't find java/io/FileDescriptor");
return -1;
}
field_fileDescriptor_descriptor = env->GetFieldID(class_fileDescriptor, "descriptor", "I");
if (field_fileDescriptor_descriptor == NULL) {
LOGE("Can't find FileDescriptor.descriptor");
return -1;
}
method_fileDescriptor_init = env->GetMethodID(class_fileDescriptor, "<init>", "()V");
if (method_fileDescriptor_init == NULL) {
LOGE("Can't find FileDescriptor.init");
return -1;
}
return 0;
}
static const char *classPathName = "jackpal/androidterm/Exec";
static JNINativeMethod method_table[] = {
{ "createSubprocess", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[I)Ljava/io/FileDescriptor;",
(void*) android_os_Exec_createSubProcess },
{ "setPtyWindowSize", "(Ljava/io/FileDescriptor;IIII)V",
(void*) android_os_Exec_setPtyWindowSize},
{ "waitFor", "(I)I",
(void*) android_os_Exec_waitFor},
{ "close", "(Ljava/io/FileDescriptor;)V",
(void*) android_os_Exec_close}
};
/*
* Register several native methods for one class.
*/
static int registerNativeMethods(JNIEnv* env, const char* className,
JNINativeMethod* gMethods, int numMethods)
{
jclass clazz;
clazz = env->FindClass(className);
if (clazz == NULL) {
LOGE("Native registration unable to find class '%s'", className);
return JNI_FALSE;
}
if (env->RegisterNatives(clazz, gMethods, numMethods) < 0) {
LOGE("RegisterNatives failed for '%s'", className);
return JNI_FALSE;
}
return JNI_TRUE;
}
/*
* Register native methods for all classes we know about.
*
* returns JNI_TRUE on success.
*/
static int registerNatives(JNIEnv* env)
{
if (!registerNativeMethods(env, classPathName, method_table,
sizeof(method_table) / sizeof(method_table[0]))) {
return JNI_FALSE;
}
return JNI_TRUE;
}
// ----------------------------------------------------------------------------
/*
* This is called by the VM when the shared library is first loaded.
*/
typedef union {
JNIEnv* env;
void* venv;
} UnionJNIEnvToVoid;
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
UnionJNIEnvToVoid uenv;
uenv.venv = NULL;
jint result = -1;
JNIEnv* env = NULL;
LOGI("JNI_OnLoad");
if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_4) != JNI_OK) {
LOGE("ERROR: GetEnv failed");
goto bail;
}
env = uenv.env;
if ((result = register_FileDescriptor(env)) < 0) {
LOGE("ERROR: registerFileDescriptor failed");
goto bail;
}
if (registerNatives(env) != JNI_TRUE) {
LOGE("ERROR: registerNatives failed");
goto bail;
}
result = JNI_VERSION_1_4;
bail:
return result;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
res/drawable-hdpi/atari_small.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 974 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1006 B

View File

@ -0,0 +1,11 @@
COMMENT Copyright (c) 1999, Thomas A. Fine
COMMENT
COMMENT License to copy, modify, and distribute for both commercial and
COMMENT non-commercial use is herby granted, provided this notice
COMMENT is preserved.
COMMENT
COMMENT Email to my last name at head.cfa.harvard.edu
COMMENT http://hea-www.harvard.edu/~fine/
COMMENT
COMMENT Produced with bdfedit, a tcl/tk font editing program
COMMENT written by Thomas A. Fine

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/* Copyright 2007, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<jackpal.androidterm.EmulatorView android:id="@+id/emulatorView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
/>
</LinearLayout>

29
res/menu/main.xml Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_preferences"
android:title="@string/preferences" />
<item android:id="@+id/menu_reset"
android:title="@string/reset" />
<item android:id="@+id/menu_send_email"
android:title="@string/send_email" />
<item android:id="@+id/menu_special_keys"
android:title="@string/special_keys" />
<item android:id="@+id/menu_toggle_soft_keyboard"
android:title="@string/toggle_soft_keyboard" />
</menu>

129
res/values/arrays.xml Normal file
View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<resources>
<string-array name="entries_statusbar_preference">
<item>Show status bar</item>
<item>Hide status bar</item>
</string-array>
<!-- Do not localize entryvalues -->
<string-array name="entryvalues_statusbar_preference">
<item>1</item>
<item>0</item>
</string-array>
<string-array name="entries_cursorblink_preference">
<item>Non-blinking cursor</item>
<item>Blinking cursor</item>
</string-array>
<!-- Do not localize entryvalues -->
<string-array name="entryvalues_cursorblink_preference">
<item>0</item>
<item>1</item>
</string-array>
<string-array name="entries_cursorstyle_preference">
<item>Rectangle</item>
<item>Underline</item>
<item>Vertical bar</item>
</string-array>
<!-- Do not localize entryvalues -->
<string-array name="entryvalues_cursorstyle_preference">
<item>0</item>
<item>1</item>
<item>2</item>
</string-array>
<string-array name="entries_fontsize_preference">
<item>4 x 8 pixels</item>
<item>6 pt</item>
<item>7 pt</item>
<item>8 pt</item>
<item>9 pt</item>
<item>10 pt</item>
<item>12 pt</item>
<item>14 pt</item>
<item>16 pt</item>
<item>20 pt</item>
</string-array>
<!-- Do not localize entryvalues -->
<string-array name="entryvalues_fontsize_preference">
<item>0</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>10</item>
<item>12</item>
<item>14</item>
<item>16</item>
<item>20</item>
</string-array>
<string-array name="entries_color_preference">
<item>Black text on white</item>
<item>White text on black</item>
<item>White text on blue</item>
<item>Green text on black</item>
<item>Amber text on black</item>
<item>Red text on black</item>
</string-array>
<!-- Do not localize entryvalues -->
<string-array name="entryvalues_color_preference">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
</string-array>
<string-array name="entries_controlkey_preference">
<item>Jog ball</item>
<item>\@ key</item>
<item>Left Alt key</item>
<item>Right Alt key</item>
<item>Vol Up key</item>
<item>Vol Down key</item>
</string-array>
<!-- Do not localize entryvalues -->
<string-array name="entryvalues_controlkey_preference">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
</string-array>
<string-array name="entries_ime_preference">
<item>Character-based</item>
<item>Word-based</item>
</string-array>
<!-- Do not localize entryvalues -->
<string-array name="entryvalues_ime_preference">
<item>0</item>
<item>1</item>
</string-array>
</resources>

22
res/values/attrs.xml Normal file
View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/* Copyright 2007, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources>
<declare-styleable name="EmulatorView">
</declare-styleable>
</resources>

83
res/values/strings.xml Normal file
View File

@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<resources>
<string name="application_terminal">Terminal Emulator</string>
<string name="preferences">Preferences</string>
<string name="reset">Reset term</string>
<string name="send_email">Email to</string>
<string name="special_keys">Special keys</string>
<string name="toggle_soft_keyboard">Toggle soft keyboard</string>
<string name="edit_text">Edit text</string>
<string name="copy_all">Copy all</string>
<string name="paste">Paste</string>
<!-- Preference dialog -->
<string name="screen_preferences">Screen</string>
<string name="title_statusbar_preference">Status bar</string>
<string name="summary_statusbar_preference">Show/hide status bar.</string>
<string name="dialog_title_statusbar_preference">Status bar</string>
<string name="title_cursorstyle_preference">Cursor style</string>
<string name="summary_cursorstyle_preference">Choose cursor style.</string>
<string name="dialog_title_cursorstyle_preference">Cursor style</string>
<string name="title_cursorblink_preference">Cursor blink</string>
<string name="summary_cursorblink_preference">Choose cursor blink.</string>
<string name="dialog_title_cursorblink_preference">Cursor blink</string>
<string name="text_preferences">Text</string>
<string name="title_fontsize_preference">Font size</string>
<string name="summary_fontsize_preference">Choose character height in points.</string>
<string name="dialog_title_fontsize_preference">Font size</string>
<string name="title_color_preference">Colors</string>
<string name="summary_color_preference">Choose text color.</string>
<string name="dialog_title_color_preference">Text color</string>
<string name="keyboard_preferences">Keyboard</string>
<string name="title_controlkey_preference">Control key</string>
<string name="summary_controlkey_preference">Choose control key.</string>
<string name="dialog_title_controlkey_preference">Control key</string>
<string name="title_ime_preference">Input method</string>
<string name="summary_ime_preference">Choose input method for soft keyboard.</string>
<string name="dialog_title_ime_preference">Input method</string>
<string name="shell_preferences">Shell</string>
<string name="title_shell_preference">Command line</string>
<string name="summary_shell_preference">Specify the shell command line.</string>
<string name="dialog_title_shell_preference">Shell</string>
<string name="title_initialcommand_preference">Initial command</string>
<string name="summary_initialcommand_preference">Sent to the shell when it starts.</string>
<string name="dialog_title_initialcommand_preference">Initial Command</string>
<!-- Don't localize these default values -->
<string name="default_value_statusbar_preference">0</string>
<string name="default_value_cursorstyle_preference">0</string>
<string name="default_value_cursorblink_preference">0</string>
<string name="default_value_fontsize_preference">10</string>
<string name="default_value_color_preference">2</string>
<string name="default_value_controlkey_preference">0</string>
<string name="default_value_ime_preference">0</string>
<string name="default_value_shell_preference">/system/bin/sh -</string>
<string name="default_value_initialcommand_preference">export PATH=/data/local/bin:$PATH</string>
</resources>

23
res/values/styles.xml Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2007 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<style name="Theme" parent="@android:style/Theme.Light">
<item name="android:windowNoTitle">true</item>
<item name="android:windowFrame">@null</item>
</style>
</resources>

117
res/xml/preferences.xml Normal file
View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2008 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/screen_preferences">
<ListPreference
android:key="statusbar"
android:defaultValue="@string/default_value_statusbar_preference"
android:title="@string/title_statusbar_preference"
android:summary="@string/summary_statusbar_preference"
android:entries="@array/entries_statusbar_preference"
android:entryValues="@array/entryvalues_statusbar_preference"
android:dialogTitle="@string/dialog_title_statusbar_preference" />
<!--
<ListPreference
android:key="cursorstyle"
android:defaultValue="@string/default_value_cursorstyle_preference"
android:title="@string/title_cursorstyle_preference"
android:summary="@string/summary_cursorstyle_preference"
android:entries="@array/entries_cursorstyle_preference"
android:entryValues="@array/entryvalues_cursorstyle_preference"
android:dialogTitle="@string/dialog_title_cursorstyle_preference" />
<ListPreference
android:key="cursorblink"
android:defaultValue="@string/default_value_cursorblink_preference"
android:title="@string/title_cursorblink_preference"
android:summary="@string/summary_cursorblink_preference"
android:entries="@array/entries_cursorblink_preference"
android:entryValues="@array/entryvalues_cursorblink_preference"
android:dialogTitle="@string/dialog_title_cursorblink_preference" />
-->
</PreferenceCategory>
<PreferenceCategory
android:title="@string/text_preferences">
<ListPreference
android:key="fontsize"
android:defaultValue="@string/default_value_fontsize_preference"
android:title="@string/title_fontsize_preference"
android:summary="@string/summary_fontsize_preference"
android:entries="@array/entries_fontsize_preference"
android:entryValues="@array/entryvalues_fontsize_preference"
android:dialogTitle="@string/dialog_title_fontsize_preference" />
<ListPreference
android:key="color"
android:defaultValue="@string/default_value_color_preference"
android:title="@string/title_color_preference"
android:summary="@string/summary_color_preference"
android:entries="@array/entries_color_preference"
android:entryValues="@array/entryvalues_color_preference"
android:dialogTitle="@string/dialog_title_color_preference" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/keyboard_preferences">
<ListPreference
android:key="controlkey"
android:defaultValue="@string/default_value_controlkey_preference"
android:title="@string/title_controlkey_preference"
android:summary="@string/summary_controlkey_preference"
android:entries="@array/entries_controlkey_preference"
android:entryValues="@array/entryvalues_controlkey_preference"
android:dialogTitle="@string/dialog_title_controlkey_preference" />
<ListPreference
android:key="ime"
android:defaultValue="@string/default_value_ime_preference"
android:title="@string/title_ime_preference"
android:summary="@string/summary_ime_preference"
android:entries="@array/entries_ime_preference"
android:entryValues="@array/entryvalues_ime_preference"
android:dialogTitle="@string/dialog_title_ime_preference" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/shell_preferences">
<EditTextPreference
android:key="shell"
android:defaultValue="@string/default_value_shell_preference"
android:title="@string/title_shell_preference"
android:summary="@string/summary_shell_preference"
android:dialogTitle="@string/dialog_title_shell_preference" />
<EditTextPreference
android:key="initialcommand"
android:defaultValue="@string/default_value_initialcommand_preference"
android:title="@string/title_initialcommand_preference"
android:summary="@string/summary_initialcommand_preference"
android:dialogTitle="@string/dialog_title_initialcommand_preference" />
</PreferenceCategory>
</PreferenceScreen>

View File

@ -0,0 +1,75 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jackpal.androidterm;
import java.io.FileDescriptor;
/**
* Utility methods for creating and managing a subprocess.
* <p>
* Note: The native methods access a package-private
* java.io.FileDescriptor field to get and set the raw Linux
* file descriptor. This might break if the implementation of
* java.io.FileDescriptor is changed.
*/
public class Exec
{
static {
System.loadLibrary("androidterm");
}
/**
* Create a subprocess. Differs from java.lang.ProcessBuilder in
* that a pty is used to communicate with the subprocess.
* <p>
* Callers are responsible for calling Exec.close() on the returned
* file descriptor.
*
* @param cmd The command to execute
* @param arg0 The first argument to the command, may be null
* @param arg1 the second argument to the command, may be null
* @param processId A one-element array to which the process ID of the
* started process will be written.
* @return the file descriptor of the started process.
*
*/
public static native FileDescriptor createSubprocess(
String cmd, String arg0, String arg1, int[] processId);
/**
* Set the widow size for a given pty. Allows programs
* connected to the pty learn how large their screen is.
*/
public static native void setPtyWindowSize(FileDescriptor fd,
int row, int col, int xpixel, int ypixel);
/**
* Causes the calling thread to wait for the process associated with the
* receiver to finish executing.
*
* @return The exit value of the Process being waited on
*
*/
public static native int waitFor(int processId);
/**
* Close a given file descriptor.
*/
public static native void close(FileDescriptor fd);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jackpal.androidterm;
import android.os.Bundle;
import android.preference.PreferenceActivity;
public class TermPreferences extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
}
}