This bachelor thesis describes the implementation of an Android framework to access mass storage devices over the USB interface of a smartphone. First the basics of USB (i.e. interfaces, endpoints and USB On the go) and accessing USB devices via the official Android API are discussed. Next the USB mass storage class is explained, which was designed by the USB-IF to access mobile mass storage like USB pen drives or external HDDs.
For communication with mass storage devices, most important are the bulk-only transfer and the SCSI transparent command set. Furthermore file systems, for accessing directories and files, are described. This thesis focuses on the FAT32 file system from Microsoft, because it is the most commonly used file system on such devices.
After the theory part it is time to look at the implementation of the framework. In this section, the first concern is the purpose in general. Then the architecture of the framework and the actual implementation are presented. Important parts are discussed in detail. The thesis finishes with an overview of the test results on various Android devices, a short conclusion and an outlook to future developments. Moreover the current status of the developed framework is visualized.
Table of Contents
1. Introduction
2. Basics about USB
2.1. Client device hierarchy
2.2. Endpoints
2.3. USB On the go
3. USB on Android
3.1. USB Host API
3.2. Enumerating devices
3.3. Requesting permission for communication
3.4. Communication
3.5. Tearing down the communication
3.6. Listening to attach and detach events
3.6.1. Via BroadcastReceiver
3.6.2. Via AndroidManifest.xml
4. USB Mass storage class
4.1. Bulk-only Transport
4.2. SCSI transparent command set
4.3. SCSI commands
4.3.1. INQUIRY
4.3.2. TEST UNIT READY
4.3.3. READ CAPACITY
4.3.4. READ(10) and WRITE(10)
4.3.5. REQUEST SENSE
5. File systems
5.1. General
5.1.1. Examples
5.1.2. Partition table
5.2. The FAT32 file system
5.2.1. General layout
5.2.2. Boot Sector and FS Information Structure
5.2.3. File Allocation Table
5.2.4. Directories and files
5.2.5. Subdirectories
5.2.6. Long File Name entries
6. Purpose and Overview
6.1. Using the Framework
7. Inside the packages
7.1. The driver package
7.2. The partition package
7.3. The file system package
8. Testing
8.1. Overview
8.1.1. Testing criteria
8.2. Results
8.2.1. Native support
8.2.2. Performance test
9. Summary
9.1. Current status
9.2. Conclusion
10. Outlook
Objectives and Research Focus
The primary objective of this bachelor thesis is the development of an open-source Android framework that enables read and write access to USB mass storage devices, such as flash drives and external hard drives, on Android devices without requiring root privileges. The research focuses on implementing low-level USB communication and file system support within the limitations of the official Android USB Host API.
- Implementation of USB communication using the bulk-only transport mechanism and SCSI transparent command set.
- Development of file system abstraction specifically for the FAT32 format to handle directories and files.
- Integration of MBR partition table support to identify storage volumes on connected devices.
- Architectural design focused on an easy-to-use API oriented towards the standard java.io.File structure.
- Evaluation of framework performance and compatibility across various Android devices and versions.
Excerpt from the Book
4.1. Bulk-only Transport
Unlike the name suggests there are two control requests in the BBB specification. The first one is a reset request to prepare the device for the next command. The second is used to get the maximum LUN (Get Max LUN request). This request informs about the number of standalone logical units the mass storage device supports[2].
As mentioned, the interface class has to be set to 08h for the mass storage class. The subclass of the interface descriptor can have different values and specifies the supported protocols used to read and write data from and to the mass storage. Table 4.1 gives an overview of the different protocols.
Summary of Chapters
1. Introduction: This chapter provides an overview of the motivation and goal of the thesis, highlighting the need for USB mass storage access on Android without root rights.
2. Basics about USB: This chapter introduces the structure of USB, including the client device hierarchy, endpoints, and the USB On-the-go (OTG) specification.
3. USB on Android: This chapter details the official Android USB Host API, explaining how to enumerate devices, request communication permissions, and handle connection events.
4. USB Mass storage class: This chapter covers the technical specifications of the USB mass storage class, focusing on bulk-only transport and standard SCSI commands.
5. File systems: This chapter explains the general concepts of file systems and provides a detailed technical breakdown of the FAT32 format, including partitions, boot sectors, and cluster chains.
6. Purpose and Overview: This chapter outlines the requirements for the developed framework and provides an architectural overview using UML diagrams.
7. Inside the packages: This chapter provides a deep dive into the framework's internal structure, specifically the driver, partition, and file system packages.
8. Testing: This chapter documents the quality management process, including testing criteria, device compatibility results, and performance measurements.
9. Summary: This chapter concludes the thesis by summarizing the current status of the framework and providing final thoughts on the implementation.
10. Outlook: This chapter discusses potential future improvements, such as advanced caching mechanisms and integration with newer Java FileSystem APIs.
Key Terms
Android, USB Host API, Mass Storage Class, Bulk-only Transport, SCSI, FAT32, Partition Table, MBR, File System, USB OTG, Java, Framework, Data Access, Root Rights, Cluster Chain
Frequently Asked Questions
What is the core focus of this bachelor thesis?
The thesis aims to implement an open-source Android framework that allows standard Android devices to access external USB mass storage devices like pen drives or HDDs without requiring root access.
Which primary communication protocols does the framework utilize?
The framework utilizes the USB bulk-only transport (BBB) mechanism and the SCSI transparent command set to communicate with connected hardware.
What is the main objective or research question?
The objective is to enable access to mass storage media on Android by implementing low-level USB communication and a file system abstraction layer within the existing Android USB Host API environment.
Which scientific or programming methods are employed?
The project follows a software engineering approach, utilizing the Java programming language to build a structured framework. It incorporates reverse engineering of standard SCSI commands and the FAT32 file system specifications to handle data.
What does the main part of the thesis cover?
The main part covers the theoretical foundation of USB and FAT32, the architecture and design of the developed framework (packages, classes), and the quality management process through practical testing on various hardware.
Which keywords characterize this work?
Key terms include Android, USB Host API, Mass Storage Class, SCSI, FAT32, MBR, Partition Table, and USB OTG.
How does the framework handle different Android versions?
The framework implements a workaround for Android versions lower than API level 18, which lack certain methods in the UsbDeviceConnection class, by using temporary buffers during data transfer.
Why is FAT32 specifically focused on?
FAT32 is the most commonly used file system on mobile storage devices like SD cards and USB sticks, and it features an open specification that makes implementation feasible for this project.
What were the findings regarding performance on different Android devices?
Testing showed that device performance can vary significantly between Android versions, with some tests indicating faster operation on older Android versions, likely due to changes in the underlying USB host stack.
- Citar trabajo
- Magnus Jahnen (Autor), 2014, Implementation of an Android Framework for USB storage access without root rights, Múnich, GRIN Verlag, https://www.grin.com/document/335634