1 /*
2 * Copyright (c) 2023 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 <gtest/gtest.h>
17 #include <gmock/gmock.h>
18 #include <thread>
19 #include "ability_manager_adapter_mock.h"
20
21 #include "account_log_wrapper.h"
22 #include "string_wrapper.h"
23
24 namespace OHOS {
25 namespace AccountSA {
26 using namespace AAFwk;
27
GetInstance()28 AbilityManagerAdapter *AbilityManagerAdapter::GetInstance()
29 {
30 static AbilityManagerAdapter *instance = new (std::nothrow) AbilityManagerAdapter();
31 return instance;
32 }
33
AbilityManagerAdapter()34 AbilityManagerAdapter::AbilityManagerAdapter()
35 {}
36
~AbilityManagerAdapter()37 AbilityManagerAdapter::~AbilityManagerAdapter()
38 {}
39
ConnectAbility(const AAFwk::Want & want,const sptr<AAFwk::IAbilityConnection> & connect,const sptr<IRemoteObject> & callerToken,int32_t userId)40 ErrCode AbilityManagerAdapter::ConnectAbility(const AAFwk::Want &want, const sptr<AAFwk::IAbilityConnection> &connect,
41 const sptr<IRemoteObject> &callerToken, int32_t userId)
42 {
43 return ERR_OK;
44 }
45
DisconnectAbility(const sptr<AAFwk::IAbilityConnection> & connect)46 ErrCode AbilityManagerAdapter::DisconnectAbility(const sptr<AAFwk::IAbilityConnection> &connect)
47 {
48 return ERR_OK;
49 }
50
StartUser(int accountId,const sptr<AAFwk::IUserCallback> & callback)51 ErrCode AbilityManagerAdapter::StartUser(int accountId, const sptr<AAFwk::IUserCallback> &callback)
52 {
53 auto task = [accountId, callback] { callback->OnStartUserDone(accountId, 0); };
54 std::thread taskThread(task);
55 pthread_setname_np(taskThread.native_handle(), "StartUser");
56 taskThread.detach();
57 return ERR_OK;
58 }
59
StopUser(int accountId,const sptr<AAFwk::IUserCallback> & callback)60 ErrCode AbilityManagerAdapter::StopUser(int accountId, const sptr<AAFwk::IUserCallback> &callback)
61 {
62 auto task = [accountId, callback] { callback->OnStopUserDone(accountId, 0); };
63 std::thread taskThread(task);
64 pthread_setname_np(taskThread.native_handle(), "StopUser");
65 taskThread.detach();
66 return ERR_OK;
67 }
68
LogoutUser(int accountId)69 ErrCode AbilityManagerAdapter::LogoutUser(int accountId)
70 {
71 return ERR_OK;
72 }
73 } // namespace AccountSA
74 } // namespace OHOS