Android Service Control Flow
<p>I'm new to Android development and I'm currently working on an Android service which has the following code:</p>

<pre><code>private void runLog() { 
    List&lt;ApplicationInfo&gt; list = getAppNames(); 
    Log.i("PackageInformation", "Number of applications: " +
            list.size());

    Process process = null; 
    try {

        if (mType == 0) { 
            process = Runtime.getRuntime().exec( "/system/bin/logcat -v         long -b " + mBuffer + " *:E");    
        } else if (mType == 1) { 
            process = Runtime.getRuntime().exec("dmesg -s 1000000"); 
        }

    } catch (IOException e) { 
        communicate(MSG_LOG_FAIL); 
    }

    BufferedReader reader = null; 
    StringBuffer errorLog = new StringBuffer(); 
    HashMap&lt;String, Boolean&gt; failedApps = new HashMap&lt;String, Boolean&gt;();

    try { reader = new BufferedReader(new InputStreamReader(    process.getInputStream()));

    String line;

    while((line = reader.readLine()) != null &amp;&amp; mLines &amp;lt;= MAX_LINES){ 
        errorLog.append(line);
        mLines++; 
    } 
    Log.i("LogcatInfo", String.valueOf(errorLog.length())); 
    Iterator&lt;ApplicationInfo&gt; itr = list.iterator();

    while (itr.hasNext()) { 
        String packageName = itr.next().name; // Pattern matching code here. 
        if(errorLog.indexOf(packageName.toString()) &gt;= 0) { 
            failedApps.put(packageName, true); 
        } 
    }

    Log.i("List of Failed Apps : ", failedApps.toString()); 
    Log.i("Logger", "Prepping thread for termination"); 
    reader.close();
    process.destroy(); 
    process = null; 
    reader = null; 
    mScrollback.removeAllElements(); 
    mScrollback = null; 
    mLines = 0; 
} catch (IOException e) { 
    communicate(MSG_READ_FAIL); 
}
 Log.d("Logger", "Exiting thread..."); 
 return; 
}
</code></pre>

<p>This method is being called by the Thread.run() method onBind() and for some reason, this code stops executing at the end of the first while loop. There are no exceptions thrown (I tried adding a try/catch block for Throwable and it didn't catch anything), the control doesn't flow past the point (I tried adding a dummy log statement which didn't get executed either) and the code doesn't execute starting at this line:</p>

<pre><code>Log.i("LogcatInfo", String.valueOf(errorLog.length()));
</code></pre>

<p>Am I missing something? Please advise. Thanks in advance for your help!</p>
