Tuesday, January 28, 2014

Android APK installation will ask for advice to / system / app approach


            
I find a lot of information, with the code to their APK install / system / app project testing needs, so that their service is not
kill off third-party softwareHere is 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 you
Reply:
Neighborhoods ah have puzzled for a long time
Hope someone pointing pointing thank you
Reply:
Nobody?

Reply:
adb shell ok then.


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

This can ah.
Reply:
reference to the third floor of the reply:
adb shell ok then.


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

This can ah.

Do you mean that
1. $ Adb push SecureSetting.apk / sdcard / / / upload files to install, to 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 be successful.
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 be achieved using cp, but generally not included in the command device. If you are using mv an error: failed on '/ sdcard / NetWork.apk' - Cross-device link.
6. # Mount-o remount, ro-t yaffs2 / dev/block/mtdblock3 / system / / restore partition properties, read-only.
7. # Exit
8. $ Exit
This right is not it?
Reply:
reference to the third floor of the reply:
adb shell ok then.


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

This can ah.

You mean
1. $ Adb push SecureSetting.apk / sdcard / / / upload files to install, to prepare for the installation.
This wrong?
Reply:
Mainly requires root privileges. . No root does not work
Reply:
references 6th Floor reply:
mainly requires root privileges. . No root does not work

With root privileges phone is that according to the Internet, but I do not know what went wrong it does not respond
Reply:
Well, I posted the code
 
package com.sfer.install;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.io.OutputStream;

public final class RootCmd {
/ / Execute linux commands and output
protected static String execRootCmd (String paramString) {
String result = "result:";
try {
Process localProcess = Runtime.getRuntime (). Exec ("su") ;/ / Root handled through the android system that is su command
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;
}
}

/ / Run linux command but does not care about the result output
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;
}
}

/ / Determine whether the machine Android root, that is, whether to obtain root privileges
protected static boolean haveRoot () {

int i = execRootCmdSilent ("echo test"); / / to detect
by executing the test commandif (i! = -1) {
return true;
}
return false;
}

}

Reply:
 
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, "Installation unsuccessful", Toast.LENGTH_LONG) show ();.
} Else {
Toast.makeText (this, "successful installation", Toast.LENGTH_LONG) show ();.
}
} Else {
. Toast.makeText (this, "without root privileges", Toast.LENGTH_LONG) show ();
}


}
}

Reply:
Your use adb shell line by line execution, which step wrong, Tieshanglai
Reply:
Find a reason in the code execution 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";

Reply:
But now I do not know whether this will succeed, I can only do the test on my phone
Interested parties can get to try to put the code in the code you want to install the APK name to his own need to install the APK into / sdcard what is the root of the problem exchange exchange
Reply:
The reply was deleted at the moderator 2012-08-13 11:30:52

Reply:
The reply was deleted at the moderator 2012-08-13 12:59:14

Reply:
reference to the 12th floor sfer520_1314 reply:
but now I do not know whether this will succeed, I can only do the test on my phone
Interested parties can get to try to put the code in the code you want to install the APK name to his own need to install the APK into / sdcard what is the root of the problem AC AC


My phone was unsuccessful. . You can add my QQ? 231599447
Reply:
LZ I successfully install apk to system / app, but the authority has not changed over the installation by the above code, apk permissions to rw -------
installedIf normal, it should be rw-r - r -, neighborhoods QQ: 263687542
Reply:
Apk successfully installed system / app and change the permissions under, but if the command is wrong, cause Runtime.getRuntime () exec (cmd);. Obstruction, now being addressed
Reply:
Upstairs, is how to solve?
Reply:
Does not have root privileges to push into it
Reply:
cited 19th floor shen332401890 reply:
without root privileges can not be pushed into it

Applications have root privileges, and now is how to copy itself in the past.
Reply:
/ System / bin / sh: cannot create / system / app / fruit.apk: Permission denied
Reply:
This post is good, my experiment has succeeded. Upstairs chmod 777 system

No comments:

Post a Comment