mirror of
https://gitee.com/openharmony/account_os_account
synced 2024-11-23 02:00:01 +00:00
[cj] support cj api for osaccount
Change-Id: Ic66b06dde2302ebfa0ec5d8a8a2343e07cb7fca5 Signed-off-by: DXwangg <wangjiawei80@huawei.com>
This commit is contained in:
parent
17fb184b14
commit
733c7d0746
@ -71,6 +71,7 @@
|
||||
"base_group": [
|
||||
"//base/account/os_account/interfaces/kits/capi:capi_packages",
|
||||
"//base/account/os_account/interfaces/kits/napi:napi_packages",
|
||||
"//base/account/os_account/interfaces/kits/cj:cj_ffi_packages",
|
||||
"//base/account/os_account/sa_profile:account_sa_profile",
|
||||
"//base/account/os_account/tools:tools_acm"
|
||||
],
|
||||
|
19
interfaces/kits/cj/BUILD.gn
Normal file
19
interfaces/kits/cj/BUILD.gn
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("../../../os_account.gni")
|
||||
|
||||
group("cj_ffi_packages") {
|
||||
deps = [ "osaccount:cj_osaccount_ffi" ]
|
||||
}
|
68
interfaces/kits/cj/osaccount/BUILD.gn
Normal file
68
interfaces/kits/cj/osaccount/BUILD.gn
Normal file
@ -0,0 +1,68 @@
|
||||
# Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
import("../../../../os_account.gni")
|
||||
|
||||
config("osaccount_ffi_kit_config") {
|
||||
include_dirs = [ "include" ]
|
||||
|
||||
cflags = []
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
|
||||
cflags += [ "-pipe" ]
|
||||
cflags_cc = [
|
||||
"-Wdate-time",
|
||||
"-Wformat=2",
|
||||
"-Wfloat-equal",
|
||||
"-Wshadow",
|
||||
]
|
||||
|
||||
defines = [
|
||||
"ACCOUNT_LOG_TAG = \"OsAccountJsKit\"",
|
||||
"LOG_DOMAIN = 0xD001B00",
|
||||
]
|
||||
}
|
||||
|
||||
ohos_shared_library("cj_osaccount_ffi") {
|
||||
sanitize = {
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
debug = false
|
||||
}
|
||||
configs = [ ":osaccount_ffi_kit_config" ]
|
||||
sources = [
|
||||
"${os_account_ffi_kits_path}/src/cj_osaccount_ffi.cpp",
|
||||
"${os_account_ffi_kits_path}/src/osaccount_manager_impl.cpp",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"${common_path}:libaccount_common",
|
||||
"${innerkits_native_path}:libaccountkits",
|
||||
"${os_account_innerkits_native_path}:os_account_innerkits",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"hilog:libhilog",
|
||||
"napi:cj_bind_ffi",
|
||||
"napi:cj_bind_native",
|
||||
]
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
part_name = "os_account"
|
||||
subsystem_name = "account"
|
||||
}
|
43
interfaces/kits/cj/osaccount/include/cj_osaccount_ffi.h
Normal file
43
interfaces/kits/cj/osaccount/include/cj_osaccount_ffi.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef CJ_OSACCOUNT_FFI_H
|
||||
#define CJ_OSACCOUNT_FFI_H
|
||||
|
||||
#include <cstdint>
|
||||
#include "cj_ffi/cj_common_ffi.h"
|
||||
#include "ffi_remote_data.h"
|
||||
#include "common.h"
|
||||
|
||||
EXTERN_C_START
|
||||
FFI_EXPORT bool FfiOHOSOsAccountIsOsAccountConstraintEnabled(char *constraint, int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiOHOSOsAccountGetOsAccountType(int32_t *errCode);
|
||||
FFI_EXPORT bool FfiOHOSOsAccountCheckOsAccountTestable(int32_t *errCode);
|
||||
FFI_EXPORT bool FfiOHOSOsAccountCheckMultiOsAccountEnabled(int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiOHOSOsAccountGetOsAccountLocalId(int32_t *errCode);
|
||||
FFI_EXPORT RetDataCArrI32 FfiOHOSOsAccountGetActivatedOsAccountLocalIds();
|
||||
FFI_EXPORT uint32_t FfiOHOSOsAccountGetOsAccountCount(int32_t *errCode);
|
||||
FFI_EXPORT char* FfiOHOSOsAccountQueryDistributedVirtualDeviceId(int32_t *errCode);
|
||||
FFI_EXPORT int64_t FfiOHOSOsAccountGetSerialNumberForOsAccountLocalId(uint32_t localId, int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiOHOSOsAccountGetOsAccountLocalIdForSerialNumber(int64_t serialNumber, int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiOHOSOsAccountGetOsAccountLocalIdForDomain(CDomainAccountInfo cDoaminInfo, int32_t *errCode);
|
||||
FFI_EXPORT int32_t FfiOHOSOsAccountGetOsAccountLocalIdForUid(int32_t uid, int32_t *errCode);
|
||||
FFI_EXPORT char* FfiOHOSOsAccountGetOsAccountName(int32_t *errCode);
|
||||
FFI_EXPORT bool FfiOHOSOsAccountIsOsAccountUnlocked(int32_t *errCode);
|
||||
FFI_EXPORT RetDataI64 FfiOHOSOsAccountGetAccountManager();
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
#endif
|
38
interfaces/kits/cj/osaccount/include/common.h
Normal file
38
interfaces/kits/cj/osaccount/include/common.h
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef CJ_OSACCOUNT_COMMON_H
|
||||
#define CJ_OSACCOUNT_COMMON_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN_C_START extern "C" {
|
||||
#define EXTERN_C_END }
|
||||
#else
|
||||
#define EXTERN_C_START
|
||||
#define EXTERN_C_END
|
||||
#endif
|
||||
|
||||
EXTERN_C_START
|
||||
|
||||
struct CDomainAccountInfo {
|
||||
char* domain;
|
||||
char* accountName;
|
||||
};
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
#endif
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef OSACCOUNT_MANAGER_IMPL_H
|
||||
#define OSACCOUNT_MANAGER_IMPL_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace OHOS::AccountJsKit {
|
||||
class OsAccountManagerImpl {
|
||||
public:
|
||||
static bool IsOsAccountConstraintEnabled(char *constraint, int32_t *errCode);
|
||||
static int32_t GetOsAccountType(int32_t *errCode);
|
||||
static bool CheckMultiOsAccountEnabled(int32_t *errCode);
|
||||
static int32_t GetOsAccountLocalId(int32_t *errCode);
|
||||
static int32_t GetActivatedOsAccountLocalIds(std::vector<int> &osAccountIds);
|
||||
static uint32_t GetOsAccountCount(int32_t *errCode);
|
||||
static char *QueryDistributedVirtualDeviceId(int32_t *errCode);
|
||||
static int64_t GetSerialNumberForOsAccountLocalId(uint32_t localId, int32_t *errCode);
|
||||
static int32_t GetOsAccountLocalIdForSerialNumber(int64_t serialNumber, int32_t *errCode);
|
||||
static int32_t GetOsAccountLocalIdForDomain(char *domain, char *accountName, int32_t *errCode);
|
||||
static int32_t GetOsAccountLocalIdForUid(int32_t uid, int32_t *errCode);
|
||||
static char *GetOsAccountName(int32_t *errCode);
|
||||
static bool IsOsAccountUnlocked(int32_t *errCode);
|
||||
|
||||
static char *MallocCString(const std::string &origin);
|
||||
|
||||
private:
|
||||
};
|
||||
}
|
||||
#endif // OSACCOUNT_MANAGER_IMPL_H
|
173
interfaces/kits/cj/osaccount/src/cj_osaccount_ffi.cpp
Normal file
173
interfaces/kits/cj/osaccount/src/cj_osaccount_ffi.cpp
Normal file
@ -0,0 +1,173 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "cj_osaccount_ffi.h"
|
||||
#include "account_error_no.h"
|
||||
#include "account_permission_manager.h"
|
||||
#include "account_log_wrapper.h"
|
||||
#include "osaccount_manager_impl.h"
|
||||
|
||||
using namespace OHOS::AccountSA;
|
||||
|
||||
namespace OHOS::AccountJsKit {
|
||||
EXTERN_C_START
|
||||
bool FfiOHOSOsAccountIsOsAccountConstraintEnabled(char *constraint, int32_t *errCode)
|
||||
{
|
||||
if (constraint == nullptr) {
|
||||
*errCode = ERR_JS_PARAMETER_ERROR;
|
||||
ACCOUNT_LOGE("[osAccount] IsOsAccountConstraintEnabled constraint is null! errCode %{public}d",
|
||||
*errCode);
|
||||
return false;
|
||||
}
|
||||
if (AccountPermissionManager::CheckSystemApp(false) != ERR_OK) {
|
||||
*errCode = ERR_JS_IS_NOT_SYSTEM_APP;
|
||||
ACCOUNT_LOGE("[osAccount] IsOsAccountConstraintEnabled CheckSystemApp failed! errCode %{public}d",
|
||||
*errCode);
|
||||
return false;
|
||||
}
|
||||
ACCOUNT_LOGE("[osAccount] IsOsAccountConstraintEnabled start");
|
||||
bool ret = OsAccountManagerImpl::IsOsAccountConstraintEnabled(constraint, errCode);
|
||||
ACCOUNT_LOGE("[osAccount] IsOsAccountConstraintEnabled success. errCode %{public}d", *errCode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t FfiOHOSOsAccountGetOsAccountType(int32_t *errCode)
|
||||
{
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountType start");
|
||||
int32_t ret = OsAccountManagerImpl::GetOsAccountType(errCode);
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountType success. errCode %{public}d", *errCode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool FfiOHOSOsAccountCheckOsAccountTestable(int32_t *errCode)
|
||||
{
|
||||
*errCode = ERR_JS_SUCCESS;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FfiOHOSOsAccountCheckMultiOsAccountEnabled(int32_t *errCode)
|
||||
{
|
||||
ACCOUNT_LOGE("[osAccount] CheckMultiOsAccountEnabled start");
|
||||
bool ret = OsAccountManagerImpl::CheckMultiOsAccountEnabled(errCode);
|
||||
ACCOUNT_LOGE("[osAccount] CheckMultiOsAccountEnabled success. errCode %{public}d", *errCode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t FfiOHOSOsAccountGetOsAccountLocalId(int32_t *errCode)
|
||||
{
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountLocalId start");
|
||||
int32_t ret = OsAccountManagerImpl::GetOsAccountLocalId(errCode);
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountLocalId success. errCode %{public}d", *errCode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
RetDataCArrI32 FfiOHOSOsAccountGetActivatedOsAccountLocalIds()
|
||||
{
|
||||
std::vector<int32_t> osAccountIds;
|
||||
ACCOUNT_LOGE("[osAccount] GetActivatedOsAccountLocalIds start");
|
||||
int32_t code = OsAccountManagerImpl::GetActivatedOsAccountLocalIds(osAccountIds);
|
||||
ACCOUNT_LOGE("[osAccount] GetActivatedOsAccountLocalIds success. errCode %{public}d", code);
|
||||
CArrI32 data = {.head = nullptr, .size = 0};
|
||||
RetDataCArrI32 ret = {.code = code, .data = data};
|
||||
if (code != ERR_JS_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
size_t listSize = osAccountIds.size();
|
||||
ret.data.size = static_cast<int64_t>(listSize);
|
||||
if (listSize > 0) {
|
||||
int32_t *retValue = static_cast<int32_t *>(malloc(sizeof(int32_t) * listSize));
|
||||
if (retValue == nullptr) {
|
||||
ret.code = ERR_JS_SYSTEM_SERVICE_EXCEPTION;
|
||||
return ret;
|
||||
}
|
||||
for (int32_t i = 0; i < listSize; i++) {
|
||||
retValue[i] = osAccountIds[i];
|
||||
}
|
||||
ret.data.head = retValue;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint32_t FfiOHOSOsAccountGetOsAccountCount(int32_t *errCode)
|
||||
{
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountCount start");
|
||||
int32_t ret = OsAccountManagerImpl::GetOsAccountCount(errCode);
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountCount success. errCode %{public}d", *errCode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *FfiOHOSOsAccountQueryDistributedVirtualDeviceId(int32_t *errCode)
|
||||
{
|
||||
ACCOUNT_LOGE("[osAccount] QueryDistributedVirtualDeviceId start");
|
||||
char *ret = OsAccountManagerImpl::QueryDistributedVirtualDeviceId(errCode);
|
||||
ACCOUNT_LOGE("[osAccount] QueryDistributedVirtualDeviceId success. errCode %{public}d", *errCode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int64_t FfiOHOSOsAccountGetSerialNumberForOsAccountLocalId(uint32_t localId, int32_t *errCode)
|
||||
{
|
||||
ACCOUNT_LOGE("[osAccount] GetSerialNumberForOsAccountLocalId start");
|
||||
int32_t ret = OsAccountManagerImpl::GetSerialNumberForOsAccountLocalId(localId, errCode);
|
||||
ACCOUNT_LOGE("[osAccount] GetSerialNumberForOsAccountLocalId success. errCode %{public}d", *errCode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t FfiOHOSOsAccountGetOsAccountLocalIdForSerialNumber(int64_t serialNumber, int32_t *errCode)
|
||||
{
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountLocalIdForSerialNumber start");
|
||||
int32_t ret = OsAccountManagerImpl::GetOsAccountLocalIdForSerialNumber(serialNumber, errCode);
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountLocalIdForSerialNumber success. errCode %{public}d", *errCode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t FfiOHOSOsAccountGetOsAccountLocalIdForDomain(CDomainAccountInfo cDoaminInfo, int32_t *errCode)
|
||||
{
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountLocalIdForDomain start");
|
||||
int32_t ret = OsAccountManagerImpl::GetOsAccountLocalIdForDomain(
|
||||
cDoaminInfo.domain, cDoaminInfo.accountName, errCode);
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountLocalIdForDomain success. errCode %{public}d", *errCode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t FfiOHOSOsAccountGetOsAccountLocalIdForUid(int32_t uid, int32_t *errCode)
|
||||
{
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountLocalIdForUid start");
|
||||
int32_t ret = OsAccountManagerImpl::GetOsAccountLocalIdForUid(uid, errCode);
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountLocalIdForUid success. errCode %{public}d", *errCode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *FfiOHOSOsAccountGetOsAccountName(int32_t *errCode)
|
||||
{
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountName start");
|
||||
char *ret = OsAccountManagerImpl::GetOsAccountName(errCode);
|
||||
ACCOUNT_LOGE("[osAccount] GetOsAccountName success. errCode %{public}d", *errCode);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool FfiOHOSOsAccountIsOsAccountUnlocked(int32_t *errCode)
|
||||
{
|
||||
if (AccountPermissionManager::CheckSystemApp(false) != ERR_OK) {
|
||||
*errCode = ERR_JS_IS_NOT_SYSTEM_APP;
|
||||
ACCOUNT_LOGE("[osAccount] IsOsAccountUnlocked CheckSystemApp failed! errCode %{public}d", *errCode);
|
||||
return false;
|
||||
}
|
||||
ACCOUNT_LOGE("[osAccount] IsOsAccountUnlocked start");
|
||||
bool ret = OsAccountManagerImpl::IsOsAccountUnlocked(errCode);
|
||||
ACCOUNT_LOGE("[osAccount] IsOsAccountUnlocked success. errCode %{public}d", *errCode);
|
||||
return ret;
|
||||
}
|
||||
EXTERN_C_END
|
||||
} // namespace OHOS::AccountJsKit
|
142
interfaces/kits/cj/osaccount/src/osaccount_manager_impl.cpp
Normal file
142
interfaces/kits/cj/osaccount/src/osaccount_manager_impl.cpp
Normal file
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "osaccount_manager_impl.h"
|
||||
#include "os_account_manager.h"
|
||||
#include "account_error_no.h"
|
||||
#include "os_account_info.h"
|
||||
#include "account_log_wrapper.h"
|
||||
|
||||
namespace OHOS::AccountJsKit {
|
||||
using namespace OHOS::AccountSA;
|
||||
|
||||
bool OsAccountManagerImpl::IsOsAccountConstraintEnabled(char *constraint, int32_t *errCode)
|
||||
{
|
||||
int32_t id = 0;
|
||||
bool isConsEnable = false;
|
||||
std::vector<int32_t> ids;
|
||||
*errCode = OsAccountManager::QueryActiveOsAccountIds(ids);
|
||||
if (*errCode != ERR_OK) {
|
||||
ACCOUNT_LOGE("isOsAccountConstraintEnabled Get id failed");
|
||||
return false;
|
||||
}
|
||||
if (ids.empty()) {
|
||||
*errCode = ERR_ACCOUNT_COMMON_INVALID_PARAMETER;
|
||||
ACCOUNT_LOGE("isOsAccountConstraintEnabled No Active OsAccount Ids");
|
||||
return false;
|
||||
}
|
||||
id = ids[0];
|
||||
*errCode = OsAccountManager::CheckOsAccountConstraintEnabled(id, constraint, isConsEnable);
|
||||
return isConsEnable;
|
||||
}
|
||||
|
||||
int32_t OsAccountManagerImpl::GetOsAccountType(int32_t *errCode)
|
||||
{
|
||||
OsAccountType type;
|
||||
*errCode = OsAccountManager::GetOsAccountTypeFromProcess(type);
|
||||
return type;
|
||||
}
|
||||
|
||||
bool OsAccountManagerImpl::CheckMultiOsAccountEnabled(int32_t *errCode)
|
||||
{
|
||||
bool isMultiOAEnable = false;
|
||||
*errCode = OsAccountManager::IsMultiOsAccountEnable(isMultiOAEnable);
|
||||
return isMultiOAEnable;
|
||||
}
|
||||
|
||||
int32_t OsAccountManagerImpl::GetOsAccountLocalId(int32_t *errCode)
|
||||
{
|
||||
int32_t id = 0;
|
||||
*errCode = OsAccountManager::GetOsAccountLocalIdFromProcess(id);
|
||||
return id;
|
||||
}
|
||||
|
||||
int32_t OsAccountManagerImpl::GetActivatedOsAccountLocalIds(std::vector<int32_t> &osAccountIds)
|
||||
{
|
||||
return OsAccountManager::QueryActiveOsAccountIds(osAccountIds);
|
||||
}
|
||||
|
||||
uint32_t OsAccountManagerImpl::GetOsAccountCount(int32_t *errCode)
|
||||
{
|
||||
uint32_t osAccountCount = 0;
|
||||
*errCode = OsAccountManager::GetCreatedOsAccountsCount(osAccountCount);
|
||||
return osAccountCount;
|
||||
}
|
||||
|
||||
char *OsAccountManagerImpl::QueryDistributedVirtualDeviceId(int32_t *errCode)
|
||||
{
|
||||
std::string deviceId;
|
||||
*errCode = OsAccountManager::GetDistributedVirtualDeviceId(deviceId);
|
||||
return MallocCString(deviceId);
|
||||
}
|
||||
|
||||
int64_t OsAccountManagerImpl::GetSerialNumberForOsAccountLocalId(uint32_t localId, int32_t *errCode)
|
||||
{
|
||||
int64_t serialNum;
|
||||
*errCode = OsAccountManager::GetSerialNumberByOsAccountLocalId(localId, serialNum);
|
||||
return serialNum;
|
||||
}
|
||||
|
||||
int32_t OsAccountManagerImpl::GetOsAccountLocalIdForSerialNumber(int64_t serialNumber, int32_t *errCode)
|
||||
{
|
||||
int32_t id = 0;
|
||||
*errCode = OsAccountManager::GetOsAccountLocalIdBySerialNumber(serialNumber, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
int32_t OsAccountManagerImpl::GetOsAccountLocalIdForDomain(char *domain, char *accountName, int32_t *errCode)
|
||||
{
|
||||
int32_t id = 0;
|
||||
DomainAccountInfo domainInfo;
|
||||
domainInfo.accountId_ = domain;
|
||||
domainInfo.accountName_ = accountName;
|
||||
*errCode = OsAccountManager::GetOsAccountLocalIdFromDomain(domainInfo, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
int32_t OsAccountManagerImpl::GetOsAccountLocalIdForUid(int32_t uid, int32_t *errCode)
|
||||
{
|
||||
int32_t id = 0;
|
||||
*errCode = OsAccountManager::GetOsAccountLocalIdFromUid(uid, id);
|
||||
return id;
|
||||
}
|
||||
|
||||
char *OsAccountManagerImpl::GetOsAccountName(int32_t *errCode)
|
||||
{
|
||||
std::string name;
|
||||
*errCode = OsAccountManager::GetOsAccountName(name);
|
||||
return MallocCString(name);
|
||||
}
|
||||
|
||||
bool OsAccountManagerImpl::IsOsAccountUnlocked(int32_t *errCode)
|
||||
{
|
||||
bool isVerified = false;
|
||||
*errCode = OsAccountManager::IsCurrentOsAccountVerified(isVerified);
|
||||
return isVerified;
|
||||
}
|
||||
|
||||
char *OsAccountManagerImpl::MallocCString(const std::string &origin)
|
||||
{
|
||||
if (origin.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto len = origin.length() + 1;
|
||||
char *res = static_cast<char *>(malloc(sizeof(char) * len));
|
||||
if (res == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::char_traits<char>::copy(res, origin.c_str(), len);
|
||||
}
|
||||
}
|
@ -38,6 +38,7 @@ os_account_innerkits_native_path =
|
||||
"${os_account_path}/frameworks/osaccount/native"
|
||||
os_account_core_path = "${os_account_path}/frameworks/osaccount/core"
|
||||
os_account_kits_path = "${os_account_path}/interfaces/kits/napi/osaccount"
|
||||
os_account_ffi_kits_path = "${os_account_path}/interfaces/kits/cj/osaccount"
|
||||
os_account_dfx_path = "${os_account_path}/dfx"
|
||||
|
||||
account_iam_kits_path = "${os_account_path}/interfaces/kits/napi/account_iam"
|
||||
|
Loading…
Reference in New Issue
Block a user