diff --git a/src/main/java/com/musala/atmosphere/agent/DeviceManager.java b/src/main/java/com/musala/atmosphere/agent/DeviceManager.java index c471511..1f632a0 100644 --- a/src/main/java/com/musala/atmosphere/agent/DeviceManager.java +++ b/src/main/java/com/musala/atmosphere/agent/DeviceManager.java @@ -214,8 +214,7 @@ String registerDevice(IDevice connectedDevice) { return null; } - Map devicePropertiesMap = connectedDevice.getProperties(); - String apiLevelString = devicePropertiesMap.get(DevicePropertyStringConstants.PROPERTY_API_LEVEL.toString()); + String apiLevelString = connectedDevice.getProperty(IDevice.PROP_BUILD_API_LEVEL); int deviceApiLevel = NO_AVAIBLE_API_LEVEL; if (apiLevelString != null) { deviceApiLevel = Integer.parseInt(apiLevelString); @@ -392,9 +391,14 @@ private String unbindWrapperForDevice(IDevice device) throws RemoteException { String rmiWrapperBindingId = getRmiWrapperBindingIdentifier(device); try { - IWrapDevice deviceWrapper = getDeviceWrapper(rmiWrapperBindingId); - deviceWrapper.unbindWrapper(); - + // IWrapDevice deviceWrapper = getDeviceWrapper(rmiWrapperBindingId); + /* + * TODO: The method 'unbindWrapper()' fails because the physical device is missing + * (if is disconnected manually by removing the USB cable). + * Find an another solution for future work. Maybe is a good idea + * to stop the onDeviceComponents from the service. + */ + // deviceWrapper.unbindWrapper(); rmiRegistry.unbind(rmiWrapperBindingId); } catch (NotBoundException e) { // Wrapper for the device was never published, so we have nothing to unbind. diff --git a/src/main/java/com/musala/atmosphere/agent/devicewrapper/util/BackgroundShellCommandRunner.java b/src/main/java/com/musala/atmosphere/agent/devicewrapper/util/BackgroundShellCommandRunner.java index e95290c..83fd606 100644 --- a/src/main/java/com/musala/atmosphere/agent/devicewrapper/util/BackgroundShellCommandRunner.java +++ b/src/main/java/com/musala/atmosphere/agent/devicewrapper/util/BackgroundShellCommandRunner.java @@ -1,6 +1,7 @@ package com.musala.atmosphere.agent.devicewrapper.util; import java.io.IOException; +import java.util.concurrent.TimeUnit; import com.android.ddmlib.AdbCommandRejectedException; import com.android.ddmlib.IDevice; @@ -11,9 +12,9 @@ /** * A class that is used for running shell commands that do not return. - * + * * @author georgi.gaydarov - * + * */ public class BackgroundShellCommandRunner implements Runnable { private final String command; @@ -25,7 +26,7 @@ public class BackgroundShellCommandRunner implements Runnable { private final IDevice wrappedDevice; /** - * + * * @param command * - shell command to be executed. * @param wrappedDevice @@ -41,10 +42,11 @@ public void run() { executorThread = Thread.currentThread(); try { NullOutputReceiver outputReceiver = new NullOutputReceiver(); - wrappedDevice.executeShellCommand(command, outputReceiver, 0 /* - * this execution will never throw a - * ShellCommandUnresponsiveException - */); + /* + * this execution will never throw a + * ShellCommandUnresponsiveException + */ + wrappedDevice.executeShellCommand(command, outputReceiver, 0, TimeUnit.MICROSECONDS); } catch (TimeoutException | AdbCommandRejectedException | IOException | ShellCommandUnresponsiveException e) { onExecutionException = new CommandFailedException("Shell command execution failed. See the enclosed exception for more information.", e); @@ -52,7 +54,7 @@ public void run() { } /** - * + * * @return true if an exception was thrown when the passed shell command was executed, false otherwise. */ public boolean isExecutionExceptionThrown() { @@ -60,7 +62,7 @@ public boolean isExecutionExceptionThrown() { } /** - * + * * @return the exception which was thrown when the passed shell command was executed (null if no exception was * thrown). */ @@ -69,7 +71,7 @@ public Exception getExecutionException() { } /** - * + * * @return the {@link Thread} object that is responsible for the shell command execution. */ public Thread getExecutorThread() {