diff options
author | Jack Palevich <> | 2009-04-02 10:09:47 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-04-02 10:09:47 -0700 |
commit | 84d8d693bd79082069d1781284213030006841b7 (patch) | |
tree | 69eaca2362799a9e9c39726a836ce2ab58b98d68 | |
parent | ff51fe211d87fd97377f7ac1afb783ea154dba6e (diff) | |
download | frameworks_base-84d8d693bd79082069d1781284213030006841b7.zip frameworks_base-84d8d693bd79082069d1781284213030006841b7.tar.gz frameworks_base-84d8d693bd79082069d1781284213030006841b7.tar.bz2 |
AI 144129: Remove hidden class android.os.Exec.
Change BugReportService to use java.os.ProcessBuilder instead.
Remove unused import from DumpStateReceiver.
An earlier change list created a private copy of this class for Term.
BUG=1750582
Automated import of CL 144129
-rw-r--r-- | core/java/android/os/Exec.java | 63 | ||||
-rw-r--r-- | core/jni/Android.mk | 1 | ||||
-rw-r--r-- | core/jni/AndroidRuntime.cpp | 2 | ||||
-rw-r--r-- | core/jni/android_os_Exec.cpp | 215 |
4 files changed, 0 insertions, 281 deletions
diff --git a/core/java/android/os/Exec.java b/core/java/android/os/Exec.java deleted file mode 100644 index a50d5fe..0000000 --- a/core/java/android/os/Exec.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 android.os; - -import java.io.FileDescriptor; - -/** - * @hide - * Tools for executing commands. Not for public consumption. - */ - -public class Exec -{ - /** - * @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 - * @return the file descriptor of the started process. - * - */ - public static FileDescriptor createSubprocess( - String cmd, String arg0, String arg1) { - return createSubprocess(cmd, arg0, arg1, null); - } - - /** - * @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); - - 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); -} - diff --git a/core/jni/Android.mk b/core/jni/Android.mk index 18f2878..31b21e5 100644 --- a/core/jni/Android.mk +++ b/core/jni/Android.mk @@ -34,7 +34,6 @@ LOCAL_SRC_FILES:= \ android_text_AndroidCharacter.cpp \ android_text_KeyCharacterMap.cpp \ android_os_Debug.cpp \ - android_os_Exec.cpp \ android_os_FileUtils.cpp \ android_os_MemoryFile.cpp \ android_os_ParcelFileDescriptor.cpp \ diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 3c162fe..bd1011b 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -125,7 +125,6 @@ extern int register_android_os_Power(JNIEnv *env); extern int register_android_os_StatFs(JNIEnv *env); extern int register_android_os_SystemProperties(JNIEnv *env); extern int register_android_os_Hardware(JNIEnv* env); -extern int register_android_os_Exec(JNIEnv *env); extern int register_android_os_SystemClock(JNIEnv* env); extern int register_android_os_FileObserver(JNIEnv *env); extern int register_android_os_FileUtils(JNIEnv *env); @@ -1107,7 +1106,6 @@ static const RegJNIRec gRegJNI[] = { REG_JNI(register_android_database_SQLiteQuery), REG_JNI(register_android_database_SQLiteStatement), REG_JNI(register_android_os_Debug), - REG_JNI(register_android_os_Exec), REG_JNI(register_android_os_FileObserver), REG_JNI(register_android_os_FileUtils), REG_JNI(register_android_os_ParcelFileDescriptor), diff --git a/core/jni/android_os_Exec.cpp b/core/jni/android_os_Exec.cpp deleted file mode 100644 index ca5e695..0000000 --- a/core/jni/android_os_Exec.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - * 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 "JNIHelp.h" -#include "jni.h" -#include "utils/Log.h" -#include "utils/misc.h" -#include "android_runtime/AndroidRuntime.h" - -#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> - -namespace android -{ - -static jclass class_fileDescriptor; -static jfieldID field_fileDescriptor_descriptor; -static jmethodID method_fileDescriptor_init; - - -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){ - int pts; - - setsid(); - - pts = open(devname, O_RDWR); - if(pts < 0) exit(-1); - - dup2(pts, 0); - dup2(pts, 1); - dup2(pts, 2); - - close(ptm); - - 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 = String8(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 = String8(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 = String8(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 = jniGetFDFromFileDescriptor(env, fileDescriptor); - - 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 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} -}; - -int register_android_os_Exec(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 AndroidRuntime::registerNativeMethods( - env, "android/os/Exec", - method_table, NELEM(method_table)); -} - -}; |