• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 "reminder_os_account_manager_helper.h"
17 #include "ans_log_wrapper.h"
18 #include "ans_inner_errors.h"
19 #include "errors.h"
20 #include "ipc_skeleton.h"
21 
22 #include "os_account_constants.h"
23 #include "os_account_info.h"
24 #include "os_account_manager.h"
25 #include <vector>
26 
27 namespace OHOS {
28 namespace Notification {
GetInstance()29 ReminderOsAccountManagerHelper &ReminderOsAccountManagerHelper::GetInstance()
30 {
31     return DelayedRefSingleton<ReminderOsAccountManagerHelper>::GetInstance();
32 }
GetOsAccountLocalIdFromUid(const int32_t uid,int32_t & userId)33 ErrCode ReminderOsAccountManagerHelper::GetOsAccountLocalIdFromUid(const int32_t uid, int32_t &userId)
34 {
35     int32_t ret = AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(uid, userId);
36     if (ret != ERR_OK) {
37         ANS_LOGE("Get userId failed, uid = <%{public}d>, code is %{public}d", uid, ret);
38         return ret;
39     }
40     ANS_LOGD("Get userId Success, uid = <%{public}d> userId = <%{public}d>", uid, userId);
41     return ret;
42 }
43 
GetCurrentActiveUserId(int32_t & id)44 ErrCode ReminderOsAccountManagerHelper::GetCurrentActiveUserId(int32_t &id)
45 {
46     int32_t ret = OHOS::AccountSA::OsAccountManager::GetForegroundOsAccountLocalId(id);
47     if (ret != ERR_OK) {
48         ANS_LOGE("Failed to call OsAccountManager::GetForegroundOsAccountLocalId, code is %{public}d", ret);
49     }
50     return ret;
51 }
52 }
53 }
54