Bug 786414 - unable to update sutagent on the panda boards. r=wlach DONTBUILD

This commit is contained in:
Joel Maher 2012-11-29 15:14:11 -05:00
parent 7c4e0bb92e
commit a0d9ea8da0
2 changed files with 19 additions and 121 deletions

View File

@ -107,7 +107,7 @@ public class DoCommand {
String ffxProvider = "org.mozilla.ffxcp";
String fenProvider = "org.mozilla.fencp";
private final String prgVersion = "SUTAgentAndroid Version 1.13";
private final String prgVersion = "SUTAgentAndroid Version 1.15";
public enum Command
{
@ -1335,7 +1335,6 @@ private void CancelNotification()
}
if (tmpFile.exists())
{
Log.i("CLINT", "tmpfile exists");
return("/data/local");
}
Log.e("SUTAgentAndroid", "ERROR: Cannot access world writeable test root");
@ -3253,69 +3252,9 @@ private void CancelNotification()
String sRet = "";
File srcFile = new File(sApp);
sRet = CopyFile(sApp, GetTmpDir() + "/" + srcFile.getName());
try {
out.write(sRet.getBytes());
out.flush();
}
catch (IOException e1)
{
e1.printStackTrace();
}
try
{
pProc = Runtime.getRuntime().exec(this.getSuArgs("mv " + GetTmpDir() + "/" +
srcFile.getName() +
" /data/local/tmp/" +
srcFile.getName() + ";exit"));
RedirOutputThread outThrd = new RedirOutputThread(pProc, out);
outThrd.start();
try {
outThrd.joinAndStopRedirect(90000);
int nRet = pProc.exitValue();
sRet = "\nmove complete [" + nRet + "]";
}
catch (IllegalThreadStateException itse) {
itse.printStackTrace();
sRet = "\nmove command timed out";
}
try
{
out.write(sRet.getBytes());
out.flush();
}
catch (IOException e1)
{
e1.printStackTrace();
}
pProc = Runtime.getRuntime().exec(this.getSuArgs("chmod 666 /data/local/tmp/" +
srcFile.getName() + ";exit"));
RedirOutputThread outThrd2 = new RedirOutputThread(pProc, out);
outThrd2.start();
try {
outThrd2.joinAndStopRedirect(10000);
int nRet2 = pProc.exitValue();
sRet = "\npermission change complete [" + nRet2 + "]\n";
}
catch (IllegalThreadStateException itse) {
itse.printStackTrace();
sRet = "\npermission change timed out";
}
try {
out.write(sRet.getBytes());
out.flush();
}
catch (IOException e1)
{
e1.printStackTrace();
}
pProc = Runtime.getRuntime().exec(this.getSuArgs("pm install -r /data/local/tmp/" +
srcFile.getName() + " Cleanup" +
";exit"));
pProc = Runtime.getRuntime().exec(this.getSuArgs("pm install -r " + sApp + " Cleanup;exit"));
RedirOutputThread outThrd3 = new RedirOutputThread(pProc, out);
outThrd3.start();
try {
@ -3335,29 +3274,6 @@ private void CancelNotification()
{
e1.printStackTrace();
}
pProc = Runtime.getRuntime().exec(this.getSuArgs("rm /data/local/tmp/" +
srcFile.getName() + ";exit"));
RedirOutputThread outThrd4 = new RedirOutputThread(pProc, out);
outThrd4.start();
try {
outThrd4.joinAndStopRedirect(60000);
int nRet4 = pProc.exitValue();
sRet = "\ntmp file removed [" + nRet4 + "]";
}
catch (IllegalThreadStateException itse) {
itse.printStackTrace();
sRet = "\nrm command timed out";
}
try {
out.write(sRet.getBytes());
out.flush();
}
catch (IOException e1)
{
e1.printStackTrace();
}
sRet = "\nSuccess";
}
catch (IOException e)
{

View File

@ -402,6 +402,7 @@ public class WatcherService extends Service
public void doToast(String sMsg)
{
Log.i("Watcher", sMsg);
Toast toast = Toast.makeText(this, sMsg, Toast.LENGTH_LONG);
toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 100);
toast.show();
@ -716,15 +717,9 @@ public class WatcherService extends Service
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 + ";exit";
try
{
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs("pm uninstall " + sApp + ";exit"));
RedirOutputThread outThrd = new RedirOutputThread(pProc, out);
outThrd.start();
@ -745,19 +740,24 @@ public class WatcherService extends Service
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 InstallApp(String sApp, OutputStream out)
{
String sRet = "";
String sHold = "";
String [] theArgs = new String [3];
theArgs[0] = "su";
theArgs[1] = "-c";
theArgs[2] = "pm install -r " + sApp + ";exit";
try
{
pProc = Runtime.getRuntime().exec(theArgs);
pProc = Runtime.getRuntime().exec(this.getSuArgs("pm install -r " + sApp + " Cleanup;exit"));
RedirOutputThread outThrd = new RedirOutputThread(pProc, out);
outThrd.start();
@ -976,7 +976,8 @@ public class WatcherService extends Service
}
}
if (bStartSUTAgent && !GetProcessInfo(sProgramName))
boolean isProc = GetProcessInfo(sProgramName);
if (bStartSUTAgent && !isProc)
{
Log.i("SUTAgentWatcher", "Starting SUTAgent from watcher code");
Intent agentIntent = new Intent();
@ -1014,26 +1015,7 @@ public class WatcherService extends Service
}
private void SendNotification(String tickerText, String expandedText) {
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
int icon = R.drawable.ateamlogo;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, tickerText, when);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;
// notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_LIGHTS;
Context context = getApplicationContext();
// Intent to launch an activity when the extended text is clicked
Intent intent = new Intent(this, WatcherService.class);
PendingIntent launchIntent = PendingIntent.getActivity(context, 0, intent, 0);
notification.setLatestEventInfo(context, tickerText, expandedText, launchIntent);
notificationManager.notify(NOTIFICATION_ID, notification);
Log.i("Watcher", expandedText);
}
private void CancelNotification() {