зеркало из https://github.com/mozilla/pjs.git
Bug 753484 - Installation/uninstallation broken with SUTAgent on ICS;r=gbrown
This commit is contained in:
Родитель
eb1667618c
Коммит
64200a541f
|
@ -1327,7 +1327,6 @@ private void CancelNotification()
|
|||
{
|
||||
String sRet = sErrorPrefix + sDir + " does not exist";
|
||||
String tmpDir = fixFileName(sDir);
|
||||
String [] theArgs = new String [3];
|
||||
int nFiles = 0;
|
||||
|
||||
if (tmpDir.contains("org.mozilla.fennec") || tmpDir.contains("org.mozilla.firefox")) {
|
||||
|
@ -1365,11 +1364,7 @@ private void CancelNotification()
|
|||
}
|
||||
else {
|
||||
try {
|
||||
theArgs[0] = "su";
|
||||
theArgs[1] = "-c";
|
||||
theArgs[2] = "ls -l " + sDir;
|
||||
|
||||
pProc = Runtime.getRuntime().exec(theArgs);
|
||||
pProc = Runtime.getRuntime().exec(this.getSuArgs("ls -l " + sDir));
|
||||
RedirOutputThread outThrd = new RedirOutputThread(pProc, null);
|
||||
outThrd.start();
|
||||
outThrd.join(5000);
|
||||
|
@ -2335,35 +2330,30 @@ private void CancelNotification()
|
|||
public String SetADB(String sWhat) {
|
||||
String sRet = "";
|
||||
String sTmp = "";
|
||||
String [] theArgs = new String [3];
|
||||
|
||||
theArgs[0] = "su";
|
||||
theArgs[1] = "-c";
|
||||
String sCmd;
|
||||
|
||||
if (sWhat.contains("ip")) {
|
||||
theArgs[2] = "setprop service.adb.tcp.port 5555";
|
||||
sCmd = "setprop service.adb.tcp.port 5555";
|
||||
} else {
|
||||
theArgs[2] = "setprop service.adb.tcp.port -1";
|
||||
sCmd = "setprop service.adb.tcp.port -1";
|
||||
}
|
||||
|
||||
try {
|
||||
pProc = Runtime.getRuntime().exec(theArgs);
|
||||
pProc = Runtime.getRuntime().exec(this.getSuArgs(sCmd));
|
||||
RedirOutputThread outThrd = new RedirOutputThread(pProc, null);
|
||||
outThrd.start();
|
||||
outThrd.join(5000);
|
||||
sTmp = outThrd.strOutput;
|
||||
Log.e("ADB", sTmp);
|
||||
if (outThrd.nExitCode == 0) {
|
||||
theArgs[2] = "stop adbd";
|
||||
pProc = Runtime.getRuntime().exec(theArgs);
|
||||
pProc = Runtime.getRuntime().exec(this.getSuArgs("stop adbd"));
|
||||
outThrd = new RedirOutputThread(pProc, null);
|
||||
outThrd.start();
|
||||
outThrd.join(5000);
|
||||
sTmp = outThrd.strOutput;
|
||||
Log.e("ADB", sTmp);
|
||||
if (outThrd.nExitCode == 0) {
|
||||
theArgs[2] = "start adbd";
|
||||
pProc = Runtime.getRuntime().exec(theArgs);
|
||||
pProc = Runtime.getRuntime().exec(this.getSuArgs("start adbd"));
|
||||
outThrd = new RedirOutputThread(pProc, null);
|
||||
outThrd.start();
|
||||
outThrd.join(5000);
|
||||
|
@ -2397,11 +2387,7 @@ private void CancelNotification()
|
|||
public String KillProcess(String sProcName, OutputStream out)
|
||||
{
|
||||
String sTmp = "";
|
||||
String [] theArgs = new String [3];
|
||||
|
||||
theArgs[0] = "su";
|
||||
theArgs[1] = "-c";
|
||||
theArgs[2] = "kill";
|
||||
String sCmd = "kill";
|
||||
|
||||
String sRet = sErrorPrefix + "Unable to kill " + sProcName + "\n";
|
||||
ActivityManager aMgr = (ActivityManager) contextWrapper.getSystemService(Activity.ACTIVITY_SERVICE);
|
||||
|
@ -2422,11 +2408,11 @@ private void CancelNotification()
|
|||
nPID = lProcesses.get(lcv).pid;
|
||||
sRet = sErrorPrefix + "Failed to kill " + nPID + " " + strProcName + "\n";
|
||||
|
||||
theArgs[2] += " " + nPID;
|
||||
sCmd += " " + nPID;
|
||||
|
||||
try
|
||||
{
|
||||
pProc = Runtime.getRuntime().exec(theArgs);
|
||||
pProc = Runtime.getRuntime().exec(this.getSuArgs(sCmd));
|
||||
RedirOutputThread outThrd = new RedirOutputThread(pProc, null);
|
||||
outThrd.start();
|
||||
outThrd.join(15000);
|
||||
|
@ -2857,10 +2843,6 @@ private void CancelNotification()
|
|||
String sRet = "";
|
||||
String sM = "";
|
||||
String sMillis = "";
|
||||
String [] theArgs = new String [3];
|
||||
|
||||
theArgs[0] = "su";
|
||||
theArgs[1] = "-c";
|
||||
|
||||
if (((sDate != null) && (sTime != null)) &&
|
||||
(sDate.contains("/") || sDate.contains(".")) &&
|
||||
|
@ -2886,10 +2868,8 @@ private void CancelNotification()
|
|||
|
||||
// if we have an argument
|
||||
if (sMillis.length() > 0) {
|
||||
theArgs[2] = "date -u " + sMillis;
|
||||
|
||||
try {
|
||||
pProc = Runtime.getRuntime().exec(theArgs);
|
||||
pProc = Runtime.getRuntime().exec(this.getSuArgs("date -u " + sMillis));
|
||||
RedirOutputThread outThrd = new RedirOutputThread(pProc, null);
|
||||
outThrd.start();
|
||||
outThrd.join(10000);
|
||||
|
@ -3123,11 +3103,7 @@ private void CancelNotification()
|
|||
{
|
||||
String sRet = "";
|
||||
Context ctx = contextWrapper.getApplicationContext();
|
||||
String [] theArgs = new String [3];
|
||||
|
||||
theArgs[0] = "su";
|
||||
theArgs[1] = "-c";
|
||||
theArgs[2] = "reboot";
|
||||
try {
|
||||
if ((sCallBackIP != null) && (sCallBackPort != null) &&
|
||||
(sCallBackIP.length() > 0) && (sCallBackPort.length() > 0)) {
|
||||
|
@ -3150,7 +3126,7 @@ private void CancelNotification()
|
|||
// Tell all of the data channels we are rebooting
|
||||
((ASMozStub)this.contextWrapper).SendToDataChannel("Rebooting ...");
|
||||
|
||||
pProc = Runtime.getRuntime().exec(theArgs);
|
||||
pProc = Runtime.getRuntime().exec(this.getSuArgs("reboot"));
|
||||
RedirOutputThread outThrd = new RedirOutputThread(pProc, out);
|
||||
outThrd.start();
|
||||
outThrd.join(10000);
|
||||
|
@ -3164,18 +3140,24 @@ private void CancelNotification()
|
|||
return (sRet);
|
||||
}
|
||||
|
||||
private String [] getSuArgs(String cmdString)
|
||||
{
|
||||
String [] theArgs = new String [3];
|
||||
theArgs[0] = "su";
|
||||
theArgs[1] = "-c";
|
||||
// as a security measure, ICS and later resets LD_LIBRARY_PATH. reset
|
||||
// it here when executing the command
|
||||
theArgs[2] = "LD_LIBRARY_PATH=/vendor/lib:/system/lib " + cmdString;
|
||||
return theArgs;
|
||||
}
|
||||
|
||||
public String UnInstallApp(String sApp, OutputStream out)
|
||||
{
|
||||
String sRet = "";
|
||||
String [] theArgs = new String [3];
|
||||
|
||||
theArgs[0] = "su";
|
||||
theArgs[1] = "-c";
|
||||
theArgs[2] = "pm uninstall " + sApp + ";reboot;exit";
|
||||
|
||||
try
|
||||
{
|
||||
pProc = Runtime.getRuntime().exec(theArgs);
|
||||
pProc = Runtime.getRuntime().exec(this.getSuArgs("pm uninstall " + sApp + ";reboot;exit"));
|
||||
|
||||
RedirOutputThread outThrd = new RedirOutputThread(pProc, out);
|
||||
outThrd.start();
|
||||
|
@ -3205,13 +3187,8 @@ private void CancelNotification()
|
|||
public String InstallApp(String sApp, OutputStream out)
|
||||
{
|
||||
String sRet = "";
|
||||
String [] theArgs = new String [3];
|
||||
File srcFile = new File(sApp);
|
||||
|
||||
theArgs[0] = "su";
|
||||
theArgs[1] = "-c";
|
||||
theArgs[2] = "mv " + GetTmpDir() + "/" + srcFile.getName() + " /data/local/tmp/" + srcFile.getName() + ";exit";
|
||||
|
||||
sRet = CopyFile(sApp, GetTmpDir() + "/" + srcFile.getName());
|
||||
try {
|
||||
out.write(sRet.getBytes());
|
||||
|
@ -3224,7 +3201,10 @@ private void CancelNotification()
|
|||
|
||||
try
|
||||
{
|
||||
pProc = Runtime.getRuntime().exec(theArgs);
|
||||
pProc = Runtime.getRuntime().exec(this.getSuArgs("mv " + GetTmpDir() + "/" +
|
||||
srcFile.getName() +
|
||||
" /data/local/tmp/" +
|
||||
srcFile.getName() + ";exit"));
|
||||
|
||||
RedirOutputThread outThrd = new RedirOutputThread(pProc, out);
|
||||
outThrd.start();
|
||||
|
@ -3247,8 +3227,8 @@ private void CancelNotification()
|
|||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
theArgs[2] = "chmod 666 /data/local/tmp/" + srcFile.getName() + ";exit";
|
||||
pProc = Runtime.getRuntime().exec(theArgs);
|
||||
pProc = Runtime.getRuntime().exec(this.getSuArgs("chmod 666 /data/local/tmp/" +
|
||||
srcFile.getName() + ";exit"));
|
||||
RedirOutputThread outThrd2 = new RedirOutputThread(pProc, out);
|
||||
outThrd2.start();
|
||||
try {
|
||||
|
@ -3269,8 +3249,9 @@ private void CancelNotification()
|
|||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
theArgs[2] = "pm install -r /data/local/tmp/" + srcFile.getName() + " Cleanup" + ";exit";
|
||||
pProc = Runtime.getRuntime().exec(theArgs);
|
||||
pProc = Runtime.getRuntime().exec(this.getSuArgs("pm install -r /data/local/tmp/" +
|
||||
srcFile.getName() + " Cleanup" +
|
||||
";exit"));
|
||||
RedirOutputThread outThrd3 = new RedirOutputThread(pProc, out);
|
||||
outThrd3.start();
|
||||
try {
|
||||
|
@ -3291,8 +3272,8 @@ private void CancelNotification()
|
|||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
theArgs[2] = "rm /data/local/tmp/" + srcFile.getName() + ";exit";
|
||||
pProc = Runtime.getRuntime().exec(theArgs);
|
||||
pProc = Runtime.getRuntime().exec(this.getSuArgs("rm /data/local/tmp/" +
|
||||
srcFile.getName() + ";exit"));
|
||||
RedirOutputThread outThrd4 = new RedirOutputThread(pProc, out);
|
||||
outThrd4.start();
|
||||
try {
|
||||
|
|
Загрузка…
Ссылка в новой задаче