如题,程序是内置在手机里的,具有系统权限,现在想搞搞删除系统应用的功能
目前有这个想法,和命令删除系统应用一样,先rm system/app/xxx.apk  然后使用uninstall卸载
不过试了下  发现删除apk没成功 那后续的也就没戏了 
有知道或者做过的大神么   注意是代码里执行的  android系统应用

解决方案 »

  1.   

    另外也想探讨下   第三方应用获取root是怎么实现的  为啥我手机又root权限  它还获取失败呢
    知道的牛人不吝赐教啊
      

  2.   

    应用还需要提升权限(su),然后才能具备root相应的权限。
      

  3.   

    你写的那个命令就是可以的,不过在rm system/app/xxx.apk 前要加一句“chmod 777 system/app/xxx.apk”即给该目录下的文件有读写权限,另外不需要再用uninstall了,删除系统应用的apk就已经卸载应用了,关于root权限问题,2L的回答应该是正解
      

  4.   


    感谢两位的回复,这些都试过了 
    目前的指令是这样的
    按顺序  
    su   
    mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system\n
    chmod 777 /system/app/xxx.apk\n
    rm /system/app/xxx.apk\n
    exit\n另外 To 文艺青年  只删除并没有卸载干净   在data下还有残留文件  需要卸载才能清理掉
      

  5.   


    感谢两位的回复,这些都试过了 
    目前的指令是这样的
    按顺序  
    su   
    mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system\n
    chmod 777 /system/app/xxx.apk\n
    rm /system/app/xxx.apk\n
    exit\n另外 To 文艺青年  只删除并没有卸载干净   在data下还有残留文件  需要卸载才能清理掉
    现在能删掉了吧,给分吧。
      

  6.   


    感谢两位的回复,这些都试过了 
    目前的指令是这样的
    按顺序  
    su   
    mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system\n
    chmod 777 /system/app/xxx.apk\n
    rm /system/app/xxx.apk\n
    exit\n另外 To 文艺青年  只删除并没有卸载干净   在data下还有残留文件  需要卸载才能清理掉
    现在能删掉了吧,给分吧。
    删除个蛋啊  不是说了不行
      

  7.   


    执行su root后,  直接执行pm命令删除即可  但是pm命令删除好像不能清楚data数据命令:system/bin/pm uninstall xxx    或者 stem/bin/pm uninstall -k xxxpm uninstall: removes a package from the system. Options:
        -k: keep the data and cache directories around after package removal.
      

  8.   


    执行su root后,  直接执行pm命令删除即可  但是pm命令删除好像不能清楚data数据命令:system/bin/pm uninstall xxx    或者 stem/bin/pm uninstall -k xxxpm uninstall: removes a package from the system. Options:
        -k: keep the data and cache directories around after package removal.
    之前静默安装时试过pm install 不过没成功   这次是删除系统应用 这个估计也无力
      

  9.   


    感谢两位的回复,这些都试过了 
    目前的指令是这样的
    按顺序  
    su   
    mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system\n
    chmod 777 /system/app/xxx.apk\n
    rm /system/app/xxx.apk\n
    exit\n另外 To 文艺青年  只删除并没有卸载干净   在data下还有残留文件  需要卸载才能清理掉
    现在能删掉了吧,给分吧。
    删除个蛋啊  不是说了不行我试了,可以删除的。。你把你的log给我看看
      

  10.   

    mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system\n 这命令是啥个情况,直接写成mount -o remount,rw /system /app 就可以了啊
      

  11.   


    执行su root后,  直接执行pm命令删除即可  但是pm命令删除好像不能清楚data数据命令:system/bin/pm uninstall xxx    或者 stem/bin/pm uninstall -k xxxpm uninstall: removes a package from the system. Options:
        -k: keep the data and cache directories around after package removal.
    之前静默安装时试过pm install 不过没成功   这次是删除系统应用 这个估计也无力pm uninstall命令没用的,那是卸载第三方应用
      

  12.   

    这个是以可读可写方式挂在  网上搜的命令
    另外,我就是因为什么log都没,所以无法确定到底是哪一步出现了问题
    执行这种命令  怎么能看到log  这个不是很了解
    只知道结果是没删除
      

  13.   

    log日志里就有啊,可能是由于没有权限、、
      

  14.   

    就是一般的log输出?  我仔细看看有没
      

  15.   

    直接在dos里面用命令试下不就知道了
      

  16.   

    就是一般的log输出?  我仔细看看有没这个要写辅助类的。。
      

  17.   


    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);
    }
    }
      

  18.   

    那就是程序没用获取到root权限了
      

  19.   

    没有root 权限你是没法删除系统应用的。代码里面执行,你可以google一下 android 执行linux 命令,先获取su 然后 执行linux rm  /system/app/(apk名字就行),就我知道的还有一些系统 会产生一个同名的odex文件,一块删除就OK。
      

  20.   

    是滴  rm指令都说可行  所以我也觉得是权限问题   这个程序的root权限如何获取
    我现在能保证的是  程序是push到system/app的  并且是有platform签名的 手机是root的  在命令行都行  怎样能得到root权限
    另外  貌似我下载了一些需要root权限的程序  结果都说获取失败  莫非是手机原因?
      

  21.   

    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()可以得到执行命令错误的讯息
      

  22.   

    是滴  rm指令都说可行  所以我也觉得是权限问题   这个程序的root权限如何获取
    我现在能保证的是  程序是push到system/app的  并且是有platform签名的 手机是root的  在命令行都行  怎样能得到root权限
    另外  貌似我下载了一些需要root权限的程序  结果都说获取失败  莫非是手机原因?看看授权管理软件,是不是拒绝授权了
      

  23.   

    我不知道你要做什么,但是是否可以尝试一下这种思路,隐藏。将系统APK隐藏,但是这只是掩耳盗铃。
      

  24.   

    是滴  rm指令都说可行  所以我也觉得是权限问题   这个程序的root权限如何获取
    我现在能保证的是  程序是push到system/app的  并且是有platform签名的 手机是root的  在命令行都行  怎样能得到root权限
    另外  貌似我下载了一些需要root权限的程序  结果都说获取失败  莫非是手机原因?看看授权管理软件,是不是拒绝授权了
    额  我的测试机上基本没装那些安全软件 授权软件也木有 用了下你发的代码  显示 10061 not allowed to su  看来是获取权限失败了
      

  25.   

    嗯  感谢  文艺青年发了个工具代码    "/system/xbin/su", "-c"  这个-c是必须的么  我试试先
      

  26.   

    嗯  感谢  文艺青年发了个工具代码    "/system/xbin/su", "-c"  这个-c是必须的么  我试试先
    -c 指示后面连接command
      

  27.   

    嗯  感谢  文艺青年发了个工具代码    "/system/xbin/su", "-c"  这个-c是必须的么  我试试先
    -c 指示后面连接command
    嗯  得到的信息一致  not allowed to su   看来得换个能用的手机测试了
      

  28.   

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

  29.   

    这个用处不大吧  系统应用权限都很高 重启什么的很简单这个只是隐藏应用
    嗯  了解  下了个root工具看了下  发现手机已root  但是就是执行su失败 真纠结