代码实现剔除系统应用

代码实现删除系统应用如题,程序是内置在手机里的,具有系统权限,现在想搞搞删除系统应用的功能目前有这个想

代码实现删除系统应用
如题,程序是内置在手机里的,具有系统权限,现在想搞搞删除系统应用的功能
目前有这个想法,和命令删除系统应用一样,先rm system/app/xxx.apk  然后使用uninstall卸载
不过试了下  发现删除apk没成功 那后续的也就没戏了 
有知道或者做过的大神么   注意是代码里执行的   android 系统应用
[解决办法]
你写的那个命令就是可以的,不过在rm system/app/xxx.apk 前要加一句“chmod 777 system/app/xxx.apk”即给该目录下的文件有读写权限,另外不需要再用uninstall了,删除系统应用的apk就已经卸载应用了,关于root权限问题,2L的回答应该是正解
[解决办法]

public class ScriptUtil {
    public static final String REMOVE_APP_LIMIT = "chmod 771 /data/app \n";
    public static final String ADD_APP_LIMIT = "chmod 551 /data/app \n";
    
public static final String TAG = "ScriptUtil";
/**
 * 输出信息接口的对象
 */
private ScriptHandler scriptHandler = null;
/**
 * Handler对象
 */
private Handler handler = null;
/**
 * 输入的命令
 */
private String strCommand = null;

/**
 * constructor
 * 
 * @param strCommand
 *            所执行的命令
 * @param scriptHandler
 *            输出信息接口对象
 */
public ScriptUtil(String strCommand, ScriptHandler scriptHandler) {
this.scriptHandler = scriptHandler;
this.strCommand = strCommand;
}

public ScriptUtil() {
// TODO Auto-generated constructor stub
}

/**
 * 关键方法:执行命令
 */
public void execCommand() {
handler = new Handler();
ShellCommandThread thread = new ShellCommandThread();
thread.start();
}

/**
 * 该线程进行io操作
 */
private class ShellCommandThread extends Thread {
/**
 * 进程对象
 */
private Process process = null;
/**
 * 正确信息缓冲流
 */
private BufferedReader brCorrect = null;
/**
 * 错误信息缓冲流
 */
private BufferedReader brError = null;

private DataOutputStream dos = null;
/**
 * 0:成功 非0:失败
 */
int code = -1;

@Override
public void run() {
try {
process = Runtime.getRuntime().exec("su");

dos = new DataOutputStream(process.getOutputStream());

dos.writeBytes(strCommand + " ");

brCorrect = new BufferedReader(new InputStreamReader(
process.getInputStream()));
brError = new BufferedReader(new InputStreamReader(
process.getErrorStream()));
String strTemp = new String();

dos.flush();

dos.close();

StringBuffer strTempCorrect = new StringBuffer();
StringBuffer strTempError = new StringBuffer();
while ((strTemp = brCorrect.readLine()) != null) {
strTempCorrect = strTempCorrect.append(strTemp + "\n");
}
strTemp = new String();
while ((strTemp = brError.readLine()) != null) {
strTempError = strTempError.append(strTemp + "\n");
}
code = process.waitFor();
Log.d(TAG, "code   :" + code);
Log.d(TAG, "strTempCorrect " + strTempCorrect.toString());
Log.e(TAG, "strTempError " + strTempError.toString());
handler.post(new ScriptRunnable(code,
strTempCorrect.toString(), strTempError.toString()));

} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
try {
if (brCorrect != null) {
brCorrect.close();
brCorrect = null;
}
if (brError != null) {
brError.close();
brError = null;
}
if (dos != null) {
dos.close();
dos = null;
}
if (process != null) {
process = null;
}

} catch (IOException e) {
e.printStackTrace();
}
}
}


}

private class ScriptRunnable implements Runnable {
private int resultCode;
private String strCorrect;
private String strError;

/**
 * constructor
 * 
 * @param resultCode
 *            待定
 * @param strCorrect
 *            正确操作的信息输出
 * @param strError
 *            错误操作的信息输出
 */
public ScriptRunnable(int resultCode, String strCorrect, String strError) {
this.resultCode = resultCode;
this.strCorrect = strCorrect;
this.strError = strError;
}

@Override
public void run() {
if ((strCorrect.equals("")) && (!strError.equals(""))
&& (resultCode != 0)) {
scriptHandler.onFailed(strError);
} else {
scriptHandler.onSuccess(strCorrect);
}
}
}

/**
 * 操作正确及错误信息的接口
 */
public interface ScriptHandler {

/**
 * 
 * @param succesMsg
 *            正确操作的输出信息
 */
void onSuccess(String strCorrect);

/**
 * 
 * @param failedMsg
 *            错误操作的输出信息
 */
void onFailed(String strError);

// void onTimeOut(String timeOutMsg);
}
}

[解决办法]
Process process = Runtime.getRuntime().exec(new String[] { "/system/xbin/su", "-c", cmdString });
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = null;
while((line = br.readLine()) != null){
    Log.i(TAG, line);
}

proc.getErrorStream()可以得到执行命令错误的讯息
[解决办法]

引用:
Quote: 引用:

http://blog.csdn.net/commonslok/article/details/8148810 

这个用处不大吧  系统应用权限都很高 重启什么的很简单


这个只是隐藏应用