// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java
// public class HexUtil
// {
//     private static final String HEXES = "0123456789ABCDEF";
//     private static final String HEX_INDICATOR = "0x";
//     private static final String SPACE = " ";
// 
//     private HexUtil()
//     {
// 
//     }
// 
//     public static String hexToString(byte[] data)
//     {
//         if(data != null)
//         {
//             StringBuilder hex = new StringBuilder(2*data.length);
//             for(int i=0;i<=data.length-1;i++)
//             {
//                 byte dataAtIndex = data[i];
//                 hex.append(HEX_INDICATOR);
//                 hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4))
//                         .append(HEXES.charAt((dataAtIndex & 0x0F)));
//                 hex.append(SPACE);
//             }
//             return hex.toString();
//         }else
//         {
//             return null;
//         }
//     }
// }
// 
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java
// public class CommandBlockWrapper extends CommandWrapper
// {
//     private int dCBWSignature;
//     private int dCBWTag;
//     private int dCBWDataLength;
//     private byte bmCBWFlags;
//     private byte bCBWLUN;
//     private byte bCBWCBLength;
//     private byte[] commandBlock;
// 
// 
//     public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength,
//                                byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength)
//     {
//         this.dCBWSignature = dCBWSignature;
//         this.dCBWTag = dCBWTag;
//         this.dCBWDataLength = dCBWDataLength;
//         this.bmCBWFlags = bmCBWFlags;
//         this.bCBWLUN = bCBWLUN;
//         this.bCBWCBLength = bCBWCBLength;
//     }
// 
//     public CommandBlockWrapper( int dCBWDataLength,
//                                 byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength)
//     {
//         this.dCBWSignature = CommandWrapper.CBW_SIGNATURE;
//         this.dCBWTag = generateTag();
//         this.dCBWDataLength = dCBWDataLength;
//         this.bmCBWFlags = bmCBWFlags;
//         this.bCBWLUN = bCBWLUN;
//         this.bCBWCBLength = bCBWCBLength;
//     }
// 
//     public void setCommandBlock(byte[] commandBlock)
//     {
//         this.commandBlock = commandBlock;
//     }
// 
//     public int getdCBWDataLength()
//     {
//         return dCBWDataLength;
//     }
// 
//     public int generateTag()
//     {
//         Random random = new Random();
//         return random.nextInt();
//     }
// 
//     @Override
//     public byte[] getCWBuffer()
//     {
//         ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE);
//         buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature));
//         buffer.putInt(dCBWTag);
//         buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength));
//         buffer.put(bmCBWFlags);
//         buffer.put(bCBWLUN);
//         buffer.put(bCBWCBLength);
//         buffer.put(commandBlock);
//         return buffer.array();
//     }
// }


