Bug 809364 - sutagent zeroconf is causing jmdns thread to spike cpu on panda boards. r=wlach DONTBUILD
authorJoel Maher <jmaher@mozilla.com>
Thu, 08 Nov 2012 07:32:58 -0500
changeset 112673 84b0991ccd9781f8231179dbc623e9a1bffe48e0
parent 112671 e0d7b394462b18bea7f70c5f6aa297800371d666
child 112674 e97f0b690380b0703715a6ac0b687e1618bdc838
push id23835
push userryanvm@gmail.com
push dateFri, 09 Nov 2012 00:52:02 +0000
treeherdermozilla-central@27ae6c86237f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswlach
bugs809364
milestone19.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 809364 - sutagent zeroconf is causing jmdns thread to spike cpu on panda boards. r=wlach DONTBUILD
build/mobile/sutagent/android/ASMozStub.java
--- a/build/mobile/sutagent/android/ASMozStub.java
+++ b/build/mobile/sutagent/android/ASMozStub.java
@@ -1,20 +1,21 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package com.mozilla.SUTAgentAndroid.service;
 
+import java.io.File;
+import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.InetAddress;
 import java.net.ServerSocket;
 import java.util.Timer;
-import java.io.IOException;
-import java.net.InetAddress;
 
 import com.mozilla.SUTAgentAndroid.SUTAgentAndroid;
 import com.mozilla.SUTAgentAndroid.R;
 
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.content.Context;
 import android.content.Intent;
@@ -34,16 +35,17 @@ public class ASMozStub extends android.a
 
     private ServerSocket cmdChnl = null;
     private ServerSocket dataChnl = null;
     private Handler handler = new Handler();
     RunCmdThread runCmdThrd = null;
     RunDataThread runDataThrd = null;
     Thread monitor = null;
     Timer timer = null;
+    boolean doZeroConfig = false;
 
     @SuppressWarnings("unchecked")
     private static final Class<?>[] mSetForegroundSignature = new Class[] {
     boolean.class};
     @SuppressWarnings("unchecked")
     private static final Class<?>[] mStartForegroundSignature = new Class[] {
         int.class, Notification.class};
     @SuppressWarnings("unchecked")
@@ -173,34 +175,46 @@ public class ASMozStub extends android.a
             runCmdThrd.start();
             doToast(String.format("Command channel port %d ...", COMMAND_PORT));
 
             dataChnl = new ServerSocket(DATA_PORT);
             runDataThrd = new RunDataThread(dataChnl, this);
             runDataThrd.start();
             doToast(String.format("Data channel port %d ...", DATA_PORT));
 
-            startZeroConf();
+            DoCommand tmpdc = new DoCommand(getApplication());
+            File dir = getFilesDir();
+            File iniFile = new File(dir, "SUTAgent.ini");
+            String sIniFile = iniFile.getAbsolutePath();
+            String zeroconf = tmpdc.GetIniData("General", "ZeroConfig", sIniFile);
+            if (zeroconf != "" && Integer.parseInt(zeroconf) == 1) {
+                this.doZeroConfig = true;
+            }
+
+            if (this.doZeroConfig) {
+                startZeroConf();
+            }
 
             Notification notification = new Notification();
             startForegroundCompat(R.string.foreground_service_started, notification);
             }
         catch (Exception e) {
             doToast(e.toString());
-//            Toast.makeText(getApplication().getApplicationContext(), e.toString(), Toast.LENGTH_LONG).show();
             }
 
         return;
         }
 
     public void onDestroy()
         {
         super.onDestroy();
 
-        stopZeroConf();
+        if (this.doZeroConfig) {
+            stopZeroConf();
+        }
 
         if (runCmdThrd.isAlive())
             {
             runCmdThrd.StopListening();
             }
 
         if (runDataThrd.isAlive())
             {