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