!2323 修改startAbilityForResult的判断条件

Merge pull request !2323 from ql/0708
This commit is contained in:
openharmony_ci 2022-07-11 13:50:12 +00:00 committed by Gitee
commit e45927da7f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
7 changed files with 13 additions and 11 deletions

View File

@ -171,6 +171,7 @@ NativeValue* JsFeatureAbility::OnStartAbilityForResult(NativeEngine &engine, Nat
HILOG_INFO("OnStartAbilityForResult async callback is called end");
};
want.SetParam(Want::PARAM_RESV_FOR_RESULT, true);
requestCode_ = (requestCode_ == INT_MAX) ? 0 : (requestCode_ + 1);
ability->StartFeatureAbilityForResult(want, requestCode_, std::move(task));

View File

@ -82,6 +82,7 @@ ErrCode AbilityProcess::StartAbility(Ability *ability, CallAbilityParam param, C
if (param.forResultOption == true) {
if (param.setting == nullptr) {
HILOG_INFO("%{public}s param.setting == nullptr call StartAbilityForResult.", __func__);
param.want.SetParam(Want::PARAM_RESV_FOR_RESULT, true);
err = ability->StartAbilityForResult(param.want, param.requestCode);
} else {
HILOG_INFO("%{public}s param.setting != nullptr call StartAbilityForResult.", __func__);

View File

@ -415,6 +415,7 @@ NativeValue* JsAbilityContext::OnStartAbilityForResult(NativeEngine& engine, Nat
HILOG_WARN("context is released");
asyncTask->Reject(engine, CreateJsError(engine, 1, "context is released!"));
} else {
want.SetParam(Want::PARAM_RESV_FOR_RESULT, true);
curRequestCode_ = (curRequestCode_ == INT_MAX) ? 0 : (curRequestCode_ + 1);
(unwrapArgc == 1) ? context->StartAbilityForResult(want, curRequestCode_, std::move(task)) :
context->StartAbilityForResult(want, startOptions, curRequestCode_, std::move(task));

View File

@ -120,7 +120,6 @@ const std::string DMS_PROCESS_NAME = "distributedsched";
const std::string DMS_MISSION_ID = "dmsMissionId";
const std::string DLP_INDEX = "ohos.dlp.params.index";
const int DEFAULT_DMS_MISSION_ID = -1;
const int DEFAULT_REQUEST_CODE = -1;
const std::map<std::string, AbilityManagerService::DumpKey> AbilityManagerService::dumpMap = {
std::map<std::string, AbilityManagerService::DumpKey>::value_type("--all", KEY_DUMP_ALL),
std::map<std::string, AbilityManagerService::DumpKey>::value_type("-a", KEY_DUMP_ALL),
@ -383,7 +382,7 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
freeInstallManager_->StartRemoteFreeInstall(want, requestCode,
validUserId, callerToken, true);
}
if (requestCode == DEFAULT_REQUEST_CODE) {
if (!want.GetBoolParam(Want::PARAM_RESV_FOR_RESULT, false)) {
HILOG_INFO("%{public}s: try to StartAbility", __func__);
return StartRemoteAbility(want, requestCode);
}

View File

@ -53,7 +53,6 @@ int64_t AbilityRecord::abilityRecordId = 0;
int64_t AbilityRecord::g_abilityRecordEventId_ = 0;
const int32_t DEFAULT_USER_ID = 0;
const int32_t SEND_RESULT_CANCELED = -1;
const int DEFAULT_REQUEST_CODE = -1;
const int VECTOR_SIZE = 2;
const std::map<AbilityState, std::string> AbilityRecord::stateToStrMap = {
std::map<AbilityState, std::string>::value_type(INITIAL, "INITIAL"),
@ -1148,7 +1147,7 @@ void AbilityRecord::AddCallerRecord(const sptr<IRemoteObject> &callerToken, int
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
HILOG_INFO("Add caller record.");
if (requestCode != DEFAULT_REQUEST_CODE && IsSystemAbilityCall(callerToken)) {
if (!srcAbilityId.empty() && IsSystemAbilityCall(callerToken)) {
AddSystemAbilityCallerRecord(callerToken, requestCode, srcAbilityId);
return;
}

View File

@ -28,7 +28,6 @@ namespace AAFwk {
const std::u16string DMS_FREE_INSTALL_CALLBACK_TOKEN = u"ohos.DistributedSchedule.IDmsFreeInstallCallback";
const std::string DMS_MISSION_ID = "dmsMissionId";
constexpr uint32_t IDMS_CALLBACK_ON_FREE_INSTALL_DONE = 0;
const int DEFAULT_REQUEST_CODE = -1;
FreeInstallManager::FreeInstallManager(const std::weak_ptr<AbilityManagerService> &server)
: server_(server)
{
@ -127,7 +126,7 @@ int FreeInstallManager::StartRemoteFreeInstall(const Want &want, int requestCode
const sptr<IRemoteObject> &callerToken, bool ifOperateRemote)
{
HILOG_INFO("%{public}s", __func__);
if (requestCode == DEFAULT_REQUEST_CODE) {
if (!want.GetBoolParam(Want::PARAM_RESV_FOR_RESULT, false)) {
HILOG_INFO("%{public}s: StartAbility freeInstall", __func__);
return StartFreeInstall(want, validUserId, requestCode, callerToken, ifOperateRemote);
}

View File

@ -266,15 +266,17 @@ int MissionListManager::StartAbilityLocked(const std::shared_ptr<AbilityRecord>
targetAbilityRecord->SetLaunchReason(LaunchReason::LAUNCHREASON_START_ABILITY);
}
std::string srcDeviceId = abilityRequest.want.GetStringParam(DMS_SRC_NETWORK_ID);
int missionId = abilityRequest.want.GetIntParam(DMS_MISSION_ID, DEFAULT_DMS_MISSION_ID);
HILOG_DEBUG("Get srcNetWorkId = %s, missionId = %d", srcDeviceId.c_str(), missionId);
if (!srcDeviceId.empty() && missionId != DEFAULT_DMS_MISSION_ID) {
std::string srcAbilityId = "";
if (abilityRequest.want.GetBoolParam(Want::PARAM_RESV_FOR_RESULT, false)) {
std::string srcDeviceId = abilityRequest.want.GetStringParam(DMS_SRC_NETWORK_ID);
int missionId = abilityRequest.want.GetIntParam(DMS_MISSION_ID, DEFAULT_DMS_MISSION_ID);
HILOG_DEBUG("Get srcNetWorkId = %s, missionId = %d", srcDeviceId.c_str(), missionId);
Want* newWant = const_cast<Want*>(&abilityRequest.want);
newWant->RemoveParam(DMS_SRC_NETWORK_ID);
newWant->RemoveParam(DMS_MISSION_ID);
newWant->RemoveParam(Want::PARAM_RESV_FOR_RESULT);
srcAbilityId = srcDeviceId + "_" + std::to_string(missionId);
}
std::string srcAbilityId = srcDeviceId + "_" + std::to_string(missionId);
targetAbilityRecord->AddCallerRecord(abilityRequest.callerToken, abilityRequest.requestCode, srcAbilityId);
// 3. move mission to target list