blob: 6f47e60cb3a07d48adb29e2abee12b4c4d5c1696 [file] [log] [blame]
bigbiff bigbiffaf32bb92018-12-18 18:39:53 -05001/*
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
17#ifndef _MTP_FFS_COMPAT_HANDLE_H
18#define _MTP_FFS_COMPAT_HANDLE_H
19
20#include <MtpFfsHandle.h>
21
22template <class T> class MtpFfsHandleTest;
23
24class MtpFfsCompatHandle : public MtpFfsHandle {
25 template <class T> friend class MtpFfsHandleTest;
26private:
27 int writeHandle(int fd, const void *data, size_t len);
28 int readHandle(int fd, void *data, size_t len);
29
30 size_t mMaxWrite;
31 size_t mMaxRead;
32
33public:
34 int read(void* data, size_t len) override;
35 int write(const void* data, size_t len) override;
36 int receiveFile(mtp_file_range mfr, bool zero_packet) override;
37 int sendFile(mtp_file_range mfr) override;
38
39 /**
40 * Open ffs endpoints and allocate necessary kernel and user memory.
41 * Will sleep until endpoints are enabled, for up to 1 second.
42 */
43 int start(bool ptp) override;
44
45 MtpFfsCompatHandle(int controlFd);
46 ~MtpFfsCompatHandle();
47};
48
49#endif // _MTP_FFS_COMPAT_HANDLE_H
50