• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 "os_account_manager_helper.h"
17 
18 #ifdef HAS_OS_ACCOUNT_PART
19 #include "os_account_manager.h"
20 #endif // HAS_OS_ACCOUNT_PART
21 
22 namespace OHOS {
23 namespace EventFwk {
24 #ifndef HAS_OS_ACCOUNT_PART
25 namespace {
26 const int32_t DEFAULT_OS_ACCOUNT_ID = 100; // default id when there is no os_account part
27 const int32_t UID_TRANSFORM_DIVISOR = 200000;
28 }
29 #endif // HAS_OS_ACCOUNT_PART
30 
QueryActiveOsAccountIds(std::vector<int32_t> & ids)31 ErrCode OsAccountManagerHelper::QueryActiveOsAccountIds(std::vector<int32_t>& ids)
32 {
33 #ifndef HAS_OS_ACCOUNT_PART
34     ids.emplace_back(DEFAULT_OS_ACCOUNT_ID);
35     return ERR_OK;
36 #else
37     return AccountSA::OsAccountManager::QueryActiveOsAccountIds(ids);
38 #endif // HAS_OS_ACCOUNT_PART
39 }
40 
GetOsAccountLocalIdFromUid(const int32_t uid,int32_t & id)41 ErrCode OsAccountManagerHelper::GetOsAccountLocalIdFromUid(const int32_t uid, int32_t &id)
42 {
43 #ifndef HAS_OS_ACCOUNT_PART
44     id = uid / UID_TRANSFORM_DIVISOR;
45     return ERR_OK;
46 #else
47     return AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(uid, id);
48 #endif // HAS_OS_ACCOUNT_PART
49 }
50 }  // namespace EventFwk
51 }  // namespace OHOS