From ea2912f187cec8d426cfc2ca715b9a503355fa37 Mon Sep 17 00:00:00 2001 From: xunchang Date: Sun, 17 Mar 2019 16:45:12 -0700 Subject: Create a FuseDataProvider base class The fuse data provider for adb/sdcard shares common code and structures. This cl creates a FuseDataProvider base class and provides implementations for adb and sdcard. In the follow cls, we can kill the provider_vtab struct; and also add another implementation to parse a block map file and provides data. Test: unit tests pass, sideload a package, apply a package from sdcard Change-Id: If8311666a52a2e3c0fbae0ee9688fa6d01e4ad09 --- minadbd/fuse_adb_provider.h | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'minadbd/fuse_adb_provider.h') diff --git a/minadbd/fuse_adb_provider.h b/minadbd/fuse_adb_provider.h index 36d86d539..e93aa0468 100644 --- a/minadbd/fuse_adb_provider.h +++ b/minadbd/fuse_adb_provider.h @@ -19,14 +19,22 @@ #include -struct adb_data { - int sfd; // file descriptor for the adb channel +#include "android-base/unique_fd.h" - uint64_t file_size; - uint32_t block_size; +#include "fuse_provider.h" + +// This class reads data from adb server. +class FuseAdbDataProvider : public FuseDataProvider { + public: + FuseAdbDataProvider(android::base::unique_fd&& fd, uint64_t file_size, uint32_t block_size) + : FuseDataProvider(std::move(fd), file_size, block_size) {} + + bool ReadBlockAlignedData(uint8_t* buffer, uint32_t fetch_size, + uint32_t start_block) const override; + + void Close() override; }; -int read_block_adb(const adb_data& ad, uint32_t block, uint8_t* buffer, uint32_t fetch_size); -int run_adb_fuse(int sfd, uint64_t file_size, uint32_t block_size); +int run_adb_fuse(android::base::unique_fd&& sfd, uint64_t file_size, uint32_t block_size); #endif -- cgit v1.2.3