• 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 #include "static_call.h"
17 
18 #include <mutex>
19 
20 namespace OHOS {
21 namespace Vsync {
GetInstance()22 sptr<StaticCall> StaticCall::GetInstance()
23 {
24     if (instance == nullptr) {
25         static std::mutex mutex;
26         std::lock_guard<std::mutex> lock(mutex);
27         if (instance == nullptr) {
28             instance = new StaticCall();
29         }
30     }
31 
32     return instance;
33 }
34 
SetInstance(sptr<StaticCall> & mockInstance)35 void StaticCall::SetInstance(sptr<StaticCall> &mockInstance)
36 {
37     instance = mockInstance;
38 }
39 
GetCast(sptr<IRemoteObject> & remoteObject)40 sptr<IVsyncManager> StaticCall::GetCast(sptr<IRemoteObject>& remoteObject)
41 {
42     auto cast = iface_cast<IVsyncManager>(remoteObject);
43     return cast;
44 }
45 
GetSystemAbilityManager()46 sptr<ISystemAbilityManager> StaticCall::GetSystemAbilityManager()
47 {
48     return SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
49 }
50 
GetSystemAbility(sptr<ISystemAbilityManager> & sm,int32_t systemAbilityId)51 sptr<IRemoteObject> StaticCall::GetSystemAbility(sptr<ISystemAbilityManager>& sm, int32_t systemAbilityId)
52 {
53     return sm->GetSystemAbility(systemAbilityId);
54 }
55 
GetVsyncFrequency(sptr<IVsyncManager> & server,uint32_t & freq)56 GSError StaticCall::GetVsyncFrequency(sptr<IVsyncManager>& server, uint32_t &freq)
57 {
58     return server->GetVsyncFrequency(freq);
59 }
60 
ListenVsync(sptr<IVsyncManager> & server,sptr<IVsyncCallback> & cb,int32_t & cbid)61 GSError StaticCall::ListenVsync(sptr<IVsyncManager>& server, sptr<IVsyncCallback>& cb, int32_t &cbid)
62 {
63     return server->ListenVsync(cb, cbid);
64 }
65 
Sync(int64_t,void * data)66 void StaticCall::Sync(int64_t, void *data)
67 {
68 }
69 
Current()70 std::shared_ptr<AppExecFwk::EventHandler> StaticCall::Current()
71 {
72     return AppExecFwk::EventHandler::Current();
73 }
74 } // namespace Vsync
75 } // namespace OHOS
76