import commandwrappers.CommandBlockWrapper;
import android.util.Log;
import com.felhr.usbmassstorageforandroid.utilities.HexUtil;
import java.nio.ByteBuffer;
        this.direction = 1;
        this.llbaa = llbaa;
        this.dbd = dbd;
        this.pc = pc;
        this.pageCode = pageCode;
        this.subPageCode = subPageCode;
        this.allocationLength = allocationLength;
        this.control = 0x00;
    }

    @Override
    public byte[] getSCSICommandBuffer()
    {
        ByteBuffer buffer = ByteBuffer.allocate(10);
        buffer.put(MODESENSE10_OPERATION_CODE);

        byte firstByte = 0x00;
        if(llbaa)
            firstByte |= (1 << 4);
        if(dbd)
            firstByte |= (1 << 3);
        buffer.put(firstByte);

        byte secondByte = (byte) pageCode;
        switch(pc)
        {
            case 0:
                secondByte &= ~(1 << 7);
                secondByte &= ~(1 << 6);
                break;
// Path: src/main/java/com/felhr/usbmassstorageforandroid/utilities/HexUtil.java
// public class HexUtil
// {
//     private static final String HEXES = "0123456789ABCDEF";
//     private static final String HEX_INDICATOR = "0x";
//     private static final String SPACE = " ";
// 
//     private HexUtil()
//     {
// 
//     }
// 
//     public static String hexToString(byte[] data)
//     {
//         if(data != null)
//         {
//             StringBuilder hex = new StringBuilder(2*data.length);
//             for(int i=0;i<=data.length-1;i++)
//             {
//                 byte dataAtIndex = data[i];
//                 hex.append(HEX_INDICATOR);
//                 hex.append(HEXES.charAt((dataAtIndex & 0xF0) >> 4))
//                         .append(HEXES.charAt((dataAtIndex & 0x0F)));
//                 hex.append(SPACE);
//             }
//             return hex.toString();
//         }else
//         {
//             return null;
//         }
//     }
// }
// 
// Path: src/main/java/commandwrappers/CommandBlockWrapper.java
// public class CommandBlockWrapper extends CommandWrapper
// {
//     private int dCBWSignature;
//     private int dCBWTag;
//     private int dCBWDataLength;
//     private byte bmCBWFlags;
//     private byte bCBWLUN;
//     private byte bCBWCBLength;
//     private byte[] commandBlock;
// 
// 
//     public CommandBlockWrapper(int dCBWSignature, int dCBWTag, int dCBWDataLength,
//                                byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength)
//     {
//         this.dCBWSignature = dCBWSignature;
//         this.dCBWTag = dCBWTag;
//         this.dCBWDataLength = dCBWDataLength;
//         this.bmCBWFlags = bmCBWFlags;
//         this.bCBWLUN = bCBWLUN;
//         this.bCBWCBLength = bCBWCBLength;
//     }
// 
//     public CommandBlockWrapper( int dCBWDataLength,
//                                 byte bmCBWFlags, byte bCBWLUN, byte bCBWCBLength)
//     {
//         this.dCBWSignature = CommandWrapper.CBW_SIGNATURE;
//         this.dCBWTag = generateTag();
//         this.dCBWDataLength = dCBWDataLength;
//         this.bmCBWFlags = bmCBWFlags;
//         this.bCBWLUN = bCBWLUN;
//         this.bCBWCBLength = bCBWCBLength;
//     }
// 
//     public void setCommandBlock(byte[] commandBlock)
//     {
//         this.commandBlock = commandBlock;
//     }
// 
//     public int getdCBWDataLength()
//     {
//         return dCBWDataLength;
//     }
// 
//     public int generateTag()
//     {
//         Random random = new Random();
//         return random.nextInt();
//     }
// 
//     @Override
//     public byte[] getCWBuffer()
//     {
//         ByteBuffer buffer = ByteBuffer.allocate(CBW_SIZE);
//         buffer.putInt(EndianessUtil.swapEndianess(dCBWSignature));
//         buffer.putInt(dCBWTag);
//         buffer.putInt(EndianessUtil.swapEndianess(dCBWDataLength));
//         buffer.put(bmCBWFlags);
//         buffer.put(bCBWLUN);
//         buffer.put(bCBWCBLength);
//         buffer.put(commandBlock);
//         return buffer.array();
//     }
// }


// Path: src/main/java/com/felhr/usbmassstorageforandroid/scsi/SCSIModeSense10.java
import commandwrappers.CommandBlockWrapper;
import android.util.Log;
import com.felhr.usbmassstorageforandroid.utilities.HexUtil;
import java.nio.ByteBuffer;

        this.direction = 1;
        this.llbaa = llbaa;
        this.dbd = dbd;
        this.pc = pc;
        this.pageCode = pageCode;
        this.subPageCode = subPageCode;
        this.allocationLength = allocationLength;
        this.control = 0x00;
    }

    @Override
    public byte[] getSCSICommandBuffer()
    {
        ByteBuffer buffer = ByteBuffer.allocate(10);
        buffer.put(MODESENSE10_OPERATION_CODE);

        byte firstByte = 0x00;
        if(llbaa)
            firstByte |= (1 << 4);
        if(dbd)
            firstByte |= (1 << 3);
        buffer.put(firstByte);

        byte secondByte = (byte) pageCode;
        switch(pc)
        {
            case 0:
                secondByte &= ~(1 << 7);
                secondByte &= ~(1 << 6);
                break;
            case 1: