2013年8月6日星期二

Neighborhoods Android will install APK / system / app method

I find a lot of information to code your own APK installed into / system / app project testing needs, so that their service is not kill off third-party software
Here's an article http://chongye89.iteye.com/blog/1412488
I tried, but no response do not know what areas need attention
hope expert guidance or what better way to achieve the effect I want
Thank
------ Solution ---------------------------------- ----------
adb shell ok then.


Direct 1, adb remount
2, adb push XXX.apk (absolute path) / system / app

This can ah.
------ Solution ---------------------------------------- ----
mainly requires root privileges. . No root impossible
------ Solution ------------------------------------ --------
you line by line using adb shell execution, which step was wrong, Tieshanglai
------ For reference only ---------- -----------------------------
neighborhoods ah have puzzled for a long time Hope someone pointing pointing
Thank
------ For reference only ----------------------- ----------------
Nobody?

------ For reference only ---------------------------------- -----

you mean that
1. $ adb push SecureSetting.apk / sdcard / / / upload files to install, prepare for the installation.
2. $ adb shell
3. $ su / / switch to the root user. If you do not get Root privileges, this step will not succeed.
4. # mount-o remount, rw-t yaffs2 / dev/block/mtdblock3 / system / / make partition writable.
5. # cat / sdcard / SecureSetting.apk> / system / app / SecureSetting.apk / / This step can use cp ; implementation, but generally not included in the command device. If you use the mv error occurs: failed on '/ sdcard / NetWork.apk' - Cross-device link.
6. # mount-o remount, ro-t yaffs2 / dev/block/mtdblock3 / system / / restore partition properties, only read.
7. # exit
8. $ exit
This right is not it?
------ For reference only -------------------------------------- -

you mean
1. $ adb push SecureSetting.apk / sdcard / / / upload files to install, prepare for the installation.
this wrong?
------ For reference only -------------------------------------- -

root privileges phone is there but I did not do it according to the online response that does not know what went wrong
------ For reference only ---- -----------------------------------
Well I put code stickers

package com.sfer.install;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public final class RootCmd {
// 执行linux命令并且输出结果
protected static String execRootCmd(String paramString) {
String result = "result : ";
try {
Process localProcess = Runtime.getRuntime().exec("su ");// 经过Root处理的android系统即有su命令
OutputStream localOutputStream = localProcess.getOutputStream();
DataOutputStream localDataOutputStream = new DataOutputStream(
localOutputStream);
InputStream localInputStream = localProcess.getInputStream();
DataInputStream localDataInputStream = new DataInputStream(
localInputStream);
String str1 = String.valueOf(paramString);
String str2 = str1 + "\n";
localDataOutputStream.writeBytes(str2);
localDataOutputStream.flush();
String str3 = null;
// while ((str3 = localDataInputStream.readLine()) != null) {
// Log.d("result", str3);
// }
localDataOutputStream.writeBytes("exit\n");
localDataOutputStream.flush();
localProcess.waitFor();
return result;
} catch (Exception localException) {
localException.printStackTrace();
return result;
}
}

// 执行linux命令但不关注结果输出
protected static int execRootCmdSilent(String paramString) {
try {
Process localProcess = Runtime.getRuntime().exec("su");
Object localObject = localProcess.getOutputStream();
DataOutputStream localDataOutputStream = new DataOutputStream(
(OutputStream) localObject);
String str = String.valueOf(paramString);
localObject = str + "\n";
localDataOutputStream.writeBytes((String) localObject);
localDataOutputStream.flush();
localDataOutputStream.writeBytes("exit\n");
localDataOutputStream.flush();
localProcess.waitFor();
int result = localProcess.exitValue();
return (Integer) result;
} catch (Exception localException) {
localException.printStackTrace();
return -1;
}
}

// 判断机器Android是否已经root,即是否获取root权限
protected static boolean haveRoot() {

int i = execRootCmdSilent("echo test"); // 通过执行测试命令来检测
if (i != -1) {
return true;
}
return false;
}

}

------ For reference only ----------------------------------- ----

package com.sfer.install;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class InstallActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        String paramString= "$ adb push MySMS.apk /sdcard/" +"\n"+
        "$ adb shell" +"\n"+
        "$ su" +"\n"+
        "# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system" +"\n"+
        "# cat /sdcard/MySMS.apk > /system/app/MySMS.apk" +"\n"+
        "# mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system" +"\n"+
        "# exit" +"\n"+
        "$ exit";       
        if(RootCmd.haveRoot()){
        if(RootCmd.execRootCmdSilent(paramString)==-1){
            Toast.makeText(this, "安装不成功", Toast.LENGTH_LONG).show();
            }else{
            Toast.makeText(this, "安装成功", Toast.LENGTH_LONG).show();
            }
        }else{
        Toast.makeText(this, "没有root权限", Toast.LENGTH_LONG).show();
        }
       
       
    }
}

------ For reference only ---------------------------- -----------
find the reasons for the implementation in the code to be changed so that the string on the line

String paramString= "adb push MySMS.apk /system/app" +"\n"+
        "adb shell" +"\n"+
        "su" +"\n"+
        "mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system" +"\n"+
        "cat /sdcard/MySMS.apk > /system/app/MySMS.apk" +"\n"+
        "mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 /system" +"\n"+
        "exit" +"\n"+
        "exit";

------ For reference only ----------------------------------- ----
but now I do not know whether this will succeed I can only do the test on my phone
are interested can get the code to try to put the code you want to install the APK name to own the need to install APK into / sdcard What is the root of the problem AC AC
------ For reference only --------------------------- ------------
  This reply was moderator deleted at 2012-08-13 11:30:52

------ For reference only ---------------------------------- -----
  This reply was moderator deleted at 2012-08-13 12:59:14

------ For reference only ---------------------------------- -----


my phone was unsuccessful. . You can add my QQ? 231599447
------ For reference only ------------------------------------- -
LZ I successfully install apk system / app, but the authority has not changed over the above code is installed, install the apk permissions rw -------
If normal, it should be rw-r - r -, neighborhoods QQ: 263687542
------ For reference only ---------------- -----------------------
successfully apk installed system / app and change the permissions down, but if the command is wrong, cause Runtime.getRuntime (). exec (cmd); obstruction, is now being addressed
------ For reference only ------------------------- --------------
upstairs, is how to solve?
------ For reference only -------------------------------------- -
without root privileges can not be pushed into it

没有评论:

发表评论