Switch the services library to using the new Slog

This commit is contained in:
Joe Onorato
2010-02-26 18:56:32 -08:00
parent 6eec2a8bf5
commit f7791634a2

View File

@@ -21,7 +21,7 @@ import android.net.LocalSocket;
import android.os.Environment; import android.os.Environment;
import android.os.SystemClock; import android.os.SystemClock;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.util.Log; import android.util.Slog;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@@ -80,7 +80,7 @@ final class NativeDaemonConnector implements Runnable {
try { try {
listenToSocket(); listenToSocket();
} catch (Exception e) { } catch (Exception e) {
Log.e(TAG, "Error in NativeDaemonConnector", e); Slog.e(TAG, "Error in NativeDaemonConnector", e);
SystemClock.sleep(5000); SystemClock.sleep(5000);
} }
} }
@@ -110,7 +110,7 @@ final class NativeDaemonConnector implements Runnable {
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
if (buffer[i] == 0) { if (buffer[i] == 0) {
String event = new String(buffer, start, i - start); String event = new String(buffer, start, i - start);
if (LOCAL_LOGD) Log.d(TAG, String.format("RCV <- {%s}", event)); if (LOCAL_LOGD) Slog.d(TAG, String.format("RCV <- {%s}", event));
String[] tokens = event.split(" "); String[] tokens = event.split(" ");
try { try {
@@ -119,29 +119,29 @@ final class NativeDaemonConnector implements Runnable {
if (code >= ResponseCode.UnsolicitedInformational) { if (code >= ResponseCode.UnsolicitedInformational) {
try { try {
if (!mCallbacks.onEvent(code, event, tokens)) { if (!mCallbacks.onEvent(code, event, tokens)) {
Log.w(TAG, String.format( Slog.w(TAG, String.format(
"Unhandled event (%s)", event)); "Unhandled event (%s)", event));
} }
} catch (Exception ex) { } catch (Exception ex) {
Log.e(TAG, String.format( Slog.e(TAG, String.format(
"Error handling '%s'", event), ex); "Error handling '%s'", event), ex);
} }
} else { } else {
try { try {
mResponseQueue.put(event); mResponseQueue.put(event);
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Log.e(TAG, "Failed to put response onto queue", ex); Slog.e(TAG, "Failed to put response onto queue", ex);
} }
} }
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
Log.w(TAG, String.format("Bad msg (%s)", event)); Slog.w(TAG, String.format("Bad msg (%s)", event));
} }
start = i + 1; start = i + 1;
} }
} }
} }
} catch (IOException ex) { } catch (IOException ex) {
Log.e(TAG, "Communications error", ex); Slog.e(TAG, "Communications error", ex);
throw ex; throw ex;
} finally { } finally {
synchronized (this) { synchronized (this) {
@@ -149,7 +149,7 @@ final class NativeDaemonConnector implements Runnable {
try { try {
mOutputStream.close(); mOutputStream.close();
} catch (IOException e) { } catch (IOException e) {
Log.w(TAG, "Failed closing output stream", e); Slog.w(TAG, "Failed closing output stream", e);
} }
mOutputStream = null; mOutputStream = null;
} }
@@ -160,7 +160,7 @@ final class NativeDaemonConnector implements Runnable {
socket.close(); socket.close();
} }
} catch (IOException ex) { } catch (IOException ex) {
Log.w(TAG, "Failed closing socket", ex); Slog.w(TAG, "Failed closing socket", ex);
} }
} }
} }
@@ -177,9 +177,9 @@ final class NativeDaemonConnector implements Runnable {
*/ */
private void sendCommand(String command, String argument) { private void sendCommand(String command, String argument) {
synchronized (this) { synchronized (this) {
if (LOCAL_LOGD) Log.d(TAG, String.format("SND -> {%s} {%s}", command, argument)); if (LOCAL_LOGD) Slog.d(TAG, String.format("SND -> {%s} {%s}", command, argument));
if (mOutputStream == null) { if (mOutputStream == null) {
Log.e(TAG, "No connection to daemon", new IllegalStateException()); Slog.e(TAG, "No connection to daemon", new IllegalStateException());
} else { } else {
StringBuilder builder = new StringBuilder(command); StringBuilder builder = new StringBuilder(command);
if (argument != null) { if (argument != null) {
@@ -190,7 +190,7 @@ final class NativeDaemonConnector implements Runnable {
try { try {
mOutputStream.write(builder.toString().getBytes()); mOutputStream.write(builder.toString().getBytes());
} catch (IOException ex) { } catch (IOException ex) {
Log.e(TAG, "IOException in sendCommand", ex); Slog.e(TAG, "IOException in sendCommand", ex);
} }
} }
} }
@@ -210,7 +210,7 @@ final class NativeDaemonConnector implements Runnable {
while (!complete) { while (!complete) {
try { try {
String line = mResponseQueue.take(); String line = mResponseQueue.take();
if (LOCAL_LOGD) Log.d(TAG, String.format("RSP <- {%s}", line)); if (LOCAL_LOGD) Slog.d(TAG, String.format("RSP <- {%s}", line));
String[] tokens = line.split(" "); String[] tokens = line.split(" ");
try { try {
code = Integer.parseInt(tokens[0]); code = Integer.parseInt(tokens[0]);
@@ -224,7 +224,7 @@ final class NativeDaemonConnector implements Runnable {
} }
response.add(line); response.add(line);
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Log.e(TAG, "Failed to process response", ex); Slog.e(TAG, "Failed to process response", ex);
} }
} }
@@ -258,12 +258,12 @@ final class NativeDaemonConnector implements Runnable {
if (code == expectedResponseCode) { if (code == expectedResponseCode) {
rdata[idx++] = line.substring(tok[0].length() + 1); rdata[idx++] = line.substring(tok[0].length() + 1);
} else if (code == NativeDaemonConnector.ResponseCode.CommandOkay) { } else if (code == NativeDaemonConnector.ResponseCode.CommandOkay) {
if (LOCAL_LOGD) Log.d(TAG, String.format("List terminated with {%s}", line)); if (LOCAL_LOGD) Slog.d(TAG, String.format("List terminated with {%s}", line));
int last = rsp.size() -1; int last = rsp.size() -1;
if (i != last) { if (i != last) {
Log.w(TAG, String.format("Recv'd %d lines after end of list {%s}", (last-i), cmd)); Slog.w(TAG, String.format("Recv'd %d lines after end of list {%s}", (last-i), cmd));
for (int j = i; j <= last ; j++) { for (int j = i; j <= last ; j++) {
Log.w(TAG, String.format("ExtraData <%s>", rsp.get(i))); Slog.w(TAG, String.format("ExtraData <%s>", rsp.get(i)));
} }
} }
return rdata; return rdata;