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