• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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,bool isAppRecovery)51 ErrCode AbilityManagerAdapter::StartUser(int accountId,
52     const sptr<AAFwk::IUserCallback> &callback, bool isAppRecovery)
53 {
54     auto task = [accountId, callback] { callback->OnStartUserDone(accountId, 0); };
55     std::thread taskThread(task);
56     pthread_setname_np(taskThread.native_handle(), "StartUser");
57     taskThread.detach();
58     return ERR_OK;
59 }
60 
StopUser(int accountId,const sptr<AAFwk::IUserCallback> & callback)61 ErrCode AbilityManagerAdapter::StopUser(int accountId, const sptr<AAFwk::IUserCallback> &callback)
62 {
63     auto task = [accountId, callback] { callback->OnStopUserDone(accountId, 0); };
64     std::thread taskThread(task);
65     pthread_setname_np(taskThread.native_handle(), "StopUser");
66     taskThread.detach();
67     return ERR_OK;
68 }
69 
LogoutUser(int32_t accountId,const sptr<IUserCallback> & callback)70 ErrCode AbilityManagerAdapter::LogoutUser(int32_t accountId, const sptr<IUserCallback> &callback)
71 {
72     auto task = [accountId, callback] { callback->OnLogoutUserDone(accountId, 0); };
73     std::thread taskThread(task);
74     pthread_setname_np(taskThread.native_handle(), "LogoutUser");
75     taskThread.detach();
76     return ERR_OK;
77 }
78 
IsAllAppDied(int32_t accountId)79 bool AbilityManagerAdapter::IsAllAppDied(int32_t accountId)
80 {
81     return true;
82 }
83 } // namespace AccountSA
84 } // namespace OHOS