mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 15:20:34 +00:00
fix codex
Signed-off-by: zhaoyuan17 <zhaoyuan17@huawei.com>
This commit is contained in:
parent
cebadf6410
commit
283f71383e
@ -26,11 +26,13 @@
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class AbilityImpl;
|
||||
class AbilityKeyEventHandle
|
||||
|
||||
#ifdef MMI_COMPILE
|
||||
: public MMI::KeyEventHandler
|
||||
class AbilityKeyEventHandle : public MMI::KeyEventHandler {
|
||||
#else
|
||||
class AbilityKeyEventHandle {
|
||||
#endif
|
||||
{
|
||||
|
||||
public:
|
||||
AbilityKeyEventHandle(const std::shared_ptr<AbilityImpl> &ability);
|
||||
~AbilityKeyEventHandle();
|
||||
|
@ -26,11 +26,12 @@
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class AbilityImpl;
|
||||
class AbilityTouchEventHandle
|
||||
|
||||
#ifdef MMI_COMPILE
|
||||
: public MMI::TouchEventHandler
|
||||
class AbilityTouchEventHandle : public MMI::TouchEventHandler {
|
||||
#else
|
||||
class AbilityTouchEventHandle {
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
AbilityTouchEventHandle(std::shared_ptr<AbilityImpl> ability);
|
||||
virtual ~AbilityTouchEventHandle();
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
virtual bool ContinuationBack(const AAFwk::Want &want) = 0;
|
||||
|
||||
enum {
|
||||
NOTIFY_SLAVE_TERMINATED = 1,
|
||||
NOTIFY_REPLICA_TERMINATED = 1,
|
||||
CONTINUATION_BACK,
|
||||
};
|
||||
};
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
virtual void NotifyReverseResult(int reverseResult) = 0;
|
||||
|
||||
enum class Message {
|
||||
PASS_MASTER = 1,
|
||||
PASS_PRIMARY = 1,
|
||||
REVERSE_CONTINUATION,
|
||||
NOTIFY_REVERSE_RESULT,
|
||||
};
|
||||
|
@ -298,11 +298,11 @@ private:
|
||||
bool isSystemCaller_ = false;
|
||||
sptr<AAFwk::IAbilityScheduler> dataAbilityProxy_ = nullptr;
|
||||
std::mutex lock_;
|
||||
static std::mutex oplock_;
|
||||
static std::mutex oplock_;
|
||||
|
||||
sptr<IRemoteObject::DeathRecipient> callerDeathRecipient_ = nullptr; // caller binderDied Recipient
|
||||
|
||||
std::map<sptr<AAFwk::IDataAbilityObserver>, sptr<AAFwk::IAbilityScheduler>> registerMap_;
|
||||
std::map<sptr<AAFwk::IDataAbilityObserver>, sptr<AAFwk::IAbilityScheduler>> registerMap_;
|
||||
|
||||
std::map<sptr<AAFwk::IDataAbilityObserver>, std::string> uriMap_;
|
||||
|
||||
|
@ -2097,7 +2097,7 @@ void Ability::CleanFormResource(const int64_t formId)
|
||||
{
|
||||
APP_LOGI("%{public}s called.", __func__);
|
||||
// compatible with int form id
|
||||
int64_t cleanId{-1L};
|
||||
int64_t cleanId {-1L};
|
||||
for (auto param : userReqParams_) {
|
||||
uint64_t unsignedFormId = static_cast<uint64_t>(formId);
|
||||
uint64_t unsignedParamFirst = static_cast<uint64_t>(param.first);
|
||||
@ -2382,8 +2382,9 @@ void Ability::OnDeathReceived()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(formLock);
|
||||
want = userReqRaram.second;
|
||||
if (want.GetBoolParam(Constants::PARAM_FORM_TEMPORARY_KEY, false) &&
|
||||
std::find(lostedTempForms.begin(), lostedTempForms.end(), formId) == lostedTempForms.end()) {
|
||||
if (want.GetBoolParam(Constants::PARAM_FORM_TEMPORARY_KEY, false)
|
||||
&& std::find(lostedTempForms.begin(), lostedTempForms.end(),
|
||||
formId) == lostedTempForms.end()) {
|
||||
lostedTempForms.emplace_back(formId);
|
||||
continue;
|
||||
}
|
||||
|
@ -133,7 +133,6 @@ void ContinuationHandler::SetAbilityInfo(std::shared_ptr<AbilityInfo> &abilityIn
|
||||
{
|
||||
APP_LOGI("%{public}s called begin", __func__);
|
||||
abilityInfo_ = abilityInfo;
|
||||
// ClearDeviceInfo(abilityInfo);
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ ReverseContinuationSchedulerPrimaryProxy::ReverseContinuationSchedulerPrimaryPro
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief Slave call this method when it terminated.
|
||||
* @brief Replica call this method when it terminated.
|
||||
*/
|
||||
void ReverseContinuationSchedulerPrimaryProxy::NotifyReplicaTerminated()
|
||||
{
|
||||
@ -44,7 +44,7 @@ void ReverseContinuationSchedulerPrimaryProxy::NotifyReplicaTerminated()
|
||||
return;
|
||||
}
|
||||
if (!remoteObject->SendRequest(
|
||||
IReverseContinuationSchedulerPrimary::NOTIFY_SLAVE_TERMINATED, data, reply, option)) {
|
||||
IReverseContinuationSchedulerPrimary::NOTIFY_REPLICA_TERMINATED, data, reply, option)) {
|
||||
APP_LOGE("ReverseContinuationSchedulerPrimaryProxy::NotifyReplicaTerminated SendRequest return false");
|
||||
return;
|
||||
}
|
||||
@ -52,7 +52,7 @@ void ReverseContinuationSchedulerPrimaryProxy::NotifyReplicaTerminated()
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Slave call this method to notify primary go on.
|
||||
* @brief Replica call this method to notify primary go on.
|
||||
*
|
||||
* @param want Contains data to be restore.
|
||||
* @return True if success, otherwise false.
|
||||
|
@ -26,7 +26,7 @@ const std::string ReverseContinuationSchedulerPrimaryStub::DESCRIPTOR(
|
||||
|
||||
ReverseContinuationSchedulerPrimaryStub::ReverseContinuationSchedulerPrimaryStub()
|
||||
{
|
||||
requestFuncMap_[NOTIFY_SLAVE_TERMINATED] = &ReverseContinuationSchedulerPrimaryStub::NotifyReplicaTerminatedInner;
|
||||
requestFuncMap_[NOTIFY_REPLICA_TERMINATED] = &ReverseContinuationSchedulerPrimaryStub::NotifyReplicaTerminatedInner;
|
||||
requestFuncMap_[CONTINUATION_BACK] = &ReverseContinuationSchedulerPrimaryStub::ContinuationBackInner;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ void ReverseContinuationSchedulerReplicaProxy::PassPrimary(const sptr<IRemoteObj
|
||||
return;
|
||||
}
|
||||
if (!remoteObject->SendRequest(
|
||||
static_cast<uint32_t>(IReverseContinuationSchedulerReplica::Message::PASS_MASTER), data, reply, option)) {
|
||||
static_cast<uint32_t>(IReverseContinuationSchedulerReplica::Message::PASS_PRIMARY), data, reply, option)) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::PassPrimary SendRequest return false");
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
@ -70,8 +70,10 @@ bool ReverseContinuationSchedulerReplicaProxy::ReverseContinuation()
|
||||
return false;
|
||||
}
|
||||
if (!remoteObject->SendRequest(
|
||||
static_cast<uint32_t>(IReverseContinuationSchedulerReplica::Message::REVERSE_CONTINUATION),
|
||||
data, reply, option)) {
|
||||
static_cast<uint32_t>(IReverseContinuationSchedulerReplica::Message::REVERSE_CONTINUATION),
|
||||
data,
|
||||
reply,
|
||||
option)) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::ReverseContinuation SendRequest return false");
|
||||
return false;
|
||||
}
|
||||
@ -98,8 +100,10 @@ void ReverseContinuationSchedulerReplicaProxy::NotifyReverseResult(int reverseRe
|
||||
return;
|
||||
}
|
||||
if (!remoteObject->SendRequest(
|
||||
static_cast<uint32_t>(IReverseContinuationSchedulerReplica::Message::NOTIFY_REVERSE_RESULT),
|
||||
data, reply, option)) {
|
||||
static_cast<uint32_t>(IReverseContinuationSchedulerReplica::Message::NOTIFY_REVERSE_RESULT),
|
||||
data,
|
||||
reply,
|
||||
option)) {
|
||||
APP_LOGE("ReverseContinuationSchedulerReplicaProxy::NotifyReverseResult SendRequest return false");
|
||||
}
|
||||
APP_LOGI("%{public}s called end", __func__);
|
||||
|
@ -20,7 +20,7 @@ namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
ReverseContinuationSchedulerReplicaStub::ReverseContinuationSchedulerReplicaStub()
|
||||
{
|
||||
continuationFuncMap_[static_cast<uint32_t>(IReverseContinuationSchedulerReplica::Message::PASS_MASTER)] =
|
||||
continuationFuncMap_[static_cast<uint32_t>(IReverseContinuationSchedulerReplica::Message::PASS_PRIMARY)] =
|
||||
&ReverseContinuationSchedulerReplicaStub::PassPrimaryInner;
|
||||
continuationFuncMap_[static_cast<uint32_t>(IReverseContinuationSchedulerReplica::Message::REVERSE_CONTINUATION)] =
|
||||
&ReverseContinuationSchedulerReplicaStub::ReverseContinuationInner;
|
||||
|
@ -24,9 +24,9 @@ namespace AppExecFwk {
|
||||
sptr<ContinuationConnector> ContinuationConnector::instance_ = nullptr;
|
||||
std::mutex ContinuationConnector::mutex_;
|
||||
const std::string ContinuationConnector::CONNECTOR_DEVICE_ID("");
|
||||
const std::string ContinuationConnector::CONNECTOR_BUNDLE_NAME("com.huawei.controlcenter");
|
||||
const std::string ContinuationConnector::CONNECTOR_BUNDLE_NAME("com.ohos.controlcenter");
|
||||
const std::string ContinuationConnector::CONNECTOR_ABILITY_NAME(
|
||||
"com.huawei.controlcenter.fatransfer.service.FeatureAbilityRegisterService");
|
||||
"com.ohos.controlcenter.fatransfer.service.FeatureAbilityRegisterService");
|
||||
|
||||
ContinuationConnector::ContinuationConnector(const std::weak_ptr<Context> &context) : context_(context)
|
||||
{}
|
||||
|
@ -208,7 +208,6 @@ std::shared_ptr<NativeRdb::AbsSharedResultSet> DataAbilityImpl::Query(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// resultSet = ability_->Query(uri, columns, predicates);
|
||||
return ability_->Query(uri, columns, predicates);
|
||||
}
|
||||
|
||||
|
@ -447,7 +447,7 @@ bool DataAbilityOperation::ReadFromParcel(Parcel &in)
|
||||
return false;
|
||||
}
|
||||
if (referenceSize >= REFERENCE_THRESHOLD) {
|
||||
APP_LOGI("DataAbilityOperation::ReadFromParcel referenceSize:%{public}d >= REFERENCE_THRESHOLD:%{public}d",referenceSize ,REFERENCE_THRESHOLD);
|
||||
APP_LOGI("DataAbilityOperation::ReadFromParcel referenceSize:%{public}d >= REFERENCE_THRESHOLD:%{public}d", referenceSize, REFERENCE_THRESHOLD);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -465,7 +465,6 @@ bool DataAbilityOperation::ReadFromParcel(Parcel &in)
|
||||
dataAbilityPredicatesBackReferences_.insert(std::make_pair(first, second));
|
||||
}
|
||||
|
||||
// interrupted_ = in.ReadBool();
|
||||
APP_LOGD("DataAbilityOperation::ReadFromParcel end");
|
||||
return true;
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ DataAbilityResult::DataAbilityResult(int count) : uri_("")
|
||||
*/
|
||||
DataAbilityResult::DataAbilityResult(Parcel &parcel) : uri_(""), count_(0)
|
||||
{
|
||||
ReadFromParcel(parcel);
|
||||
ReadFromParcel(parcel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,7 +85,7 @@ int DataAbilityResult::GetCount()
|
||||
DataAbilityResult *DataAbilityResult::CreateFromParcel(Parcel &parcel)
|
||||
{
|
||||
DataAbilityResult *dataAbilityResult = new (std::nothrow) DataAbilityResult(parcel);
|
||||
if(dataAbilityResult == nullptr){
|
||||
if (dataAbilityResult == nullptr) {
|
||||
APP_LOGE("DataAbilityResult::CreateFromParcel dataAbilityResult is nullptr");
|
||||
}
|
||||
return dataAbilityResult;
|
||||
@ -100,7 +100,7 @@ std::string DataAbilityResult::ToString()
|
||||
std::string stringBuilder = "DataAbilityResult(";
|
||||
stringBuilder.append("uri=").append(uri_.ToString()).append(" ");
|
||||
stringBuilder.append("count=").append(std::to_string(count_)).append(" ");
|
||||
stringBuilder.erase(stringBuilder.length() - 1 , 1);
|
||||
stringBuilder.erase(stringBuilder.length() - 1, 1);
|
||||
stringBuilder.append(")");
|
||||
return stringBuilder;
|
||||
}
|
||||
@ -112,7 +112,7 @@ std::string DataAbilityResult::ToString()
|
||||
*/
|
||||
bool DataAbilityResult::Marshalling(Parcel &parcel) const
|
||||
{
|
||||
//uri_
|
||||
// uri_
|
||||
if (uri_.ToString().empty()) {
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, VALUE_NULL);
|
||||
} else {
|
||||
@ -124,7 +124,7 @@ bool DataAbilityResult::Marshalling(Parcel &parcel) const
|
||||
}
|
||||
}
|
||||
|
||||
//count_
|
||||
// count_
|
||||
if (!parcel.WriteInt32(count_)) {
|
||||
return false;
|
||||
}
|
||||
@ -140,8 +140,8 @@ bool DataAbilityResult::Marshalling(Parcel &parcel) const
|
||||
DataAbilityResult *DataAbilityResult::Unmarshalling(Parcel &parcel)
|
||||
{
|
||||
DataAbilityResult *dataAbilityResult = new (std::nothrow) DataAbilityResult(0);
|
||||
if (dataAbilityResult != nullptr ) {
|
||||
if(!dataAbilityResult->ReadFromParcel(parcel)){
|
||||
if (dataAbilityResult != nullptr) {
|
||||
if (!dataAbilityResult->ReadFromParcel(parcel)) {
|
||||
delete dataAbilityResult;
|
||||
dataAbilityResult = nullptr;
|
||||
}
|
||||
@ -152,7 +152,7 @@ DataAbilityResult *DataAbilityResult::Unmarshalling(Parcel &parcel)
|
||||
|
||||
bool DataAbilityResult::ReadFromParcel(Parcel &parcel)
|
||||
{
|
||||
//uri_
|
||||
// uri_
|
||||
int32_t empty = VALUE_NULL;
|
||||
if (!parcel.ReadInt32(empty)) {
|
||||
return false;
|
||||
@ -169,7 +169,7 @@ bool DataAbilityResult::ReadFromParcel(Parcel &parcel)
|
||||
}
|
||||
}
|
||||
|
||||
//count_
|
||||
// count_
|
||||
if (!parcel.ReadInt32(count_)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public:
|
||||
{
|
||||
return BATCHINSERTNUM;
|
||||
};
|
||||
virtual bool ScheduleRegisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver)
|
||||
virtual bool ScheduleRegisterObserver(const Uri &uri, const sptr<AAFwk::IDataAbilityObserver> &dataObserver)
|
||||
{
|
||||
return true;
|
||||
};
|
||||
|
@ -67,7 +67,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void SetMockStatus(bool nflag) {
|
||||
void SetMockStatus(bool nflag)
|
||||
{
|
||||
mockStatus = nflag;
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ public:
|
||||
};
|
||||
virtual bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos) override
|
||||
{
|
||||
return true;
|
||||
return true;
|
||||
};
|
||||
virtual bool CheckIsSystemAppByUid(const int uid) override
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
ResourceManagerTestInstance(){};
|
||||
virtual ~ResourceManagerTestInstance(){};
|
||||
|
||||
virtual bool AddResource(const char *path) override
|
||||
bool AddResource(const char *path) override
|
||||
{
|
||||
return false;
|
||||
};
|
||||
@ -52,7 +52,7 @@ public:
|
||||
outValue = iter->second;
|
||||
return SUCCESS;
|
||||
};
|
||||
virtual void SetStringById(uint32_t id, std::string &inValue) override
|
||||
void SetStringById(uint32_t id, std::string &inValue) override
|
||||
{
|
||||
if (!StringById_.empty()) {
|
||||
StringById_.clear();
|
||||
@ -69,7 +69,7 @@ public:
|
||||
{
|
||||
return ERROR;
|
||||
};
|
||||
virtual void SetStringFormatById(std::string &inValue, uint32_t id, ...) override{};
|
||||
void SetStringFormatById(std::string &inValue, uint32_t id, ...) override{};
|
||||
|
||||
virtual RState GetStringFormatByName(std::string &outValue, const char *name, ...)
|
||||
{
|
||||
@ -224,7 +224,7 @@ public:
|
||||
outValue = iter->second;
|
||||
return SUCCESS;
|
||||
};
|
||||
virtual void SetColorById(uint32_t id, uint32_t &inValue) override
|
||||
void SetColorById(uint32_t id, uint32_t &inValue) override
|
||||
{
|
||||
if (!ColorById_.empty()) {
|
||||
ColorById_.clear();
|
||||
|
@ -109,7 +109,6 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_Query_0100, Function | MediumTes
|
||||
|
||||
NativeRdb::DataAbilityPredicates predicates("test");
|
||||
std::shared_ptr<NativeRdb::AbsSharedResultSet> resultSet = abilitythread->Query(uri, columns, predicates);
|
||||
// EXPECT_STREQ(resultSet->testInf_.c_str(), "TestResultSet");
|
||||
EXPECT_TRUE(resultSet != nullptr);
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ HWTEST_F(DataAbilityOperationTest, AaFwk_DataAbilityOperation_Create_0200, Funct
|
||||
Parcel in;
|
||||
std::shared_ptr<DataAbilityOperation> dataAbilityOperation = std::make_shared<DataAbilityOperation>(in);
|
||||
EXPECT_EQ(dataAbilityOperation->GetUri(), nullptr);
|
||||
EXPECT_EQ(dataAbilityOperation->GetType(), 0);
|
||||
EXPECT_EQ(dataAbilityOperation->GetType(), -1);
|
||||
GTEST_LOG_(INFO) << "AaFwk_DataAbilityOperation_Create_0200 end";
|
||||
}
|
||||
|
||||
@ -113,7 +113,7 @@ HWTEST_F(DataAbilityOperationTest, AaFwk_DataAbilityOperation_Create_0400, Funct
|
||||
std::shared_ptr<Uri> uri = std::make_shared<Uri>(URI);
|
||||
std::unique_ptr<DataAbilityOperation> operation = std::make_unique<DataAbilityOperation>(dataAbilityOperation, uri);
|
||||
EXPECT_EQ(operation->GetUri()->ToString(), URI);
|
||||
EXPECT_EQ(operation->GetType(), 0);
|
||||
EXPECT_EQ(operation->GetType(), -1);
|
||||
dataAbilityOperation.reset();
|
||||
GTEST_LOG_(INFO) << "AaFwk_DataAbilityOperation_Create_0400 end";
|
||||
}
|
||||
|
@ -20,45 +20,59 @@
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
const Uuid Uuid::Empty = {
|
||||
0x00000000, 0x0000, 0x0000, 0x0000, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}};
|
||||
0x00000000, 0x0000, 0x0000, 0x0000, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IInterface = {
|
||||
0x00000000, 0x0000, 0x0000, 0x0000, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}};
|
||||
0x00000000, 0x0000, 0x0000, 0x0000, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IBoolean = {
|
||||
0x492ef6c0, 0xe122, 0x401d, 0x80c4, {0xb, 0xb, 0x6, 0x5, 0xe, 0x2, 0x3, 0x2, 0x5, 0x7, 0x6, 0x6}};
|
||||
0x492ef6c0, 0xe122, 0x401d, 0x80c4, {0xb, 0xb, 0x6, 0x5, 0xe, 0x2, 0x3, 0x2, 0x5, 0x7, 0x6, 0x6}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IChar = {
|
||||
0x6da72e7c, 0xd353, 0x4d7b, 0x85ef, {0x2, 0x1, 0x4, 0x6, 0xa, 0xd, 0xd, 0x3, 0x4, 0x2, 0x1, 0x9}};
|
||||
0x6da72e7c, 0xd353, 0x4d7b, 0x85ef, {0x2, 0x1, 0x4, 0x6, 0xa, 0xd, 0xd, 0x3, 0x4, 0x2, 0x1, 0x9}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IByte = {
|
||||
0x2c9fd6ff, 0x73f7, 0x4a22, 0x9ea8, {0x1, 0xe, 0x3, 0x7, 0xb, 0x2, 0x2, 0x1, 0x3, 0xc, 0xa, 0x1}};
|
||||
0x2c9fd6ff, 0x73f7, 0x4a22, 0x9ea8, {0x1, 0xe, 0x3, 0x7, 0xb, 0x2, 0x2, 0x1, 0x3, 0xc, 0xa, 0x1}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IShort = {
|
||||
0x54fe1291, 0x0813, 0x43c9, 0xb6f7, {0xb, 0x0, 0x0, 0x8, 0xe, 0xd, 0xe, 0xf, 0x7, 0xf, 0x3, 0x4}};
|
||||
0x54fe1291, 0x0813, 0x43c9, 0xb6f7, {0xb, 0x0, 0x0, 0x8, 0xe, 0xd, 0xe, 0xf, 0x7, 0xf, 0x3, 0x4}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IInteger = {
|
||||
0x0672d282, 0x7cdb, 0x49b8, 0x92c7, {0x1, 0xa, 0xf, 0x3, 0x5, 0xe, 0x2, 0xd, 0x4, 0x9, 0x4, 0x9}};
|
||||
0x0672d282, 0x7cdb, 0x49b8, 0x92c7, {0x1, 0xa, 0xf, 0x3, 0x5, 0xe, 0x2, 0xd, 0x4, 0x9, 0x4, 0x9}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_ILong = {
|
||||
0xd7550828, 0x2eaf, 0x4281, 0x8604, {0x4, 0x2, 0xa, 0x8, 0x2, 0xa, 0xb, 0x9, 0xb, 0xc, 0xd, 0xc}};
|
||||
0xd7550828, 0x2eaf, 0x4281, 0x8604, {0x4, 0x2, 0xa, 0x8, 0x2, 0xa, 0xb, 0x9, 0xb, 0xc, 0xd, 0xc}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IFloat = {
|
||||
0xb5428638, 0xca53, 0x4a27, 0x95a0, {0x3, 0xf, 0x2, 0x4, 0xe, 0x5, 0x4, 0xa, 0x5, 0x8, 0xd, 0x5}};
|
||||
0xb5428638, 0xca53, 0x4a27, 0x95a0, {0x3, 0xf, 0x2, 0x4, 0xe, 0x5, 0x4, 0xa, 0x5, 0x8, 0xd, 0x5}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IDouble = {
|
||||
0x596dc69a, 0xae7d, 0x42ad, 0xb00f, {0x0, 0xd, 0x5, 0xe, 0xb, 0x0, 0x1, 0xa, 0x2, 0x5, 0x5, 0x7}};
|
||||
0x596dc69a, 0xae7d, 0x42ad, 0xb00f, {0x0, 0xd, 0x5, 0xe, 0xb, 0x0, 0x1, 0xa, 0x2, 0x5, 0x5, 0x7}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IString = {
|
||||
0x69644bf4, 0xdd20, 0x417b, 0x9055, {0x5, 0xa, 0x2, 0x6, 0xe, 0x3, 0xe, 0x1, 0x7, 0x9, 0x3, 0xb}};
|
||||
0x69644bf4, 0xdd20, 0x417b, 0x9055, {0x5, 0xa, 0x2, 0x6, 0xe, 0x3, 0xe, 0x1, 0x7, 0x9, 0x3, 0xb}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IArray = {
|
||||
0x875b9da6, 0x9913, 0x4370, 0x8847, {0xe, 0x1, 0x9, 0x6, 0x1, 0xb, 0xe, 0x6, 0xe, 0x5, 0x6, 0x0}};
|
||||
0x875b9da6, 0x9913, 0x4370, 0x8847, {0xe, 0x1, 0x9, 0x6, 0x1, 0xb, 0xe, 0x6, 0xe, 0x5, 0x6, 0x0}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IPacMap = {
|
||||
0xf92066fd, 0xfd0c, 0x401b, 0xa3f6, {0x6, 0x2, 0x6, 0xd, 0xa, 0x3, 0xb, 0xa, 0xc, 0x9, 0xd, 0x5}};
|
||||
0xf92066fd, 0xfd0c, 0x401b, 0xa3f6, {0x6, 0x2, 0x6, 0xd, 0xa, 0x3, 0xb, 0xa, 0xc, 0x9, 0xd, 0x5}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IUserObject = {
|
||||
0x4edb325d, 0x8532, 0x4af7, 0xb42e, {0x8, 0x2, 0xf, 0x4, 0xf, 0x2, 0x9, 0xd, 0xf, 0xd, 0xe, 0xa}};
|
||||
0x4edb325d, 0x8532, 0x4af7, 0xb42e, {0x8, 0x2, 0xf, 0x4, 0xf, 0x2, 0x9, 0xd, 0xf, 0xd, 0xe, 0xa}
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
@ -24,13 +24,16 @@
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
const InterfaceID g_IID_IObject = {
|
||||
0x8321f710, 0xa0c0, 0x4cbe, 0xbfbc, {0x5, 0xa, 0x7, 0x8, 0xf, 0x1, 0x3, 0x1, 0x2, 0xb, 0x1, 0xb}};
|
||||
0x8321f710, 0xa0c0, 0x4cbe, 0xbfbc, {0x5, 0xa, 0x7, 0x8, 0xf, 0x1, 0x3, 0x1, 0x2, 0xb, 0x1, 0xb}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IWeakReference = {
|
||||
0x26ab1978, 0x1d11, 0x4a4f, 0x826d, {0x6, 0x1, 0x7, 0x8, 0x5, 0xc, 0x0, 0x4, 0x8, 0xc, 0xc, 0xa}};
|
||||
0x26ab1978, 0x1d11, 0x4a4f, 0x826d, {0x6, 0x1, 0x7, 0x8, 0x5, 0xc, 0x0, 0x4, 0x8, 0xc, 0xc, 0xa}
|
||||
};
|
||||
|
||||
const InterfaceID g_IID_IWeakReferenceSource = {
|
||||
0xbc3f5250, 0x34d7, 0x42d2, 0x9b40, {0xf, 0xf, 0xc, 0xe, 0x8, 0x3, 0xf, 0xd, 0x4, 0x0, 0x6, 0x1}};
|
||||
0xbc3f5250, 0x34d7, 0x42d2, 0x9b40, {0xf, 0xf, 0xc, 0xe, 0x8, 0x3, 0xf, 0xd, 0x4, 0x0, 0x6, 0x1}
|
||||
};
|
||||
|
||||
class WeakReferenceImpl final : public LightRefCountBase, public IWeakReference {
|
||||
public:
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <cstdlib>
|
||||
#include <iomanip>
|
||||
#include "parcel_macro.h"
|
||||
#include "string_ex.h"
|
||||
#include "ohos/aafwk/base/array_wrapper.h"
|
||||
@ -110,7 +111,7 @@ const std::regex NUMBER_REGEX("^[-+]?([0-9]+)([.]([0-9]+))?$");
|
||||
if (it != (mapList).end()) { \
|
||||
if (IArray::Query(it->second.GetRefPtr()) != nullptr) { \
|
||||
if (Array::Is##id##Array(IArray::Query(it->second.GetRefPtr()))) { \
|
||||
auto func = [&](IInterface *object) { \
|
||||
auto func = [ & ](IInterface * object) { \
|
||||
if (I##id::Query(object) != nullptr) { \
|
||||
(value).push_back(id::Unbox(I##id::Query(object))); \
|
||||
} \
|
||||
@ -121,7 +122,7 @@ const std::regex NUMBER_REGEX("^[-+]?([0-9]+)([.]([0-9]+))?$");
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
template <typename IClassName, typename baseValue>
|
||||
template<typename IClassName, typename baseValue>
|
||||
static void GetBaseDataValue(OHOS::AAFwk::IInterface *baseObj, Json::Value &json, int type)
|
||||
{
|
||||
IClassName *data = IClassName::Query(baseObj);
|
||||
@ -139,10 +140,10 @@ static void GetBaseDataValue(OHOS::AAFwk::IInterface *baseObj, Json::Value &json
|
||||
(json)["type"] = type; \
|
||||
} while (0);
|
||||
|
||||
template <typename RawType>
|
||||
template<typename RawType>
|
||||
static std::string RawTypeToString(const RawType value, unsigned int precisionAfterPoint);
|
||||
|
||||
template <typename IClassName, typename ClassName, typename baseValue>
|
||||
template<typename IClassName, typename ClassName, typename baseValue>
|
||||
static void GetBaseFloatDoubleDataValue(OHOS::AAFwk::IInterface *baseObj, Json::Value &json, int type, int precision)
|
||||
{
|
||||
IClassName *data = IClassName::Query(baseObj);
|
||||
@ -180,7 +181,7 @@ static void GetBaseFloatDoubleDataValue(OHOS::AAFwk::IInterface *baseObj, Json::
|
||||
(json)["type"] = type; \
|
||||
} while (0);
|
||||
|
||||
template <typename IClassName, typename ClassName, typename valueType>
|
||||
template<typename IClassName, typename ClassName, typename valueType>
|
||||
static void PacmapGetArrayVal(OHOS::AAFwk::IInterface *ao, std::vector<valueType> &array)
|
||||
{
|
||||
if (ao == nullptr) {
|
||||
@ -204,7 +205,7 @@ static void PacmapGetArrayVal(OHOS::AAFwk::IInterface *ao, std::vector<valueType
|
||||
return false; \
|
||||
} \
|
||||
if (IArray::Query((it)->second.GetRefPtr()) != nullptr) { \
|
||||
auto func = [&](AAFwk::IInterface *object) { \
|
||||
auto func = [ & ](AAFwk::IInterface * object) { \
|
||||
if (object != nullptr) { \
|
||||
idInterface *value = idInterface::Query(object); \
|
||||
if (value != nullptr) { \
|
||||
@ -938,7 +939,7 @@ bool PacMap::EqualPacMapData(const PacMapList &leftPacMapList, const PacMapList
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename iid, typename id, typename value>
|
||||
template<typename iid, typename id, typename value>
|
||||
static void GetArrayData(
|
||||
AAFwk::IInterface *interface, std::vector<value> &array, std::function<bool(IArray *)> IsArrayfunc)
|
||||
{
|
||||
@ -951,7 +952,7 @@ static void GetArrayData(
|
||||
}
|
||||
}
|
||||
|
||||
template <typename iid, typename id, typename value>
|
||||
template<typename iid, typename id, typename value>
|
||||
static bool CompareTwoArrayData(
|
||||
AAFwk::IInterface *one_interface, AAFwk::IInterface *two_interface, std::function<bool(IArray *)> IsArrayfunc)
|
||||
{
|
||||
@ -989,44 +990,44 @@ bool PacMap::CompareArrayData(AAFwk::IInterface *one_interface, AAFwk::IInterfac
|
||||
}
|
||||
if (AAFwk::Array::IsBooleanArray(IArray::Query(one_interface))) {
|
||||
if (!CompareTwoArrayData<AAFwk::IBoolean, AAFwk::Boolean, bool>(
|
||||
one_interface, two_interface, AAFwk::Array::IsBooleanArray)) {
|
||||
one_interface, two_interface, AAFwk::Array::IsBooleanArray)) {
|
||||
return false;
|
||||
}
|
||||
} else if (AAFwk::Array::IsCharArray(AAFwk::IArray::Query(one_interface))) {
|
||||
return false;
|
||||
} else if (AAFwk::Array::IsByteArray(IArray::Query(one_interface))) {
|
||||
if (!CompareTwoArrayData<AAFwk::IByte, AAFwk::Byte, byte>(
|
||||
one_interface, two_interface, AAFwk::Array::IsByteArray)) {
|
||||
one_interface, two_interface, AAFwk::Array::IsByteArray)) {
|
||||
return false;
|
||||
}
|
||||
} else if (AAFwk::Array::IsShortArray(IArray::Query(one_interface))) {
|
||||
if (!CompareTwoArrayData<AAFwk::IShort, AAFwk::Short, short>(
|
||||
one_interface, two_interface, AAFwk::Array::IsShortArray)) {
|
||||
one_interface, two_interface, AAFwk::Array::IsShortArray)) {
|
||||
return false;
|
||||
}
|
||||
} else if (AAFwk::Array::IsIntegerArray(IArray::Query(one_interface))) {
|
||||
if (!CompareTwoArrayData<AAFwk::IInteger, AAFwk::Integer, int>(
|
||||
one_interface, two_interface, AAFwk::Array::IsIntegerArray)) {
|
||||
one_interface, two_interface, AAFwk::Array::IsIntegerArray)) {
|
||||
return false;
|
||||
}
|
||||
} else if (AAFwk::Array::IsLongArray(IArray::Query(one_interface))) {
|
||||
if (!CompareTwoArrayData<AAFwk::ILong, AAFwk::Long, long>(
|
||||
one_interface, two_interface, AAFwk::Array::IsLongArray)) {
|
||||
one_interface, two_interface, AAFwk::Array::IsLongArray)) {
|
||||
return false;
|
||||
}
|
||||
} else if (AAFwk::Array::IsFloatArray(IArray::Query(one_interface))) {
|
||||
if (!CompareTwoArrayData<AAFwk::IFloat, AAFwk::Float, float>(
|
||||
one_interface, two_interface, AAFwk::Array::IsFloatArray)) {
|
||||
one_interface, two_interface, AAFwk::Array::IsFloatArray)) {
|
||||
return false;
|
||||
}
|
||||
} else if (AAFwk::Array::IsDoubleArray(IArray::Query(one_interface))) {
|
||||
if (!CompareTwoArrayData<AAFwk::IDouble, AAFwk::Double, double>(
|
||||
one_interface, two_interface, AAFwk::Array::IsDoubleArray)) {
|
||||
one_interface, two_interface, AAFwk::Array::IsDoubleArray)) {
|
||||
return false;
|
||||
}
|
||||
} else if (AAFwk::Array::IsStringArray(IArray::Query(one_interface))) {
|
||||
if (!CompareTwoArrayData<AAFwk::IString, AAFwk::String, std::string>(
|
||||
one_interface, two_interface, AAFwk::Array::IsStringArray)) {
|
||||
one_interface, two_interface, AAFwk::Array::IsStringArray)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
@ -1223,12 +1224,12 @@ bool PacMap::ToJson(const PacMapList &mapList, Json::Value &dataObject) const
|
||||
}
|
||||
return true;
|
||||
}
|
||||
template <typename RawType>
|
||||
|
||||
template<typename RawType>
|
||||
static std::string RawTypeToString(const RawType value, unsigned int precisionAfterPoint)
|
||||
{
|
||||
std::ostringstream out("RawTypeToString");
|
||||
out.precision(std::numeric_limits<double>::digits10);
|
||||
out << value;
|
||||
out << std::setw(0) << std::setprecision(precisionAfterPoint) << value;
|
||||
|
||||
std::string res = out.str();
|
||||
auto pos = res.find('.');
|
||||
|
@ -1336,7 +1336,7 @@ void Want::ToUriStringInner(std::string &uriString) const
|
||||
}
|
||||
if (operation_.GetFlags() != 0) {
|
||||
uriString += "flag=";
|
||||
char buf[HEX_STRING_BUF_LEN]{0};
|
||||
char buf[HEX_STRING_BUF_LEN] {0};
|
||||
std::size_t len = snprintf_s(buf, HEX_STRING_BUF_LEN, HEX_STRING_BUF_LEN - 1, "0x%08x", operation_.GetFlags());
|
||||
if (len == HEX_STRING_LEN) {
|
||||
std::string flag = buf;
|
||||
|
@ -633,7 +633,7 @@ bool WantParams::Marshalling(Parcel &parcel) const
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename dataType, typename className>
|
||||
template<typename dataType, typename className>
|
||||
static bool SetArray(const InterfaceID &id, const std::vector<dataType> &value, sptr<IArray> &ao)
|
||||
{
|
||||
typename std::vector<dataType>::size_type size = value.size();
|
||||
@ -647,7 +647,7 @@ static bool SetArray(const InterfaceID &id, const std::vector<dataType> &value,
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
template<typename T1, typename T2, typename T3>
|
||||
static void FillArray(IArray *ao, std::vector<T1> &array)
|
||||
{
|
||||
auto func = [&](IInterface *object) {
|
||||
@ -661,7 +661,7 @@ static void FillArray(IArray *ao, std::vector<T1> &array)
|
||||
Array::ForEach(ao, func);
|
||||
}
|
||||
// inner use template function
|
||||
template <typename T1, typename T2, typename T3>
|
||||
template<typename T1, typename T2, typename T3>
|
||||
static void SetNewArray(const AAFwk::InterfaceID &id, AAFwk::IArray *orgIArray, sptr<AAFwk::IArray> &ao)
|
||||
{
|
||||
if (orgIArray == nullptr) {
|
||||
|
@ -16,9 +16,11 @@
|
||||
#include <algorithm>
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
#define WANT_PARAM_WRAPPER_TWO 2
|
||||
IINTERFACE_IMPL_1(WantParamWrapper, Object, IWantParams);
|
||||
const InterfaceID g_IID_IWantParams = {
|
||||
0xa75b9db6, 0x9813, 0x4371, 0x8848, {0xd, 0x2, 0x9, 0x6, 0x6, 0xc, 0xe, 0x6, 0xe, 0xc, 0x6, 0x8}};
|
||||
0xa75b9db6, 0x9813, 0x4371, 0x8848, {0xd, 0x2, 0x9, 0x6, 0x6, 0xc, 0xe, 0x6, 0xe, 0xc, 0x6, 0x8}
|
||||
};
|
||||
ErrCode WantParamWrapper::GetValue(WantParams &value)
|
||||
{
|
||||
|
||||
@ -77,7 +79,7 @@ bool WantParamWrapper::ValidateStr(const std::string &str)
|
||||
if (str == "" || str == "{}" || str == "{\"\"}") {
|
||||
return false;
|
||||
}
|
||||
if (count(str.begin(), str.end(), '\"') % 2 != 0) {
|
||||
if (count(str.begin(), str.end(), '\"') % WANT_PARAM_WRAPPER_TWO != 0) {
|
||||
return false;
|
||||
}
|
||||
if (count(str.begin(), str.end(), '{') != count(str.begin(), str.end(), '}')) {
|
||||
|
@ -522,49 +522,48 @@ HWTEST_F(WantBaseTest, AaFwk_Want_Parcelable_0500, Function | MediumTest | Level
|
||||
GTEST_LOG_(INFO) << "WantOut_->GetStringParam(keyStr): " << param_content.c_str();
|
||||
|
||||
// want SetParam arraydata test
|
||||
std::vector<bool> retboolArray; // boolArrayValue = {true, false, true};
|
||||
std::vector<bool> retboolArray;
|
||||
retboolArray = WantOut_->GetBoolArrayParam(std::string("bool_arraykey"));
|
||||
|
||||
bool arraycompare = CompareArrayData<bool>(retboolArray, boolArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
|
||||
std::vector<byte> retbyteArrayValue; // byteArrayValue = {'?', 'a', '\\'};
|
||||
std::vector<byte> retbyteArrayValue;
|
||||
retbyteArrayValue = WantOut_->GetByteArrayParam(std::string("byte_arraykey"));
|
||||
arraycompare = CompareArrayData<byte>(retbyteArrayValue, byteArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
|
||||
std::vector<zchar> retcharArrayValue; // charArrayValue = {U'e', U'l', U'l', U'o'};
|
||||
std::vector<zchar> retcharArrayValue;
|
||||
retcharArrayValue = WantOut_->GetCharArrayParam(std::string("char_arraykey"));
|
||||
arraycompare = CompareArrayData<zchar>(retcharArrayValue, charArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
|
||||
std::vector<short> retshortArrayValue; // shortArrayValue = {-1, 0, 1};
|
||||
std::vector<short> retshortArrayValue;
|
||||
retshortArrayValue = WantOut_->GetShortArrayParam(std::string("short_arraykey"));
|
||||
arraycompare = CompareArrayData<short>(retshortArrayValue, shortArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
|
||||
std::vector<int> retintArrayValue; // intArrayValue = {-10, 0, 10};
|
||||
std::vector<int> retintArrayValue;
|
||||
retintArrayValue = WantOut_->GetIntArrayParam(std::string("int_arraykey"));
|
||||
arraycompare = CompareArrayData<int>(retintArrayValue, intArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
|
||||
std::vector<long> retlonArrayValue; // longArrayValue = {-100, 0, 100};
|
||||
std::vector<long> retlonArrayValue;
|
||||
retlonArrayValue = WantOut_->GetLongArrayParam(std::string("long_arraykey"));
|
||||
arraycompare = CompareArrayData<long>(retlonArrayValue, longArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
|
||||
std::vector<float> retfloatArrayValue; // floatArrayValue = {-100.1, 0.1, 100.1};
|
||||
std::vector<float> retfloatArrayValue;
|
||||
retfloatArrayValue = WantOut_->GetFloatArrayParam(std::string("float_arraykey"));
|
||||
arraycompare = CompareArrayData<float>(retfloatArrayValue, floatArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
|
||||
std::vector<double> retdoubleArrayValue; // doubleArrayValue = {-1000.1, 0.1, 1000.1};
|
||||
std::vector<double> retdoubleArrayValue;
|
||||
retdoubleArrayValue = WantOut_->GetDoubleArrayParam(std::string("double_arraykey"));
|
||||
arraycompare = CompareArrayData<double>(retdoubleArrayValue, doubleArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
|
||||
std::vector<std::string> retstringArrayValue; // stringArrayValue = {"stringtest1", "string@test2",
|
||||
// "string@!#test2"};
|
||||
std::vector<std::string> retstringArrayValue;
|
||||
retstringArrayValue = WantOut_->GetStringArrayParam(std::string("string_arraykey"));
|
||||
arraycompare = CompareArrayData<std::string>(retstringArrayValue, stringArrayValue);
|
||||
EXPECT_EQ(arraycompare, true);
|
||||
|
@ -25,18 +25,24 @@
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
|
||||
#define INSERT 20
|
||||
#define UPDATE 33
|
||||
#define OPENRAWFILE 122
|
||||
#define BATCHINSERT 115
|
||||
#define DELETE 234
|
||||
|
||||
class MockAbilityTest : public Ability {
|
||||
public:
|
||||
|
||||
int Insert(const Uri &uri, const NativeRdb::ValuesBucket &value)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MockAbilityTest::Insert called";
|
||||
return 20;
|
||||
return INSERT;
|
||||
}
|
||||
int Update(const Uri &uri, const NativeRdb::ValuesBucket &value, const NativeRdb::DataAbilityPredicates &predicates)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MockAbilityTest::Update called";
|
||||
return 33;
|
||||
return UPDATE;
|
||||
}
|
||||
|
||||
std::vector<std::string> GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter)
|
||||
@ -53,15 +59,15 @@ public:
|
||||
int fd;
|
||||
GTEST_LOG_(INFO) << "MockAbilityTest::OpenFile called";
|
||||
FILE *fd1 = fopen("/dataability_openfile_test.txt", "w+");
|
||||
if(fd1 == nullptr) {
|
||||
if (fd1 == nullptr) {
|
||||
GTEST_LOG_(INFO) << "MockAbilityTest::OpenFile fd1 == nullptr";
|
||||
return -1;
|
||||
}
|
||||
fputs("123456",fd1);
|
||||
fputs("123456", fd1);
|
||||
fclose(fd1);
|
||||
|
||||
FILE *fd2 = fopen("/dataability_openfile_test.txt", "r");
|
||||
if(fd2 == nullptr) {
|
||||
if (fd2 == nullptr) {
|
||||
GTEST_LOG_(INFO) << "MockAbilityTest::OpenFile fd2 == nullptr";
|
||||
return -1;
|
||||
}
|
||||
@ -74,13 +80,13 @@ public:
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MockAbilityTest::OpenRawFile called";
|
||||
|
||||
return 122;
|
||||
return OPENRAWFILE;
|
||||
}
|
||||
|
||||
int BatchInsert(const Uri &uri, const std::vector<NativeRdb::ValuesBucket> &values)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MockAbilityTest::BatchInsert called";
|
||||
return 115;
|
||||
return BATCHINSERT;
|
||||
}
|
||||
|
||||
bool Reload(const Uri &uri, const PacMap &extras)
|
||||
@ -92,7 +98,7 @@ public:
|
||||
int Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "MockAbilityTest::Delete called";
|
||||
return 234;
|
||||
return DELETE;
|
||||
}
|
||||
|
||||
std::string GetType(const Uri &uri)
|
||||
|
@ -55,9 +55,8 @@ sptr<AAFwk::IAbilityScheduler> AAFwk::AbilityManagerClient::AcquireDataAbility(
|
||||
|
||||
retval = remoteProxy;
|
||||
|
||||
if(retval == nullptr)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "mock_ability_thread_for_data_observer:mock result retval is nullptr called";
|
||||
if (retval == nullptr) {
|
||||
GTEST_LOG_(INFO) << "mock_ability_thread_for_data_observer:mock result retval is nullptr called";
|
||||
}
|
||||
} else {
|
||||
retval = iter->second;
|
||||
|
@ -34,20 +34,17 @@ namespace AppExecFwk {
|
||||
sptr<AppExecFwk::AbilityThread> MockCreateAbilityThread()
|
||||
{
|
||||
sptr<AppExecFwk::AbilityThread> abilitythread(new (std::nothrow) AppExecFwk::AbilityThread());
|
||||
if(abilitythread == nullptr)
|
||||
{
|
||||
if (abilitythread == nullptr) {
|
||||
GTEST_LOG_(INFO) << "mock_ability_thread_for_data_observer:mock abilityhreadptr is nullptr called";
|
||||
}
|
||||
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
if(application == nullptr)
|
||||
{
|
||||
if (application == nullptr) {
|
||||
GTEST_LOG_(INFO) << "mock_ability_thread_for_data_observer:mock applicationptr is nullptr called";
|
||||
}
|
||||
|
||||
std::shared_ptr<AbilityInfo> info = std::make_shared<AbilityInfo>();
|
||||
if(info == nullptr)
|
||||
{
|
||||
if (info == nullptr) {
|
||||
GTEST_LOG_(INFO) << "mock_ability_thread_for_data_observer:mock AbilityInfo::info is nullptr called";
|
||||
}
|
||||
|
||||
@ -55,7 +52,6 @@ sptr<AppExecFwk::AbilityThread> MockCreateAbilityThread()
|
||||
info->type = AbilityType::DATA;
|
||||
info->isNativeAbility = true;
|
||||
std::cout << "info->name : " << (*info).name <<std::endl;
|
||||
//std::cout << "info->type : " << (*info).type. <<std::endl;
|
||||
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new AbilityThread());
|
||||
|
||||
|
@ -254,10 +254,9 @@ HWTEST_F(DataAbilityHelperTest, AaFwk_DataAbilityHelper_OpenFile_Test_0100, Func
|
||||
}
|
||||
string stringstr(str);
|
||||
EXPECT_STREQ(stringstr.c_str(), result.c_str());
|
||||
|
||||
fclose(file);
|
||||
system("rm /dataability_openfile_test.txt");
|
||||
}
|
||||
fclose(file);
|
||||
system("rm /dataability_openfile_test.txt");
|
||||
|
||||
GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_OpenFile_Test_0100 end";
|
||||
}
|
||||
@ -295,10 +294,9 @@ HWTEST_F(DataAbilityHelperTest, AaFwk_DataAbilityHelper_OpenFile_Test_0200, Func
|
||||
}
|
||||
string stringstr(str);
|
||||
EXPECT_STREQ(stringstr.c_str(), result.c_str());
|
||||
|
||||
fclose(file);
|
||||
system("rm /dataability_openfile_test.txt");
|
||||
}
|
||||
fclose(file);
|
||||
system("rm /dataability_openfile_test.txt");
|
||||
|
||||
GTEST_LOG_(INFO) << "AaFwk_DataAbilityHelper_OpenFile_Test_0200 end";
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ namespace AAFwk {
|
||||
\
|
||||
void DecStrongRef(const void *id = nullptr) override; \
|
||||
\
|
||||
IInterface *Query(const InterfaceID &iid) override; \
|
||||
IInterface *Query(const InterfaceID & iid) override; \
|
||||
\
|
||||
InterfaceID GetInterfaceID(IInterface *object) override;
|
||||
|
||||
@ -82,7 +82,7 @@ namespace AAFwk {
|
||||
Object::DecStrongRef(id); \
|
||||
} \
|
||||
\
|
||||
IInterface *ClassName::Query(const InterfaceID &iid) \
|
||||
IInterface *ClassName::Query(const InterfaceID & iid) \
|
||||
{ \
|
||||
if (iid == g_IID_##InterfaceName) { \
|
||||
return static_cast<InterfaceName *>(this); \
|
||||
@ -113,7 +113,7 @@ namespace AAFwk {
|
||||
{ \
|
||||
Object::DecStrongRef(id); \
|
||||
} \
|
||||
IInterface *ClassName::Query(const InterfaceID &iid) \
|
||||
IInterface *ClassName::Query(const InterfaceID & iid) \
|
||||
{ \
|
||||
if (iid == g_IID_##InterfaceName1) { \
|
||||
return static_cast<InterfaceName1 *>(this); \
|
||||
|
@ -30,7 +30,7 @@ private: \
|
||||
friend DelayedIPCSingleton<MyClass>; \
|
||||
MyClass();
|
||||
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
class DelayedIPCSingleton : public NoCopyable {
|
||||
public:
|
||||
static sptr<T> GetInstance()
|
||||
@ -52,13 +52,13 @@ private:
|
||||
static std::mutex mutex_;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
sptr<T> DelayedIPCSingleton<T>::instance_ = nullptr;
|
||||
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
std::mutex DelayedIPCSingleton<T>::mutex_;
|
||||
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
void DelayedIPCSingleton<T>::DestroyInstance()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
@ -123,7 +123,7 @@ private:
|
||||
static __attribute__((constructor)) void RegisterUserMapObject_##className() \
|
||||
{ \
|
||||
UserObjectBaseLoader::GetInstance().RegisterUserObject( \
|
||||
#className, []() -> UserObjectBase * { return new (std::nothrow)(className); }); \
|
||||
#className, []()->UserObjectBase * { return new (std::nothrow)(className); }); \
|
||||
}
|
||||
|
||||
} // namespace AAFwk
|
||||
|
@ -56,7 +56,7 @@ napi_value ParseBundleName(napi_env env, std::string &bundleName, napi_value arg
|
||||
size_t len = 0;
|
||||
napi_get_value_string_utf8(env, args, buf, BUFFER_LENGTH_MAX, &len);
|
||||
HILOG_INFO("bundleName= [%{public}s].", buf);
|
||||
bundleName = std::string{buf};
|
||||
bundleName = std::string(buf);
|
||||
// create reutrn
|
||||
napi_value ret = 0;
|
||||
NAPI_CALL(env, napi_create_int32(env, 0, &ret));
|
||||
@ -162,6 +162,14 @@ void GetAbilityMissionInfosForResult(
|
||||
napi_create_string_utf8(env, item.baseAbility.GetAbilityName().c_str(), NAPI_AUTO_LENGTH, &abilityName));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, baseAbility, "abilityName", abilityName));
|
||||
|
||||
napi_value uri = nullptr;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, "", NAPI_AUTO_LENGTH, &uri));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, baseAbility, "uri", uri));
|
||||
|
||||
napi_value shortName = nullptr;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, "", NAPI_AUTO_LENGTH, &shortName));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, baseAbility, "shortName", shortName));
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objRecentMissionInfo, "bottomAbility", baseAbility));
|
||||
|
||||
napi_value topAbility = nullptr;
|
||||
@ -178,6 +186,13 @@ void GetAbilityMissionInfosForResult(
|
||||
NAPI_CALL_RETURN_VOID(env,
|
||||
napi_create_string_utf8(env, item.topAbility.GetAbilityName().c_str(), NAPI_AUTO_LENGTH, &abilityName));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, topAbility, "abilityName", abilityName));
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, "", NAPI_AUTO_LENGTH, &uri));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, topAbility, "uri", uri));
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, "", NAPI_AUTO_LENGTH, &shortName));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, topAbility, "shortName", shortName));
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objRecentMissionInfo, "topAbility", topAbility));
|
||||
|
||||
napi_value nWindowMode = nullptr;
|
||||
|
@ -37,13 +37,15 @@ EXTERN_C_END
|
||||
/*
|
||||
* The module definition.
|
||||
*/
|
||||
static napi_module _module = {.nm_version = 1,
|
||||
static napi_module _module = {
|
||||
.nm_version = 1,
|
||||
.nm_flags = 0,
|
||||
.nm_filename = nullptr,
|
||||
.nm_register_func = Init,
|
||||
.nm_modname = "ability.dataUriUtils",
|
||||
.nm_priv = ((void *)0),
|
||||
.reserved = {0}};
|
||||
.reserved = {0}
|
||||
};
|
||||
|
||||
/*
|
||||
* The module registration.
|
||||
|
@ -29,8 +29,6 @@ using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
extern napi_value g_classContext;
|
||||
extern napi_value g_dataAbilityHelper;
|
||||
static int64_t dummyRequestCode_ = 0;
|
||||
CallbackInfo g_aceCallbackInfo;
|
||||
|
||||
@ -936,7 +934,7 @@ napi_value UnwrapForResultParam(CallAbilityParam ¶m, napi_env env, napi_valu
|
||||
// dummy requestCode for NativeC++ interface and onabilityresult callback
|
||||
param.requestCode = dummyRequestCode_;
|
||||
param.forResultOption = true;
|
||||
dummyRequestCode_ < INT64_MAX ? dummyRequestCode_ = dummyRequestCode_ + 1 : dummyRequestCode_ = 0;
|
||||
dummyRequestCode_ = (dummyRequestCode_ < INT64_MAX) ? (dummyRequestCode_ + 1) : 0;
|
||||
HILOG_INFO("%{public}s, reqCode=%{public}d forResultOption=%{public}d.",
|
||||
__func__,
|
||||
param.requestCode,
|
||||
@ -1207,7 +1205,7 @@ void GetDataAbilityHelperAsyncCompleteCB(napi_env env, napi_status status, void
|
||||
NAPI_CALL_RETURN_VOID(env, napi_get_undefined(env, &undefined));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, dataAbilityHelperCB->uri, &uri));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, dataAbilityHelperCB->cbBase.cbInfo.callback, &callback));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_new_instance(env, g_dataAbilityHelper, 1, &uri, &dataAbilityHelperCB->result));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_new_instance(env, GetGlobalDataAbilityHelper(), 1, &uri, &dataAbilityHelperCB->result));
|
||||
|
||||
result[PARAM0] = GetCallbackErrorValue(env, NO_ERROR);
|
||||
result[PARAM1] = dataAbilityHelperCB->result;
|
||||
@ -1229,7 +1227,7 @@ void GetDataAbilityHelperPromiseCompleteCB(napi_env env, napi_status status, voi
|
||||
napi_value uri = nullptr;
|
||||
napi_value result = nullptr;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_get_reference_value(env, dataAbilityHelperCB->uri, &uri));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_new_instance(env, g_dataAbilityHelper, 1, &uri, &dataAbilityHelperCB->result));
|
||||
NAPI_CALL_RETURN_VOID(env, napi_new_instance(env, GetGlobalDataAbilityHelper(), 1, &uri, &dataAbilityHelperCB->result));
|
||||
result = dataAbilityHelperCB->result;
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, dataAbilityHelperCB->cbBase.deferred, result));
|
||||
|
@ -30,6 +30,9 @@ namespace AppExecFwk {
|
||||
*/
|
||||
napi_value FAConstantInit(napi_env env, napi_value exports)
|
||||
{
|
||||
const int Window_Configuration_Zero = 100;
|
||||
const int Window_Configuration_One = 101;
|
||||
const int Window_Configuration_Two = 102;
|
||||
HILOG_INFO("%{public}s,called", __func__);
|
||||
napi_value abilityStartSetting = nullptr;
|
||||
napi_value abilityWindowConfiguration = nullptr;
|
||||
@ -42,9 +45,9 @@ napi_value FAConstantInit(napi_env env, napi_value exports)
|
||||
|
||||
SetNamedProperty(env, abilityWindowConfiguration, 0, "WINDOW_MODE_UNDEFINED");
|
||||
SetNamedProperty(env, abilityWindowConfiguration, 1, "WINDOW_MODE_FULLSCREEN");
|
||||
SetNamedProperty(env, abilityWindowConfiguration, 100, "WINDOW_MODE_SPLIT_PRIMARY");
|
||||
SetNamedProperty(env, abilityWindowConfiguration, 101, "WINDOW_MODE_SPLIT_SECONDARY");
|
||||
SetNamedProperty(env, abilityWindowConfiguration, 102, "WINDOW_MODE_FLOATING");
|
||||
SetNamedProperty(env, abilityWindowConfiguration, Window_Configuration_Zero, "WINDOW_MODE_SPLIT_PRIMARY");
|
||||
SetNamedProperty(env, abilityWindowConfiguration, Window_Configuration_One, "WINDOW_MODE_SPLIT_SECONDARY");
|
||||
SetNamedProperty(env, abilityWindowConfiguration, Window_Configuration_Two, "WINDOW_MODE_FLOATING");
|
||||
|
||||
napi_property_descriptor exportFuncs[] = {
|
||||
DECLARE_NAPI_PROPERTY("AbilityStartSetting", abilityStartSetting),
|
||||
|
@ -410,7 +410,7 @@ void CallOnRequestPermissionsFromUserResult(int requestCode, const std::vector<s
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -430,7 +430,7 @@ void CallOnRequestPermissionsFromUserResult(int requestCode, const std::vector<s
|
||||
|
||||
for (size_t i = 0; i < onRequestPermissionCB->permissions.size(); i++) {
|
||||
napi_create_string_utf8(onRequestPermissionCB->cb.env,
|
||||
onRequestPermissionCB->permissions[i].c_str(),
|
||||
onRequestPermissionCB->permissions[i].c_str(),
|
||||
NAPI_AUTO_LENGTH,
|
||||
&perValue);
|
||||
napi_set_element(onRequestPermissionCB->cb.env, perArray, i, perValue);
|
||||
@ -441,9 +441,9 @@ void CallOnRequestPermissionsFromUserResult(int requestCode, const std::vector<s
|
||||
napi_value grantArray;
|
||||
napi_create_array(onRequestPermissionCB->cb.env, &grantArray);
|
||||
|
||||
for (size_t i = 0; i < onRequestPermissionCB->grantResults.size(); i++) {
|
||||
napi_create_int32(onRequestPermissionCB->cb.env, onRequestPermissionCB->grantResults[i], &perValue);
|
||||
napi_set_element(onRequestPermissionCB->cb.env, grantArray, i, perValue);
|
||||
for (size_t j = 0; j < onRequestPermissionCB->grantResults.size(); j++) {
|
||||
napi_create_int32(onRequestPermissionCB->cb.env, onRequestPermissionCB->grantResults[j], &perValue);
|
||||
napi_set_element(onRequestPermissionCB->cb.env, grantArray, j, perValue);
|
||||
}
|
||||
napi_set_named_property(onRequestPermissionCB->cb.env, result[PARAM1], "authResults", grantArray);
|
||||
|
||||
@ -2254,12 +2254,21 @@ void GetOrCreateLocalDirExecuteCB(napi_env env, void *data)
|
||||
std::string dataDir = getOrCreateLocalDirCB->cbBase.ability->GetAbilityInfo()->applicationInfo.dataDir;
|
||||
std::shared_ptr<HapModuleInfo> hap = getOrCreateLocalDirCB->cbBase.ability->GetHapModuleInfo();
|
||||
std::string moduleName = (hap != nullptr) ? hap->name : std::string();
|
||||
std::string dataDirWithModuleName = dataDir + CONTEXT_DEAL_FILE_SEPARATOR + moduleName;
|
||||
HILOG_INFO("NAPI_GetOrCreateLocalDir, dataDir:%{public}s moduleName:%{public}s abilityName:%{public}s",
|
||||
dataDir.c_str(),
|
||||
moduleName.c_str(),
|
||||
abilityName.c_str());
|
||||
|
||||
HILOG_INFO("NAPI_GetOrCreateLocalDir, abilityName:%{public}s moduleName:%{public}s",
|
||||
abilityName.c_str(),
|
||||
moduleName.c_str());
|
||||
getOrCreateLocalDirCB->rootDir =
|
||||
dataDir + CONTEXT_DEAL_FILE_SEPARATOR + moduleName + CONTEXT_DEAL_FILE_SEPARATOR + abilityName;
|
||||
// if dataDirWithModuleName is not exits, do nothing and return.
|
||||
if (!OHOS::FileExists(dataDirWithModuleName)) {
|
||||
getOrCreateLocalDirCB->rootDir = "";
|
||||
HILOG_INFO("NAPI_GetOrCreateLocalDir, dirWithModuleName is not exits:%{public}s, do nothing and return null.",
|
||||
dataDirWithModuleName.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
getOrCreateLocalDirCB->rootDir = dataDirWithModuleName + CONTEXT_DEAL_FILE_SEPARATOR + abilityName;
|
||||
HILOG_INFO("NAPI_GetOrCreateLocalDir, GetDir rootDir:%{public}s", getOrCreateLocalDirCB->rootDir.c_str());
|
||||
if (!OHOS::FileExists(getOrCreateLocalDirCB->rootDir)) {
|
||||
HILOG_INFO("NAPI_GetOrCreateLocalDir dir is not exits, create dir.");
|
||||
|
@ -234,10 +234,10 @@ void AnalysisValuesBucket(NativeRdb::ValuesBucket &valuesBucket, const napi_env
|
||||
}
|
||||
HILOG_INFO("ValuesBucket num:%{public}d ", arrLen);
|
||||
for (size_t i = 0; i < arrLen; ++i) {
|
||||
napi_value key;
|
||||
napi_value key = 0;
|
||||
status = napi_get_element(env, keys, i, &key);
|
||||
std::string keyStr = UnwrapStringFromJS(env, key);
|
||||
napi_value value;
|
||||
napi_value value = 0;
|
||||
napi_get_property(env, arg, key, &value);
|
||||
|
||||
SetValuesBucketObject(valuesBucket, env, keyStr, value);
|
||||
@ -257,7 +257,7 @@ void SetValuesBucketObject(
|
||||
valueString.c_str());
|
||||
valuesBucket.PutString(keyStr, valueString);
|
||||
} else if (valueType == napi_number) {
|
||||
double valueNumber;
|
||||
double valueNumber = 0;
|
||||
napi_get_value_double(env, value, &valueNumber);
|
||||
valuesBucket.PutDouble(keyStr, valueNumber);
|
||||
HILOG_INFO(
|
||||
@ -420,7 +420,6 @@ napi_value UnwrapValuesBucket(std::string &value, napi_env env, napi_value args)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief DataAbilityHelper NAPI method : notifyChange.
|
||||
*
|
||||
@ -432,19 +431,24 @@ napi_value UnwrapValuesBucket(std::string &value, napi_env env, napi_value args)
|
||||
napi_value NAPI_NotifyChange(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("%{public}s,called", __func__);
|
||||
DAHelperNotifyChangeCB *notifyChangeCB = new (std::nothrow) DAHelperNotifyChangeCB{
|
||||
.cbBase.cbInfo.env = env,
|
||||
.cbBase.asyncWork = nullptr,
|
||||
.cbBase.deferred = nullptr,
|
||||
.cbBase.ability = nullptr,
|
||||
};
|
||||
DAHelperNotifyChangeCB *notifyChangeCB = new (std::nothrow) DAHelperNotifyChangeCB;
|
||||
if (notifyChangeCB == nullptr) {
|
||||
HILOG_ERROR("%{public}s, notifyChangeCB == nullptr.", __func__);
|
||||
return WrapVoidToJS(env);
|
||||
}
|
||||
notifyChangeCB->cbBase.cbInfo.env = env;
|
||||
notifyChangeCB->cbBase.asyncWork = nullptr;
|
||||
notifyChangeCB->cbBase.deferred = nullptr;
|
||||
notifyChangeCB->cbBase.ability = nullptr;
|
||||
|
||||
napi_value ret = NotifyChangeWrap(env, info, notifyChangeCB);
|
||||
if (ret == nullptr) {
|
||||
HILOG_ERROR("%{public}s, ret == nullptr.", __func__);
|
||||
if (notifyChangeCB != nullptr) {
|
||||
delete notifyChangeCB;
|
||||
notifyChangeCB = nullptr;
|
||||
}
|
||||
ret = WrapVoidToJS(env);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -557,7 +561,7 @@ napi_value NotifyChangePromise(napi_env env, DAHelperNotifyChangeCB *notifyChang
|
||||
void NotifyChangeExecuteCB(napi_env env, void *data)
|
||||
{
|
||||
HILOG_INFO("NAPI_NotifyChange, worker pool thread execute.");
|
||||
DAHelperNotifyChangeCB *notifyChangeCB = (DAHelperNotifyChangeCB *)data;
|
||||
DAHelperNotifyChangeCB *notifyChangeCB = static_cast<DAHelperNotifyChangeCB *>(data);
|
||||
if (notifyChangeCB->dataAbilityHelper != nullptr) {
|
||||
OHOS::Uri uri(notifyChangeCB->uri);
|
||||
notifyChangeCB->dataAbilityHelper->NotifyChange(uri);
|
||||
@ -567,7 +571,7 @@ void NotifyChangeExecuteCB(napi_env env, void *data)
|
||||
void NotifyChangeAsyncCompleteCB(napi_env env, napi_status status, void *data)
|
||||
{
|
||||
HILOG_INFO("NAPI_NotifyChange, main event thread complete.");
|
||||
DAHelperNotifyChangeCB *notifyChangeCB = (DAHelperNotifyChangeCB *)data;
|
||||
DAHelperNotifyChangeCB *notifyChangeCB = static_cast<DAHelperNotifyChangeCB *>(data);
|
||||
napi_value callback = nullptr;
|
||||
napi_value undefined = nullptr;
|
||||
napi_value result[ARGS_TWO] = {nullptr};
|
||||
@ -590,7 +594,7 @@ void NotifyChangeAsyncCompleteCB(napi_env env, napi_status status, void *data)
|
||||
void NotifyChangePromiseCompleteCB(napi_env env, napi_status status, void *data)
|
||||
{
|
||||
HILOG_INFO("NAPI_NotifyChange, main event thread complete.");
|
||||
DAHelperNotifyChangeCB *notifyChangeCB = (DAHelperNotifyChangeCB *)data;
|
||||
DAHelperNotifyChangeCB *notifyChangeCB = static_cast<DAHelperNotifyChangeCB *>(data);
|
||||
napi_value result = nullptr;
|
||||
napi_create_int32(env, 0, &result);
|
||||
NAPI_CALL_RETURN_VOID(env, napi_resolve_deferred(env, notifyChangeCB->cbBase.deferred, result));
|
||||
@ -610,15 +614,26 @@ void NotifyChangePromiseCompleteCB(napi_env env, napi_status status, void *data)
|
||||
napi_value NAPI_Register(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("%{public}s,called", __func__);
|
||||
DAHelperOnOffCB *onCB = new (std::nothrow) DAHelperOnOffCB{
|
||||
.cbBase.cbInfo.env = env,
|
||||
.cbBase.asyncWork = nullptr,
|
||||
.cbBase.deferred = nullptr,
|
||||
.cbBase.ability = nullptr,
|
||||
};
|
||||
DAHelperOnOffCB *onCB = new (std::nothrow) DAHelperOnOffCB;
|
||||
if (onCB == nullptr) {
|
||||
HILOG_ERROR("%{public}s, onCB == nullptr.", __func__);
|
||||
return WrapVoidToJS(env);
|
||||
}
|
||||
onCB->cbBase.cbInfo.env = env;
|
||||
onCB->cbBase.asyncWork = nullptr;
|
||||
onCB->cbBase.deferred = nullptr;
|
||||
onCB->cbBase.ability = nullptr;
|
||||
|
||||
napi_value ret = RegisterWrap(env, info, onCB);
|
||||
|
||||
if (ret == nullptr) {
|
||||
HILOG_ERROR("%{public}s, ret == nullptr.", __func__);
|
||||
if (onCB != nullptr) {
|
||||
delete onCB;
|
||||
onCB = nullptr;
|
||||
}
|
||||
ret = WrapVoidToJS(env);
|
||||
}
|
||||
HILOG_INFO("%{public}s,called end", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -700,7 +715,8 @@ napi_value RegisterAsync(
|
||||
}
|
||||
|
||||
NAPI_CALL(env,
|
||||
napi_create_async_work(env,
|
||||
napi_create_async_work(
|
||||
env,
|
||||
nullptr,
|
||||
resourceName,
|
||||
RegisterExecuteCB,
|
||||
@ -718,7 +734,7 @@ napi_value RegisterAsync(
|
||||
void RegisterExecuteCB(napi_env env, void *data)
|
||||
{
|
||||
HILOG_INFO("NAPI_Register, worker pool thread execute.");
|
||||
DAHelperOnOffCB *onCB = (DAHelperOnOffCB *)data;
|
||||
DAHelperOnOffCB *onCB = static_cast<DAHelperOnOffCB *>(data);
|
||||
if (onCB->dataAbilityHelper != nullptr) {
|
||||
onCB->observer->SetEnv(env);
|
||||
onCB->observer->SetCallbackRef(onCB->cbBase.cbInfo.callback);
|
||||
@ -739,15 +755,26 @@ void RegisterExecuteCB(napi_env env, void *data)
|
||||
napi_value NAPI_UnRegister(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("%{public}s,called", __func__);
|
||||
DAHelperOnOffCB *offCB = new (std::nothrow) DAHelperOnOffCB{
|
||||
.cbBase.cbInfo.env = env,
|
||||
.cbBase.asyncWork = nullptr,
|
||||
.cbBase.deferred = nullptr,
|
||||
.cbBase.ability = nullptr,
|
||||
};
|
||||
DAHelperOnOffCB *offCB = new (std::nothrow) DAHelperOnOffCB;
|
||||
if (offCB == nullptr) {
|
||||
HILOG_ERROR("%{public}s, offCB == nullptr.", __func__);
|
||||
return WrapVoidToJS(env);
|
||||
}
|
||||
offCB->cbBase.cbInfo.env = env;
|
||||
offCB->cbBase.asyncWork = nullptr;
|
||||
offCB->cbBase.deferred = nullptr;
|
||||
offCB->cbBase.ability = nullptr;
|
||||
|
||||
napi_value ret = UnRegisterWrap(env, info, offCB);
|
||||
|
||||
if (ret == nullptr) {
|
||||
HILOG_ERROR("%{public}s, ret == nullptr.", __func__);
|
||||
if (offCB != nullptr) {
|
||||
delete offCB;
|
||||
offCB = nullptr;
|
||||
}
|
||||
ret = WrapVoidToJS(env);
|
||||
}
|
||||
HILOG_INFO("%{public}s,called end", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -838,10 +865,11 @@ napi_value UnRegisterAsync(
|
||||
NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
|
||||
|
||||
NAPI_CALL(env,
|
||||
napi_create_async_work(env,
|
||||
napi_create_async_work(
|
||||
env,
|
||||
nullptr,
|
||||
resourceName,
|
||||
UnRegisterExecuteCB,
|
||||
[](napi_env env, void *data) { HILOG_INFO("NAPI_UnRegister, worker pool thread execute."); },
|
||||
UnRegisterCompleteCB,
|
||||
(void *)offCB,
|
||||
&offCB->cbBase.asyncWork));
|
||||
@ -851,62 +879,11 @@ napi_value UnRegisterAsync(
|
||||
return result;
|
||||
}
|
||||
|
||||
void UnRegisterExecuteCB(napi_env env, void *data)
|
||||
{
|
||||
HILOG_INFO("NAPI_UnRegister, worker pool thread execute.");
|
||||
#if 0
|
||||
DAHelperOnOffCB *offCB = (DAHelperOnOffCB *)data;
|
||||
if (offCB->dataAbilityHelper != nullptr) {
|
||||
HILOG_INFO("NAPI_UnRegister uri=%{public}s", offCB->uri.c_str());
|
||||
if (offCB->uri != "") {
|
||||
// with uri
|
||||
std::string strUri = offCB->uri;
|
||||
do {
|
||||
HILOG_INFO("NAPI_UnRegister registerInstances_ size = %{public}d", registerInstances_.size());
|
||||
auto helper = std::find_if(registerInstances_.begin(),
|
||||
registerInstances_.end(),
|
||||
[strUri](const DAHelperOnOffCB *helper) { return helper->uri == strUri; });
|
||||
if (helper != registerInstances_.end()) {
|
||||
// match uri
|
||||
OHOS::Uri uri((*helper)->uri);
|
||||
(*helper)->dataAbilityHelper->UnregisterObserver(uri, (*helper)->observer);
|
||||
delete *helper;
|
||||
registerInstances_.erase(helper);
|
||||
HILOG_INFO("NAPI_UnRegister erase registerInstances_ size = %{public}d", registerInstances_.size());
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
} else {
|
||||
// without both uri
|
||||
DataAbilityHelper *dataAbilityHelper = offCB->dataAbilityHelper;
|
||||
do {
|
||||
HILOG_INFO("NAPI_UnRegister registerInstances_ size = %{public}d", registerInstances_.size());
|
||||
auto helper = std::find_if(registerInstances_.begin(),
|
||||
registerInstances_.end(),
|
||||
[dataAbilityHelper](
|
||||
const DAHelperOnOffCB *helper) { return helper->dataAbilityHelper == dataAbilityHelper; });
|
||||
if (helper != registerInstances_.end()) {
|
||||
// match dataAbilityHelper
|
||||
OHOS::Uri uri((*helper)->uri);
|
||||
(*helper)->dataAbilityHelper->UnregisterObserver(uri, (*helper)->observer);
|
||||
delete *helper;
|
||||
registerInstances_.erase(helper);
|
||||
HILOG_INFO("NAPI_UnRegister erase registerInstances_ size = %{public}d", registerInstances_.size());
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void UnRegisterCompleteCB(napi_env env, napi_status status, void *data)
|
||||
{
|
||||
HILOG_INFO("NAPI_UnRegister, main event thread complete.");
|
||||
// cannot run it in executeCB, because need to use napi_strict_equals compare callbacks.
|
||||
DAHelperOnOffCB *offCB = (DAHelperOnOffCB *)data;
|
||||
DAHelperOnOffCB *offCB = static_cast<DAHelperOnOffCB *>(data);
|
||||
if (offCB == nullptr || offCB->dataAbilityHelper == nullptr) {
|
||||
HILOG_ERROR("NAPI_UnRegister, offCB is null:%{public}p,%{public}p.", offCB, offCB->dataAbilityHelper);
|
||||
return;
|
||||
@ -916,8 +893,8 @@ void UnRegisterCompleteCB(napi_env env, napi_status status, void *data)
|
||||
// if match callback ,or match both callback and uri
|
||||
napi_ref callback = offCB->cbBase.cbInfo.callback;
|
||||
do {
|
||||
auto helper =
|
||||
std::find_if(registerInstances_.begin(), registerInstances_.end(), [callback](const DAHelperOnOffCB *helper) {
|
||||
auto helper = std::find_if(
|
||||
registerInstances_.begin(), registerInstances_.end(), [callback](const DAHelperOnOffCB *helper) {
|
||||
bool result = false;
|
||||
napi_value callbackA = 0;
|
||||
napi_value callbackB = 0;
|
||||
@ -925,17 +902,17 @@ void UnRegisterCompleteCB(napi_env env, napi_status status, void *data)
|
||||
napi_get_reference_value(helper->cbBase.cbInfo.env, helper->cbBase.cbInfo.callback, &callbackA);
|
||||
auto ret = napi_strict_equals(helper->cbBase.cbInfo.env, callbackA, callbackB, &result);
|
||||
HILOG_INFO("NAPI_UnRegister cb equals status=%{public}d result=%{public}d.", ret, result);
|
||||
// return helper->cbBase.cbInfo.callback == callback;
|
||||
return result;
|
||||
});
|
||||
if (helper != registerInstances_.end()) {
|
||||
OHOS::Uri uri((*helper)->uri);
|
||||
// if uri is not empty, uri and callback has to be equal at the same time.
|
||||
if ((offCB->uri == "") || (offCB->uri == uri.ToString())) {
|
||||
if (offCB->uri == uri.ToString()) {
|
||||
// match callback, or match both callback and uri
|
||||
(*helper)->dataAbilityHelper->UnregisterObserver(uri, (*helper)->observer);
|
||||
delete *helper;
|
||||
registerInstances_.erase(helper);
|
||||
delete *helper;
|
||||
*helper = nullptr;
|
||||
HILOG_INFO("NAPI_UnRegister Instances erase size = %{public}zu", registerInstances_.size());
|
||||
} else {
|
||||
HILOG_INFO("NAPI_UnRegister uri=%{public}s,helper.Uri=%{public}s",
|
||||
@ -943,6 +920,7 @@ void UnRegisterCompleteCB(napi_env env, napi_status status, void *data)
|
||||
uri.ToString().c_str());
|
||||
}
|
||||
} else {
|
||||
HILOG_INFO("NAPI_UnRegister not match any callback.");
|
||||
break; // not match any callback
|
||||
}
|
||||
} while (true);
|
||||
@ -959,32 +937,17 @@ void UnRegisterCompleteCB(napi_env env, napi_status status, void *data)
|
||||
// match uri
|
||||
OHOS::Uri uri((*helper)->uri);
|
||||
(*helper)->dataAbilityHelper->UnregisterObserver(uri, (*helper)->observer);
|
||||
delete *helper;
|
||||
registerInstances_.erase(helper);
|
||||
delete *helper;
|
||||
*helper = nullptr;
|
||||
HILOG_INFO("NAPI_UnRegister Instances erase size = %{public}zu", registerInstances_.size());
|
||||
} else {
|
||||
HILOG_INFO("NAPI_UnRegister not match any uri.");
|
||||
break; // not match any uri
|
||||
}
|
||||
} while (true);
|
||||
} else {
|
||||
// without both uri and callback, unregister all observers corresponding the helper
|
||||
DataAbilityHelper *dataAbilityHelper = offCB->dataAbilityHelper;
|
||||
do {
|
||||
auto helper = std::find_if(
|
||||
registerInstances_.begin(), registerInstances_.end(), [dataAbilityHelper](const DAHelperOnOffCB *helper) {
|
||||
return helper->dataAbilityHelper == dataAbilityHelper;
|
||||
});
|
||||
if (helper != registerInstances_.end()) {
|
||||
// match dataAbilityHelper
|
||||
OHOS::Uri uri((*helper)->uri);
|
||||
(*helper)->dataAbilityHelper->UnregisterObserver(uri, (*helper)->observer);
|
||||
delete *helper;
|
||||
registerInstances_.erase(helper);
|
||||
HILOG_INFO("NAPI_UnRegister Instances erase size = %{public}zu", registerInstances_.size());
|
||||
} else {
|
||||
break; // not match any helper
|
||||
}
|
||||
} while (true);
|
||||
HILOG_ERROR("NAPI_UnRegister, error: uri is null.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1004,17 +967,33 @@ void NAPIDataAbilityObserver::OnChange()
|
||||
HILOG_INFO("%{public}s, called.", __func__);
|
||||
|
||||
uv_loop_s *loop = nullptr;
|
||||
|
||||
#if NAPI_VERSION >= 2
|
||||
napi_get_uv_event_loop(env_, &loop);
|
||||
#endif // NAPI_VERSION >= 2
|
||||
if (loop == nullptr) {
|
||||
HILOG_ERROR("%{public}s, loop == nullptr.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
uv_work_t *work = new uv_work_t;
|
||||
DAHelperOnOffCB *onCB =
|
||||
new (std::nothrow) DAHelperOnOffCB{.cbBase.cbInfo.env = env_, .cbBase.cbInfo.callback = ref_};
|
||||
if (work == nullptr) {
|
||||
HILOG_ERROR("%{public}s, work==nullptr.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
DAHelperOnOffCB *onCB = new (std::nothrow) DAHelperOnOffCB;
|
||||
if (onCB == nullptr) {
|
||||
HILOG_ERROR("%{public}s, onCB == nullptr.", __func__);
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
return;
|
||||
}
|
||||
onCB->cbBase.cbInfo.env = env_;
|
||||
onCB->cbBase.cbInfo.callback = ref_;
|
||||
work->data = (void *)onCB;
|
||||
|
||||
uv_queue_work(loop,
|
||||
int rev = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
[](uv_work_t *work, int status) {
|
||||
@ -1037,7 +1016,18 @@ void NAPIDataAbilityObserver::OnChange()
|
||||
delete event;
|
||||
delete work;
|
||||
});
|
||||
if (rev != 0) {
|
||||
if (onCB != nullptr) {
|
||||
delete onCB;
|
||||
onCB = nullptr;
|
||||
}
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
napi_value NAPI_GetType(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("%{public}s,called", __func__);
|
||||
@ -2957,19 +2947,24 @@ void ReleasePromiseCompleteCB(napi_env env, napi_status status, void *data)
|
||||
napi_value NAPI_ExecuteBatch(napi_env env, napi_callback_info info)
|
||||
{
|
||||
HILOG_INFO("%{public}s,start", __func__);
|
||||
DAHelperExecuteBatchCB *executeBatchCB = new (std::nothrow) DAHelperExecuteBatchCB{
|
||||
.cbBase.cbInfo.env = env,
|
||||
.cbBase.asyncWork = nullptr,
|
||||
.cbBase.deferred = nullptr,
|
||||
.cbBase.ability = nullptr,
|
||||
};
|
||||
DAHelperExecuteBatchCB *executeBatchCB = new (std::nothrow) DAHelperExecuteBatchCB;
|
||||
if (executeBatchCB == nullptr) {
|
||||
HILOG_ERROR("%{public}s, executeBatchCB == nullptr.", __func__);
|
||||
return WrapVoidToJS(env);
|
||||
}
|
||||
executeBatchCB->cbBase.cbInfo.env = env;
|
||||
executeBatchCB->cbBase.asyncWork = nullptr;
|
||||
executeBatchCB->cbBase.deferred = nullptr;
|
||||
executeBatchCB->cbBase.ability = nullptr;
|
||||
|
||||
napi_value ret = ExecuteBatchWrap(env, info, executeBatchCB);
|
||||
if (ret == nullptr) {
|
||||
HILOG_ERROR("%{public}s, ret == nullptr.", __func__);
|
||||
if (executeBatchCB != nullptr) {
|
||||
delete executeBatchCB;
|
||||
executeBatchCB = nullptr;
|
||||
}
|
||||
ret = WrapVoidToJS(env);
|
||||
}
|
||||
HILOG_INFO("%{public}s,end", __func__);
|
||||
return ret;
|
||||
@ -3110,7 +3105,7 @@ napi_value ExecuteBatchPromise(napi_env env, DAHelperExecuteBatchCB *executeBatc
|
||||
void ExecuteBatchExecuteCB(napi_env env, void *data)
|
||||
{
|
||||
HILOG_INFO("%{public}s,NAPI_ExecuteBatch, worker pool thread execute start.", __func__);
|
||||
DAHelperExecuteBatchCB *executeBatchCB = (DAHelperExecuteBatchCB *)data;
|
||||
DAHelperExecuteBatchCB *executeBatchCB = static_cast<DAHelperExecuteBatchCB *>(data);
|
||||
if (executeBatchCB->dataAbilityHelper != nullptr) {
|
||||
OHOS::Uri uri(executeBatchCB->uri);
|
||||
executeBatchCB->result = executeBatchCB->dataAbilityHelper->ExecuteBatch(uri, executeBatchCB->operations);
|
||||
@ -3122,7 +3117,7 @@ void ExecuteBatchExecuteCB(napi_env env, void *data)
|
||||
void ExecuteBatchAsyncCompleteCB(napi_env env, napi_status status, void *data)
|
||||
{
|
||||
HILOG_INFO("%{public}s, NAPI_ExecuteBatch, main event thread complete start.", __func__);
|
||||
DAHelperExecuteBatchCB *executeBatchCB = (DAHelperExecuteBatchCB *)data;
|
||||
DAHelperExecuteBatchCB *executeBatchCB = static_cast<DAHelperExecuteBatchCB *>(data);
|
||||
napi_value callback = nullptr;
|
||||
napi_value undefined = nullptr;
|
||||
napi_value result[ARGS_TWO] = {nullptr};
|
||||
@ -3147,7 +3142,7 @@ void ExecuteBatchAsyncCompleteCB(napi_env env, napi_status status, void *data)
|
||||
void ExecuteBatchPromiseCompleteCB(napi_env env, napi_status status, void *data)
|
||||
{
|
||||
HILOG_INFO("%{public}s, NAPI_ExecuteBatch, main event thread complete start.", __func__);
|
||||
DAHelperExecuteBatchCB *executeBatchCB = (DAHelperExecuteBatchCB *)data;
|
||||
DAHelperExecuteBatchCB *executeBatchCB = static_cast<DAHelperExecuteBatchCB *>(data);
|
||||
napi_value result = nullptr;
|
||||
napi_create_array(env, &result);
|
||||
GetDataAbilityResultForResult(env, executeBatchCB->result, result);
|
||||
|
@ -27,8 +27,8 @@ public:
|
||||
void SetCallbackRef(const napi_ref &ref);
|
||||
|
||||
private:
|
||||
napi_env env_;
|
||||
napi_ref ref_;
|
||||
napi_env env_ = nullptr;
|
||||
napi_ref ref_ = nullptr;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -255,7 +255,6 @@ napi_value UnRegisterAsync(
|
||||
* @param env The environment that the Node-API call is invoked under.
|
||||
* @param data Point to asynchronous processing of data.
|
||||
*/
|
||||
void UnRegisterExecuteCB(napi_env env, void *data);
|
||||
void UnRegisterCompleteCB(napi_env env, napi_status status, void *data);
|
||||
/**
|
||||
* @brief Parse the ValuesBucket parameters.
|
||||
|
@ -25,14 +25,18 @@ namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
napi_value DataAbilityOperationInit(napi_env env, napi_value exports)
|
||||
{
|
||||
const int INSERT = 1;
|
||||
const int UPDATE = 2;
|
||||
const int DELETE = 3;
|
||||
const int ASSERT = 4;
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
|
||||
napi_value dataAbilityOperationType = nullptr;
|
||||
napi_create_object(env, &dataAbilityOperationType);
|
||||
SetNamedProperty(env, dataAbilityOperationType, "TYPE_INSERT", 1);
|
||||
SetNamedProperty(env, dataAbilityOperationType, "TYPE_UPDATE", 2);
|
||||
SetNamedProperty(env, dataAbilityOperationType, "TYPE_DELETE", 3);
|
||||
SetNamedProperty(env, dataAbilityOperationType, "TYPE_ASSERT", 4);
|
||||
SetNamedProperty(env, dataAbilityOperationType, "TYPE_INSERT", INSERT);
|
||||
SetNamedProperty(env, dataAbilityOperationType, "TYPE_UPDATE", UPDATE);
|
||||
SetNamedProperty(env, dataAbilityOperationType, "TYPE_DELETE", DELETE);
|
||||
SetNamedProperty(env, dataAbilityOperationType, "TYPE_ASSERT", ASSERT);
|
||||
|
||||
napi_property_descriptor properties[] = {
|
||||
DECLARE_NAPI_PROPERTY("DataAbilityOperationType", dataAbilityOperationType),
|
||||
@ -70,7 +74,7 @@ napi_value BuildDataAbilityOperation(
|
||||
std::shared_ptr<Uri> uri = std::make_shared<Uri>(uriStr);
|
||||
|
||||
// get type property
|
||||
int type;
|
||||
int type = 0;
|
||||
if (!UnwrapInt32ByPropertyName(env, param, "type", type)) {
|
||||
HILOG_ERROR("%{public}s, type:%{public}d is not exist.", __func__, type);
|
||||
return nullptr;
|
||||
@ -101,7 +105,7 @@ napi_value BuildDataAbilityOperation(
|
||||
}
|
||||
|
||||
// get expectedcount property
|
||||
int expectedCount;
|
||||
int expectedCount = 0;
|
||||
UnwrapInt32ByPropertyName(env, param, "expectedCount", expectedCount);
|
||||
HILOG_INFO("%{public}s, expectedCount:%{public}d", __func__, expectedCount);
|
||||
if (expectedCount > 0) {
|
||||
@ -114,7 +118,7 @@ napi_value BuildDataAbilityOperation(
|
||||
UnwrapDataAbilityPredicatesBackReferences(builder, env, jsPredicatesBackReferences);
|
||||
|
||||
// get interrupted property
|
||||
bool interrupted;
|
||||
bool interrupted = false;
|
||||
UnwrapBooleanByPropertyName(env, param, "interrupted", interrupted);
|
||||
builder->WithInterruptionAllowed(interrupted);
|
||||
|
||||
|
@ -45,13 +45,15 @@ EXTERN_C_END
|
||||
/*
|
||||
* The module definition.
|
||||
*/
|
||||
static napi_module _module = {.nm_version = 1,
|
||||
static napi_module _module = {
|
||||
.nm_version = 1,
|
||||
.nm_flags = 0,
|
||||
.nm_filename = nullptr,
|
||||
.nm_register_func = Init,
|
||||
.nm_modname = "ability.featureAbility",
|
||||
.nm_priv = ((void *)0),
|
||||
.reserved = {0}};
|
||||
.reserved = {0}
|
||||
};
|
||||
|
||||
/*
|
||||
* The module registration.
|
||||
|
258
interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.cpp
Normal file → Executable file
258
interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.cpp
Normal file → Executable file
@ -33,6 +33,11 @@ napi_value *GetGlobalClassContext(void)
|
||||
return &g_classContext;
|
||||
}
|
||||
|
||||
napi_value GetGlobalDataAbilityHelper(void)
|
||||
{
|
||||
return g_dataAbilityHelper;
|
||||
}
|
||||
|
||||
bool CheckAbilityType(AbilityType typeInAbility, AbilityType typeWant)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
@ -1654,8 +1659,6 @@ napi_value GetContextWrap(napi_env env, napi_callback_info info, AsyncCallbackIn
|
||||
|
||||
napi_value result = nullptr;
|
||||
napi_new_instance(env, g_classContext, 0, nullptr, &result);
|
||||
delete asyncCallbackInfo;
|
||||
asyncCallbackInfo = nullptr;
|
||||
HILOG_INFO("%{public}s, end.", __func__);
|
||||
return result;
|
||||
}
|
||||
@ -1680,15 +1683,16 @@ napi_value NAPI_GetContextCommon(napi_env env, napi_callback_info info, AbilityT
|
||||
asyncCallbackInfo->errCode = NAPI_ERR_NO_ERROR;
|
||||
asyncCallbackInfo->abilityType = abilityType;
|
||||
napi_value ret = GetContextWrap(env, info, asyncCallbackInfo);
|
||||
|
||||
delete asyncCallbackInfo;
|
||||
asyncCallbackInfo = nullptr;
|
||||
|
||||
if (ret == nullptr) {
|
||||
HILOG_ERROR("%{public}s ret == nullptr", __func__);
|
||||
if (asyncCallbackInfo != nullptr) {
|
||||
delete asyncCallbackInfo;
|
||||
asyncCallbackInfo = nullptr;
|
||||
}
|
||||
ret = WrapVoidToJS(env);
|
||||
HILOG_ERROR("%{public}s ret == nullptr", __func__);
|
||||
} else {
|
||||
HILOG_INFO("%{public}s, end.", __func__);
|
||||
}
|
||||
HILOG_INFO("%{public}s, end.", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2166,6 +2170,36 @@ napi_value NAPI_GetAbilityNameCommon(napi_env env, napi_callback_info info, Abil
|
||||
return ret;
|
||||
}
|
||||
|
||||
void UnwrapAbilityStartSettingForNumber(
|
||||
napi_env env, const std::string key, napi_value param, AAFwk::AbilityStartSetting &setting)
|
||||
{
|
||||
int32_t natValue32 = 0;
|
||||
double natValueDouble = 0.0;
|
||||
bool isReadValue32 = false;
|
||||
bool isReadDouble = false;
|
||||
if (napi_get_value_int32(env, param, &natValue32) == napi_ok) {
|
||||
HILOG_INFO("%{public}s called. Property value=%{public}d.", __func__, natValue32);
|
||||
isReadValue32 = true;
|
||||
}
|
||||
|
||||
if (napi_get_value_double(env, param, &natValueDouble) == napi_ok) {
|
||||
HILOG_INFO("%{public}s called. Property value=%{public}lf.", __func__, natValueDouble);
|
||||
isReadDouble = true;
|
||||
}
|
||||
|
||||
if (isReadValue32 && isReadDouble) {
|
||||
if (abs(natValueDouble - natValue32 * 1.0) > 0.0) {
|
||||
setting.AddProperty(key, std::to_string(natValueDouble));
|
||||
} else {
|
||||
setting.AddProperty(key, std::to_string(natValue32));
|
||||
}
|
||||
} else if (isReadValue32) {
|
||||
setting.AddProperty(key, std::to_string(natValue32));
|
||||
} else if (isReadDouble) {
|
||||
setting.AddProperty(key, std::to_string(natValueDouble));
|
||||
}
|
||||
}
|
||||
|
||||
bool UnwrapAbilityStartSetting(napi_env env, napi_value param, AAFwk::AbilityStartSetting &setting)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
@ -2206,34 +2240,9 @@ bool UnwrapAbilityStartSetting(napi_env env, napi_value param, AAFwk::AbilitySta
|
||||
setting.AddProperty(strProName, std::to_string(natValue));
|
||||
break;
|
||||
}
|
||||
case napi_number: {
|
||||
int32_t natValue32 = 0;
|
||||
double natValueDouble = 0.0;
|
||||
bool isReadValue32 = false;
|
||||
bool isReadDouble = false;
|
||||
if (napi_get_value_int32(env, jsProValue, &natValue32) == napi_ok) {
|
||||
HILOG_INFO("%{public}s called. Property value=%{public}d.", __func__, natValue32);
|
||||
isReadValue32 = true;
|
||||
}
|
||||
|
||||
if (napi_get_value_double(env, jsProValue, &natValueDouble) == napi_ok) {
|
||||
HILOG_INFO("%{public}s called. Property value=%{public}lf.", __func__, natValueDouble);
|
||||
isReadDouble = true;
|
||||
}
|
||||
|
||||
if (isReadValue32 && isReadDouble) {
|
||||
if (abs(natValueDouble - natValue32 * 1.0) > 0.0) {
|
||||
setting.AddProperty(strProName, std::to_string(natValueDouble));
|
||||
} else {
|
||||
setting.AddProperty(strProName, std::to_string(natValue32));
|
||||
}
|
||||
} else if (isReadValue32) {
|
||||
setting.AddProperty(strProName, std::to_string(natValue32));
|
||||
} else if (isReadDouble) {
|
||||
setting.AddProperty(strProName, std::to_string(natValueDouble));
|
||||
}
|
||||
case napi_number:
|
||||
UnwrapAbilityStartSettingForNumber(env, strProName, jsProValue, setting);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -2789,7 +2798,11 @@ napi_value ConnectAbilityWrap(napi_env env, napi_callback_info info, ConnectAbil
|
||||
key.id = connectAbilityCB->id;
|
||||
key.want = connectAbilityCB->want;
|
||||
connects_.emplace(key, conn);
|
||||
serialNumber_ < INT64_MAX ? serialNumber_++ : serialNumber_ = 0;
|
||||
if (serialNumber_ < INT64_MAX) {
|
||||
serialNumber_++;
|
||||
} else {
|
||||
serialNumber_ = 0;
|
||||
}
|
||||
HILOG_INFO("%{public}s not find connection, make new one:%{public}p.", __func__, conn.GetRefPtr());
|
||||
}
|
||||
HILOG_INFO("%{public}s id:%{public}" PRId64, __func__, connectAbilityCB->id);
|
||||
@ -3132,6 +3145,40 @@ void NAPIAbilityConnection::SetDisconnectCBRef(const napi_ref &ref)
|
||||
disconnectRef_ = ref;
|
||||
}
|
||||
|
||||
void UvWorkOnAbilityConnectDone(uv_work_t *work, int status)
|
||||
{
|
||||
HILOG_INFO("UvWorkOnAbilityConnectDone, uv_queue_work");
|
||||
// JS Thread
|
||||
ConnectAbilityCB *connectAbilityCB = static_cast<ConnectAbilityCB *>(work->data);
|
||||
napi_value result[ARGS_TWO] = {0};
|
||||
result[PARAM0] =
|
||||
WrapElementName(connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->abilityConnectionCB.elementName);
|
||||
napi_value jsRemoteObject = NAPI_ohos_rpc_CreateJsRemoteObject(
|
||||
connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->abilityConnectionCB.connection);
|
||||
result[PARAM1] = jsRemoteObject;
|
||||
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(connectAbilityCB->cbBase.cbInfo.env, &undefined);
|
||||
napi_value callResult = 0;
|
||||
napi_get_reference_value(connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->cbBase.cbInfo.callback, &callback);
|
||||
|
||||
napi_call_function(
|
||||
connectAbilityCB->cbBase.cbInfo.env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult);
|
||||
if (connectAbilityCB->cbBase.cbInfo.callback != nullptr) {
|
||||
napi_delete_reference(connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->cbBase.cbInfo.callback);
|
||||
}
|
||||
if (connectAbilityCB != nullptr) {
|
||||
delete connectAbilityCB;
|
||||
connectAbilityCB = nullptr;
|
||||
}
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
HILOG_INFO("UvWorkOnAbilityConnectDone, uv_queue_work end");
|
||||
}
|
||||
|
||||
void NAPIAbilityConnection::OnAbilityConnectDone(
|
||||
const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode)
|
||||
{
|
||||
@ -3171,43 +3218,7 @@ void NAPIAbilityConnection::OnAbilityConnectDone(
|
||||
work->data = (void *)connectAbilityCB;
|
||||
|
||||
int rev = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
[](uv_work_t *work, int status) {
|
||||
HILOG_INFO("OnAbilityConnectDone, uv_queue_work");
|
||||
// JS Thread
|
||||
ConnectAbilityCB *connectAbilityCB = static_cast<ConnectAbilityCB *>(work->data);
|
||||
napi_value result[ARGS_TWO] = {0};
|
||||
result[PARAM0] =
|
||||
WrapElementName(connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->abilityConnectionCB.elementName);
|
||||
napi_value jsRemoteObject = NAPI_ohos_rpc_CreateJsRemoteObject(
|
||||
connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->abilityConnectionCB.connection);
|
||||
result[PARAM1] = jsRemoteObject;
|
||||
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(connectAbilityCB->cbBase.cbInfo.env, &undefined);
|
||||
napi_value callResult = 0;
|
||||
napi_get_reference_value(
|
||||
connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->cbBase.cbInfo.callback, &callback);
|
||||
|
||||
napi_call_function(
|
||||
connectAbilityCB->cbBase.cbInfo.env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult);
|
||||
if (connectAbilityCB->cbBase.cbInfo.callback != nullptr) {
|
||||
napi_delete_reference(connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->cbBase.cbInfo.callback);
|
||||
}
|
||||
if (connectAbilityCB != nullptr) {
|
||||
delete connectAbilityCB;
|
||||
connectAbilityCB = nullptr;
|
||||
}
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
HILOG_INFO("OnAbilityConnectDone, uv_queue_work end");
|
||||
});
|
||||
|
||||
loop, work, [](uv_work_t *work) {}, UvWorkOnAbilityConnectDone);
|
||||
if (rev != 0) {
|
||||
if (connectAbilityCB != nullptr) {
|
||||
delete connectAbilityCB;
|
||||
@ -3221,6 +3232,52 @@ void NAPIAbilityConnection::OnAbilityConnectDone(
|
||||
HILOG_INFO("%{public}s, end.", __func__);
|
||||
}
|
||||
|
||||
void UvWorkOnAbilityDisconnectDone(uv_work_t *work, int status)
|
||||
{
|
||||
HILOG_INFO("UvWorkOnAbilityDisconnectDone, uv_queue_work");
|
||||
// JS Thread
|
||||
ConnectAbilityCB *connectAbilityCB = static_cast<ConnectAbilityCB *>(work->data);
|
||||
napi_value result = nullptr;
|
||||
result = WrapElementName(connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->abilityConnectionCB.elementName);
|
||||
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(connectAbilityCB->cbBase.cbInfo.env, &undefined);
|
||||
napi_value callResult = 0;
|
||||
napi_get_reference_value(connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->cbBase.cbInfo.callback, &callback);
|
||||
|
||||
napi_call_function(connectAbilityCB->cbBase.cbInfo.env, undefined, callback, ARGS_ONE, &result, &callResult);
|
||||
if (connectAbilityCB->cbBase.cbInfo.callback != nullptr) {
|
||||
napi_delete_reference(connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->cbBase.cbInfo.callback);
|
||||
}
|
||||
|
||||
// release connect
|
||||
HILOG_INFO("UvWorkOnAbilityDisconnectDone connects_.size:%{public}zu", connects_.size());
|
||||
std::string bundleName = connectAbilityCB->abilityConnectionCB.elementName.GetBundleName();
|
||||
std::string abilityName = connectAbilityCB->abilityConnectionCB.elementName.GetAbilityName();
|
||||
auto item = std::find_if(connects_.begin(),
|
||||
connects_.end(),
|
||||
[bundleName, abilityName](const std::map<ConnecttionKey, sptr<NAPIAbilityConnection>>::value_type &obj) {
|
||||
return (bundleName == obj.first.want.GetBundle()) &&
|
||||
(abilityName == obj.first.want.GetElement().GetAbilityName());
|
||||
});
|
||||
if (item != connects_.end()) {
|
||||
// match bundlename && abilityname
|
||||
connects_.erase(item);
|
||||
HILOG_INFO("UvWorkOnAbilityDisconnectDone erase connects_.size:%{public}zu", connects_.size());
|
||||
}
|
||||
|
||||
if (connectAbilityCB != nullptr) {
|
||||
delete connectAbilityCB;
|
||||
connectAbilityCB = nullptr;
|
||||
}
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
HILOG_INFO("UvWorkOnAbilityDisconnectDone, uv_queue_work end");
|
||||
}
|
||||
|
||||
void NAPIAbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode)
|
||||
{
|
||||
HILOG_INFO("%{public}s, called.", __func__);
|
||||
@ -3258,58 +3315,7 @@ void NAPIAbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementNam
|
||||
work->data = (void *)connectAbilityCB;
|
||||
|
||||
int rev = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
[](uv_work_t *work, int status) {
|
||||
HILOG_INFO("OnAbilityDisconnectDone, uv_queue_work");
|
||||
// JS Thread
|
||||
ConnectAbilityCB *connectAbilityCB = static_cast<ConnectAbilityCB *>(work->data);
|
||||
napi_value result = nullptr;
|
||||
result =
|
||||
WrapElementName(connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->abilityConnectionCB.elementName);
|
||||
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(connectAbilityCB->cbBase.cbInfo.env, &undefined);
|
||||
napi_value callResult = 0;
|
||||
napi_get_reference_value(
|
||||
connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->cbBase.cbInfo.callback, &callback);
|
||||
|
||||
napi_call_function(
|
||||
connectAbilityCB->cbBase.cbInfo.env, undefined, callback, ARGS_ONE, &result, &callResult);
|
||||
if (connectAbilityCB->cbBase.cbInfo.callback != nullptr) {
|
||||
napi_delete_reference(connectAbilityCB->cbBase.cbInfo.env, connectAbilityCB->cbBase.cbInfo.callback);
|
||||
}
|
||||
|
||||
// release connect
|
||||
HILOG_INFO("OnAbilityDisconnectDone connects_.size:%{public}zu", connects_.size());
|
||||
std::string bundleName = connectAbilityCB->abilityConnectionCB.elementName.GetBundleName();
|
||||
std::string abilityName = connectAbilityCB->abilityConnectionCB.elementName.GetAbilityName();
|
||||
auto item = std::find_if(connects_.begin(),
|
||||
connects_.end(),
|
||||
[bundleName, abilityName](
|
||||
const std::map<ConnecttionKey, sptr<NAPIAbilityConnection>>::value_type &obj) {
|
||||
return (bundleName == obj.first.want.GetBundle()) &&
|
||||
(abilityName == obj.first.want.GetElement().GetAbilityName());
|
||||
});
|
||||
if (item != connects_.end()) {
|
||||
// match bundlename && abilityname
|
||||
connects_.erase(item);
|
||||
HILOG_INFO("OnAbilityDisconnectDone erase connects_.size:%{public}zu", connects_.size());
|
||||
}
|
||||
|
||||
if (connectAbilityCB != nullptr) {
|
||||
delete connectAbilityCB;
|
||||
connectAbilityCB = nullptr;
|
||||
}
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
HILOG_INFO("OnAbilityDisconnectDone, uv_queue_work end");
|
||||
});
|
||||
|
||||
loop, work, [](uv_work_t *work) {}, UvWorkOnAbilityDisconnectDone);
|
||||
if (rev != 0) {
|
||||
if (connectAbilityCB != nullptr) {
|
||||
delete connectAbilityCB;
|
||||
@ -3335,7 +3341,6 @@ napi_value NAPI_AcquireDataAbilityHelperCommon(napi_env env, napi_callback_info
|
||||
{
|
||||
HILOG_INFO("%{public}s,called", __func__);
|
||||
DataAbilityHelperCB *dataAbilityHelperCB = new (std::nothrow) DataAbilityHelperCB;
|
||||
dataAbilityHelperCB->cbBase.cbInfo.env = env;
|
||||
if (dataAbilityHelperCB == nullptr) {
|
||||
HILOG_ERROR("%{public}s, dataAbilityHelperCB == nullptr", __func__);
|
||||
return WrapVoidToJS(env);
|
||||
@ -3352,6 +3357,7 @@ napi_value NAPI_AcquireDataAbilityHelperCommon(napi_env env, napi_callback_info
|
||||
return WrapVoidToJS(env);
|
||||
}
|
||||
|
||||
dataAbilityHelperCB->cbBase.cbInfo.env = env;
|
||||
dataAbilityHelperCB->cbBase.ability = ability;
|
||||
dataAbilityHelperCB->cbBase.errCode = NAPI_ERR_NO_ERROR;
|
||||
dataAbilityHelperCB->cbBase.abilityType = abilityType;
|
||||
|
5
interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.h
Normal file → Executable file
5
interfaces/kits/napi/aafwk/inner/napi_common/napi_common_ability.h
Normal file → Executable file
@ -25,6 +25,7 @@ namespace AppExecFwk {
|
||||
const std::int32_t STR_MAX_SIZE = 128;
|
||||
|
||||
napi_value *GetGlobalClassContext(void);
|
||||
napi_value GetGlobalDataAbilityHelper(void);
|
||||
void SaveAppInfo(AppInfo_ &appInfo, const ApplicationInfo &appInfoOrg);
|
||||
napi_value WrapAppInfo(napi_env env, const AppInfo_ &appInfo);
|
||||
|
||||
@ -150,8 +151,6 @@ napi_value GetContinueAbilityOptionsInfoCommon(
|
||||
napi_value GetContinueAbilityOptionsReversible(
|
||||
const napi_env &env, const napi_value &value, ContinueAbilityOptionsInfo &info);
|
||||
|
||||
napi_value ConvertAbilityInfo(napi_env env, const AbilityInfo &abilityInfo);
|
||||
|
||||
/**
|
||||
* @brief Obtains the continue ability Info this application.
|
||||
*
|
||||
@ -222,6 +221,8 @@ napi_value AcquireDataAbilityHelperWrap(
|
||||
*/
|
||||
napi_value NAPI_AcquireDataAbilityHelperCommon(napi_env env, napi_callback_info info, AbilityType abilityType);
|
||||
|
||||
napi_value ConvertAbilityInfo(napi_env env, const AbilityInfo &abilityInfo);
|
||||
|
||||
struct ConnecttionKey {
|
||||
Want want;
|
||||
int64_t id;
|
||||
|
@ -786,15 +786,19 @@ AsyncJSCallbackInfo *CreateAsyncJSCallbackInfo(napi_env env)
|
||||
Ability *ability = nullptr;
|
||||
NAPI_CALL(env, napi_get_value_external(env, abilityObj, (void **)&ability));
|
||||
|
||||
AsyncJSCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncJSCallbackInfo{
|
||||
.cbInfo.env = env,
|
||||
.cbInfo.callback = nullptr,
|
||||
.asyncWork = nullptr,
|
||||
.deferred = nullptr,
|
||||
.ability = ability,
|
||||
.abilityType = AbilityType::UNKNOWN,
|
||||
.aceCallback = nullptr,
|
||||
};
|
||||
AsyncJSCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncJSCallbackInfo;
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
HILOG_ERROR("%{public}s, asyncCallbackInfo == nullptr.", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
asyncCallbackInfo->cbInfo.env = env;
|
||||
asyncCallbackInfo->cbInfo.callback = nullptr;
|
||||
asyncCallbackInfo->asyncWork = nullptr;
|
||||
asyncCallbackInfo->deferred = nullptr;
|
||||
asyncCallbackInfo->ability = ability;
|
||||
asyncCallbackInfo->abilityType = AbilityType::UNKNOWN;
|
||||
asyncCallbackInfo->aceCallback = nullptr;
|
||||
|
||||
if (asyncCallbackInfo != nullptr) {
|
||||
ClearThreadReturnData(&asyncCallbackInfo->native_data);
|
||||
}
|
||||
@ -1050,7 +1054,7 @@ std::vector<std::string> ConvertStrVector(napi_env env, napi_value value, size_t
|
||||
char *buf = new char[strMax + 1];
|
||||
size_t len = 0;
|
||||
for (size_t i = 0; i < arrLen; ++i) {
|
||||
napi_value element;
|
||||
napi_value element = nullptr;
|
||||
napi_get_element(env, value, i, &element);
|
||||
len = 0;
|
||||
napi_get_value_string_utf8(env, element, buf, strMax, &len);
|
||||
@ -1069,15 +1073,15 @@ std::vector<uint8_t> ConvertU8Vector(napi_env env, napi_value jsValue)
|
||||
}
|
||||
|
||||
napi_typedarray_type type;
|
||||
size_t length;
|
||||
napi_value buffer;
|
||||
size_t offset;
|
||||
size_t length = 0;
|
||||
napi_value buffer = nullptr;
|
||||
size_t offset = 0;
|
||||
NAPI_CALL_BASE(env, napi_get_typedarray_info(env, jsValue, &type, &length, nullptr, &buffer, &offset), {});
|
||||
if (type != napi_uint8_array) {
|
||||
return {};
|
||||
}
|
||||
uint8_t *data;
|
||||
size_t total;
|
||||
uint8_t *data = nullptr;
|
||||
size_t total = 0;
|
||||
NAPI_CALL_BASE(env, napi_get_arraybuffer_info(env, buffer, reinterpret_cast<void **>(&data), &total), {});
|
||||
length = std::min<size_t>(length, total - offset);
|
||||
std::vector<uint8_t> result(sizeof(uint8_t) + length);
|
||||
@ -1111,7 +1115,7 @@ napi_value ConvertJSValue(napi_env env, std::string &value)
|
||||
|
||||
napi_value ConvertJSValue(napi_env env, std::vector<uint8_t> &value)
|
||||
{
|
||||
napi_value jsValue;
|
||||
napi_value jsValue = nullptr;
|
||||
void *native = nullptr;
|
||||
napi_value buffer = nullptr;
|
||||
napi_status status = napi_create_arraybuffer(env, value.size(), &native, &buffer);
|
||||
|
@ -36,13 +36,15 @@ EXTERN_C_END
|
||||
/*
|
||||
* The module definition.
|
||||
*/
|
||||
static napi_module _module = {.nm_version = 1,
|
||||
static napi_module _module = {
|
||||
.nm_version = 1,
|
||||
.nm_flags = 0,
|
||||
.nm_filename = nullptr,
|
||||
.nm_register_func = ParticleInit,
|
||||
.nm_modname = "ability.particleAbility",
|
||||
.nm_priv = ((void *)0),
|
||||
.reserved = {0}};
|
||||
.reserved = {0}
|
||||
};
|
||||
|
||||
/*
|
||||
* The module registration.
|
||||
|
@ -37,13 +37,15 @@ EXTERN_C_END
|
||||
/*
|
||||
* The module definition.
|
||||
*/
|
||||
static napi_module _module = {.nm_version = 1,
|
||||
static napi_module _module = {
|
||||
.nm_version = 1,
|
||||
.nm_flags = 0,
|
||||
.nm_filename = nullptr,
|
||||
.nm_register_func = Init,
|
||||
.nm_modname = "ability.wantConstant",
|
||||
.nm_priv = ((void *)0),
|
||||
.reserved = {0}};
|
||||
.reserved = {0}
|
||||
};
|
||||
|
||||
/*
|
||||
* The module registration.
|
||||
|
@ -576,7 +576,7 @@ private:
|
||||
void StartingLauncherAbility();
|
||||
|
||||
/**
|
||||
*starting system ui abilites.
|
||||
* starting system ui abilites.
|
||||
*
|
||||
*/
|
||||
void StartingSystemUiAbility(const SatrtUiMode &mode);
|
||||
|
@ -685,47 +685,47 @@ private:
|
||||
|
||||
static int64_t abilityRecordId;
|
||||
int recordId_ = 0; // record id
|
||||
Want want_; // want to start this ability
|
||||
AppExecFwk::AbilityInfo abilityInfo_; // the ability info get from BMS
|
||||
AppExecFwk::ApplicationInfo applicationInfo_; // the ability info get from BMS
|
||||
sptr<Token> token_; // used to interact with kit and wms
|
||||
std::weak_ptr<MissionRecord> missionRecord_; // mission of this ability
|
||||
std::weak_ptr<AbilityRecord> preAbilityRecord_; // who starts this ability record
|
||||
std::weak_ptr<AbilityRecord> nextAbilityRecord_; // ability that started by this ability
|
||||
std::weak_ptr<AbilityRecord> backAbilityRecord_; // who back to this ability record
|
||||
std::unique_ptr<LifecycleDeal> lifecycleDeal_; // life manager used to schedule life
|
||||
Want want_ = {}; // want to start this ability
|
||||
AppExecFwk::AbilityInfo abilityInfo_ = {}; // the ability info get from BMS
|
||||
AppExecFwk::ApplicationInfo applicationInfo_ = {}; // the ability info get from BMS
|
||||
sptr<Token> token_ = {}; // used to interact with kit and wms
|
||||
std::weak_ptr<MissionRecord> missionRecord_ = {}; // mission of this ability
|
||||
std::weak_ptr<AbilityRecord> preAbilityRecord_ = {}; // who starts this ability record
|
||||
std::weak_ptr<AbilityRecord> nextAbilityRecord_ = {}; // ability that started by this ability
|
||||
std::weak_ptr<AbilityRecord> backAbilityRecord_ = {}; // who back to this ability record
|
||||
std::unique_ptr<LifecycleDeal> lifecycleDeal_ = {}; // life manager used to schedule life
|
||||
int64_t startTime_ = 0; // records first time of ability start
|
||||
bool isReady_ = false; // is ability thread attached?
|
||||
bool isWindowAttached_ = false; // Is window of this ability attached?
|
||||
bool isLauncherAbility_ = false; // is launcher?
|
||||
int64_t eventId_ = 0; // post event id
|
||||
static int64_t g_abilityRecordEventId_;
|
||||
sptr<IAbilityScheduler> scheduler_; // kit scheduler
|
||||
sptr<IAbilityScheduler> scheduler_ = {}; // kit scheduler
|
||||
bool isTerminating_ = false; // is terminating ?
|
||||
LifeCycleStateInfo lifeCycleStateInfo_; // target life state info
|
||||
AbilityState currentState_; // current life state
|
||||
AbilityState currentState_ = AbilityState::INITIAL; // current life state
|
||||
std::shared_ptr<WindowInfo> windowInfo_; // add window info
|
||||
bool isCreateByConnect_ = false; // is created by connect ability mode?
|
||||
bool isToEnd_ = false; // is to end ?
|
||||
|
||||
int requestCode_ = -1; // requestCode_: >= 0 for-result start mode; <0 for normal start mode in default.
|
||||
sptr<IRemoteObject::DeathRecipient> schedulerDeathRecipient_; // scheduler binderDied Recipient
|
||||
sptr<IRemoteObject::DeathRecipient> schedulerDeathRecipient_ = {}; // scheduler binderDied Recipient
|
||||
|
||||
/**
|
||||
* result_: ability starts with for-result mode will send result before being terminated.
|
||||
* Its caller will receive results before active.
|
||||
* Now we assume only one result generate when terminate.
|
||||
*/
|
||||
std::shared_ptr<AbilityResult> result_;
|
||||
std::shared_ptr<AbilityResult> result_ = {};
|
||||
|
||||
// service(ability) can be connected by multi-pages(abilites), so need to store this service's connections
|
||||
std::list<std::shared_ptr<ConnectionRecord>> connRecordList_;
|
||||
std::list<std::shared_ptr<ConnectionRecord>> connRecordList_ = {};
|
||||
// service(ability) onConnect() return proxy of service ability
|
||||
sptr<IRemoteObject> connRemoteObject_;
|
||||
sptr<IRemoteObject> connRemoteObject_ = {};
|
||||
int startId_ = 0; // service(ability) start id
|
||||
|
||||
// page(ability) can be started by multi-pages(abilites), so need to store this ability's caller
|
||||
std::list<std::shared_ptr<CallerRecord>> callerList_;
|
||||
std::list<std::shared_ptr<CallerRecord>> callerList_ = {};
|
||||
|
||||
bool isUninstall_ = false;
|
||||
bool isForceTerminate_ = false;
|
||||
@ -740,7 +740,7 @@ private:
|
||||
PacMap stateDatas_; // ability saved ability state data
|
||||
bool isRestarting_ = false; // is restarting ?
|
||||
bool isInMovingState_ = false; // whether complete multi window moving state.
|
||||
AppState appState_;
|
||||
AppState appState_ = AppState::BEGIN;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -22,11 +22,11 @@
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace AmsConfig {
|
||||
const std::string AMS_CONFIG_FILE_PATH{"/system/etc/ams_service_config.json"};
|
||||
const std::string SERVICE_ITEM_AMS{"service_startup_config"};
|
||||
const std::string STARTUP_LUNCHER{"startup_launcher"};
|
||||
const std::string STARTUP_STATUS_BAR{"startup_system_ui_status_bar"};
|
||||
const std::string STARTUP_NAVIGATION_BAR{"startup_system_ui_navigation_bar"};
|
||||
const std::string AMS_CONFIG_FILE_PATH {"/system/etc/ams_service_config.json"};
|
||||
const std::string SERVICE_ITEM_AMS {"service_startup_config"};
|
||||
const std::string STARTUP_LUNCHER {"startup_launcher"};
|
||||
const std::string STARTUP_STATUS_BAR {"startup_system_ui_status_bar"};
|
||||
const std::string STARTUP_NAVIGATION_BAR {"startup_system_ui_navigation_bar"};
|
||||
} // namespace AmsConfig
|
||||
|
||||
enum class SatrtUiMode { STATUSBAR = 1, NAVIGATIONBAR = 2, STARTUIBOTH = 3 };
|
||||
@ -70,10 +70,10 @@ private:
|
||||
int LoadAmsConfiguration(const std::string &filePath);
|
||||
|
||||
private:
|
||||
bool nonConfigFile{false};
|
||||
bool canStartLuncher{false};
|
||||
bool canStartUiStatusBar{false};
|
||||
bool canStartUiNavigationBar{false};
|
||||
bool nonConfigFile {false};
|
||||
bool canStartLuncher {false};
|
||||
bool canStartUiStatusBar {false};
|
||||
bool canStartUiNavigationBar {false};
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -79,7 +79,6 @@ AbilityRecord::AbilityRecord(const Want &want, const AppExecFwk::AbilityInfo &ab
|
||||
: want_(want), abilityInfo_(abilityInfo), applicationInfo_(applicationInfo), requestCode_(requestCode)
|
||||
{
|
||||
recordId_ = abilityRecordId++;
|
||||
currentState_ = AbilityState::INITIAL;
|
||||
}
|
||||
|
||||
AbilityRecord::~AbilityRecord()
|
||||
|
@ -499,8 +499,6 @@ std::shared_ptr<NativeRdb::AbsSharedResultSet> AbilitySchedulerProxy::Query(
|
||||
HILOG_ERROR("Query fail to SendRequest. err: %d", err);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HILOG_INFO("AbilitySchedulerProxy::Query end");
|
||||
return OHOS::NativeRdb::ISharedResultSet::ReadFromParcel(reply);
|
||||
}
|
||||
|
||||
|
@ -265,7 +265,8 @@ int AbilitySchedulerStub::UpdatetInner(MessageParcel &data, MessageParcel &reply
|
||||
HILOG_ERROR("ReadParcelable value is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates(data.ReadParcelable<NativeRdb::DataAbilityPredicates>());
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates(
|
||||
data.ReadParcelable<NativeRdb::DataAbilityPredicates>());
|
||||
if (predicates == nullptr) {
|
||||
HILOG_ERROR("ReadParcelable predicates is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
@ -285,7 +286,8 @@ int AbilitySchedulerStub::DeleteInner(MessageParcel &data, MessageParcel &reply)
|
||||
HILOG_ERROR("AbilitySchedulerStub uri is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates(data.ReadParcelable<NativeRdb::DataAbilityPredicates>());
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates(
|
||||
data.ReadParcelable<NativeRdb::DataAbilityPredicates>());
|
||||
if (predicates == nullptr) {
|
||||
HILOG_ERROR("ReadParcelable predicates is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
@ -310,7 +312,8 @@ int AbilitySchedulerStub::QueryInner(MessageParcel &data, MessageParcel &reply)
|
||||
HILOG_ERROR("fail to ReadStringVector columns");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates(data.ReadParcelable<NativeRdb::DataAbilityPredicates>());
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates(
|
||||
data.ReadParcelable<NativeRdb::DataAbilityPredicates>());
|
||||
if (predicates == nullptr) {
|
||||
HILOG_ERROR("ReadParcelable predicates is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
@ -535,7 +538,6 @@ int AbilitySchedulerStub::ExecuteBatchInner(MessageParcel &data, MessageParcel &
|
||||
operations.push_back(dataAbilityOperation);
|
||||
}
|
||||
|
||||
//HILOG_ERROR("AbilitySchedulerStub::ExecuteBatchInner operations.size:%{public}d", operations.size());
|
||||
std::vector<std::shared_ptr<AppExecFwk::DataAbilityResult>> results = ExecuteBatch(operations);
|
||||
int total = results.size();
|
||||
if (!reply.WriteInt32(total)) {
|
||||
|
@ -2749,7 +2749,7 @@ int AbilityStackManager::CheckMultiWindowCondition(
|
||||
|
||||
if (currentTopAbility &&
|
||||
AbilityUtil::IsSystemDialogAbility(
|
||||
currentTopAbility->GetAbilityInfo().bundleName, currentTopAbility->GetAbilityInfo().name)) {
|
||||
currentTopAbility->GetAbilityInfo().bundleName, currentTopAbility->GetAbilityInfo().name)) {
|
||||
HILOG_ERROR("Top page ability is dialog type, cannot return to launcher.");
|
||||
return START_ABILITY_SETTING_FAILED;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ AbilityStartSetting &AbilityStartSetting::operator=(const AbilityStartSetting &o
|
||||
*/
|
||||
std::shared_ptr<AbilityStartSetting> AbilityStartSettingCreator()
|
||||
{
|
||||
std::shared_ptr<AbilityStartSetting> abilityStartSetting{new (std::nothrow) AbilityStartSetting()};
|
||||
std::shared_ptr<AbilityStartSetting> abilityStartSetting {new (std::nothrow) AbilityStartSetting()};
|
||||
return abilityStartSetting;
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ DataAbilityManager::DataAbilityRecordPtr DataAbilityManager::LoadLocked(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto insertResult = dataAbilityRecordsLoading_.insert({ name, dataAbilityRecord });
|
||||
auto insertResult = dataAbilityRecordsLoading_.insert( {name, dataAbilityRecord} );
|
||||
if (!insertResult.second) {
|
||||
HILOG_ERROR("Failed to insert data ability to loading map.");
|
||||
return nullptr;
|
||||
|
@ -334,7 +334,6 @@ void MissionRecord::Resume(const std::shared_ptr<MissionRecord> &backup)
|
||||
}
|
||||
|
||||
ability->SetAbilityState(AbilityState::INITIAL);
|
||||
// ability->ClearFlag();
|
||||
diffAbilitys.emplace_back(ability);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,9 @@ public:
|
||||
Uri NormalizeUri(const Uri &uri) override;
|
||||
Uri DenormalizeUri(const Uri &uri) override;
|
||||
|
||||
void NotifyTopActiveAbilityChanged(bool flag) override{};
|
||||
void NotifyTopActiveAbilityChanged(bool flag) override
|
||||
{
|
||||
};
|
||||
virtual bool ScheduleRegisterObserver(const Uri &uri, const sptr<IDataAbilityObserver> &dataObserver) override
|
||||
{
|
||||
return true;
|
||||
|
@ -36,7 +36,7 @@ AppScheduler::~AppScheduler()
|
||||
bool AppScheduler::Init(const std::weak_ptr<AppStateCallback> &callback)
|
||||
{
|
||||
HILOG_INFO("Test AppScheduler::Init()");
|
||||
if(!callback.lock()){
|
||||
if (!callback.lock()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -46,7 +46,7 @@ int AppScheduler::LoadAbility(const sptr<IRemoteObject> &token, const sptr<IRemo
|
||||
const AppExecFwk::AbilityInfo &abilityInfo, const AppExecFwk::ApplicationInfo &applicationInfo)
|
||||
{
|
||||
HILOG_INFO("Test AppScheduler::LoadAbility()");
|
||||
if(applicationInfo.bundleName.find("com.ix.First.Test") != std::string::npos){
|
||||
if (applicationInfo.bundleName.find("com.ix.First.Test") != std::string::npos) {
|
||||
return INNER_ERR;
|
||||
}
|
||||
return ERR_OK;
|
||||
|
@ -596,52 +596,52 @@ HWTEST_F(AbilityManagerServiceTest, Interface_015, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(AbilityManagerServiceTest, Interface_016, TestSize.Level1)
|
||||
{
|
||||
// Want wantLuncher;
|
||||
// ElementName elementLun("device", "com.ix.hiworld", "LauncherAbility");
|
||||
// wantLuncher.SetElement(elementLun);
|
||||
// StartAbility(wantLuncher);
|
||||
// WaitUntilTaskFinished();
|
||||
Want wantLuncher;
|
||||
ElementName elementLun("device", "com.ix.hiworld", "LauncherAbility");
|
||||
wantLuncher.SetElement(elementLun);
|
||||
StartAbility(wantLuncher);
|
||||
WaitUntilTaskFinished();
|
||||
|
||||
// EXPECT_TRUE(abilityMs_->GetStackManager() != nullptr);
|
||||
// EXPECT_TRUE(abilityMs_->GetStackManager()->GetTopMissionRecord() != nullptr);
|
||||
// EXPECT_TRUE(abilityMs_->GetStackManager()->GetTopMissionRecord()->GetTopAbilityRecord() != nullptr);
|
||||
// auto launcherWant = abilityMs_->GetStackManager()->GetTopMissionRecord()->GetTopAbilityRecord()->GetWant();
|
||||
EXPECT_TRUE(abilityMs_->GetStackManager() != nullptr);
|
||||
EXPECT_TRUE(abilityMs_->GetStackManager()->GetTopMissionRecord() != nullptr);
|
||||
EXPECT_TRUE(abilityMs_->GetStackManager()->GetTopMissionRecord()->GetTopAbilityRecord() != nullptr);
|
||||
auto launcherWant = abilityMs_->GetStackManager()->GetTopMissionRecord()->GetTopAbilityRecord()->GetWant();
|
||||
|
||||
// EXPECT_EQ(abilityMs_->RemoveMission(-1), OHOS::ERR_INVALID_VALUE);
|
||||
EXPECT_EQ(abilityMs_->RemoveMission(-1), OHOS::ERR_INVALID_VALUE);
|
||||
|
||||
// EXPECT_EQ(abilityMs_->RemoveMission(100), REMOVE_MISSION_ID_NOT_EXIST);
|
||||
EXPECT_EQ(abilityMs_->RemoveMission(100), REMOVE_MISSION_ID_NOT_EXIST);
|
||||
|
||||
// auto topMissionId = abilityMs_->GetStackManager()->GetTopMissionRecord()->GetMissionRecordId();
|
||||
// EXPECT_EQ(abilityMs_->RemoveMission(topMissionId), REMOVE_MISSION_LAUNCHER_DENIED);
|
||||
// GTEST_LOG_(INFO) << "topMissionId " << topMissionId;
|
||||
// abilityMs_->GetStackManager()->GetCurrentTopAbility()->SetAbilityState(OHOS::AAFwk::AbilityState::ACTIVE);
|
||||
// Want want;
|
||||
// want.AddEntity(Want::ENTITY_HOME);
|
||||
// ElementName element("device", "com.ix.music", "MusicAbility");
|
||||
// want.SetElement(element);
|
||||
// auto result = StartAbility(want);
|
||||
// WaitUntilTaskFinished();
|
||||
// EXPECT_EQ(OHOS::ERR_OK, result);
|
||||
auto topMissionId = abilityMs_->GetStackManager()->GetTopMissionRecord()->GetMissionRecordId();
|
||||
EXPECT_EQ(abilityMs_->RemoveMission(topMissionId), REMOVE_MISSION_LAUNCHER_DENIED);
|
||||
GTEST_LOG_(INFO) << "topMissionId " << topMissionId;
|
||||
abilityMs_->GetStackManager()->GetCurrentTopAbility()->SetAbilityState(OHOS::AAFwk::AbilityState::ACTIVE);
|
||||
Want want;
|
||||
want.AddEntity(Want::ENTITY_HOME);
|
||||
ElementName element("device", "com.ix.music", "MusicAbility");
|
||||
want.SetElement(element);
|
||||
auto result = StartAbility(want);
|
||||
WaitUntilTaskFinished();
|
||||
EXPECT_EQ(OHOS::ERR_OK, result);
|
||||
|
||||
// topMissionId = abilityMs_->GetStackManager()->GetTopMissionRecord()->GetMissionRecordId();
|
||||
// GTEST_LOG_(INFO) << "topMissionId " << topMissionId;
|
||||
// EXPECT_FALSE(abilityMs_->GetStackManager()->IsLauncherMission(topMissionId));
|
||||
// EXPECT_EQ(abilityMs_->RemoveMission(topMissionId), ERR_OK);
|
||||
topMissionId = abilityMs_->GetStackManager()->GetTopMissionRecord()->GetMissionRecordId();
|
||||
GTEST_LOG_(INFO) << "topMissionId " << topMissionId;
|
||||
EXPECT_FALSE(abilityMs_->GetStackManager()->IsLauncherMission(topMissionId));
|
||||
EXPECT_EQ(abilityMs_->RemoveMission(topMissionId), ERR_OK);
|
||||
|
||||
// auto musicAbility = abilityMs_->GetStackManager()->GetCurrentTopAbility();
|
||||
// musicAbility->SetAbilityState(OHOS::AAFwk::AbilityState::ACTIVE);
|
||||
// EXPECT_EQ(abilityMs_->RemoveMission(topMissionId), ERR_OK);
|
||||
auto musicAbility = abilityMs_->GetStackManager()->GetCurrentTopAbility();
|
||||
musicAbility->SetAbilityState(OHOS::AAFwk::AbilityState::ACTIVE);
|
||||
EXPECT_EQ(abilityMs_->RemoveMission(topMissionId), ERR_OK);
|
||||
|
||||
// auto result1 = StartAbility(launcherWant);
|
||||
// WaitUntilTaskFinished();
|
||||
// EXPECT_EQ(OHOS::ERR_OK, result1);
|
||||
auto result1 = StartAbility(launcherWant);
|
||||
WaitUntilTaskFinished();
|
||||
EXPECT_EQ(OHOS::ERR_OK, result1);
|
||||
|
||||
// EXPECT_EQ(musicAbility->GetAbilityState(), OHOS::AAFwk::AbilityState::INACTIVATING);
|
||||
// EXPECT_NE(topMissionId, abilityMs_->GetStackManager()->GetTopMissionRecord()->GetMissionRecordId());
|
||||
// musicAbility->SetAbilityState(OHOS::AAFwk::AbilityState::MOVING_BACKGROUND);
|
||||
EXPECT_EQ(musicAbility->GetAbilityState(), OHOS::AAFwk::AbilityState::INACTIVATING);
|
||||
EXPECT_NE(topMissionId, abilityMs_->GetStackManager()->GetTopMissionRecord()->GetMissionRecordId());
|
||||
musicAbility->SetAbilityState(OHOS::AAFwk::AbilityState::MOVING_BACKGROUND);
|
||||
|
||||
// EXPECT_EQ(abilityMs_->RemoveMission(topMissionId), 0);
|
||||
// WaitUntilTaskFinished();
|
||||
EXPECT_EQ(abilityMs_->RemoveMission(topMissionId), 0);
|
||||
WaitUntilTaskFinished();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -788,11 +788,6 @@ HWTEST_F(AbilityManagerServiceTest, Interface_020, TestSize.Level1)
|
||||
EXPECT_EQ(stackManage->GetCurrentMissionStack()->GetMissionRecordCount(), 1);
|
||||
EXPECT_EQ(abilityMs_->RemoveStack(1), ERR_OK);
|
||||
|
||||
// stackManage->GetCurrentTopAbility()->SetAbilityState(OHOS::AAFwk::AbilityState::ACTIVE);
|
||||
// auto launcherWant = abilityMs_->GetStackManager()->GetTopMissionRecord()->GetTopAbilityRecord()->GetWant();
|
||||
// auto result2 = abilityMs_->StartAbility(launcherWant);
|
||||
// WaitUntilTaskFinished();
|
||||
// EXPECT_EQ(OHOS::ERR_OK, result2);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1840,7 +1840,6 @@ HWTEST_F(AbilityStackManagerTest, ability_stack_manager_operating_052, TestSize.
|
||||
EXPECT_EQ(0, result);
|
||||
|
||||
auto musicMisionRecord = stackManager_->GetTopMissionRecord();
|
||||
// auto musicMisionRecordId = musicMisionRecord->GetMissionRecordId();
|
||||
|
||||
auto topAbilityRecord = stackManager_->GetCurrentTopAbility();
|
||||
topAbilityRecord->SetAbilityState(OHOS::AAFwk::ACTIVE);
|
||||
|
@ -172,7 +172,7 @@ HWTEST_F(AppSchedulerTest, AppScheduler_oprator_004, TestSize.Level0)
|
||||
*/
|
||||
HWTEST_F(AppSchedulerTest, AppScheduler_oprator_005, TestSize.Level0)
|
||||
{
|
||||
// EXPECT_EQ(false, DelayedSingleton<AppScheduler>::GetInstance()->Init(appStateMock_));
|
||||
EXPECT_EQ(false, DelayedSingleton<AppScheduler>::GetInstance()->Init(appStateMock_));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -124,7 +124,7 @@ int DataObsMgrService::RegisterObserver(const Uri &uri, const sptr<IDataAbilityO
|
||||
return DATAOBS_SERVICE_OBS_LIMMIT;
|
||||
}
|
||||
|
||||
std::function<void()> registerObserverFunc =
|
||||
std::function <void()> registerObserverFunc =
|
||||
std::bind(&DataObsMgrInner::HandleRegisterObserver, dataObsMgrInner_, uri, dataObserver);
|
||||
|
||||
dataObsMgrInner_->AtomicAddTaskCount();
|
||||
@ -160,7 +160,7 @@ int DataObsMgrService::UnregisterObserver(const Uri &uri, const sptr<IDataAbilit
|
||||
return DATAOBS_SERVICE_TASK_LIMMIT;
|
||||
}
|
||||
|
||||
std::function<void()> unregisterObserverFunc =
|
||||
std::function <void()> unregisterObserverFunc =
|
||||
std::bind(&DataObsMgrInner::HandleUnregisterObserver, dataObsMgrInner_, uri, dataObserver);
|
||||
|
||||
dataObsMgrInner_->AtomicAddTaskCount();
|
||||
@ -191,7 +191,7 @@ int DataObsMgrService::NotifyChange(const Uri &uri)
|
||||
return DATAOBS_SERVICE_TASK_LIMMIT;
|
||||
}
|
||||
|
||||
std::function<void()> notifyChangeFunc = std::bind(&DataObsMgrInner::HandleNotifyChange, dataObsMgrInner_, uri);
|
||||
std::function <void()> notifyChangeFunc = std::bind(&DataObsMgrInner::HandleNotifyChange, dataObsMgrInner_, uri);
|
||||
|
||||
dataObsMgrInner_->AtomicAddTaskCount();
|
||||
bool ret = handler_->PostTask(notifyChangeFunc);
|
||||
|
@ -41,7 +41,7 @@ std::shared_ptr<DataObsMgrClient> MockDataObsMgrClient::GetInstance()
|
||||
{
|
||||
if (instance_ == nullptr) {
|
||||
if (instance_ == nullptr) {
|
||||
std::shared_ptr<DataObsMgrClient> client{new (std::nothrow) MockDataObsMgrClient()};
|
||||
std::shared_ptr<DataObsMgrClient> client {new (std::nothrow) MockDataObsMgrClient()};
|
||||
if (client != nullptr) {
|
||||
((MockDataObsMgrClient *)client.get())->Connect();
|
||||
}
|
||||
|
@ -391,8 +391,9 @@ void AbilityMgrModuleTest::CheckTestRecord(std::shared_ptr<AbilityRecord> &recor
|
||||
void AbilityMgrModuleTest::MockLoadHandlerInner(int &testId, sptr<MockAbilityScheduler> &scheduler)
|
||||
{
|
||||
auto handler = [&testId](const Want &want, bool restart, int startid) { testId = startid; };
|
||||
int counts = 3;
|
||||
EXPECT_CALL(*scheduler, ScheduleCommandAbility(_, _, _))
|
||||
.Times(3)
|
||||
.Times(counts)
|
||||
.WillOnce(Invoke(handler))
|
||||
.WillOnce(Invoke(handler))
|
||||
.WillOnce(Invoke(handler));
|
||||
|
@ -79,8 +79,10 @@ void AbilityStackModuleTest::SetUpTestCase(void)
|
||||
|
||||
if (!bundleObject_) {
|
||||
bundleObject_ = new (std::nothrow) BundleMgrService();
|
||||
OHOS::DelayedSingleton<SaMgrClient>::GetInstance()->RegisterSystemAbility(
|
||||
OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID, bundleObject_);
|
||||
if (bundleObject_) {
|
||||
OHOS::DelayedSingleton<SaMgrClient>::GetInstance()->RegisterSystemAbility(
|
||||
OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID, bundleObject_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,6 @@ ohos_shared_library("zlib") {
|
||||
"kits/napi/napi_zlib_common.cpp",
|
||||
"kits/napi/native_module.cpp",
|
||||
"src/file_path.cpp",
|
||||
"src/utf.cpp",
|
||||
"src/zip.cpp",
|
||||
"src/zip_internal.cpp",
|
||||
"src/zip_reader.cpp",
|
||||
|
@ -30,11 +30,11 @@ struct LookUpHelper {};
|
||||
struct LookUpHelper2 : public hidden::LookUpHelper {};
|
||||
|
||||
// IsPtr - partial specialization only
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
struct IsPtr {
|
||||
enum { value = false };
|
||||
};
|
||||
template <typename T>
|
||||
template<typename T>
|
||||
struct IsPtr<T *> {
|
||||
enum { value = true };
|
||||
};
|
||||
@ -78,11 +78,11 @@ private:
|
||||
|
||||
// implementation
|
||||
namespace hidden {
|
||||
template <typename T, typename X, bool isPtr>
|
||||
template<typename T, typename X, bool isPtr>
|
||||
struct checked_cast_impl;
|
||||
|
||||
// pointer variant
|
||||
template <typename T, typename X>
|
||||
template<typename T, typename X>
|
||||
struct checked_cast_impl<T, X, true> {
|
||||
static T cast(X &x, hidden::LookUpHelper2 const &)
|
||||
{
|
||||
@ -113,21 +113,17 @@ struct checked_cast_impl<T, X, true> {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename X>
|
||||
template<typename T, typename X>
|
||||
struct checked_cast_impl<T, X, false> {
|
||||
static T cast(X &x, hidden::LookUpHelper2 const &)
|
||||
{
|
||||
#ifdef CHECKED_CAST_SAFE_CONVERSATION
|
||||
try {
|
||||
T t = dynamic_cast<T>(x);
|
||||
|
||||
// check cross cast
|
||||
if (&t != &static_cast<T>(x))
|
||||
throw std::bad_cast();
|
||||
return t;
|
||||
} catch (...) {
|
||||
BAD_CHECKED_CAST(x, T);
|
||||
}
|
||||
T t = dynamic_cast<T>(x);
|
||||
// check cross cast
|
||||
if (&t != &static_cast<T>(x)) {
|
||||
throw std::bad_cast();
|
||||
}
|
||||
return t;
|
||||
#else
|
||||
return static_cast<T>(x);
|
||||
#endif
|
||||
@ -154,12 +150,12 @@ struct checked_cast_impl<T, X, false> {
|
||||
|
||||
} // namespace hidden
|
||||
|
||||
template <typename T, typename X>
|
||||
template<typename T, typename X>
|
||||
inline T checked_cast(X &x)
|
||||
{
|
||||
return hidden::checked_cast_impl<T, X, hidden::IsPtr<X>::value>::cast(x, hidden::LookUpHelper2());
|
||||
}
|
||||
template <typename T, typename X>
|
||||
template<typename T, typename X>
|
||||
inline T checked_cast(X const &x)
|
||||
{
|
||||
return hidden::checked_cast_impl<T, X, hidden::IsPtr<X>::value>::cast(x, hidden::LookUpHelper2());
|
||||
|
@ -23,7 +23,7 @@ namespace LIBZIP {
|
||||
#define FILE_PATH_LITERAL(x) x
|
||||
#define PRFilePath "s"
|
||||
|
||||
template <typename T, size_t N>
|
||||
template<typename T, size_t N>
|
||||
char (&ArraySizeHelper(T (&array)[N]))[N];
|
||||
#define arraysize(array) (sizeof(ArraySizeHelper(array)))
|
||||
|
||||
|
@ -1,357 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 FOUNDATION_AAFWK_STANDARD_TOOLS_UTF_H
|
||||
#define FOUNDATION_AAFWK_STANDARD_TOOLS_UTF_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace LIBZIP {
|
||||
|
||||
using UChar32 = int32_t;
|
||||
using UChar = uint16_t;
|
||||
using UBool = int8_t;
|
||||
/**
|
||||
* This value is intended for sentinel values for APIs that
|
||||
* (take or) return single code points (UChar32).
|
||||
* It is outside of the Unicode code point range 0..0x10ffff.
|
||||
*
|
||||
* For example, a "done" or "error" value in a new API
|
||||
* could be indicated with CBU_SENTINEL.
|
||||
*
|
||||
* ICU APIs designed before ICU 2.4 usually define service-specific "done"
|
||||
* values, mostly 0xffff.
|
||||
* Those may need to be distinguished from
|
||||
* actual U+ffff text contents by calling functions like
|
||||
* CharacterIterator::hasNext() or UnicodeString::length().
|
||||
*
|
||||
* @return -1
|
||||
* @see UChar32
|
||||
*/
|
||||
#define UTF_SENTINEL (-1)
|
||||
|
||||
/**
|
||||
* Is this code point a Unicode noncharacter?
|
||||
* @param c 32-bit code point
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
#define UTF_IS_UNICODE_NONCHAR(c) \
|
||||
((c) >= 0xfdd0 && ((uint32_t)(c) <= 0xfdef || ((c)&0xfffe) == 0xfffe) && (uint32_t)(c) <= 0x10ffff)
|
||||
|
||||
/**
|
||||
* Is c a Unicode code point value (0..U+10ffff)
|
||||
* that can be assigned a character?
|
||||
*
|
||||
* Code points that are not characters include:
|
||||
* - single surrogate code points (U+d800..U+dfff, 2048 code points)
|
||||
* - the last two code points on each plane (U+__fffe and U+__ffff, 34 code points)
|
||||
* - U+fdd0..U+fdef (new with Unicode 3.1, 32 code points)
|
||||
* - the highest Unicode code point value is U+10ffff
|
||||
*
|
||||
* This means that all code points below U+d800 are character code points,
|
||||
* and that boundary is tested first for performance.
|
||||
*
|
||||
* @param c 32-bit code point
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
#define UTF_IS_UNICODE_CHAR(c) \
|
||||
((uint32_t)(c) < 0xd800 || ((uint32_t)(c) > 0xdfff && (uint32_t)(c) <= 0x10ffff && !UTF_IS_UNICODE_NONCHAR(c)))
|
||||
|
||||
/**
|
||||
* Is this code point a surrogate (U+d800..U+dfff)?
|
||||
* @param c 32-bit code point
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
#define UTF_IS_SURROGATE(c) (((c)&0xfffff800) == 0xd800)
|
||||
|
||||
/**
|
||||
* Assuming c is a surrogate code point (U_IS_SURROGATE(c)),
|
||||
* is it a lead surrogate?
|
||||
* @param c 32-bit code point
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
#define UTF_IS_SURROGATE_LEAD(c) (((c)&0x400) == 0)
|
||||
|
||||
// UTF-8 macros
|
||||
// from utf8.h
|
||||
|
||||
extern const uint8_t utf8_countTrailBytes[256];
|
||||
|
||||
/**
|
||||
* Count the trail bytes for a UTF-8 lead byte.
|
||||
* @internal
|
||||
*/
|
||||
#define UTF8_COUNT_TRAIL_BYTES(leadByte) (utf8_countTrailBytes[(uint8_t)leadByte])
|
||||
|
||||
/**
|
||||
* Mask a UTF-8 lead byte, leave only the lower bits that form part of the code point value.
|
||||
* @internal
|
||||
*/
|
||||
#define UTF8_MASK_LEAD_BYTE(leadByte, countTrailBytes) ((leadByte) &= (1 << (6 - (countTrailBytes))) - 1)
|
||||
|
||||
/**
|
||||
* Does this code unit (byte) encode a code point by itself (US-ASCII 0..0x7f)?
|
||||
* @param c 8-bit code unit (byte)
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
#define UTF8_IS_SINGLE(c) (((c)&0x80) == 0)
|
||||
|
||||
/**
|
||||
* Is this code unit (byte) a UTF-8 lead byte?
|
||||
* @param c 8-bit code unit (byte)
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
#define UTF8_IS_LEAD(c) ((uint8_t)((c)-0xc0) < 0x3e)
|
||||
|
||||
/**
|
||||
* Is this code unit (byte) a UTF-8 trail byte?
|
||||
* @param c 8-bit code unit (byte)
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
#define UTF8_IS_TRAIL(c) (((c)&0xc0) == 0x80)
|
||||
|
||||
/**
|
||||
* How many code units (bytes) are used for the UTF-8 encoding
|
||||
* of this Unicode code point?
|
||||
* @param c 32-bit code point
|
||||
* @return 1..4, or 0 if c is a surrogate or not a Unicode code point
|
||||
*/
|
||||
#define UTF8_LENGTH(c) \
|
||||
((uint32_t)(c) <= 0x7f ? 1 \
|
||||
: ((uint32_t)(c) <= 0x7ff \
|
||||
? 2 \
|
||||
: ((uint32_t)(c) <= 0xd7ff ? 3 \
|
||||
: ((uint32_t)(c) <= 0xdfff || (uint32_t)(c) > 0x10ffff \
|
||||
? 0 \
|
||||
: ((uint32_t)(c) <= 0xffff ? 3 : 4)))))
|
||||
|
||||
/**
|
||||
* The maximum number of UTF-8 code units (bytes) per Unicode code point (U+0000..U+10ffff).
|
||||
* @return 4
|
||||
*/
|
||||
#define UTF8_MAX_LENGTH 4
|
||||
|
||||
/**
|
||||
* Function for handling "next code point" with error-checking.
|
||||
* @internal
|
||||
*/
|
||||
UChar32 Utf8NextCharSafeBody(const uint8_t *s, int32_t *pi, int32_t length, UChar32 c, UBool strict);
|
||||
|
||||
/**
|
||||
* Get a code point from a string at a code point boundary offset,
|
||||
* and advance the offset to the next code point boundary.
|
||||
* (Post-incrementing forward iteration.)
|
||||
* "Safe" macro, checks for illegal sequences and for string boundaries.
|
||||
*
|
||||
* The offset may point to the lead byte of a multi-byte sequence,
|
||||
* in which case the macro will read the whole sequence.
|
||||
* If the offset points to a trail byte or an illegal UTF-8 sequence, then
|
||||
* c is set to a negative value.
|
||||
*
|
||||
* @param s const uint8_t * string
|
||||
* @param i string offset, i<length
|
||||
* @param length string length
|
||||
* @param c output UChar32 variable, set to <0 in case of an error
|
||||
* @see UTF8_NEXT_UNSAFE
|
||||
*/
|
||||
#define UTF8_NEXT(s, i, length, c) \
|
||||
{ \
|
||||
(c) = (s)[(i)++]; \
|
||||
if (((uint8_t)(c)) >= 0x80) { \
|
||||
if (UTF8_IS_LEAD(c)) { \
|
||||
(c) = Utf8NextCharSafeBody((const uint8_t *)s, &(i), (int32_t)(length), c, -1); \
|
||||
} else { \
|
||||
(c) = UTF_SENTINEL; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a code point to a string, overwriting 1 to 4 bytes.
|
||||
* The offset points to the current end of the string contents
|
||||
* and is advanced (post-increment).
|
||||
* "Unsafe" macro, assumes a valid code point and sufficient space in the
|
||||
* string.
|
||||
* Otherwise, the result is undefined.
|
||||
*
|
||||
* @param s const uint8_t * string buffer
|
||||
* @param i string offset
|
||||
* @param c code point to append
|
||||
* @see UTF8_APPEND
|
||||
*/
|
||||
#define UTF8_APPEND_UNSAFE(s, i, c) \
|
||||
{ \
|
||||
if ((uint32_t)(c) <= 0x7f) { \
|
||||
(s)[(i)++] = (uint8_t)(c); \
|
||||
} else { \
|
||||
if ((uint32_t)(c) <= 0x7ff) { \
|
||||
(s)[(i)++] = (uint8_t)(((c) >> 6) | 0xc0); \
|
||||
} else { \
|
||||
if ((uint32_t)(c) <= 0xffff) { \
|
||||
(s)[(i)++] = (uint8_t)(((c) >> 12) | 0xe0); \
|
||||
} else { \
|
||||
(s)[(i)++] = (uint8_t)(((c) >> 18) | 0xf0); \
|
||||
(s)[(i)++] = (uint8_t)((((c) >> 12) & 0x3f) | 0x80); \
|
||||
} \
|
||||
(s)[(i)++] = (uint8_t)((((c) >> 6) & 0x3f) | 0x80); \
|
||||
} \
|
||||
(s)[(i)++] = (uint8_t)(((c)&0x3f) | 0x80); \
|
||||
} \
|
||||
}
|
||||
|
||||
// UTF-16 macros
|
||||
// from utf16.h
|
||||
|
||||
/**
|
||||
* Does this code unit alone encode a code point (BMP, not a surrogate)?
|
||||
* @param c 16-bit code unit
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
#define UTF16_IS_SINGLE(c) !UTF_IS_SURROGATE(c)
|
||||
|
||||
/**
|
||||
* Is this code unit a lead surrogate (U+d800..U+dbff)?
|
||||
* @param c 16-bit code unit
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
#define UTF16_IS_LEAD(c) (((c)&0xfffffc00) == 0xd800)
|
||||
|
||||
/**
|
||||
* Is this code unit a trail surrogate (U+dc00..U+dfff)?
|
||||
* @param c 16-bit code unit
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
#define UTF16_IS_TRAIL(c) (((c)&0xfffffc00) == 0xdc00)
|
||||
|
||||
/**
|
||||
* Is this code unit a surrogate (U+d800..U+dfff)?
|
||||
* @param c 16-bit code unit
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
#define UTF16_IS_SURROGATE(c) UTF_IS_SURROGATE(c)
|
||||
|
||||
/**
|
||||
* Assuming c is a surrogate code point (U16_IS_SURROGATE(c)),
|
||||
* is it a lead surrogate?
|
||||
* @param c 16-bit code unit
|
||||
* @return TRUE or FALSE
|
||||
*/
|
||||
#define UTF16_IS_SURROGATE_LEAD(c) (((c)&0x400) == 0)
|
||||
|
||||
/**
|
||||
* Helper constant for UTF16_GET_SUPPLEMENTARY.
|
||||
* @internal
|
||||
*/
|
||||
#define UTF16_SURROGATE_OFFSET ((0xd800 << 10UL) + 0xdc00 - 0x10000)
|
||||
|
||||
/**
|
||||
* Get a supplementary code point value (U+10000..U+10ffff)
|
||||
* from its lead and trail surrogates.
|
||||
* The result is undefined if the input values are not
|
||||
* lead and trail surrogates.
|
||||
*
|
||||
* @param lead lead surrogate (U+d800..U+dbff)
|
||||
* @param trail trail surrogate (U+dc00..U+dfff)
|
||||
* @return supplementary code point (U+10000..U+10ffff)
|
||||
*/
|
||||
#define UTF16_GET_SUPPLEMENTARY(lead, trail) (((UChar32)(lead) << 10UL) + (UChar32)(trail)-UTF16_SURROGATE_OFFSET)
|
||||
|
||||
/**
|
||||
* Get the lead surrogate (0xd800..0xdbff) for a
|
||||
* supplementary code point (0x10000..0x10ffff).
|
||||
* @param supplementary 32-bit code point (U+10000..U+10ffff)
|
||||
* @return lead surrogate (U+d800..U+dbff) for supplementary
|
||||
*/
|
||||
#define UTF16_LEAD(supplementary) (UChar)(((supplementary) >> 10) + 0xd7c0)
|
||||
|
||||
/**
|
||||
* Get the trail surrogate (0xdc00..0xdfff) for a
|
||||
* supplementary code point (0x10000..0x10ffff).
|
||||
* @param supplementary 32-bit code point (U+10000..U+10ffff)
|
||||
* @return trail surrogate (U+dc00..U+dfff) for supplementary
|
||||
*/
|
||||
#define UTF16_TRAIL(supplementary) (base_icu::UChar)(((supplementary)&0x3ff) | 0xdc00)
|
||||
|
||||
/**
|
||||
* How many 16-bit code units are used to encode this Unicode code point? (1 or 2)
|
||||
* The result is not defined if c is not a Unicode code point (U+0000..U+10ffff).
|
||||
* @param c 32-bit code point
|
||||
* @return 1 or 2
|
||||
*/
|
||||
#define UTF16_LENGTH(c) ((uint32_t)(c) <= 0xffff ? 1 : 2)
|
||||
|
||||
/**
|
||||
* The maximum number of 16-bit code units per Unicode code point (U+0000..U+10ffff).
|
||||
* @return 2
|
||||
*/
|
||||
#define UTF16_MAX_LENGTH 2
|
||||
|
||||
/**
|
||||
* Get a code point from a string at a code point boundary offset,
|
||||
* and advance the offset to the next code point boundary.
|
||||
* (Post-incrementing forward iteration.)
|
||||
* "Safe" macro, handles unpaired surrogates and checks for string boundaries.
|
||||
*
|
||||
* The offset may point to the lead surrogate unit
|
||||
* for a supplementary code point, in which case the macro will read
|
||||
* the following trail surrogate as well.
|
||||
* If the offset points to a trail surrogate or
|
||||
* to a single, unpaired lead surrogate, then that itself
|
||||
* will be returned as the code point.
|
||||
*
|
||||
* @param s const UChar * string
|
||||
* @param i string offset, i<length
|
||||
* @param length string length
|
||||
* @param c output UChar32 variable
|
||||
*/
|
||||
#define UTF16_NEXT(s, i, length, c) \
|
||||
{ \
|
||||
(c) = (s)[(i)++]; \
|
||||
if (UTF16_IS_LEAD(c)) { \
|
||||
uint16_t __c2; \
|
||||
if ((i) < (length) && UTF16_IS_TRAIL(__c2 = (s)[(i)])) { \
|
||||
++(i); \
|
||||
(c) = UTF16_GET_SUPPLEMENTARY((c), __c2); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a code point to a string, overwriting 1 or 2 code units.
|
||||
* The offset points to the current end of the string contents
|
||||
* and is advanced (post-increment).
|
||||
* "Unsafe" macro, assumes a valid code point and sufficient space in the string.
|
||||
* Otherwise, the result is undefined.
|
||||
*
|
||||
* @param s const UChar * string buffer
|
||||
* @param i string offset
|
||||
* @param c code point to append
|
||||
* @see CBU16_APPEND
|
||||
*/
|
||||
#define UTF16_APPEND_UNSAFE(s, i, c) \
|
||||
{ \
|
||||
if ((uint32_t)(c) <= 0xffff) { \
|
||||
(s)[(i)++] = (uint16_t)(c); \
|
||||
} else { \
|
||||
(s)[(i)++] = (uint16_t)(((c) >> 10) + 0xd7c0); \
|
||||
(s)[(i)++] = (uint16_t)(((c)&0x3ff) | 0xdc00); \
|
||||
} \
|
||||
}
|
||||
|
||||
} // namespace LIBZIP
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif // FOUNDATION_AAFWK_STANDARD_TOOLS_UTF_H
|
@ -49,23 +49,7 @@ public:
|
||||
virtual void SetTimeModified(const struct tm *modifiedTime) = 0;
|
||||
};
|
||||
|
||||
// This class is used for reading zip files. A typical use case of this
|
||||
// class is to scan entries in a zip file and extract them. The code will
|
||||
// look like:
|
||||
//
|
||||
// ZipReader reader;
|
||||
// reader.Open(zipFilePath);
|
||||
// while (reader.HasMore()) {
|
||||
// reader.OpenCurrentEntryInZip();
|
||||
// const base::FilePath& entry_path =
|
||||
// reader.CurrentEntryInfo()->file_path();
|
||||
// auto writer = CreateFilePathWriterDelegate(extract_dir, entry_path);
|
||||
// reader.ExtractCurrentEntry(writer, std::numeric_limits<uint64_t>::max());
|
||||
// reader.AdvanceToNextEntry();
|
||||
// }
|
||||
//
|
||||
// For simplicity, error checking is omitted in the example code above. The
|
||||
// production code should check return values from all of these functions.
|
||||
// This class is used for reading zip files.
|
||||
class ZipReader {
|
||||
public:
|
||||
// A callback that is called when the operation is successful.
|
||||
@ -73,9 +57,7 @@ public:
|
||||
using SuccessCallback = std::function<void()>;
|
||||
// A callback that is called when the operation fails.
|
||||
using FailureCallback = std::function<void()>;
|
||||
// A callback that is called periodically during the operation with the number
|
||||
// of bytes that have been processed so far.
|
||||
// using ProgressCallback = base::RepeatingCallback<void(int64_t)>;
|
||||
|
||||
using ProgressCallback = std::function<void(int64_t)>;
|
||||
|
||||
// This class represents information of an entry (file or directory) in
|
||||
@ -129,11 +111,11 @@ public:
|
||||
|
||||
private:
|
||||
FilePath filePath_;
|
||||
int64_t originalSize_;
|
||||
int64_t originalSize_ = 0;
|
||||
struct tm lastModified_;
|
||||
bool isDirectory_;
|
||||
bool isUnsafe_;
|
||||
bool isEncrypted_;
|
||||
bool isDirectory_ = false;
|
||||
bool isUnsafe_ = false;
|
||||
bool isEncrypted_ = false;
|
||||
DISALLOW_COPY_AND_ASSIGN(EntryInfo);
|
||||
};
|
||||
|
||||
@ -183,20 +165,6 @@ public:
|
||||
// the entire file was extracted.
|
||||
bool ExtractCurrentEntry(WriterDelegate *delegate, uint64_t numBytesToExtract) const;
|
||||
|
||||
// Extracts the current entry into memory. If the current entry is a
|
||||
// directory, the |output| parameter is set to the empty string. If the
|
||||
// current entry is a file, the |output| parameter is filled with its
|
||||
// contents. OpenCurrentEntryInZip() must be called beforehand. Note: the
|
||||
// |output| parameter can be filled with a big amount of data, avoid passing
|
||||
// it around by value, but by reference or pointer. Note: the value returned
|
||||
// by EntryInfo::original_size() cannot be trusted, so the real size of the
|
||||
// uncompressed contents can be different. |max_read_bytes| limits the ammount
|
||||
// of memory used to carry the entry. Returns true if the entire content is
|
||||
// read. If the entry is bigger than |max_read_bytes|, returns false and
|
||||
// |output| is filled with |max_read_bytes| of data. If an error occurs,
|
||||
// returns false, and |output| is set to the empty string.
|
||||
// bool ExtractCurrentEntryToString(uint64_t max_read_bytes, std::string *output) const;
|
||||
|
||||
// Returns the current entry info. Returns NULL if the current entry is
|
||||
// not yet opened. OpenCurrentEntryInZip() must be called beforehand.
|
||||
EntryInfo *CurrentEntryInfo() const
|
||||
|
@ -41,7 +41,7 @@ using CALLBACK = std::function<void(int)>;
|
||||
#if !defined(DISALLOW_COPY_AND_ASSIGN)
|
||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName &); \
|
||||
void operator=(const TypeName &)
|
||||
void operator = (const TypeName &)
|
||||
#endif
|
||||
|
||||
using PlatformFile = int;
|
||||
|
92
tools/zip/kits/js/@ohos.zlib.d.ts
vendored
Normal file
92
tools/zip/kits/js/@ohos.zlib.d.ts
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 { AsyncCallback } from './basic';
|
||||
|
||||
declare namespace zlib {
|
||||
//Zlib library constant definition
|
||||
export enum FlushType {
|
||||
FLUSH_TYPE_NO_FLUSH = 0,
|
||||
FLUSH_TYPE_PARTIAL_FLUSH = 1,
|
||||
FLUSH_TYPE_SYNC_FLUSH = 2,
|
||||
FLUSH_TYPE_FULL_FLUSH = 3,
|
||||
FLUSH_TYPE_FINISH = 4,
|
||||
FLUSH_TYPE_BLOCK = 5,
|
||||
FLUSH_TYPE_TREES = 6
|
||||
}
|
||||
|
||||
// The return code of the compression and decompression function.
|
||||
// A negative number indicates an error and a positive number indicates a normal event
|
||||
// enum ErrorCode
|
||||
export enum ErrorCode {
|
||||
ERROR_CODE_OK = 0,
|
||||
ERROR_CODE_STREAM_END = 1,
|
||||
ERROR_CODE_NEED_DICT = 2,
|
||||
ERROR_CODE_ERRNO = -1,
|
||||
ERROR_CODE_STREAM_ERROR = -2,
|
||||
ERROR_CODE_DATA_ERROR = -3,
|
||||
ERROR_CODE_MEM_ERROR = -4,
|
||||
ERROR_CODE_BUF_ERROR = -5,
|
||||
ERROR_CODE_VERSION_ERROR = -6
|
||||
}
|
||||
|
||||
//enum CompressLevel
|
||||
export enum CompressLevel {
|
||||
COMPRESS_LEVEL_NO_COMPRESSION = 0,
|
||||
COMPRESS_LEVEL_BEST_SPEED = 1,
|
||||
COMPRESS_LEVEL_BEST_COMPRESSION = 9,
|
||||
COMPRESS_LEVEL_DEFAULT_COMPRESSION = -1
|
||||
}
|
||||
|
||||
//enum CompressStrategy
|
||||
export enum CompressStrategy {
|
||||
COMPRESS_STRATEGY_DEFAULT_STRATEGY = 0,
|
||||
COMPRESS_STRATEGY_FILTERED = 1,
|
||||
COMPRESS_STRATEGY_HUFFMAN_ONLY = 2,
|
||||
COMPRESS_STRATEGY_RLE = 3,
|
||||
COMPRESS_STRATEGY_FIXED = 4
|
||||
}
|
||||
|
||||
//enum MemLevel
|
||||
export enum MemLevel {
|
||||
MEM_LEVEL_MIN_MEMLEVEL = 1,
|
||||
MEM_LEVEL_DEFAULT_MEMLEVEL = 8,
|
||||
MEM_LEVEL_MAX_MEMLEVEL = 9
|
||||
}
|
||||
|
||||
//zip options
|
||||
interface Options {
|
||||
flush?: FlushType; //corresponding zlib library macro
|
||||
finishFlush?: FlushType; //corresponding zlib library macro #define Z_FINISH 4
|
||||
chunkSize?: number; //Buffer size,>64
|
||||
level?: CompressLevel; //Compression level. The compression level is a number from 0 to 9.
|
||||
//0 has the fastest compression speed (compression process), 9 has the slowest compression speed,
|
||||
// the largest compression rate, and 0 does not compress.
|
||||
|
||||
memLevel?: MemLevel; //How much memory should be allocated for the specified internal compression state.
|
||||
// Memlevel = 1 uses the minimum memory, but it is very slow, reducing the compression ratio; Memlevel = 9 uses the maximum memory to get the best speed. The default value is 8.
|
||||
strategy?: CompressStrategy; //CompressStrategy
|
||||
dictionary?: ArrayBuffer; //deflate/inflate only, empty dictionary by default
|
||||
}
|
||||
|
||||
|
||||
//The interface for compressing the specified file. There is only one callback callback interface
|
||||
function zipFile(inFile:string, outFile:string, options: Options, callback: AsyncCallback<void>): void;
|
||||
function zipFile(inFile:string, outFile:string, options: Options): Promise<number>;
|
||||
|
||||
//The interface for decompressing the specified file. There is only one callback callback interface
|
||||
function unzipFile(inFile:string, outFile:string, options: Options, callback: AsyncCallback<void>): void;
|
||||
function unzipFile(inFile:string, outFile:string, options: Options): Promise<number>;
|
||||
}
|
@ -105,7 +105,7 @@ AsyncZipCallbackInfo *CreateZipAsyncCallbackInfo(napi_env env)
|
||||
HILOG_ERROR("%{public}s get_global=%{public}d err:%{public}s", __func__, ret, errorInfo->error_message);
|
||||
}
|
||||
|
||||
AsyncZipCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncZipCallbackInfo{
|
||||
AsyncZipCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncZipCallbackInfo {
|
||||
.asyncWork = nullptr,
|
||||
.aceCallback = nullptr,
|
||||
};
|
||||
@ -145,6 +145,11 @@ napi_value NAPI_ZipFile(napi_env env, napi_callback_info info)
|
||||
|
||||
ret = ZipFileWrap(env, info, asyncZipCallbackInfo);
|
||||
if (ret == nullptr) {
|
||||
|
||||
if (g_zipAceCallbackInfo!= nullptr) {
|
||||
g_zipAceCallbackInfo.reset();
|
||||
g_zipAceCallbackInfo = nullptr;
|
||||
}
|
||||
if (asyncZipCallbackInfo != nullptr) {
|
||||
delete asyncZipCallbackInfo;
|
||||
asyncZipCallbackInfo = nullptr;
|
||||
@ -479,7 +484,19 @@ napi_value NAPI_UnzipFile(napi_env env, napi_callback_info info)
|
||||
} else {
|
||||
ret = UnzipFilePromise(env, asyncZipCallbackInfo);
|
||||
}
|
||||
if (ret == nullptr) {
|
||||
HILOG_ERROR("%{public}s,ret == nullptr", __func__);
|
||||
if(g_unzipAceCallbackInfo!= nullptr){
|
||||
g_unzipAceCallbackInfo.reset();
|
||||
g_unzipAceCallbackInfo = nullptr;
|
||||
}
|
||||
if (asyncZipCallbackInfo != nullptr) {
|
||||
delete asyncZipCallbackInfo;
|
||||
asyncZipCallbackInfo = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
HILOG_INFO("%{public}s,end", __func__);
|
||||
return ret;
|
||||
}
|
||||
napi_value UnzipFilePromise(napi_env env, AsyncZipCallbackInfo *asyncZipCallbackInfo)
|
||||
@ -605,7 +622,7 @@ void UnzipFilePromiseCallBack(int result)
|
||||
}
|
||||
ZipAndUnzipFileAsyncCallBack(g_unzipAceCallbackInfo, result);
|
||||
}
|
||||
void ZipAndUnzipFileAsyncCallBackInnerJsThread(uv_work_t *work, int status)
|
||||
void ZipAndUnzipFileAsyncCallBackInnerJsThread(uv_work_t *work)
|
||||
{
|
||||
// JS Thread
|
||||
ZlibCallbackInfo *asyncCallbackInfo = (ZlibCallbackInfo *)work->data;
|
||||
@ -638,10 +655,6 @@ void ZipAndUnzipFileAsyncCallBackInnerJsThread(uv_work_t *work, int status)
|
||||
delete asyncCallbackInfo;
|
||||
asyncCallbackInfo = nullptr;
|
||||
}
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
void ZipAndUnzipFileAsyncCallBack(std::shared_ptr<ZlibCallbackInfo> &zipAceCallbackInfo, int result)
|
||||
{
|
||||
@ -662,6 +675,8 @@ void ZipAndUnzipFileAsyncCallBack(std::shared_ptr<ZlibCallbackInfo> &zipAceCallb
|
||||
}
|
||||
ZlibCallbackInfo *asyncCallbackInfo = new (std::nothrow) ZlibCallbackInfo();
|
||||
if (asyncCallbackInfo == nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
return;
|
||||
}
|
||||
asyncCallbackInfo->callbackResult = result;
|
||||
@ -675,7 +690,7 @@ void ZipAndUnzipFileAsyncCallBack(std::shared_ptr<ZlibCallbackInfo> &zipAceCallb
|
||||
[](uv_work_t *work) {},
|
||||
[](uv_work_t *work, int status) {
|
||||
HILOG_INFO("ZipAndUnzipFileAsyncCallBack, uv_queue_work");
|
||||
ZipAndUnzipFileAsyncCallBackInnerJsThread(work, status);
|
||||
ZipAndUnzipFileAsyncCallBackInnerJsThread(work);
|
||||
HILOG_INFO("ZipAndUnzipFileAsyncCallBack, uv_queue_work end.");
|
||||
});
|
||||
if (rev != E_OK) {
|
||||
|
@ -36,13 +36,15 @@ EXTERN_C_END
|
||||
/*
|
||||
* The module definition.
|
||||
*/
|
||||
static napi_module _module = {.nm_version = 1,
|
||||
static napi_module _module = {
|
||||
.nm_version = 1,
|
||||
.nm_flags = 0,
|
||||
.nm_filename = nullptr,
|
||||
.nm_register_func = Init,
|
||||
.nm_modname = "zlib",
|
||||
.nm_priv = ((void *)0),
|
||||
.reserved = {0}};
|
||||
.reserved = {0}
|
||||
};
|
||||
|
||||
/*
|
||||
* The module registration.
|
||||
|
@ -125,16 +125,19 @@ FilePath FilePath::DirName()
|
||||
std::string::size_type letter = FindDriveLetter(newPath.path_);
|
||||
std::string::size_type lastSeparator =
|
||||
newPath.path_.find_last_of(kSeparators, std::string::npos, kSeparatorsLength - 1);
|
||||
std::string::size_type one = 1;
|
||||
std::string::size_type two = 2;
|
||||
std::string::size_type three = 3;
|
||||
if (lastSeparator == std::string::npos) {
|
||||
// path_ is in the current directory.
|
||||
newPath.path_.resize(letter + 1);
|
||||
} else if (lastSeparator == letter + 1) {
|
||||
newPath.path_.resize(letter + one);
|
||||
} else if (lastSeparator == letter + one) {
|
||||
// path_ is in the root directory.
|
||||
newPath.path_.resize(letter + 2);
|
||||
} else if (lastSeparator == letter + 2 && IsSeparator(newPath.path_[letter + 1])) {
|
||||
newPath.path_.resize(letter + two);
|
||||
} else if (lastSeparator == letter + two && IsSeparator(newPath.path_[letter + one])) {
|
||||
// path_ is in "//" (possibly with a drive letter); leave the double
|
||||
// separator intact indicating alternate root.
|
||||
newPath.path_.resize(letter + 3);
|
||||
newPath.path_.resize(letter + three);
|
||||
} else if (lastSeparator != 0) {
|
||||
// path_ is somewhere else, trim the basename.
|
||||
newPath.path_.resize(lastSeparator);
|
||||
@ -173,11 +176,13 @@ void FilePath::StripTrailingSeparatorsInternal()
|
||||
if (path_.size() == 0) {
|
||||
return;
|
||||
}
|
||||
std::string::size_type start = FindDriveLetter(path_) + 2;
|
||||
std::string::size_type one = 1;
|
||||
std::string::size_type two = 2;
|
||||
std::string::size_type start = FindDriveLetter(path_) + two;
|
||||
std::string::size_type lastStripped = std::string::npos;
|
||||
for (std::string::size_type pos = path_.length(); pos > start && FilePath::IsSeparator(path_[pos - 1]); --pos) {
|
||||
if (pos != start + 1 || lastStripped == start + 2 || !FilePath::IsSeparator(path_[start - 1])) {
|
||||
path_.resize(pos - 1);
|
||||
for (std::string::size_type pos = path_.length(); pos > start && FilePath::IsSeparator(path_[pos - one]); --pos) {
|
||||
if (pos != start + one || lastStripped == start + two || !FilePath::IsSeparator(path_[start - one])) {
|
||||
path_.resize(pos - one);
|
||||
lastStripped = pos;
|
||||
}
|
||||
}
|
||||
@ -229,13 +234,13 @@ bool FilePath::CreateDirectory(const FilePath &fullPath)
|
||||
subpaths.push_back(path);
|
||||
lastPath = path;
|
||||
}
|
||||
|
||||
mode_t rootMode= 0777;
|
||||
// Iterate through the parents and create the missing ones.
|
||||
for (std::vector<FilePath>::reverse_iterator i = subpaths.rbegin(); i != subpaths.rend(); ++i) {
|
||||
if (DirectoryExists(*i)) {
|
||||
continue;
|
||||
}
|
||||
if (mkdir(i->Value().c_str(), 0777) == 0) {
|
||||
if (mkdir(i->Value().c_str(), rootMode) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -1,427 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 "utf.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace LIBZIP {
|
||||
#define UTFTF8_ERROR_VALUE_1 0x15
|
||||
#define UTFTF8_ERROR_VALUE_2 0x9f
|
||||
#define UTFTF_ERROR_VALUE 0xffff
|
||||
/*
|
||||
* This table could be replaced on many machines by
|
||||
* a few lines of assembler code using an
|
||||
* "index of first 0-bit from msb" instruction and
|
||||
* one or two more integer instructions.
|
||||
*
|
||||
* For example, on an i386, do something like
|
||||
* - MOV AL, leadByte
|
||||
* - NOT AL (8-bit, leave b15..b8==0..0, reverse only b7..b0)
|
||||
* - MOV AH, 0
|
||||
* - BSR BX, AX (16-bit)
|
||||
* - MOV AX, 6 (result)
|
||||
* - JZ finish (ZF==1 if leadByte==0xff)
|
||||
* - SUB AX, BX (result)
|
||||
* -finish:
|
||||
* (BSR: Bit Scan Reverse, scans for a 1-bit, starting from the MSB)
|
||||
*
|
||||
* In Unicode, all UTF-8 byte sequences with more than 4 bytes are illegal;
|
||||
* lead bytes above 0xf4 are illegal.
|
||||
* We keep them in this table for skipping long ISO 10646-UTF-8 sequences.
|
||||
*/
|
||||
const uint8_t utf8_countTrailBytes[256] = {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3, /* illegal in Unicode */
|
||||
4,
|
||||
4,
|
||||
4,
|
||||
4, /* illegal in Unicode */
|
||||
5,
|
||||
5, /* illegal in Unicode */
|
||||
0,
|
||||
0 /* illegal bytes 0xfe and 0xff */
|
||||
};
|
||||
|
||||
static const UChar32 utf8_minLegal[4] = {0, 0x80, 0x800, 0x10000};
|
||||
|
||||
static const UChar32 utf8_errorValue[6] = {
|
||||
UTFTF8_ERROR_VALUE_1, UTFTF8_ERROR_VALUE_2, UTFTF_ERROR_VALUE, 0x10ffff, 0x3ffffff, 0x7fffffff};
|
||||
|
||||
/*
|
||||
* Handle the non-inline part of the U8_NEXT() macro and its obsolete sibling
|
||||
* UTF8_NEXT_CHAR_SAFE().
|
||||
*
|
||||
* The "strict" parameter controls the error behavior:
|
||||
* <0 "Safe" behavior of U8_NEXT(): All illegal byte sequences yield a negative
|
||||
* code point result.
|
||||
* 0 Obsolete "safe" behavior of UTF8_NEXT_CHAR_SAFE(..., FALSE):
|
||||
* All illegal byte sequences yield a positive code point such that this
|
||||
* result code point would be encoded with the same number of bytes as
|
||||
* the illegal sequence.
|
||||
* >0 Obsolete "strict" behavior of UTF8_NEXT_CHAR_SAFE(..., TRUE):
|
||||
* Same as the obsolete "safe" behavior, but non-characters are also treated
|
||||
* like illegal sequences.
|
||||
*
|
||||
* The special negative (<0) value -2 is used for lenient treatment of surrogate
|
||||
* code points as legal. Some implementations use this for roundtripping of
|
||||
* Unicode 16-bit strings that are not well-formed UTF-16, that is, they
|
||||
* contain unpaired surrogates.
|
||||
*
|
||||
* Note that a UBool is the same as an int8_t.
|
||||
*/
|
||||
UChar32 Utf8NextCharSafeBody(const uint8_t *s, int32_t *pi, int32_t length, UChar32 c, UBool strict)
|
||||
{
|
||||
int32_t i = *pi;
|
||||
uint8_t count = UTF8_COUNT_TRAIL_BYTES(c);
|
||||
if ((i) + count <= (length)) {
|
||||
uint8_t trail, illegal = 0;
|
||||
|
||||
UTF8_MASK_LEAD_BYTE((c), count);
|
||||
/* count==0 for illegally leading trail bytes and the illegal bytes 0xfe and 0xff */
|
||||
switch (count) {
|
||||
/* each branch falls through to the next one */
|
||||
case 5:
|
||||
case 4:
|
||||
/* count>=4 is always illegal: no more than 3 trail bytes in Unicode's UTF-8 */
|
||||
illegal = 1;
|
||||
break;
|
||||
case 3:
|
||||
trail = s[(i)++];
|
||||
(c) = ((c) << 6) | (trail & 0x3f);
|
||||
if (c < 0x110) {
|
||||
illegal |= (trail & 0xc0) ^ 0x80;
|
||||
} else {
|
||||
/* code point>0x10ffff, outside Unicode */
|
||||
illegal = 1;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
trail = s[(i)++];
|
||||
(c) = ((c) << 6) | (trail & 0x3f);
|
||||
illegal |= (trail & 0xc0) ^ 0x80;
|
||||
case 1:
|
||||
trail = s[(i)++];
|
||||
(c) = ((c) << 6) | (trail & 0x3f);
|
||||
illegal |= (trail & 0xc0) ^ 0x80;
|
||||
break;
|
||||
case 0:
|
||||
if (strict >= 0) {
|
||||
return UTFTF8_ERROR_VALUE_1;
|
||||
} else {
|
||||
return UTF_SENTINEL;
|
||||
}
|
||||
/* no default branch to optimize switch() - all values are covered */
|
||||
}
|
||||
|
||||
/*
|
||||
* All the error handling should return a value
|
||||
* that needs count bytes so that UTF8_GET_CHAR_SAFE() works right.
|
||||
*
|
||||
* Starting with Unicode 3.0.1, non-shortest forms are illegal.
|
||||
* Starting with Unicode 3.2, surrogate code points must not be
|
||||
* encoded in UTF-8, and there are no irregular sequences any more.
|
||||
*
|
||||
* U8_ macros (new in ICU 2.4) return negative values for error conditions.
|
||||
*/
|
||||
|
||||
/* correct sequence - all trail bytes have (b7..b6)==(10)? */
|
||||
/* illegal is also set if count>=4 */
|
||||
if (illegal || (c) < utf8_minLegal[count] || (UTF_IS_SURROGATE(c) && strict != -2)) {
|
||||
/* error handling */
|
||||
uint8_t errorCount = count;
|
||||
/* don't go beyond this sequence */
|
||||
i = *pi;
|
||||
while (count > 0 && UTF8_IS_TRAIL(s[i])) {
|
||||
++(i);
|
||||
--count;
|
||||
}
|
||||
if (strict >= 0) {
|
||||
c = utf8_errorValue[errorCount - count];
|
||||
} else {
|
||||
c = UTF_SENTINEL;
|
||||
}
|
||||
} else if ((strict) > 0 && UTF_IS_UNICODE_NONCHAR(c)) {
|
||||
/* strict: forbid non-characters like U+fffe */
|
||||
c = utf8_errorValue[count];
|
||||
}
|
||||
} else /* too few bytes left */ {
|
||||
/* error handling */
|
||||
int32_t i0 = i;
|
||||
/* don't just set (i)=(length) in case there is an illegal sequence */
|
||||
while ((i) < (length) && UTF8_IS_TRAIL(s[i])) {
|
||||
++(i);
|
||||
}
|
||||
if (strict >= 0) {
|
||||
c = utf8_errorValue[i - i0];
|
||||
} else {
|
||||
c = UTF_SENTINEL;
|
||||
}
|
||||
}
|
||||
*pi = i;
|
||||
return c;
|
||||
}
|
||||
} // namespace LIBZIP
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
@ -124,12 +124,12 @@ bool Zip(const ZipParams ¶ms, const OPTIONS &options, CALLBACK callback)
|
||||
filesToAdd = &allRelativeFiles;
|
||||
std::list<FileAccessor::DirectoryContentEntry> entries;
|
||||
if (endIsSeparator) {
|
||||
entries.push_back(FileAccessor::DirectoryContentEntry(params.SrcDir(), true /* is directory*/));
|
||||
entries.push_back(FileAccessor::DirectoryContentEntry(params.SrcDir(), true));
|
||||
FilterCallback filterCallback = params.GetFilterCallback();
|
||||
for (auto iter = entries.begin(); iter != entries.end(); ++iter) {
|
||||
const FilePath &constEntryPath = iter->path;
|
||||
if (iter != entries.begin() && ((!params.GetIncludeHiddenFiles() && IsHiddenFile(constEntryPath)) ||
|
||||
(filterCallback && !filterCallback(constEntryPath)))) {
|
||||
(filterCallback && !filterCallback(constEntryPath)))) {
|
||||
continue;
|
||||
}
|
||||
if (iter != entries.begin()) {
|
||||
@ -270,7 +270,11 @@ bool Unzip(const FilePath &srcFile, const FilePath &destDir, const OPTIONS &opti
|
||||
destDirTemp.Value().c_str());
|
||||
|
||||
std::shared_ptr<Runnable> innerTask = std::make_shared<Runnable>([srcFile, destDir, options, callback]() {
|
||||
UnzipParam unzipParam{.callback = callback, .filterCB = ExcludeNoFilesFilter, .logSkippedFiles = true};
|
||||
UnzipParam unzipParam{
|
||||
.callback = callback,
|
||||
.filterCB = ExcludeNoFilesFilter,
|
||||
.logSkippedFiles = true
|
||||
};
|
||||
UnzipWithFilterCallback(srcFile, destDir, options, unzipParam);
|
||||
});
|
||||
|
||||
|
@ -32,8 +32,9 @@ struct tm GetTmDataFromTickts(int64_t sec)
|
||||
if (tmNow == nullptr) {
|
||||
return now;
|
||||
}
|
||||
int baseYeaar = 1900;
|
||||
now = *tmNow;
|
||||
now.tm_year += 1900;
|
||||
now.tm_year += baseYeaar;
|
||||
now.tm_mon += 1;
|
||||
return now;
|
||||
}
|
||||
@ -88,7 +89,7 @@ void FillFdOpenFileFunc(zlib_filefunc_def *pzlibFilefuncDef, PlatformFile fd)
|
||||
// a zip archive stored in memory directly. The following I/O API functions
|
||||
// expect their opaque parameters refer to this struct.
|
||||
struct ZipBuffer {
|
||||
const char *data; // weak
|
||||
const char *data;
|
||||
size_t length;
|
||||
size_t offset;
|
||||
};
|
||||
@ -99,7 +100,7 @@ struct ZipBuffer {
|
||||
// given opaque parameter and returns it because this parameter stores all
|
||||
// information needed for uncompressing data. (This function does not support
|
||||
// writing compressed data and it returns NULL for this case.)
|
||||
void *OpenZipBuffer(void *opaque, const char * /*filename*/, int mode)
|
||||
void *OpenZipBuffer(void *opaque, const char *, int mode)
|
||||
{
|
||||
uint32_t modeInner = static_cast<uint32_t>(mode);
|
||||
if ((modeInner & ZLIB_FILEFUNC_MODE_READWRITEFILTER) != ZLIB_FILEFUNC_MODE_READ) {
|
||||
@ -107,15 +108,16 @@ void *OpenZipBuffer(void *opaque, const char * /*filename*/, int mode)
|
||||
return NULL;
|
||||
}
|
||||
ZipBuffer *buffer = static_cast<ZipBuffer *>(opaque);
|
||||
if (!buffer || !buffer->data || !buffer->length)
|
||||
if (!buffer || !buffer->data || !buffer->length) {
|
||||
return NULL;
|
||||
}
|
||||
buffer->offset = 0;
|
||||
return opaque;
|
||||
}
|
||||
|
||||
// Reads compressed data from the specified stream. This function copies data
|
||||
// refered by the opaque parameter and returns the size actually copied.
|
||||
uLong ReadZipBuffer(void *opaque, void * /*stream*/, void *buf, uLong size)
|
||||
uLong ReadZipBuffer(void *opaque, void *, void *buf, uLong size)
|
||||
{
|
||||
ZipBuffer *buffer = static_cast<ZipBuffer *>(opaque);
|
||||
if (buffer == nullptr) {
|
||||
@ -128,8 +130,9 @@ uLong ReadZipBuffer(void *opaque, void * /*stream*/, void *buf, uLong size)
|
||||
}
|
||||
|
||||
size_t remaining_bytes = buffer->length - buffer->offset;
|
||||
if (!buffer || !buffer->data || !remaining_bytes)
|
||||
if (!buffer || !buffer->data || !remaining_bytes) {
|
||||
return 0;
|
||||
}
|
||||
size = std::min(size, static_cast<uLong>(remaining_bytes));
|
||||
if (memcpy_s(buf, size, &buffer->data[buffer->offset], size) != EOK) {
|
||||
return 0;
|
||||
@ -140,27 +143,29 @@ uLong ReadZipBuffer(void *opaque, void * /*stream*/, void *buf, uLong size)
|
||||
|
||||
// Writes compressed data to the stream. This function always returns zero
|
||||
// because this implementation is only for reading compressed data.
|
||||
uLong WriteZipBuffer(void * /*opaque*/, void * /*stream*/, const void * /*buf*/, uLong /*size*/)
|
||||
uLong WriteZipBuffer(void *, void *, const void *, uLong)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Returns the offset from the beginning of the data.
|
||||
long GetOffsetOfZipBuffer(void *opaque, void * /*stream*/)
|
||||
long GetOffsetOfZipBuffer(void *opaque, void *)
|
||||
{
|
||||
ZipBuffer *buffer = static_cast<ZipBuffer *>(opaque);
|
||||
if (!buffer)
|
||||
if (!buffer) {
|
||||
return -1;
|
||||
}
|
||||
return static_cast<long>(buffer->offset);
|
||||
}
|
||||
|
||||
// Moves the current offset to the specified position.
|
||||
long SeekZipBuffer(void *opaque, void * /*stream*/, uLong offset, int origin)
|
||||
long SeekZipBuffer(void *opaque, void *, uLong offset, int origin)
|
||||
{
|
||||
ZipBuffer *buffer = static_cast<ZipBuffer *>(opaque);
|
||||
if (!buffer)
|
||||
if (!buffer) {
|
||||
return -1;
|
||||
}
|
||||
if (origin == ZLIB_FILEFUNC_SEEK_CUR) {
|
||||
buffer->offset = std::min(buffer->offset + static_cast<size_t>(offset), buffer->length);
|
||||
return 0;
|
||||
@ -181,16 +186,17 @@ long SeekZipBuffer(void *opaque, void * /*stream*/, uLong offset, int origin)
|
||||
// uncompressing data. This function deletes the ZipBuffer object referred by
|
||||
// the opaque parameter since zlib deletes the unzFile object and it does not
|
||||
// use this object any longer.
|
||||
int CloseZipBuffer(void *opaque, void * /*stream*/)
|
||||
int CloseZipBuffer(void *opaque, void *)
|
||||
{
|
||||
if (opaque)
|
||||
if (opaque) {
|
||||
free(opaque);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Returns the last error happened when reading or writing data. This function
|
||||
// always returns zero, which means there are not any errors.
|
||||
int GetErrorOfZipBuffer(void * /*opaque*/, void * /*stream*/)
|
||||
int GetErrorOfZipBuffer(void *, void *)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -226,9 +232,9 @@ unzFile OpenFdForUnzipping(int zipFD)
|
||||
// static
|
||||
unzFile PrepareMemoryForUnzipping(const std::string &data)
|
||||
{
|
||||
if (data.empty())
|
||||
if (data.empty()) {
|
||||
return NULL;
|
||||
|
||||
}
|
||||
ZipBuffer *buffer = static_cast<ZipBuffer *>(malloc(sizeof(ZipBuffer)));
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
@ -253,7 +259,7 @@ zipFile OpenForZipping(const std::string &fileNameUtf8, int appendFlag)
|
||||
zlib_filefunc_def *zipFuncPtrs = NULL;
|
||||
return zipOpen2(fileNameUtf8.c_str(),
|
||||
appendFlag,
|
||||
NULL, // global comment
|
||||
NULL,
|
||||
zipFuncPtrs);
|
||||
}
|
||||
|
||||
@ -272,24 +278,24 @@ bool ZipOpenNewFileInZip(
|
||||
|
||||
zip_fileinfo fileInfo = {};
|
||||
TimeToZipFileInfo(lastModifiedTime, fileInfo);
|
||||
if (ZIP_OK != zipOpenNewFileInZip4(zipFile, // file
|
||||
strPath.c_str(), // filename
|
||||
&fileInfo, // zip_fileinfo
|
||||
NULL, // extrafield_local,
|
||||
0u, // size_extrafield_local
|
||||
NULL, // extrafield_global
|
||||
0u, // size_extrafield_global
|
||||
NULL, // comment
|
||||
Z_DEFLATED, // method
|
||||
(int)options.level, // level:default Z_DEFAULT_COMPRESSION
|
||||
0, // raw
|
||||
-MAX_WBITS, // windowBits
|
||||
(int)options.memLevel, // memLevel: default DEF_MEM_LEVEL
|
||||
(int)options.strategy, // strategy:default Z_DEFAULT_STRATEGY
|
||||
NULL, // password
|
||||
0, // crcForCrypting
|
||||
0, // versionMadeBy
|
||||
LANGUAGE_ENCODING_FLAG)) { // flagBase
|
||||
if (ZIP_OK != zipOpenNewFileInZip4(zipFile, // file
|
||||
strPath.c_str(), // filename
|
||||
&fileInfo, // zip_fileinfo
|
||||
NULL, // extrafield_local,
|
||||
0u, // size_extrafield_local
|
||||
NULL, // extrafield_global
|
||||
0u, // size_extrafield_global
|
||||
NULL, // comment
|
||||
Z_DEFLATED, // method
|
||||
(int)options.level, // level:default Z_DEFAULT_COMPRESSION
|
||||
0, // raw
|
||||
-MAX_WBITS, // windowBits
|
||||
(int)options.memLevel, // memLevel: default DEF_MEM_LEVEL
|
||||
(int)options.strategy, // strategy:default Z_DEFAULT_STRATEGY
|
||||
NULL, // password
|
||||
0, // crcForCrypting
|
||||
0, // versionMadeBy
|
||||
LANGUAGE_ENCODING_FLAG)) { // flagBase
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -78,7 +78,6 @@ bool ZipReader::Open(FilePath &zipFilePath)
|
||||
|
||||
// Use of "Unsafe" function does not look good, but there is no way to do
|
||||
// this safely on Linux. See file_util.h for details.
|
||||
// zipFile_ = internal::OpenForUnzipping(zipFilePath.AsUTF8Unsafe());
|
||||
std::string zipfile = zipFilePath.Value();
|
||||
zipFile_ = OpenForUnzipping(zipfile);
|
||||
if (zipFile_ == nullptr) {
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include <pthread.h>
|
||||
#include <memory>
|
||||
#include <regex>
|
||||
#include "utf.h"
|
||||
#include "runnable.h"
|
||||
#include "task_dispatcher_context.h"
|
||||
#include "parallel_task_dispatcher.h"
|
||||
@ -51,7 +50,8 @@ struct tm *GetCurrentSystemTime(void)
|
||||
if (time == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
time->tm_mday = time->tm_mday + 1900;
|
||||
int baseYear = 1900;
|
||||
time->tm_mday = time->tm_mday + baseYear;
|
||||
time->tm_mday = time->tm_mon + 1;
|
||||
return time;
|
||||
}
|
||||
|
@ -34,7 +34,6 @@ ohos_unittest("zip_test") {
|
||||
include_dirs = [ "//foundation/aafwk/standard/tools/zip/include" ]
|
||||
sources = [
|
||||
"//foundation/aafwk/standard/tools/zip/src/file_path.cpp",
|
||||
"//foundation/aafwk/standard/tools/zip/src/utf.cpp",
|
||||
"//foundation/aafwk/standard/tools/zip/src/zip.cpp",
|
||||
"//foundation/aafwk/standard/tools/zip/src/zip_internal.cpp",
|
||||
"//foundation/aafwk/standard/tools/zip/src/zip_reader.cpp",
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 "ability_handler.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
AbilityHandler::AbilityHandler(const std::shared_ptr<EventRunner> &runner, const sptr<AbilityThread> &server)
|
||||
: EventHandler(runner), server_(server)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Process the event. Developers should override this method.
|
||||
*
|
||||
* @param event The event should be processed.
|
||||
*/
|
||||
void AbilityHandler::ProcessEvent([[maybe_unused]] const InnerEvent::Pointer &event)
|
||||
{}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -1,588 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 "ability_impl.h"
|
||||
#include "app_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
void AbilityImpl::Init(std::shared_ptr<OHOSApplication> &application, const std::shared_ptr<AbilityLocalRecord> &record,
|
||||
std::shared_ptr<Ability> &ability, std::shared_ptr<AbilityHandler> &handler, const sptr<IRemoteObject> &token,
|
||||
std::shared_ptr<ContextDeal> &contextDeal)
|
||||
{
|
||||
APP_LOGI("AbilityImpl::init begin");
|
||||
|
||||
if ((token == nullptr) || (application == nullptr) || (handler == nullptr) || (record == nullptr) ||
|
||||
ability == nullptr || contextDeal == nullptr) {
|
||||
APP_LOGE("AbilityImpl::init failed, token is nullptr, application is nullptr, handler is nullptr, record is "
|
||||
"nullptr, ability is nullptr, contextDeal is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
token_ = record->GetToken();
|
||||
record->SetAbilityImpl(shared_from_this());
|
||||
ability_ = ability;
|
||||
ability_->Init(record->GetAbilityInfo(), application, handler, token);
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_INITIAL;
|
||||
abilityLifecycleCallbacks_ = application;
|
||||
contextDeal_ = contextDeal;
|
||||
|
||||
APP_LOGI("AbilityImpl::init end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_INACTIVE. And notifies the application
|
||||
* that it belongs to of the lifecycle status.
|
||||
*
|
||||
* @param want The Want object to switch the life cycle.
|
||||
*/
|
||||
void AbilityImpl::Start(const Want &want)
|
||||
{
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Start ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGI("AbilityImpl::Start");
|
||||
ability_->OnStart(want);
|
||||
if (ability_->GetAbilityInfo()->type == AbilityType::DATA) {
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_ACTIVE;
|
||||
} else {
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_INACTIVE;
|
||||
}
|
||||
|
||||
abilityLifecycleCallbacks_->OnAbilityStart(ability_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_INITIAL. And notifies the application
|
||||
* that it belongs to of the lifecycle status.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::Stop()
|
||||
{
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Stop ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGD("AbilityImpl::Stop");
|
||||
ability_->OnStop();
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_INITIAL;
|
||||
abilityLifecycleCallbacks_->OnAbilityStop(ability_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_ACTIVE. And notifies the application
|
||||
* that it belongs to of the lifecycle status.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::Active()
|
||||
{
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Active ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGD("AbilityImpl::Active");
|
||||
ability_->OnActive();
|
||||
|
||||
if ((lifecycleState_ == AAFwk::ABILITY_STATE_INACTIVE) && (ability_->GetAbilityInfo()->type == AbilityType::PAGE)) {
|
||||
ability_->OnTopActiveAbilityChanged(true);
|
||||
ability_->OnWindowFocusChanged(true);
|
||||
}
|
||||
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_ACTIVE;
|
||||
abilityLifecycleCallbacks_->OnAbilityActive(ability_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_INACTIVE. And notifies the application
|
||||
* that it belongs to of the lifecycle status.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::Inactive()
|
||||
{
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Inactive ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGD("AbilityImpl::Inactive");
|
||||
ability_->OnInactive();
|
||||
|
||||
if ((lifecycleState_ == AAFwk::ABILITY_STATE_ACTIVE) && (ability_->GetAbilityInfo()->type == AbilityType::PAGE)) {
|
||||
ability_->OnTopActiveAbilityChanged(false);
|
||||
ability_->OnWindowFocusChanged(false);
|
||||
}
|
||||
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_INACTIVE;
|
||||
abilityLifecycleCallbacks_->OnAbilityInactive(ability_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_INACTIVE. And notifies the application
|
||||
* that it belongs to of the lifecycle status.
|
||||
*
|
||||
* @param want The Want object to switch the life cycle.
|
||||
*/
|
||||
void AbilityImpl::Foreground(const Want &want)
|
||||
{
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Foreground ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGD("AbilityImpl::Foreground");
|
||||
ability_->OnForeground(want);
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_INACTIVE;
|
||||
abilityLifecycleCallbacks_->OnAbilityForeground(ability_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Toggles the lifecycle status of Ability to AAFwk::ABILITY_STATE_BACKGROUND. And notifies the application
|
||||
* that it belongs to of the lifecycle status.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::Background()
|
||||
{
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Background ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGD("AbilityImpl::Background");
|
||||
ability_->OnLeaveForeground();
|
||||
ability_->OnBackground();
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_BACKGROUND;
|
||||
abilityLifecycleCallbacks_->OnAbilityBackground(ability_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Save data and states of an ability when it is restored by the system. and Calling information back to Ability.
|
||||
* This method should be implemented by a Page ability.
|
||||
* @param instate The Want object to connect to.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::DispatchSaveAbilityState(PacMap &outState)
|
||||
{
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::DispatchSaveAbilityState ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGD("AbilityImpl::DispatchSaveAbilityState");
|
||||
ability_->OnSaveAbilityState(outState);
|
||||
abilityLifecycleCallbacks_->OnAbilitySaveState(outState);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Restores data and states of an ability when it is restored by the system. and Calling information back to
|
||||
* Ability. This method should be implemented by a Page ability.
|
||||
* @param instate The Want object to connect to.
|
||||
*
|
||||
*/
|
||||
void AbilityImpl::DispatchRestoreAbilityState(const PacMap &inState)
|
||||
{
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::DispatchRestoreAbilityState ability_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGD("AbilityImpl:: DispatchRestoreAbilityState");
|
||||
ability_->OnRestoreAbilityState(inState);
|
||||
}
|
||||
|
||||
void AbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState)
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief Connect the ability. and Calling information back to Ability.
|
||||
*
|
||||
* @param want The Want object to connect to.
|
||||
*
|
||||
*/
|
||||
sptr<IRemoteObject> AbilityImpl::ConnectAbility(const Want &want)
|
||||
{
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::ConnectAbility ability_ is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
APP_LOGD("AbilityImpl:: ConnectAbility");
|
||||
sptr<IRemoteObject> object = ability_->OnConnect(want);
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_ACTIVE;
|
||||
abilityLifecycleCallbacks_->OnAbilityActive(ability_);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Disconnects the connected object.
|
||||
*
|
||||
* @param want The Want object to disconnect to.
|
||||
*/
|
||||
void AbilityImpl::DisconnectAbility(const Want &want)
|
||||
{
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::DisconnectAbility ability_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
ability_->OnDisconnect(want);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Command the ability. and Calling information back to Ability.
|
||||
*
|
||||
* @param want The Want object to command to.
|
||||
*
|
||||
* * @param restart Indicates the startup mode. The value true indicates that Service is restarted after being
|
||||
* destroyed, and the value false indicates a normal startup.
|
||||
*
|
||||
* @param startId Indicates the number of times the Service ability has been started. The startId is incremented by 1
|
||||
* every time the ability is started. For example, if the ability has been started for six times, the value of startId
|
||||
* is 6.
|
||||
*/
|
||||
void AbilityImpl::CommandAbility(const Want &want, bool restart, int startId)
|
||||
{
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::CommandAbility ability_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
APP_LOGD("AbilityImpl:: CommandAbility");
|
||||
ability_->OnCommand(want, restart, startId);
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_ACTIVE;
|
||||
abilityLifecycleCallbacks_->OnAbilityActive(ability_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the current Ability status.
|
||||
*
|
||||
*/
|
||||
int AbilityImpl::GetCurrentState()
|
||||
{
|
||||
return lifecycleState_;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Execution the KeyDown callback of the ability
|
||||
* @param keyCode Indicates the code of the key pressed.
|
||||
* @param keyEvent Indicates the key-down event.
|
||||
*
|
||||
* @return Returns true if this event is handled and will not be passed further; returns false if this event is
|
||||
* not handled and should be passed to other handlers.
|
||||
*
|
||||
*/
|
||||
bool AbilityImpl::DoKeyDown(int keyCode, const KeyEvent &keyEvent)
|
||||
{
|
||||
APP_LOGD("AbilityImpl::DoKeyDown called");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Execution the KeyUp callback of the ability
|
||||
* @param keyCode Indicates the code of the key released.
|
||||
* @param keyEvent Indicates the key-up event.
|
||||
*
|
||||
* @return Returns true if this event is handled and will not be passed further; returns false if this event is
|
||||
* not handled and should be passed to other handlers.
|
||||
*
|
||||
*/
|
||||
bool AbilityImpl::DoKeyUp(int keyCode, const KeyEvent &keyEvent)
|
||||
{
|
||||
APP_LOGD("AbilityImpl::DoKeyUp called");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when a touch event is dispatched to this ability. The default implementation of this callback
|
||||
* does nothing and returns false.
|
||||
* @param touchEvent Indicates information about the touch event.
|
||||
*
|
||||
* @return Returns true if the event is handled; returns false otherwise.
|
||||
*
|
||||
*/
|
||||
bool AbilityImpl::DoTouchEvent(const TouchEvent &touchEvent)
|
||||
{
|
||||
APP_LOGD("AbilityImpl::DoTouchEvent called");
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Send the result code and data to be returned by this Page ability to the caller.
|
||||
* When a Page ability is destroyed, the caller overrides the AbilitySlice#onAbilityResult(int, int, Want) method to
|
||||
* receive the result set in the current method. This method can be called only after the ability has been initialized.
|
||||
*
|
||||
* @param requestCode Indicates the request code.
|
||||
* @param resultCode Indicates the result code returned after the ability is destroyed. You can define the result code
|
||||
* to identify an error.
|
||||
* @param resultData Indicates the data returned after the ability is destroyed. You can define the data returned. This
|
||||
* parameter can be null.
|
||||
*/
|
||||
void AbilityImpl::SendResult(int requestCode, int resultCode, const Want &resultData)
|
||||
{
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::SendResult ability_ is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
if (resultData.HasParameter(OHOS_RESULT_PERMISSION_KEY) && resultData.HasParameter(OHOS_RESULT_PERMISSIONS_LIST) &&
|
||||
resultData.HasParameter(OHOS_RESULT_CALLER_BUNDLERNAME)) {
|
||||
|
||||
if (resultCode > 0) {
|
||||
std::vector<std::string> permissions = resultData.GetStringArrayParam(OHOS_RESULT_PERMISSIONS_LIST);
|
||||
std::vector<std::string> grantYes = resultData.GetStringArrayParam(OHOS_RESULT_PERMISSIONS_LIST_YES);
|
||||
std::vector<std::string> grantNo = resultData.GetStringArrayParam(OHOS_RESULT_PERMISSIONS_LIST_NO);
|
||||
std::vector<int> grantResult;
|
||||
int intOK = 0;
|
||||
for (size_t i = 0; i < permissions.size(); i++) {
|
||||
intOK = 0;
|
||||
for (size_t j = 0; j < grantYes.size(); j++) {
|
||||
if (permissions[i] == grantYes[j]) {
|
||||
intOK = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
grantResult.push_back(intOK);
|
||||
}
|
||||
ability_->OnRequestPermissionsFromUserResult(requestCode, permissions, grantResult);
|
||||
} else {
|
||||
APP_LOGE("AbilityImpl::SendResult user cancel permissions");
|
||||
}
|
||||
} else {
|
||||
ability_->OnAbilityResult(requestCode, resultCode, resultData);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Called when the launch mode of an ability is set to singleInstance. This happens when you re-launch
|
||||
* an ability that has been at the top of the ability stack.
|
||||
*
|
||||
* @param want Indicates the new Want containing information about the ability.
|
||||
*/
|
||||
void AbilityImpl::NewWant(const Want &want)
|
||||
{
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::NewWant ability_ is nullptr");
|
||||
return;
|
||||
}
|
||||
ability_->SetWant(want);
|
||||
ability_->OnNewWant(want);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the MIME types of files supported.
|
||||
*
|
||||
* @param uri Indicates the path of the files to obtain.
|
||||
* @param mimeTypeFilter Indicates the MIME types of the files to obtain. This parameter cannot be null.
|
||||
*
|
||||
* @return Returns the matched MIME types. If there is no match, null is returned.
|
||||
*/
|
||||
std::vector<std::string> AbilityImpl::GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter)
|
||||
{
|
||||
std::vector<std::string> types;
|
||||
return types;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Opens a file in a specified remote path.
|
||||
*
|
||||
* @param uri Indicates the path of the file to open.
|
||||
* @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access
|
||||
* (erasing whatever data is currently in the file), "wt" for write access that truncates any existing file,
|
||||
* "wa" for write-only access to append to any existing data, "rw" for read and write access on any existing data,
|
||||
* or "rwt" for read and write access that truncates any existing file.
|
||||
*
|
||||
* @return Returns the file descriptor.
|
||||
*/
|
||||
int AbilityImpl::OpenFile(const Uri &uri, const std::string &mode)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This is like openFile, open a file that need to be able to return sub-sections of files,often assets
|
||||
* inside of their .hap.
|
||||
*
|
||||
* @param uri Indicates the path of the file to open.
|
||||
* @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access
|
||||
* (erasing whatever data is currently in the file), "wt" for write access that truncates any existing file,
|
||||
* "wa" for write-only access to append to any existing data, "rw" for read and write access on any existing
|
||||
* data, or "rwt" for read and write access that truncates any existing file.
|
||||
*
|
||||
* @return Returns the RawFileDescriptor object containing file descriptor.
|
||||
*/
|
||||
int AbilityImpl::OpenRawFile(const Uri &uri, const std::string &mode)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inserts a single data record into the database.
|
||||
*
|
||||
* @param uri Indicates the path of the data to operate.
|
||||
* @param value Indicates the data record to insert. If this parameter is null, a blank row will be inserted.
|
||||
*
|
||||
* @return Returns the index of the inserted data record.
|
||||
*/
|
||||
int AbilityImpl::Insert(const Uri &uri, const NativeRdb::ValuesBucket &value)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Updates data records in the database.
|
||||
*
|
||||
* @param uri Indicates the path of data to update.
|
||||
* @param value Indicates the data to update. This parameter can be null.
|
||||
* @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null.
|
||||
*
|
||||
* @return Returns the number of data records updated.
|
||||
*/
|
||||
int AbilityImpl::Update(const Uri &uri, const NativeRdb::ValuesBucket &value, const NativeRdb::DataAbilityPredicates &predicates)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deletes one or more data records from the database.
|
||||
*
|
||||
* @param uri Indicates the path of the data to operate.
|
||||
* @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null.
|
||||
*
|
||||
* @return Returns the number of data records deleted.
|
||||
*/
|
||||
int AbilityImpl::Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deletes one or more data records from the database.
|
||||
*
|
||||
* @param uri Indicates the path of data to query.
|
||||
* @param columns Indicates the columns to query. If this parameter is null, all columns are queried.
|
||||
* @param predicates Indicates filter criteria. You should define the processing logic when this parameter is null.
|
||||
*
|
||||
* @return Returns the query result.
|
||||
*/
|
||||
std::shared_ptr<NativeRdb::AbsSharedResultSet> AbilityImpl::Query(
|
||||
const Uri &uri, std::vector<std::string> &columns, const NativeRdb::DataAbilityPredicates &predicates)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the MIME type matching the data specified by the URI of the Data ability. This method should be
|
||||
* implemented by a Data ability. Data abilities supports general data types, including text, HTML, and JPEG.
|
||||
*
|
||||
* @param uri Indicates the URI of the data.
|
||||
*
|
||||
* @return Returns the MIME type that matches the data specified by uri.
|
||||
*/
|
||||
std::string AbilityImpl::GetType(const Uri &uri)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reloads data in the database.
|
||||
*
|
||||
* @param uri Indicates the position where the data is to reload. This parameter is mandatory.
|
||||
* @param extras Indicates the PacMap object containing the additional parameters to be passed in this call. This
|
||||
* parameter can be null. If a custom Sequenceable object is put in the PacMap object and will be transferred across
|
||||
* processes, you must call BasePacMap.setClassLoader(ClassLoader) to set a class loader for the custom object.
|
||||
*
|
||||
* @return Returns true if the data is successfully reloaded; returns false otherwise.
|
||||
*/
|
||||
bool AbilityImpl::Reload(const Uri &uri, const PacMap &extras)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Inserts multiple data records into the database.
|
||||
*
|
||||
* @param uri Indicates the path of the data to operate.
|
||||
* @param values Indicates the data records to insert.
|
||||
*
|
||||
* @return Returns the number of data records inserted.
|
||||
*/
|
||||
int AbilityImpl::BatchInsert(const Uri &uri, const std::vector<NativeRdb::ValuesBucket> &values)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SerUriString
|
||||
*/
|
||||
void AbilityImpl::SerUriString(const std::string &uri)
|
||||
{
|
||||
if (contextDeal_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::SerUriString contextDeal_ is nullptr");
|
||||
return;
|
||||
}
|
||||
contextDeal_->SerUriString(uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the LifeCycleStateInfo to the deal.
|
||||
*
|
||||
* @param info the info to set.
|
||||
*/
|
||||
void AbilityImpl::SetLifeCycleStateInfo(const AAFwk::LifeCycleStateInfo &info)
|
||||
{
|
||||
if (contextDeal_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::SetLifeCycleStateInfo contextDeal_ is nullptr");
|
||||
return;
|
||||
}
|
||||
contextDeal_->SetLifeCycleStateInfo(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set deviceId/bundleName/abilityName of the calling ability
|
||||
*
|
||||
* @param deviceId deviceId of the calling ability
|
||||
*
|
||||
* @param deviceId bundleName of the calling ability
|
||||
*
|
||||
* @param deviceId abilityName of the calling ability
|
||||
*/
|
||||
void AbilityImpl::SetCallingContext(
|
||||
const std::string &deviceId, const std::string &bundleName, const std::string &abilityName)
|
||||
{
|
||||
if (ability_ != nullptr) {
|
||||
ability_->SetCallingContext(deviceId, bundleName, abilityName);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief ScheduleUpdateConfiguration, scheduling update configuration.
|
||||
*/
|
||||
void AbilityImpl::ScheduleUpdateConfiguration(const AAFwk::GlobalConfiguration &config)
|
||||
{
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::ScheduleUpdateConfiguration ability_ is nullptr");
|
||||
}
|
||||
|
||||
Configuration configtest;
|
||||
ability_->OnConfigurationUpdated(configtest);
|
||||
// ability_->OnConfigurationUpdated(config);
|
||||
}
|
||||
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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 "ability_impl_factory.h"
|
||||
#include "app_log_wrapper.h"
|
||||
#include "data_ability_impl.h"
|
||||
#include "page_ability_impl.h"
|
||||
#include "service_ability_impl.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
/**
|
||||
*
|
||||
* default constructor
|
||||
*
|
||||
*/
|
||||
AbilityImplFactory::AbilityImplFactory()
|
||||
{}
|
||||
|
||||
/**
|
||||
*
|
||||
* default Destructor
|
||||
*
|
||||
*/
|
||||
AbilityImplFactory::~AbilityImplFactory()
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief Create impl object based on abilitytype
|
||||
*
|
||||
* @param type AbilityType:PAGE/SERVICE/PROVIDER
|
||||
*
|
||||
* @return AbilityImpl object
|
||||
*/
|
||||
std::shared_ptr<AbilityImpl> AbilityImplFactory::MakeAbilityImplObject(const std::shared_ptr<AbilityInfo> &info)
|
||||
{
|
||||
if (info == nullptr) {
|
||||
APP_LOGE("AbilityImplFactory::MakeAbilityImplObject is error nullptr == info ");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<AbilityImpl> abilityImpl = nullptr;
|
||||
APP_LOGI("AbilityImplFactory::MakeAbilityImplObject type:%{public}d", info->type);
|
||||
|
||||
switch (info->type) {
|
||||
case AppExecFwk::AbilityType::PAGE:
|
||||
abilityImpl = std::make_shared<PageAbilityImpl>();
|
||||
break;
|
||||
case AppExecFwk::AbilityType::SERVICE:
|
||||
abilityImpl = std::make_shared<ServiceAbilityImpl>();
|
||||
break;
|
||||
case AppExecFwk::AbilityType::DATA:
|
||||
abilityImpl = std::make_shared<DataAbilityImpl>();
|
||||
break;
|
||||
default:
|
||||
APP_LOGE("AbilityImplFactory::MakeAbilityImplObject is error");
|
||||
break;
|
||||
}
|
||||
|
||||
return abilityImpl;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
Loading…
Reference in New Issue
Block a user