* Starts the monitoring.
*/
void start() {
+ Log.d("DeviceMonitor", "start monitoring");
new Thread("Device List Monitor") { //$NON-NLS-1$
@Override
public void run() {
* Stops the monitoring.
*/
void stop() {
+ Log.d("DeviceMonitor", "stop monitoring");
mQuit = true;
// wake up the main loop thread by closing the main connection to sdb.
do {
try {
if (mMainSdbConnection == null) {
- Log.d("DeviceMonitor", "Opening sdb connection");
+ Log.d("DeviceMonitor", "opening sdb connection");
mMainSdbConnection = openSdbConnection();
if (mMainSdbConnection == null) {
+ Log.d("DeviceMonitor", "start sdb");
if (mServer.startSdb() == false) {
mRestartAttemptCount++;
Log.e("DeviceMonitor",
}
waitABit();
} else {
- Log.d("DeviceMonitor", "Connected to sdb for device monitoring");
+ Log.d("DeviceMonitor", "connected to sdb for device monitoring");
}
}
private void handleExpectioninMonitorLoop(Exception e) {
if (mQuit == false) {
if (e instanceof TimeoutException) {
- Log.e("DeviceMonitor", "Sdb connection Error: timeout");
+ Log.e("DeviceMonitor", "sdb connection Error: timeout");
} else {
- Log.e("DeviceMonitor", "Sdb connection Error:" + e.getMessage());
+ Log.e("DeviceMonitor", "sdb connection Error:" + e.getMessage());
}
mMonitoring = false;
if (mMainSdbConnection != null) {
* @return a connect socket if success, null otherwise
*/
private SocketChannel openSdbConnection() {
- Log.d("DeviceMonitor", "Connecting to sdb for Device List Monitoring...");
+ Log.d("DeviceMonitor", "connecting to sdb for Device List Monitoring...");
SocketChannel sdbChannel = null;
try {
*/
private boolean sendDeviceListMonitoringRequest() throws TimeoutException, IOException {
byte[] request = SdbHelper.formSdbRequest("host:track-devices"); //$NON-NLS-1$
-
+ Log.d("DeviceMonitor", "send monitoring request");
try {
SdbHelper.write(mMainSdbConnection, request);
return resp.okay;
} catch (IOException e) {
- Log.e("DeviceMonitor", "Sending Tracking request failed!");
+ Log.e("DeviceMonitor", "sending tracking request failed!");
mMainSdbConnection.close();
throw e;
}
String[] devices = result.split("\n"); // $NON-NLS-1$
for (String d : devices) {
+ Log.d("DeviceMonitor", "deviceData: " + d);
String[] param = d.split("\t"); // $NON-NLS-1$
if (param.length == 3) {
// new sdb uses only serial numbers to identify devices
//add the device to the list
list.add(device);
+ Log.d("DeviceMonitor", "deviceData: " + device.getSerialNumber() + " added to list");
}
}
}
{
device.checkArchitecture();
device.checkDeviceType();
+ Log.d("DeviceMonitor", "updateDevices: " + device.getSerialNumber() + " onlined");
}
device.update(Device.CHANGE_STATE);
}
// to process the next one.
removeDevice(device);
mServer.deviceDisconnected(device);
+ Log.d("DeviceMonitor", "updateDevices: " + device.getSerialNumber() + " off-lined");
} else {
// process the next one
d++;
if (newDevice.isOnline()) {
devicesToQuery.add(newDevice);
mServer.deviceConnected(newDevice);
+ Log.d("DeviceMonitor", "updateDevices: " + newDevice.getSerialNumber() + " newly connected.");
}
}
}
*/
public final class SdbPreferences {
- public final static LogLevel DEFAULT_LOG_LEVEL = LogLevel.ERROR;
+ public static LogLevel DEFAULT_LOG_LEVEL = LogLevel.ERROR;
/** Default timeout values for sdb connection (milliseconds) */
public static final int DEFAULT_TIMEOUT = 5000; // standard delay, in ms
* Returns the minimum {@link LogLevel} being displayed.
*/
public static LogLevel getLogLevel() {
+ String default_level = System.getProperty("default.sdblib.loglevel");
+ if(default_level != null)
+ {
+ LogLevel levels[] = LogLevel.values();
+ for(LogLevel level : levels)
+ {
+ if(level.getPriority() == Integer.parseInt(default_level))
+ {
+ DEFAULT_LOG_LEVEL = level;
+ return DEFAULT_LOG_LEVEL;
+ }
+ }
+ }
return sLogLevel;
}
command[0] = mSdbOsLocation;
command[1] = "start-server"; //$NON-NLS-1$
Log.d(SDBLIB,
- String.format("Launching '%1$s %2$s' to ensure SDB is running.", //$NON-NLS-1$
+ String.format("launching '%1$s %2$s' to ensure SDB is running.", //$NON-NLS-1$
mSdbOsLocation, command[1]));
proc = Runtime.getRuntime().exec(command);
false /* waitForReaders */);
} catch (IOException ioe) {
- Log.d(SDBLIB, "Unable to run 'sdb': " + ioe.getMessage()); //$NON-NLS-1$
+ Log.d(SDBLIB, "unable to run 'sdb': " + ioe.getMessage()); //$NON-NLS-1$
// we'll return false;
} catch (InterruptedException ie) {
- Log.d(SDBLIB, "Unable to run 'sdb': " + ie.getMessage()); //$NON-NLS-1$
+ Log.d(SDBLIB, "unable to run 'sdb': " + ie.getMessage()); //$NON-NLS-1$
// we'll return false;
}