mirror of
https://github.com/openharmony/security_device_auth.git
synced 2026-08-25 09:19:33 -04:00
@@ -29,10 +29,10 @@ int32_t GetFrontUserId(int32_t *userId)
|
||||
std::vector<int32_t> ids;
|
||||
int32_t errCode = OHOS::AccountSA::OsAccountManager::QueryActiveOsAccountIds(ids);
|
||||
if (errCode != ERR_OK || ids.empty()) {
|
||||
LOGE("QueryActiveOsAccountIds failed");
|
||||
LOGE("[OsAccountNativeFwk][QueryActiveOsAccountIds]: failed");
|
||||
return ERR_FAILED;
|
||||
}
|
||||
LOGI("QueryActiveOsAccountIds success");
|
||||
LOGI("[OsAccountNativeFwk][QueryActiveOsAccountIds]: success");
|
||||
*userId = ids[0];
|
||||
#else
|
||||
LOGI("no os account part, set default user");
|
||||
|
||||
@@ -56,15 +56,15 @@ void NetObserver::StartObserver()
|
||||
}
|
||||
int32_t ret = NetConnClient::GetInstance().RegisterNetConnCallback(specifier, observer, 0);
|
||||
if (ret == NetConnResultCode::NET_CONN_SUCCESS) {
|
||||
LOGI("[NetObserver]: Register net connection callback succeeded.");
|
||||
LOGI("[NetMgrSubsysterm][RegisterNetConnCallback]: Register net connection callback succeeded.");
|
||||
g_netCallback = observer;
|
||||
return;
|
||||
}
|
||||
retryCount++;
|
||||
LOGW("[NetObserver]: Register failed, errCode = %d, retry.", ret);
|
||||
LOGW("[NetMgrSubsysterm][RegisterNetConnCallback]: Register failed, errCode = %d, retry.", ret);
|
||||
sleep(1);
|
||||
} while (retryCount < RETRY_MAX_TIMES);
|
||||
LOGE("[NetObserver]: Register net connection callback failed!");
|
||||
LOGE("[NetMgrSubsysterm][RegisterNetConnCallback]: Register net connection callback failed!");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ void NetObserver::StopObserver()
|
||||
}
|
||||
int32_t ret = NetConnClient::GetInstance().UnregisterNetConnCallback(g_netCallback);
|
||||
if (ret == 0) {
|
||||
LOGI("[NetObserver]: unregister net connection callback succeeded.");
|
||||
LOGI("[NetMgrSubsysterm][UnregisterNetConnCallback]: unregister net connection callback succeeded.");
|
||||
g_netCallback = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -183,12 +183,12 @@ int32_t GetCurrentActiveOsAccountId(void)
|
||||
std::vector<int> activatedOsAccountIds;
|
||||
OHOS::ErrCode res = OHOS::AccountSA::OsAccountManager::QueryActiveOsAccountIds(activatedOsAccountIds);
|
||||
if ((res != OHOS::ERR_OK) || (activatedOsAccountIds.size() <= 0)) {
|
||||
LOGE("[OsAccountAdapter]: QueryActiveOsAccountIds fail. [Res]: %d", res);
|
||||
LOGE("[OsAccountNativeFwk][QueryActiveOsAccountIds]: fail. [Res]: %d", res);
|
||||
return INVALID_OS_ACCOUNT;
|
||||
}
|
||||
int osAccountId = activatedOsAccountIds[0];
|
||||
if (osAccountId != SYSTEM_DEFAULT_USER) {
|
||||
LOGI("[OsAccountAdapter]: Current active os accountId: %d", osAccountId);
|
||||
LOGI("[OsAccountNativeFwk][QueryActiveOsAccountIds]: Current active os accountId: %d", osAccountId);
|
||||
}
|
||||
return osAccountId;
|
||||
}
|
||||
@@ -225,7 +225,8 @@ bool IsOsAccountUnlocked(int32_t osAccountId)
|
||||
bool isUnlocked = false;
|
||||
OHOS::ErrCode res = OHOS::AccountSA::OsAccountManager::IsOsAccountVerified(osAccountId, isUnlocked);
|
||||
if (res != OHOS::ERR_OK) {
|
||||
LOGE("[OsAccountAdapter]: Check account verify status failed, res: %d, accountId: %d", res, osAccountId);
|
||||
LOGE("[OsAccountNativeFwk][IsOsAccountVerified]: Check account verify status failed, res: %d,
|
||||
accountId: %d", res, osAccountId);
|
||||
return false;
|
||||
}
|
||||
return isUnlocked;
|
||||
@@ -241,7 +242,7 @@ int32_t GetAllOsAccountIds(int32_t **osAccountIds, uint32_t *size)
|
||||
OHOS::ErrCode res = OHOS::AccountSA::OsAccountManager::QueryAllCreatedOsAccounts(osAccountInfos);
|
||||
uint32_t accountSize = osAccountInfos.size();
|
||||
if ((res != OHOS::ERR_OK) || (accountSize <= 0)) {
|
||||
LOGE("[OsAccountAdapter]: QueryAllCreatedOsAccounts failed. [Res]: %d", res);
|
||||
LOGE("[OsAccountNativeFwk][QueryAllCreatedOsAccounts]: failed. [Res]: %d", res);
|
||||
return HC_ERROR;
|
||||
}
|
||||
*osAccountIds = (int32_t *)HcMalloc(accountSize * sizeof(int32_t), 0);
|
||||
|
||||
@@ -87,12 +87,12 @@ int32_t CheckPermission(int32_t methodId)
|
||||
AccessTokenID tokenId = IPCSkeleton::GetCallingTokenID();
|
||||
ATokenTypeEnum tokenType = AccessTokenKit::GetTokenTypeFlag(tokenId);
|
||||
if (tokenType != TOKEN_NATIVE) {
|
||||
LOGE("Invalid token type: %d", tokenType);
|
||||
LOGE("[AccessTokenKit][GetTokenTypeFlag]: Invalid token type: %d", tokenType);
|
||||
return HC_ERROR;
|
||||
}
|
||||
NativeTokenInfo findInfo;
|
||||
if (AccessTokenKit::GetNativeTokenInfo(tokenId, findInfo) != 0) {
|
||||
LOGE("GetNativeTokenInfo failed!");
|
||||
LOGE("[AccessTokenKit][GetNativeTokenInfo]: failed!");
|
||||
return HC_ERROR;
|
||||
}
|
||||
if ((findInfo.apl != APL_SYSTEM_CORE) && (findInfo.apl != APL_SYSTEM_BASIC)) {
|
||||
|
||||
Reference in New Issue
Block a user