• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_IPC_BINDER_CONNECTOR_H
17 #define OHOS_IPC_BINDER_CONNECTOR_H
18 
19 #include <string>
20 #include <mutex>
21 
22 namespace OHOS {
23 #ifdef CONFIG_IPC_SINGLE
24 namespace IPC_SINGLE {
25 #endif
26 
27 class BinderConnector {
28 public:
29     static BinderConnector *GetInstance();
30     BinderConnector(const std::string &deviceName);
31     ~BinderConnector();
32 
33     int WriteBinder(unsigned long request, void *value);
34     void ExitCurrentThread(unsigned long request);
35     bool IsDriverAlive();
36     bool IsAccessTokenSupported();
37 private:
38     static BinderConnector *instance_;
39     static std::mutex skeletonMutex;
40     bool OpenDriver();
41     int driverFD_;
42     void *vmAddr_;
43     const std::string deviceName_;
44     int32_t version_;
45     uint64_t featureSet_;
46 };
47 #ifdef CONFIG_IPC_SINGLE
48 } // namespace IPC_SINGLE
49 #endif
50 } // namespace OHOS
51 #endif // OHOS_IPC_BINDER_CONNECTOR_H
52