mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-12-19 07:58:03 +00:00
修改bug
Signed-off-by: donglin <donglin9@huawei.com>
This commit is contained in:
parent
0c9f40c114
commit
230f8579f3
@ -16,6 +16,7 @@
|
||||
#ifndef OHOS_ABILITY_RUNTIME_APPLICATION_CONTROLL_UTILS_H
|
||||
#define OHOS_ABILITY_RUNTIME_APPLICATION_CONTROLL_UTILS_H
|
||||
|
||||
#include <chrono>
|
||||
#include <string>
|
||||
|
||||
#include "ability_manager_service.h"
|
||||
@ -31,20 +32,22 @@ namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace ApplicationControllUtils {
|
||||
using Want = OHOS::AAFwk::Want;
|
||||
const std::string CROWDTEST_EXPEIRD_IMPLICIT_ACTION_NAME = "ohos.action.crowdtestDead";
|
||||
const std::string CROWDTEST_EXPEIRD_IMPLICIT_ACTION_NAME = "ohos.want.action.crowdtest";
|
||||
const std::string CROWDTEST_EXPEIRD_IMPLICIT_BUNDLE_NAME = "com.demo.crowdtest";
|
||||
const int32_t CROWDTEST_EXPEIRD_IMPLICIT_START_FAILED = 1;
|
||||
const int32_t CROWDTEST_EXPEIRD_REFUSED = -1;
|
||||
|
||||
static bool IsCrowdtestExpired(const Want &want)
|
||||
static bool IsCrowdtestExpired(const Want &want, int32_t userId)
|
||||
{
|
||||
auto bms = AbilityUtil::GetBundleManager();
|
||||
CHECK_POINTER_AND_RETURN(bms, ERR_INVALID_VALUE);
|
||||
if (!bms) {
|
||||
HILOG_ERROR("%{public}s fail to get bundle manager.", __func__);
|
||||
}
|
||||
std::string bundleName = want.GetBundle();
|
||||
AppExecFwk::ApplicationInfo callerAppInfo;
|
||||
bool result = IN_PROCESS_CALL(
|
||||
bms->GetApplicationInfo(bundleName, AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT,
|
||||
0, callerAppInfo)
|
||||
userId, callerAppInfo)
|
||||
);
|
||||
if (!result) {
|
||||
HILOG_ERROR("%{public}s GetApplicaionInfo from bms failed.", __func__);
|
||||
@ -53,26 +56,27 @@ static bool IsCrowdtestExpired(const Want &want)
|
||||
|
||||
auto appDistributionType = callerAppInfo.appDistributionType;
|
||||
auto appCrowdtestDeadline = callerAppInfo.crowdtestDeadline;
|
||||
int64_t now = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
if (appDistributionType == AppExecFwk::Constants::APP_DISTRIBUTION_TYPE_CROWDTESTING &&
|
||||
appCrowdtestDeadline <= 0) {
|
||||
appCrowdtestDeadline <= now) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int CheckCrowdtestForeground(Want &want)
|
||||
static int CheckCrowdtestForeground(Want &want, int32_t userId)
|
||||
{
|
||||
if (IsCrowdtestExpired(want)) {
|
||||
want.SetElementName(CROWDTEST_EXPEIRD_IMPLICIT_BUNDLE_NAME, NULL);
|
||||
if (IsCrowdtestExpired(want, userId)) {
|
||||
want.SetElementName(CROWDTEST_EXPEIRD_IMPLICIT_BUNDLE_NAME, "");
|
||||
want.SetAction(CROWDTEST_EXPEIRD_IMPLICIT_ACTION_NAME);
|
||||
return CROWDTEST_EXPEIRD_REFUSED;
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
static int CheckCrowdtestBackground(const Want &want)
|
||||
static int CheckCrowdtestBackground(const Want &want, int32_t userId)
|
||||
{
|
||||
if (IsCrowdtestExpired(want)) {
|
||||
if (IsCrowdtestExpired(want, userId)) {
|
||||
return CROWDTEST_EXPEIRD_REFUSED;
|
||||
}
|
||||
return ERR_OK;
|
||||
|
@ -348,13 +348,15 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
|
||||
}
|
||||
|
||||
Want crowdtestWant = want;
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestForeground(crowdtestWant);
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestForeground(crowdtestWant, GetUserId());
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_DEBUG("%{public}s: Crowdtest expired", __func__);
|
||||
HILOG_ERROR("%{public}s: Crowdtest expired", __func__);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (ret == AAFwk::ApplicationControllUtils::CROWDTEST_EXPEIRD_REFUSED) {
|
||||
return StartAbilityInner(crowdtestWant, nullptr, requestCode, -1, userId);
|
||||
}
|
||||
HILOG_ERROR("%{public}s: CheckCrowdtestForeground faild", __func__);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -513,13 +515,15 @@ int AbilityManagerService::StartAbility(const Want &want, const AbilityStartSett
|
||||
}
|
||||
|
||||
Want crowdtestWant = want;
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestForeground(crowdtestWant);
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestForeground(crowdtestWant, GetUserId());
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_DEBUG("%{public}s: Crowdtest expired", __func__);
|
||||
HILOG_ERROR("%{public}s: Crowdtest expired", __func__);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (ret == AAFwk::ApplicationControllUtils::CROWDTEST_EXPEIRD_REFUSED) {
|
||||
return StartAbilityInner(crowdtestWant, nullptr, requestCode, -1, userId);
|
||||
}
|
||||
HILOG_ERROR("%{public}s: CheckCrowdtestForeground faild", __func__);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -637,7 +641,7 @@ int AbilityManagerService::StartAbility(const Want &want, const AbilityStartSett
|
||||
HiSysEventType::FAULT, eventInfo);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
auto ret = missionListManager->StartAbility(abilityRequest);
|
||||
ret = missionListManager->StartAbility(abilityRequest);
|
||||
if (ret != ERR_OK) {
|
||||
eventInfo.errCode = ret;
|
||||
AAFWK::EventReport::SendAbilityEvent(AAFWK::START_ABILITY_ERROR,
|
||||
@ -676,13 +680,15 @@ int AbilityManagerService::StartAbility(const Want &want, const StartOptions &st
|
||||
}
|
||||
|
||||
Want crowdtestWant = want;
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestForeground(crowdtestWant);
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestForeground(crowdtestWant, GetUserId());
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_DEBUG("%{public}s: Crowdtest expired", __func__);
|
||||
HILOG_ERROR("%{public}s: Crowdtest expired", __func__);
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
if (ret == AAFwk::ApplicationControllUtils::CROWDTEST_EXPEIRD_REFUSED) {
|
||||
return StartAbilityInner(crowdtestWant, nullptr, requestCode, -1, userId);
|
||||
}
|
||||
HILOG_ERROR("%{public}s: CheckCrowdtestForeground faild", __func__);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -895,9 +901,9 @@ int AbilityManagerService::StartExtensionAbility(const Want &want, const sptr<IR
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestBackground(want);
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestBackground(want, GetUserId());
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_DEBUG("%{public}s: Crowdtest expired", __func__);
|
||||
HILOG_ERROR("%{public}s: Crowdtest expired", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1211,11 +1217,6 @@ int AbilityManagerService::SendResultToAbility(int requestCode, int resultCode,
|
||||
int AbilityManagerService::StartRemoteAbility(const Want &want, int requestCode)
|
||||
{
|
||||
HILOG_INFO("%{public}s", __func__);
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestBackground(want);
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_DEBUG("%{public}s: Crowdtest expired", __func__);
|
||||
return ret;
|
||||
}
|
||||
int32_t callerUid = IPCSkeleton::GetCallingUid();
|
||||
uint32_t accessToken = IPCSkeleton::GetCallingTokenID();
|
||||
DistributedClient dmsClient;
|
||||
@ -1409,9 +1410,9 @@ int AbilityManagerService::ConnectAbility(
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestBackground(want);
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestBackground(want, GetUserId());
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_DEBUG("%{public}s: Crowdtest expired", __func__);
|
||||
HILOG_ERROR("%{public}s: Crowdtest expired", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -1517,12 +1518,6 @@ int AbilityManagerService::ConnectLocalAbility(const Want &want, const int32_t u
|
||||
return result;
|
||||
}
|
||||
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestBackground(want);
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_DEBUG("%{public}s: Crowdtest expired", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
auto abilityInfo = abilityRequest.abilityInfo;
|
||||
int32_t validUserId = abilityInfo.applicationInfo.singleton ? U0_USER_ID : userId;
|
||||
HILOG_DEBUG("validUserId : %{public}d, singleton is : %{public}d",
|
||||
@ -1567,12 +1562,6 @@ int AbilityManagerService::ConnectLocalAbility(const Want &want, const int32_t u
|
||||
int AbilityManagerService::ConnectRemoteAbility(const Want &want, const sptr<IRemoteObject> &connect)
|
||||
{
|
||||
HILOG_INFO("%{public}s begin ConnectAbilityRemote", __func__);
|
||||
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestBackground(want);
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_DEBUG("%{public}s: Crowdtest expired", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t callerUid = IPCSkeleton::GetCallingUid();
|
||||
int32_t callerPid = IPCSkeleton::GetCallingPid();
|
||||
@ -3699,6 +3688,12 @@ int AbilityManagerService::StartAbilityByCall(
|
||||
CHECK_POINTER_AND_RETURN(connect, ERR_INVALID_VALUE);
|
||||
CHECK_POINTER_AND_RETURN(connect->AsObject(), ERR_INVALID_VALUE);
|
||||
|
||||
int ret = AAFwk::ApplicationControllUtils::CheckCrowdtestBackground(want, GetUserId());
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_ERROR("%{public}s: Crowdtest expired", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (CheckIfOperateRemote(want)) {
|
||||
HILOG_INFO("start remote ability by call");
|
||||
return StartRemoteAbilityByCall(want, connect->AsObject());
|
||||
|
Loading…
Reference in New Issue
Block a user