MtpFfsCompatHandle.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (C) 2016 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef _MTP_FFS_COMPAT_HANDLE_H
  17. #define _MTP_FFS_COMPAT_HANDLE_H
  18. #include <MtpFfsHandle.h>
  19. namespace android {
  20. template <class T> class MtpFfsHandleTest;
  21. class MtpFfsCompatHandle : public MtpFfsHandle {
  22. template <class T> friend class android::MtpFfsHandleTest;
  23. private:
  24. int writeHandle(int fd, const void *data, size_t len);
  25. int readHandle(int fd, void *data, size_t len);
  26. size_t mMaxWrite;
  27. size_t mMaxRead;
  28. public:
  29. int read(void* data, size_t len) override;
  30. int write(const void* data, size_t len) override;
  31. int receiveFile(mtp_file_range mfr, bool zero_packet) override;
  32. int sendFile(mtp_file_range mfr) override;
  33. /**
  34. * Open ffs endpoints and allocate necessary kernel and user memory.
  35. * Will sleep until endpoints are enabled, for up to 1 second.
  36. */
  37. int start(bool ptp) override;
  38. MtpFfsCompatHandle(int controlFd);
  39. ~MtpFfsCompatHandle();
  40. };
  41. } // namespace android
  42. #endif // _MTP_FFS_COMPAT_HANDLE_H