mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 23:30:44 +00:00
!7171 proxy超大函数整改
Merge pull request !7171 from savior-xzh/superfunction
This commit is contained in:
commit
04aa4b4c68
@ -30,6 +30,15 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace {
|
||||
#define PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(messageParcel, type, value) \
|
||||
do { \
|
||||
if (!(messageParcel).Write##type(value)) { \
|
||||
HILOG_ERROR("failed to write %{public}s", #value); \
|
||||
return INNER_ERR; \
|
||||
} \
|
||||
} while (0)
|
||||
}
|
||||
using AutoStartupInfo = AbilityRuntime::AutoStartupInfo;
|
||||
constexpr int32_t CYCLE_LIMIT = 1000;
|
||||
constexpr int32_t MAX_AUTO_STARTUP_COUNT = 100;
|
||||
@ -310,53 +319,29 @@ int AbilityManagerProxy::StartAbility(const Want &want, const StartOptions &star
|
||||
int AbilityManagerProxy::StartAbilityAsCaller(const Want &want, const sptr<IRemoteObject> &callerToken,
|
||||
sptr<IRemoteObject> asCallerSourceToken, int32_t userId, int requestCode, bool isSendDialogResult)
|
||||
{
|
||||
int error;
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteParcelable(&want)) {
|
||||
HILOG_ERROR("want write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Parcelable, &want);
|
||||
if (callerToken) {
|
||||
if (!data.WriteBool(true) || !data.WriteRemoteObject(callerToken)) {
|
||||
HILOG_ERROR("callerToken and flag write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, true);
|
||||
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, RemoteObject, callerToken);
|
||||
} else {
|
||||
if (!data.WriteBool(false)) {
|
||||
HILOG_ERROR("flag write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, false);
|
||||
}
|
||||
if (asCallerSourceToken) {
|
||||
if (!data.WriteBool(true) || !data.WriteRemoteObject(asCallerSourceToken)) {
|
||||
HILOG_ERROR("asCallerSourceToken and flag write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, true);
|
||||
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, RemoteObject, asCallerSourceToken);
|
||||
} else {
|
||||
if (!data.WriteBool(false)) {
|
||||
HILOG_ERROR("flag write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, false);
|
||||
}
|
||||
if (!data.WriteInt32(userId)) {
|
||||
HILOG_ERROR("userId write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteInt32(requestCode)) {
|
||||
HILOG_ERROR("requestCode write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteBool(isSendDialogResult)) {
|
||||
HILOG_ERROR("isSendDialogResult write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
error = SendRequest(AbilityManagerInterfaceCode::START_ABILITY_AS_CALLER_BY_TOKEN, data, reply, option);
|
||||
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, userId);
|
||||
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Int32, requestCode);
|
||||
PROXY_WRITE_PARCEL_AND_RETURN_IF_FAIL(data, Bool, isSendDialogResult);
|
||||
int error = SendRequest(AbilityManagerInterfaceCode::START_ABILITY_AS_CALLER_BY_TOKEN, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Send request error: %{public}d", error);
|
||||
return error;
|
||||
|
Loading…
Reference in New Issue
Block a user