AdbDeviceFileSystem implements DeviceFileSystem { @NotNull @Override public DeviceState getDeviceState() { IDevice.DeviceState state = myDevice.getState(); if (state == null) { return DeviceState.DISCONNECTED; } switch (state) { case ONLINE: return DeviceState.ONLINE; case OFFLINE: return DeviceState.OFFLINE; case UNAUTHORIZED: return DeviceState.UNAUTHORIZED; case DISCONNECTED: return DeviceState.DISCONNECTED; case BOOTLOADER: return DeviceState.BOOTLOADER; case RECOVERY: return DeviceState.RECOVERY; case SIDELOAD: return DeviceState.SIDELOAD; default: return DeviceState.DISCONNECTED; } } AdbDeviceFileSystem(@NotNull IDevice device, @NotNull Executor edtExecutor, @NotNull Executor taskExecutor);  AdbDeviceFileSystem(AdbDeviceFileSystemService service, IDevice device); @NotNull AdbDeviceCapabilities getCapabilities(); @NotNull AdbFileListing getAdbFileListing(); @NotNull AdbFileOperations getAdbFileOperations(); @NotNull AdbFileTransfer getAdbFileTransfer(); @NotNull @Override String getName(); @NotNull @Override DeviceState getDeviceState(); @NotNull @Override ListenableFuture<DeviceFileEntry> getRootDirectory(); @NotNull @Override ListenableFuture<DeviceFileEntry> getEntry(@NotNull String path); @NotNull ListenableFuture<AdbDeviceFileEntry> resolveMountPoint(@NotNull AdbDeviceFileEntry entry);  }
@Test public void test_FileSystem_Exposes_DeviceState() { assert myFileSystem != null; assert myMockDevice != null; TestDevices.addNexus7Api23Commands(myMockDevice.getShellCommands()); myMockDevice.setState(null); assertThat(myFileSystem.getDeviceState()).isEqualTo(DeviceState.DISCONNECTED); myMockDevice.setState(IDevice.DeviceState.BOOTLOADER); assertThat(myFileSystem.getDeviceState()).isEqualTo(DeviceState.BOOTLOADER); myMockDevice.setState(IDevice.DeviceState.OFFLINE); assertThat(myFileSystem.getDeviceState()).isEqualTo(DeviceState.OFFLINE); myMockDevice.setState(IDevice.DeviceState.ONLINE); assertThat(myFileSystem.getDeviceState()).isEqualTo(DeviceState.ONLINE); myMockDevice.setState(IDevice.DeviceState.RECOVERY); assertThat(myFileSystem.getDeviceState()).isEqualTo(DeviceState.RECOVERY); myMockDevice.setState(IDevice.DeviceState.SIDELOAD); assertThat(myFileSystem.getDeviceState()).isEqualTo(DeviceState.SIDELOAD); myMockDevice.setState(IDevice.DeviceState.UNAUTHORIZED); assertThat(myFileSystem.getDeviceState()).isEqualTo(DeviceState.UNAUTHORIZED); myMockDevice.setState(IDevice.DeviceState.DISCONNECTED); assertThat(myFileSystem.getDeviceState()).isEqualTo(DeviceState.DISCONNECTED); }