• 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 "multiple_user_connector.h"
17 
18 #include "dm_log.h"
19 #if !(defined(__LITEOS_M__) || defined(LITE_DEVICE))
20 #include "os_account_manager.h"
21 
22 using namespace OHOS::AccountSA;
23 #endif
24 
25 namespace OHOS {
26 namespace DistributedHardware {
27 int32_t MultipleUserConnector::oldUserId_ = -1;
28 
GetCurrentAccountUserID(void)29 int32_t MultipleUserConnector::GetCurrentAccountUserID(void)
30 {
31 #if (defined(__LITEOS_M__) || defined(LITE_DEVICE))
32     return 0;
33 #else
34     std::vector<int> ids;
35     ErrCode ret = OsAccountManager::QueryActiveOsAccountIds(ids);
36     if (ret != ERR_OK || ids.empty()) {
37         return -1;
38     }
39     return ids[0];
40 #endif
41 }
42 
SetSwitchOldUserId(int32_t userId)43 void MultipleUserConnector::SetSwitchOldUserId(int32_t userId)
44 {
45     oldUserId_ = userId;
46 }
47 
GetSwitchOldUserId(void)48 int32_t MultipleUserConnector::GetSwitchOldUserId(void)
49 {
50     return oldUserId_;
51 }
52 } // namespace DistributedHardware
53 } // namespace OHOS
54