Bug 926997 - Eliminate toasts from Watcher service, bump version to 1.17; r=wlach
authorGeoff Brown <gbrown@mozilla.com>
Wed, 16 Oct 2013 13:47:47 -0600
changeset 164887 11c7c6810c730a28aceb31e9112b8797770c1fe9
parent 164886 77a86dcd14d8cda674e21f7796b19bcb127567fb
child 164888 e282e8a9712a1a1fb6034ed74d188a65c9acf8c9
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswlach
bugs926997
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 926997 - Eliminate toasts from Watcher service, bump version to 1.17; r=wlach
build/mobile/sutagent/android/watcher/RedirOutputThread.java
build/mobile/sutagent/android/watcher/WatcherService.java
--- a/build/mobile/sutagent/android/watcher/RedirOutputThread.java
+++ b/build/mobile/sutagent/android/watcher/RedirOutputThread.java
@@ -96,17 +96,16 @@ public class RedirOutputThread extends T
                             strOutput += sRep;
                         }
                     }
 
                 bStillRunning = (IsProcRunning(pProc) || (sutOut.available() > 0) || (sutErr.available() > 0));
                 }
             catch (IOException e)
                 {
-//                Toast.makeText(SUTAgentAndroid.me.getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
                 e.printStackTrace();
                 }
             }
 
         pProc.destroy();
         buffer = null;
         System.gc();
         }
--- a/build/mobile/sutagent/android/watcher/WatcherService.java
+++ b/build/mobile/sutagent/android/watcher/WatcherService.java
@@ -38,23 +38,21 @@ import android.content.pm.PackageManager
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.os.BatteryManager;
 import android.os.Debug;
 import android.os.IBinder;
 import android.os.PowerManager;
 import android.os.RemoteException;
 import android.provider.Settings;
 import android.util.Log;
-import android.view.Gravity;
-import android.widget.Toast;
 import android.os.Environment;
 
 public class WatcherService extends Service
 {
-    private final String prgVersion = "Watcher Version 1.16";
+    private final String prgVersion = "Watcher Version 1.17";
     private final String LOGTAG = "Watcher";
 
     String sErrorPrefix = "##Installer Error## ";
     String currentDir = "/";
     String sPingTarget = "";
     long lDelay = 60000;
     long lPeriod = 300000;
     int nMaxStrikes = 0; // maximum number of tries before we consider network unreachable (0 means don't check)
@@ -130,26 +128,26 @@ public class WatcherService extends Serv
         this.bStartSUTAgent = Boolean.parseBoolean(sHold.trim());
 
         sHold = GetIniData("watcher", "stayon", sIniFile,"0");
         int nStayOn = Integer.parseInt(sHold.trim());
         
         try {
             if (nStayOn != 0) {
                 if (!Settings.System.putInt(getContentResolver(), Settings.System.STAY_ON_WHILE_PLUGGED_IN, BatteryManager.BATTERY_PLUGGED_AC | BatteryManager.BATTERY_PLUGGED_USB)) {
-                    doToast("Screen couldn't be set to Always On [stay on while plugged in]");
+                    Log.e(LOGTAG, "Screen couldn't be set to Always On [stay on while plugged in]");
                 }
             }
         } catch (Exception e) {
             e.printStackTrace();
             String sExcept = e.getMessage();
-            doToast("Screen couldn't be set to Always On [exception " + sExcept + "]");
+            Log.e(LOGTAG, "Screen couldn't be set to Always On [exception " + sExcept + "]");
         }
 
-        doToast("WatcherService created");
+        Log.i(LOGTAG, "WatcherService created");
         }
 
     public String GetIniData(String sSection, String sKey, String sFile, String sDefault)
         {
         String sRet = sDefault;
         String sComp = "";
         String sLine = "";
         boolean bFound = false;
@@ -223,30 +221,30 @@ public class WatcherService extends Serv
                 Log.i(LOGTAG, "WatcherService updating " + sPkgName + " using file " + sPkgFile);
 
                 UpdateApplication worker = new UpdateApplication(sPkgName, sPkgFile, sOutFile, nReboot);
                 }
             else if (sCmd.equalsIgnoreCase("start"))
                 {
                 if (!this.bStartedTimer) 
                     {
-                    doToast("WatcherService started");
+                    Log.i(LOGTAG, "WatcherService started");
                     myTimer = new Timer();
                     Date startSchedule = new Date(System.currentTimeMillis() + lDelay);
                     myTimer.schedule(new MyTime(), startSchedule, lPeriod);
                     this.bStartedTimer = true;
                     }
                 }
             else
                 {
-                doToast("WatcherService unknown command");
+                Log.w(LOGTAG, "WatcherService unknown command");
                 }
             }
         else
-            doToast("WatcherService created");
+            Log.w(LOGTAG, "WatcherService intent had null command");
         }
 
     public void writeVersion() {
         PrintWriter pw = null;
         String appPath = getApplicationContext().getFilesDir().getAbsolutePath();
         String versionPath = appPath + "/version.txt";
         Log.i(LOGTAG, "writing version string to: " + versionPath);
         try {
@@ -275,17 +273,17 @@ public class WatcherService extends Serv
         writeVersion();
         handleCommand(intent);
         return START_STICKY;
     }
 
     @Override
     public void onDestroy() {
         super.onDestroy();
-        doToast("WatcherService destroyed");
+        Log.i(LOGTAG, "WatcherService destroyed");
         if (pwl != null)
             pwl.release();
         stopForegroundCompat(R.string.foreground_service_started);
     }
 
     @Override
     public void onLowMemory() {
         Log.e(LOGTAG, "onLowMemory");
@@ -442,24 +440,16 @@ public class WatcherService extends Serv
                 e.printStackTrace();
             } catch (InvocationTargetException e) {
                 Log.e(LOGTAG, "Unable to invoke setForeground", e);
                 e.printStackTrace();
             }
         }
     }
 
-    public void doToast(String sMsg)
-        {
-        Log.i(LOGTAG, sMsg);
-        Toast toast = Toast.makeText(this, sMsg, Toast.LENGTH_LONG);
-        toast.setGravity(Gravity.TOP|Gravity.CENTER_HORIZONTAL, 0, 100);
-        toast.show();
-        }
-
     public void CheckMem() 
         {
         System.gc();
         long lFreeMemory = Runtime.getRuntime().freeMemory();
         long lTotMemory = Runtime.getRuntime().totalMemory();
         long lMaxMemory = Runtime.getRuntime().maxMemory();
 
         Log.i(LOGTAG, "Free: " + lFreeMemory + "Total: " + lTotMemory + "Max: " + lMaxMemory);