mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-22 23:00:39 +00:00
Merge remote-tracking branch 'upstream/master' into huke_mws1_one_build0827
Signed-off-by: jiangzhijun8 <jiangzhijun7@huawei.com>
This commit is contained in:
commit
42722f2e76
10
bundle.json
10
bundle.json
@ -77,6 +77,7 @@
|
||||
"jsoncpp",
|
||||
"kv_store",
|
||||
"libuv",
|
||||
"media_library",
|
||||
"memmgr",
|
||||
"memory_utils",
|
||||
"napi",
|
||||
@ -93,7 +94,6 @@
|
||||
"sandbox_manager",
|
||||
"screenlock_mgr",
|
||||
"storage_service",
|
||||
"skia",
|
||||
"toolchain",
|
||||
"webview",
|
||||
"window_manager",
|
||||
@ -274,6 +274,14 @@
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:extensionkit_native"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/",
|
||||
"header_files": [
|
||||
]
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:abilitykit_utils"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/",
|
||||
|
@ -42,13 +42,9 @@ ohos_shared_library("autostartupcallback") {
|
||||
"c_utils:utils",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
# "form_fwk:form_manager",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
# "resource_management:global_resmgr",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
|
@ -41,18 +41,15 @@ ohos_shared_library("autostartupmanager") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
# "ability_base:session_info",
|
||||
"access_token:libtokenid_sdk",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
"samgr:samgr_proxy",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
|
||||
relative_install_dir = "module/app/ability"
|
||||
|
@ -15,13 +15,7 @@ import("//build/ohos.gni")
|
||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
|
||||
ohos_shared_library("featureability") {
|
||||
include_dirs = [
|
||||
"./",
|
||||
"${relational_store_napi_path}/common/include",
|
||||
"${relational_store_napi_path}/dataability/include",
|
||||
"${relational_store_napi_path}/rdb/include",
|
||||
"${relational_store_base_path}/frameworks/common/include",
|
||||
]
|
||||
include_dirs = [ "./" ]
|
||||
|
||||
sources = [
|
||||
"feature_ability.cpp",
|
||||
@ -54,14 +48,9 @@ ohos_shared_library("featureability") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"kv_store:distributeddata_inner",
|
||||
"data_share:datashare_provider",
|
||||
"libuv:uv",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
@ -77,25 +66,24 @@ ohos_shared_library("featureability") {
|
||||
]
|
||||
}
|
||||
|
||||
# if (ability_runtime_relational) {
|
||||
# include_dirs += [
|
||||
# "${relational_store_napi_path}/common/include",
|
||||
# "${relational_store_napi_path}/dataability/include",
|
||||
# "${relational_store_napi_path}/rdb/include",
|
||||
# ]
|
||||
# sources += [
|
||||
# "${relational_store_napi_path}/common/src/js_utils.cpp",
|
||||
# "${relational_store_napi_path}/dataability/src/napi_data_ability_predicates.cpp",
|
||||
# "${relational_store_napi_path}/rdb/src/napi_rdb_js_utils.cpp",
|
||||
# "${relational_store_napi_path}/rdb/src/napi_result_set.cpp",
|
||||
# ]
|
||||
# external_deps += [
|
||||
# "kv_store:distributeddata_mgr",
|
||||
# "relational_store:native_dataability",
|
||||
# "relational_store:native_rdb",
|
||||
# "relational_store:rdb_data_share_adapter",
|
||||
# ]
|
||||
# }
|
||||
if (ability_runtime_relational) {
|
||||
include_dirs += [ "data_ability/include" ]
|
||||
sources += [
|
||||
"data_ability/js_utils.cpp",
|
||||
"data_ability/napi_data_ability_predicates.cpp",
|
||||
"data_ability/napi_rdb_js_utils.cpp",
|
||||
"data_ability/napi_result_set.cpp",
|
||||
]
|
||||
external_deps += [
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
"kv_store:distributeddata_mgr",
|
||||
"relational_store:native_appdatafwk",
|
||||
"relational_store:native_dataability",
|
||||
"relational_store:native_rdb",
|
||||
"relational_store:rdb_data_share_adapter",
|
||||
]
|
||||
}
|
||||
cflags_cc = []
|
||||
if (os_dlp_part_enabled) {
|
||||
cflags_cc += [ "-DWITH_DLP" ]
|
||||
|
@ -0,0 +1,363 @@
|
||||
/*
|
||||
* 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 DISTRIBUTEDDATAMGR_APPDATAMGR_JSUTILS_H
|
||||
#define DISTRIBUTEDDATAMGR_APPDATAMGR_JSUTILS_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <variant>
|
||||
#include <vector>
|
||||
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "napi/native_node_api.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppDataMgrJsKit {
|
||||
namespace JSUtils {
|
||||
#define DECLARE_JS_PROPERTY(env, key, value) \
|
||||
napi_property_descriptor(DECLARE_NAPI_DEFAULT_PROPERTY((key), Convert2JSValue((env), (value))))
|
||||
|
||||
#define ASSERT(condition, message, retVal) \
|
||||
do { \
|
||||
if (!(condition)) { \
|
||||
LOG_ERROR("test (" #condition ") failed: " message); \
|
||||
return retVal; \
|
||||
} \
|
||||
} while (0)
|
||||
static constexpr int OK = 0;
|
||||
static constexpr int ERR = -1;
|
||||
static constexpr uint32_t ASYNC_RST_SIZE = 2;
|
||||
static constexpr uint32_t DEFAULT_VALUE_LENGTH = 1024;
|
||||
static constexpr uint32_t MAX_VALUE_LENGTH = 1024 * 1024 * 8; // the max length of all kand of out string value
|
||||
static constexpr uint32_t SYNC_RESULT_ELEMENT_NUM = 2;
|
||||
struct JsFeatureSpace {
|
||||
const char *spaceName;
|
||||
const char *nameBase64;
|
||||
bool isComponent;
|
||||
};
|
||||
|
||||
void SetHapVersion(int32_t hapversion);
|
||||
int32_t GetHapVersion();
|
||||
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, napi_value &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, bool &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, double &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, int64_t &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::string &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::vector<uint8_t> &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::vector<float> &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::monostate &value);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::map<std::string, int32_t> &output);
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::map<std::string, bool> &output);
|
||||
|
||||
bool IsNull(napi_env env, napi_value value);
|
||||
|
||||
bool Equal(napi_env env, napi_ref ref, napi_value value);
|
||||
|
||||
template<typename T>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, T &output);
|
||||
|
||||
template<typename T>
|
||||
int32_t Convert2ValueExt(napi_env env, napi_value jsValue, T &output);
|
||||
|
||||
int32_t Convert2ValueExt(napi_env env, napi_value jsValue, uint32_t &output);
|
||||
int32_t Convert2ValueExt(napi_env env, napi_value jsValue, int32_t &output);
|
||||
int32_t Convert2ValueExt(napi_env env, napi_value jsValue, int64_t &output);
|
||||
|
||||
template<typename T>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::vector<T> &value);
|
||||
|
||||
template<typename T>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::map<std::string, T> &value);
|
||||
|
||||
template<typename... Types>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, std::variant<Types...> &value);
|
||||
|
||||
using Descriptor = std::function<std::vector<napi_property_descriptor>()>;
|
||||
const std::optional<JsFeatureSpace> GetJsFeatureSpace(const std::string &name);
|
||||
/* napi_define_class wrapper */
|
||||
napi_value DefineClass(napi_env env, const std::string &spaceName, const std::string &className,
|
||||
const Descriptor &descriptor, napi_callback ctor);
|
||||
napi_value GetClass(napi_env env, const std::string &spaceName, const std::string &className);
|
||||
std::string Convert2String(napi_env env, napi_value jsStr);
|
||||
|
||||
int32_t Convert2JSValue(napi_env env, std::string value, napi_value &output);
|
||||
int32_t Convert2JSValue(napi_env env, bool value, napi_value &output);
|
||||
int32_t Convert2JSValue(napi_env env, double value, napi_value &output);
|
||||
|
||||
napi_value Convert2JSValue(napi_env env, const std::string &value);
|
||||
napi_value Convert2JSValue(napi_env env, const std::vector<uint8_t> &value);
|
||||
napi_value Convert2JSValue(napi_env env, const std::vector<float> &value);
|
||||
napi_value Convert2JSValue(napi_env env, int32_t value);
|
||||
napi_value Convert2JSValue(napi_env env, uint32_t value);
|
||||
napi_value Convert2JSValue(napi_env env, int64_t value);
|
||||
napi_value Convert2JSValue(napi_env env, double value);
|
||||
napi_value Convert2JSValue(napi_env env, bool value);
|
||||
napi_value Convert2JSValue(napi_env env, const std::map<std::string, int> &value);
|
||||
napi_value Convert2JSValue(napi_env env, const std::monostate &value);
|
||||
|
||||
template<typename T>
|
||||
napi_value Convert2JSValue(napi_env env, const T &value);
|
||||
|
||||
template<typename T>
|
||||
napi_value Convert2JSValue(napi_env env, const std::vector<T> &value);
|
||||
|
||||
template<typename K, typename V>
|
||||
napi_value Convert2JSValue(napi_env env, const std::map<K, V> &value);
|
||||
|
||||
template<typename T>
|
||||
napi_value Convert2JSValue(napi_env env, const std::tuple<int32_t, std::string, T> &value);
|
||||
|
||||
template<typename... Types>
|
||||
napi_value Convert2JSValue(napi_env env, const std::variant<Types...> &value);
|
||||
|
||||
template<typename T>
|
||||
std::string ToString(const T &key);
|
||||
|
||||
template<typename K>
|
||||
std::enable_if_t<!std::is_same_v<K, std::string>, std::string> ConvertMapKey(const K &key)
|
||||
{
|
||||
return ToString(key);
|
||||
}
|
||||
|
||||
template<typename K>
|
||||
std::enable_if_t<std::is_same_v<K, std::string>, const std::string &> ConvertMapKey(const K &key)
|
||||
{
|
||||
return key;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
int32_t GetCPPValue(napi_env env, napi_value jsValue, T &value)
|
||||
{
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
template<typename T, typename First, typename... Types>
|
||||
int32_t GetCPPValue(napi_env env, napi_value jsValue, T &value)
|
||||
{
|
||||
First cValue;
|
||||
auto ret = Convert2Value(env, jsValue, cValue);
|
||||
if (ret == napi_ok) {
|
||||
value = cValue;
|
||||
return ret;
|
||||
}
|
||||
return GetCPPValue<T, Types...>(env, jsValue, value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
napi_value GetJSValue(napi_env env, const T &value)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template<typename T, typename First, typename... Types>
|
||||
napi_value GetJSValue(napi_env env, const T &value)
|
||||
{
|
||||
auto *val = std::get_if<First>(&value);
|
||||
if (val != nullptr) {
|
||||
return Convert2JSValue(env, *val);
|
||||
}
|
||||
return GetJSValue<T, Types...>(env, value);
|
||||
}
|
||||
|
||||
std::pair<napi_status, napi_value> GetInnerValue(napi_env env, napi_value in, const std::string &prop, bool optional);
|
||||
|
||||
template<typename T>
|
||||
inline std::enable_if_t<std::is_same_v<T, int32_t> || std::is_same_v<T, uint32_t>, int32_t> GetNamedProperty(
|
||||
napi_env env, napi_value in, const std::string &prop, T &value, bool optional = false)
|
||||
{
|
||||
auto [status, jsValue] = GetInnerValue(env, in, prop, optional);
|
||||
if (jsValue == nullptr) {
|
||||
return status;
|
||||
}
|
||||
return Convert2ValueExt(env, jsValue, value);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline std::enable_if_t<!std::is_same_v<T, int32_t> && !std::is_same_v<T, uint32_t>, int32_t> GetNamedProperty(
|
||||
napi_env env, napi_value in, const std::string &prop, T &value, bool optional = false)
|
||||
{
|
||||
auto [status, jsValue] = GetInnerValue(env, in, prop, optional);
|
||||
if (jsValue == nullptr) {
|
||||
return status;
|
||||
}
|
||||
return Convert2Value(env, jsValue, value);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
inline int32_t SetNamedProperty(napi_env env, napi_value in, const std::string &prop, T value)
|
||||
{
|
||||
return napi_set_named_property(env, in, prop.c_str(), Convert2JSValue(env, value));
|
||||
};
|
||||
|
||||
napi_value ToJsObject(napi_env env, napi_value sendableValue);
|
||||
napi_value ToJsArray(napi_env env, napi_value sendableValue);
|
||||
napi_value ToJsTypedArray(napi_env env, napi_value sendableValue);
|
||||
napi_value Convert2JSValue(napi_env env, napi_value sendableValue);
|
||||
} // namespace JSUtils
|
||||
|
||||
template<typename T>
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::vector<T> &value)
|
||||
{
|
||||
bool isArray = false;
|
||||
napi_is_array(env, jsValue, &isArray);
|
||||
if (!isArray) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
uint32_t arrLen = 0;
|
||||
napi_get_array_length(env, jsValue, &arrLen);
|
||||
if (arrLen == 0) {
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < arrLen; ++i) {
|
||||
napi_value element;
|
||||
napi_get_element(env, jsValue, i, &element);
|
||||
T item;
|
||||
auto status = Convert2Value(env, element, item);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
value.push_back(std::move(item));
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::map<std::string, T> &value)
|
||||
{
|
||||
napi_value jsMapList = nullptr;
|
||||
uint32_t jsCount = 0;
|
||||
napi_status status = napi_get_property_names(env, jsValue, &jsMapList);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
status = napi_get_array_length(env, jsMapList, &jsCount);
|
||||
if (status != napi_ok || jsCount <= 0) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
napi_value jsKey = nullptr;
|
||||
napi_value jsVal = nullptr;
|
||||
for (uint32_t index = 0; index < jsCount; index++) {
|
||||
status = napi_get_element(env, jsMapList, index, &jsKey);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
std::string key;
|
||||
int ret = Convert2Value(env, jsKey, key);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
status = napi_get_property(env, jsValue, jsKey, &jsVal);
|
||||
if (status != napi_ok || jsVal == nullptr) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
T val;
|
||||
ret = Convert2Value(env, jsVal, val);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
value.insert(std::pair<std::string, T>(key, val));
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
template<typename K, typename V>
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::map<K, V> &value)
|
||||
{
|
||||
napi_value jsValue;
|
||||
napi_status status = napi_create_object(env, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (const auto &[key, val] : value) {
|
||||
const std::string &name = ConvertMapKey(key);
|
||||
status = napi_set_named_property(env, jsValue, name.c_str(), Convert2JSValue(env, val));
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::tuple<int32_t, std::string, T> &value)
|
||||
{
|
||||
napi_value jsValue;
|
||||
napi_status status = napi_create_object(env, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
napi_value code = Convert2JSValue(env, std::get<0>(value));
|
||||
napi_value description = Convert2JSValue(env, std::get<1>(value));
|
||||
napi_value val = Convert2JSValue(env, std::get<2>(value));
|
||||
if (description == nullptr || val == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
napi_set_named_property(env, jsValue, "code", code);
|
||||
napi_set_named_property(env, jsValue, "description", description);
|
||||
napi_set_named_property(env, jsValue, "value", val);
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
template<typename... Types>
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::variant<Types...> &value)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
if (type == napi_undefined) {
|
||||
return napi_generic_failure;
|
||||
}
|
||||
|
||||
return GetCPPValue<decltype(value), Types...>(env, jsValue, value);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::vector<T> &value)
|
||||
{
|
||||
napi_value jsValue;
|
||||
napi_status status = napi_create_array_with_length(env, value.size(), &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < value.size(); ++i) {
|
||||
napi_set_element(env, jsValue, i, Convert2JSValue(env, value[i]));
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
template<typename... Types>
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::variant<Types...> &value)
|
||||
{
|
||||
return GetJSValue<decltype(value), Types...>(env, value);
|
||||
}
|
||||
} // namespace AppDataMgrJsKit
|
||||
} // namespace OHOS
|
||||
#endif // DISTRIBUTEDDATAMGR_APPDATAMGR_JSUTILS_H
|
@ -0,0 +1,177 @@
|
||||
/*
|
||||
* 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 PREFERENCES_JSKIT_NAPI_ASYNC_PROXY_H
|
||||
#define PREFERENCES_JSKIT_NAPI_ASYNC_PROXY_H
|
||||
#include <vector>
|
||||
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "securec.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppDataMgrJsKit {
|
||||
constexpr int MAX_INPUT_COUNT = 10;
|
||||
constexpr int OK = 0;
|
||||
constexpr int ERR = -1;
|
||||
|
||||
// T inherits AysncContext
|
||||
template<class T> class NapiAsyncProxy {
|
||||
public:
|
||||
constexpr static int RESULT_COUNT = 2;
|
||||
using InputParser = void (*)(const napi_env &, const napi_value &, T *);
|
||||
using NapiAsyncExecute = int (*)(T *);
|
||||
using NapiAsyncComplete = int (*)(T *, napi_value &);
|
||||
|
||||
// AsyncContext base
|
||||
struct AysncContext {
|
||||
AysncContext()
|
||||
{
|
||||
}
|
||||
virtual ~AysncContext()
|
||||
{
|
||||
if (env == nullptr) {
|
||||
return;
|
||||
}
|
||||
napi_delete_async_work(env, work);
|
||||
napi_delete_reference(env, callbackRef);
|
||||
}
|
||||
napi_env env = nullptr;
|
||||
napi_callback_info info = nullptr;
|
||||
napi_async_work work = nullptr;
|
||||
napi_deferred deferred = nullptr;
|
||||
napi_ref callbackRef = nullptr;
|
||||
NapiAsyncExecute execFunc = nullptr;
|
||||
int execStatus = ERR;
|
||||
NapiAsyncComplete completeFunc = nullptr;
|
||||
void *boundObj = nullptr;
|
||||
};
|
||||
|
||||
public:
|
||||
void Init(napi_env env, napi_callback_info info)
|
||||
{
|
||||
asyncContext = new T();
|
||||
if (asyncContext == nullptr) {
|
||||
return;
|
||||
}
|
||||
asyncContext->env = env;
|
||||
asyncContext->info = info;
|
||||
}
|
||||
|
||||
~NapiAsyncProxy()
|
||||
{
|
||||
if (asyncContext == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete asyncContext;
|
||||
asyncContext = nullptr;
|
||||
}
|
||||
|
||||
static void DefParserThis(const napi_env &env, const napi_value &self, T *context)
|
||||
{
|
||||
napi_unwrap(env, self, &context->boundObj);
|
||||
}
|
||||
|
||||
void ParseInputs(const std::vector<InputParser> &parsers, InputParser parserThis = DefParserThis)
|
||||
{
|
||||
if (asyncContext == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
napi_value thisObj = nullptr;
|
||||
size_t argc = parsers.size() + 1;
|
||||
napi_value args[MAX_INPUT_COUNT] = { 0 };
|
||||
napi_get_cb_info(asyncContext->env, asyncContext->info, &argc, args, &thisObj, nullptr);
|
||||
for (size_t i = 0; i < argc && argc <= MAX_INPUT_COUNT; i++) {
|
||||
if (i >= parsers.size()) {
|
||||
napi_valuetype valueType = napi_undefined;
|
||||
napi_typeof(asyncContext->env, args[i], &valueType);
|
||||
if (valueType == napi_function) {
|
||||
napi_create_reference(asyncContext->env, args[i], 1, &asyncContext->callbackRef);
|
||||
}
|
||||
break;
|
||||
}
|
||||
auto *parserFunction = parsers[i];
|
||||
if (parserFunction != nullptr) {
|
||||
parserFunction(asyncContext->env, args[i], this->asyncContext);
|
||||
}
|
||||
}
|
||||
parserThis(asyncContext->env, thisObj, asyncContext);
|
||||
}
|
||||
|
||||
napi_value DoAsyncWork(std::string resourceName, NapiAsyncExecute execFunc, NapiAsyncComplete completeFunc)
|
||||
{
|
||||
if (asyncContext == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value ret = nullptr;
|
||||
if (asyncContext->callbackRef == nullptr) {
|
||||
napi_create_promise(asyncContext->env, &asyncContext->deferred, &ret);
|
||||
} else {
|
||||
napi_get_undefined(asyncContext->env, &ret);
|
||||
}
|
||||
|
||||
napi_value resource = nullptr;
|
||||
napi_create_string_utf8(asyncContext->env, resourceName.c_str(), NAPI_AUTO_LENGTH, &resource);
|
||||
asyncContext->execFunc = execFunc;
|
||||
asyncContext->completeFunc = completeFunc;
|
||||
NAPI_CALL_BASE(asyncContext->env, napi_create_async_work(asyncContext->env, nullptr, resource,
|
||||
[](napi_env env, void *data) {
|
||||
T *context = (T *)data;
|
||||
context->execStatus = context->execFunc(context);
|
||||
},
|
||||
[](napi_env env, napi_status status, void *data) {
|
||||
T *context = (T *)data;
|
||||
napi_value output = nullptr;
|
||||
int completeStatus = context->completeFunc(context, output);
|
||||
napi_value result[RESULT_COUNT] = { 0 };
|
||||
if (context->execStatus == OK && completeStatus == OK) {
|
||||
napi_get_undefined(env, &result[0]);
|
||||
result[1] = output;
|
||||
} else {
|
||||
napi_value message = nullptr;
|
||||
napi_create_string_utf8(env, "async call failed", NAPI_AUTO_LENGTH, &message);
|
||||
napi_create_error(env, nullptr, message, &result[0]);
|
||||
napi_get_undefined(env, &result[1]);
|
||||
}
|
||||
if (context->deferred) {
|
||||
// promise
|
||||
if (context->execStatus == OK && completeStatus == OK) {
|
||||
napi_resolve_deferred(env, context->deferred, result[1]);
|
||||
} else {
|
||||
napi_reject_deferred(env, context->deferred, result[0]);
|
||||
}
|
||||
} else {
|
||||
// callback
|
||||
napi_value callback = nullptr;
|
||||
napi_get_reference_value(env, context->callbackRef, &callback);
|
||||
napi_value callbackResult = nullptr;
|
||||
napi_call_function(env, nullptr, callback, RESULT_COUNT, result, &callbackResult);
|
||||
}
|
||||
delete context;
|
||||
},
|
||||
(void *)asyncContext, &asyncContext->work), ret);
|
||||
NAPI_CALL_BASE(asyncContext->env, napi_queue_async_work(asyncContext->env, asyncContext->work), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
T *asyncContext;
|
||||
};
|
||||
} // namespace AppDataMgrJsKit
|
||||
} // namespace OHOS
|
||||
#endif
|
@ -0,0 +1,101 @@
|
||||
/*
|
||||
* 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 DATAABILITY_JSKIT_NAPI_DATA_ABILITY_PREDICATES_H
|
||||
#define DATAABILITY_JSKIT_NAPI_DATA_ABILITY_PREDICATES_H
|
||||
|
||||
#include <memory>
|
||||
#include "data_ability_predicates.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "napi/native_node_api.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DataAbilityJsKit {
|
||||
class DataAbilityPredicatesProxy {
|
||||
public:
|
||||
static void Init(napi_env env, napi_value exports);
|
||||
static napi_value NewInstance(napi_env env, std::shared_ptr<NativeRdb::DataAbilityPredicates> value);
|
||||
static std::shared_ptr<NativeRdb::DataAbilityPredicates> GetNativePredicates(
|
||||
const napi_env env, const napi_value arg);
|
||||
static void Destructor(napi_env env, void *nativeObject, void *finalize_hint);
|
||||
|
||||
DataAbilityPredicatesProxy();
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> GetPredicates() const;
|
||||
|
||||
private:
|
||||
~DataAbilityPredicatesProxy();
|
||||
|
||||
static napi_value New(napi_env env, napi_callback_info info);
|
||||
static std::shared_ptr<NativeRdb::DataAbilityPredicates> GetNativePredicates(napi_env env,
|
||||
napi_callback_info info);
|
||||
static napi_value EqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value NotEqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value BeginWrap(napi_env env, napi_callback_info info);
|
||||
static napi_value EndWrap(napi_env env, napi_callback_info info);
|
||||
static napi_value Or(napi_env env, napi_callback_info info);
|
||||
static napi_value And(napi_env env, napi_callback_info info);
|
||||
static napi_value Contains(napi_env env, napi_callback_info info);
|
||||
static napi_value BeginsWith(napi_env env, napi_callback_info info);
|
||||
static napi_value EndsWith(napi_env env, napi_callback_info info);
|
||||
static napi_value IsNull(napi_env env, napi_callback_info info);
|
||||
static napi_value IsNotNull(napi_env env, napi_callback_info info);
|
||||
static napi_value Like(napi_env env, napi_callback_info info);
|
||||
static napi_value Glob(napi_env env, napi_callback_info info);
|
||||
static napi_value Between(napi_env env, napi_callback_info info);
|
||||
static napi_value NotBetween(napi_env env, napi_callback_info info);
|
||||
static napi_value GreaterThan(napi_env env, napi_callback_info info);
|
||||
static napi_value LessThan(napi_env env, napi_callback_info info);
|
||||
static napi_value GreaterThanOrEqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value LessThanOrEqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value OrderByAsc(napi_env env, napi_callback_info info);
|
||||
static napi_value OrderByDesc(napi_env env, napi_callback_info info);
|
||||
static napi_value Distinct(napi_env env, napi_callback_info info);
|
||||
static napi_value Limit(napi_env env, napi_callback_info info);
|
||||
static napi_value Offset(napi_env env, napi_callback_info info);
|
||||
static napi_value GroupBy(napi_env env, napi_callback_info info);
|
||||
static napi_value IndexedBy(napi_env env, napi_callback_info info);
|
||||
static napi_value In(napi_env env, napi_callback_info info);
|
||||
static napi_value NotIn(napi_env env, napi_callback_info info);
|
||||
static napi_value Clear(napi_env env, napi_callback_info info);
|
||||
static napi_value IsRawSelection(napi_env env, napi_callback_info info);
|
||||
static napi_value GetWhereClause(napi_env env, napi_callback_info info);
|
||||
static napi_value SetWhereClause(napi_env env, napi_callback_info info);
|
||||
static napi_value GetWhereArgs(napi_env env, napi_callback_info info);
|
||||
static napi_value SetWhereArgs(napi_env env, napi_callback_info info);
|
||||
static napi_value GetOrder(napi_env env, napi_callback_info info);
|
||||
static napi_value SetOrder(napi_env env, napi_callback_info info);
|
||||
static napi_value GetLimit(napi_env env, napi_callback_info info);
|
||||
static napi_value GetOffset(napi_env env, napi_callback_info info);
|
||||
static napi_value IsDistinct(napi_env env, napi_callback_info info);
|
||||
static napi_value GetGroup(napi_env env, napi_callback_info info);
|
||||
static napi_value GetIndex(napi_env env, napi_callback_info info);
|
||||
static napi_value IsNeedAnd(napi_env env, napi_callback_info info);
|
||||
static napi_value IsSorted(napi_env env, napi_callback_info info);
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> predicates_;
|
||||
};
|
||||
} // namespace DataAbilityJsKit
|
||||
} // namespace OHOS
|
||||
|
||||
EXTERN_C_START
|
||||
__attribute__((visibility("default")))
|
||||
napi_value NAPI_OHOS_Data_DataAbilityJsKit_DataAbilityPredicatesProxy_NewInstance(napi_env env,
|
||||
OHOS::NativeRdb::DataAbilityPredicates *predicates);
|
||||
|
||||
__attribute__((visibility("default"))) OHOS::NativeRdb::DataAbilityPredicates *
|
||||
NAPI_OHOS_Data_DataAbilityJsKit_DataAbilityPredicatesProxy_GetNativeObject(
|
||||
const napi_env env, const napi_value arg);
|
||||
EXTERN_C_END
|
||||
#endif // DATAABILITY_JSKIT_NAPI_DATA_ABILITY_PREDICATES_H
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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 APPDATAMGR_NAPI_PREDICATES_UTILS_H
|
||||
#define APPDATAMGR_NAPI_PREDICATES_UTILS_H
|
||||
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "napi/native_node_api.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace DataAbilityJsKit {
|
||||
napi_value InitPredicatesUtils(napi_env env, napi_value info);
|
||||
#define RDB_CHECK_RETURN_NULLPTR(assertion, message) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
LOG_ERROR("%{public}s", message); \
|
||||
return nullptr; \
|
||||
} \
|
||||
} while (0)
|
||||
} // namespace DataAbilityJsKit
|
||||
} // namespace OHOS
|
||||
#endif // APPDATAMGR_NAPI_PREDICATES_UTILS_H
|
@ -0,0 +1,213 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 RDB_JS_NAPI_ERROR_H
|
||||
#define RDB_JS_NAPI_ERROR_H
|
||||
|
||||
#include "logger.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppDataMgrJsKit {
|
||||
constexpr int MAX_INPUT_COUNT = 10;
|
||||
constexpr int OK = 0;
|
||||
constexpr int ERR = -1;
|
||||
constexpr int APIVERSION_V9 = 9;
|
||||
constexpr int APIVERSION_8 = 8;
|
||||
|
||||
constexpr int E_PARAM_ERROR = 401;
|
||||
constexpr int E_INNER_ERROR = 14800000;
|
||||
|
||||
constexpr int E_DB_INVALID = 14800010;
|
||||
constexpr int E_DB_CORRUPTED = 14800011;
|
||||
constexpr int E_RESULT_GET_ERROR = 14800013;
|
||||
constexpr int E_RESULT_GOTO_ERROR = 14800012;
|
||||
|
||||
#define RDB_NAPI_ASSERT_BASE_FROMV9(env, assertion, error, retVal, version) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
if ((error) == nullptr) { \
|
||||
LOG_ERROR("throw error: error message is empty,version= %{public}d", version); \
|
||||
napi_throw_error((env), nullptr, "error message is empty"); \
|
||||
return retVal; \
|
||||
} \
|
||||
if (((version) > (APIVERSION_8)) || (((error)->GetCode()) == (401))) { \
|
||||
LOG_ERROR("throw error: code = %{public}d , message = %{public}s, version= %{public}d", \
|
||||
(error)->GetCode(), (error)->GetMessage().c_str(), version); \
|
||||
napi_throw_error((env), std::to_string((error)->GetCode()).c_str(), (error)->GetMessage().c_str()); \
|
||||
return retVal; \
|
||||
} \
|
||||
LOG_ERROR("nothrow error: code = %{public}d , message = %{public}s, version= %{public}d", \
|
||||
(error)->GetCode(), (error)->GetMessage().c_str(), version); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RDB_REVT_NOTHING
|
||||
|
||||
#define RDB_NAPI_ASSERT_FROMV9(env, assertion, error, version) \
|
||||
RDB_NAPI_ASSERT_BASE_FROMV9(env, assertion, error, nullptr, version)
|
||||
|
||||
#define RDB_NAPI_ASSERT_RETURN_VOID_FROMV9(env, assertion, error, version) \
|
||||
RDB_NAPI_ASSERT_BASE_FROMV9(env, assertion, error, NAPI_RETVAL_NOTHING, version)
|
||||
|
||||
#define RDB_ASYNC_PARAM_CHECK_FUNCTION(theCall) \
|
||||
do { \
|
||||
int err = (theCall); \
|
||||
if (err != OK) { \
|
||||
return err; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RDB_CHECK_RETURN_NULLPTR(assertion, message) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
LOG_ERROR("%{public}s", message); \
|
||||
return nullptr; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define RDB_CHECK_RETURN_VOID(assertion, message) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
LOG_ERROR("%{public}s", message); \
|
||||
return; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_RETURN_CORE(assertion, theCall, revt) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
theCall; \
|
||||
return revt; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define CHECK_RETURN_ERR(assertion) \
|
||||
CHECK_RETURN_CORE(assertion, RDB_REVT_NOTHING, ERR)
|
||||
|
||||
#define RDB_CHECK_RETURN_CALL_RESULT(assertion, theCall) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
(theCall); \
|
||||
return ERR; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
class Error {
|
||||
public:
|
||||
virtual ~Error(){};
|
||||
virtual std::string GetMessage() = 0;
|
||||
virtual int GetCode() = 0;
|
||||
};
|
||||
|
||||
class InnerError : public Error {
|
||||
public:
|
||||
InnerError() = default;
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "System error.";
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_INNER_ERROR;
|
||||
};
|
||||
};
|
||||
|
||||
class ParamTypeError : public Error {
|
||||
public:
|
||||
ParamTypeError(const std::string &name, const std::string &wantType) : name(name), wantType(wantType){};
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "Parameter error. The type of '" + name + "' must be " + wantType;
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_PARAM_ERROR;
|
||||
};
|
||||
|
||||
private:
|
||||
std::string name;
|
||||
std::string wantType;
|
||||
};
|
||||
|
||||
class ParamNumError : public Error {
|
||||
public:
|
||||
ParamNumError(const std::string &wantNum) : wantNum(wantNum){};
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "Parameter error. Need " + wantNum + " parameters!";
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_PARAM_ERROR;
|
||||
};
|
||||
|
||||
private:
|
||||
std::string wantNum;
|
||||
};
|
||||
|
||||
class DbInvalidError : public Error {
|
||||
public:
|
||||
DbInvalidError() = default;
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "Failed open database, invalid database name.";
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_DB_INVALID;
|
||||
};
|
||||
};
|
||||
|
||||
class DbCorruptedError : public Error {
|
||||
public:
|
||||
DbCorruptedError() = default;
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "Failed open database, database corrupted.";
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_DB_CORRUPTED;
|
||||
};
|
||||
};
|
||||
|
||||
class ResultGetError : public Error {
|
||||
public:
|
||||
ResultGetError() = default;
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "The column value is null or the column type is incompatible.";
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_RESULT_GET_ERROR;
|
||||
};
|
||||
};
|
||||
|
||||
class ResultGotoError : public Error {
|
||||
public:
|
||||
ResultGotoError() = default;
|
||||
std::string GetMessage() override
|
||||
{
|
||||
return "The result set is empty or the specified location is invalid.";
|
||||
};
|
||||
int GetCode() override
|
||||
{
|
||||
return E_RESULT_GOTO_ERROR;
|
||||
};
|
||||
};
|
||||
} // namespace AppDataMgrJsKit
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // RDB_JS_NAPI_ERROR_H
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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 RDB_JSKIT_NAPI_RDB_JS_UTILS_H
|
||||
#define RDB_JSKIT_NAPI_RDB_JS_UTILS_H
|
||||
#include "asset_value.h"
|
||||
#include "js_utils.h"
|
||||
#include "result_set.h"
|
||||
#include "value_object.h"
|
||||
namespace OHOS::AppDataMgrJsKit {
|
||||
namespace JSUtils {
|
||||
using Asset = OHOS::NativeRdb::AssetValue;
|
||||
using RowEntity = OHOS::NativeRdb::RowEntity;
|
||||
using ValueObject = OHOS::NativeRdb::ValueObject;
|
||||
using BigInt = OHOS::NativeRdb::BigInteger;
|
||||
template<>
|
||||
int32_t Convert2Value(napi_env env, napi_value input, Asset &output);
|
||||
template<>
|
||||
napi_value Convert2JSValue(napi_env env, const Asset &value);
|
||||
template<>
|
||||
napi_value Convert2JSValue(napi_env env, const RowEntity &value);
|
||||
template<>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, ValueObject &valueObject);
|
||||
template<>
|
||||
napi_value Convert2JSValue(napi_env env, const BigInt &value);
|
||||
template<>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, BigInt &value);
|
||||
}; // namespace JSUtils
|
||||
} // namespace OHOS::AppDataMgrJsKit
|
||||
#endif // RDB_JSKIT_NAPI_RDB_JS_UTILS_H
|
@ -0,0 +1,113 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 RDB_JSKIT_NAPI_RDB_PREDICATES_H
|
||||
#define RDB_JSKIT_NAPI_RDB_PREDICATES_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "napi_rdb_error.h"
|
||||
#include "rdb_predicates.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RdbJsKit {
|
||||
class RdbPredicatesProxy {
|
||||
public:
|
||||
static void Init(napi_env env, napi_value exports);
|
||||
static napi_value NewInstance(
|
||||
napi_env env, std::shared_ptr<NativeRdb::RdbPredicates> value, int version = AppDataMgrJsKit::APIVERSION_8);
|
||||
static void Destructor(napi_env env, void *nativeObject, void *finalize_hint);
|
||||
|
||||
explicit RdbPredicatesProxy(std::string &tableName);
|
||||
std::shared_ptr<NativeRdb::RdbPredicates> GetPredicates() const;
|
||||
int apiversion = AppDataMgrJsKit::APIVERSION_8;
|
||||
|
||||
private:
|
||||
~RdbPredicatesProxy();
|
||||
|
||||
static napi_value New(napi_env env, napi_callback_info info);
|
||||
static napi_value NewV9(napi_env env, napi_callback_info info);
|
||||
static napi_value InnerNew(napi_env env, napi_callback_info info, int version = AppDataMgrJsKit::APIVERSION_8);
|
||||
static std::shared_ptr<NativeRdb::RdbPredicates> GetNativePredicates(napi_env env, napi_callback_info info);
|
||||
|
||||
static RdbPredicatesProxy *ParseFieldArrayByName(napi_env env, napi_callback_info info, napi_value &thiz,
|
||||
std::vector<std::string> &fieldarray, const std::string fieldName, const std::string fieldType);
|
||||
static RdbPredicatesProxy *ParseFieldByName(
|
||||
napi_env env, napi_callback_info info, napi_value &thiz, std::string &field, const std::string fieldName);
|
||||
static RdbPredicatesProxy *ParseInt32FieldByName(
|
||||
napi_env env, napi_callback_info info, napi_value &thiz, int32_t &field, const std::string fieldName);
|
||||
static RdbPredicatesProxy *ParseFieldAndValueArray(napi_env env, napi_callback_info info, napi_value &thiz,
|
||||
std::string &field, std::vector<NativeRdb::ValueObject> &value, const std::string valueType);
|
||||
static RdbPredicatesProxy *ParseFieldAndValue(napi_env env, napi_callback_info info, napi_value &thiz,
|
||||
std::string &field, NativeRdb::ValueObject &value, const std::string valueType);
|
||||
static RdbPredicatesProxy *ParseFieldAndStringValue(napi_env env, napi_callback_info info, napi_value &thiz,
|
||||
std::string &field, std::string &value, const std::string valueType);
|
||||
static RdbPredicatesProxy *ParseFieldLowAndHigh(napi_env env, napi_callback_info info, napi_value &thiz,
|
||||
std::string &field, NativeRdb::ValueObject &low, NativeRdb::ValueObject &High);
|
||||
|
||||
static napi_value EqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value NotEqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value BeginWrap(napi_env env, napi_callback_info info);
|
||||
static napi_value EndWrap(napi_env env, napi_callback_info info);
|
||||
static napi_value Or(napi_env env, napi_callback_info info);
|
||||
static napi_value And(napi_env env, napi_callback_info info);
|
||||
static napi_value Contains(napi_env env, napi_callback_info info);
|
||||
static napi_value BeginsWith(napi_env env, napi_callback_info info);
|
||||
static napi_value EndsWith(napi_env env, napi_callback_info info);
|
||||
static napi_value IsNull(napi_env env, napi_callback_info info);
|
||||
static napi_value IsNotNull(napi_env env, napi_callback_info info);
|
||||
static napi_value Like(napi_env env, napi_callback_info info);
|
||||
static napi_value Glob(napi_env env, napi_callback_info info);
|
||||
static napi_value Between(napi_env env, napi_callback_info info);
|
||||
static napi_value NotBetween(napi_env env, napi_callback_info info);
|
||||
static napi_value GreaterThan(napi_env env, napi_callback_info info);
|
||||
static napi_value LessThan(napi_env env, napi_callback_info info);
|
||||
static napi_value GreaterThanOrEqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value LessThanOrEqualTo(napi_env env, napi_callback_info info);
|
||||
static napi_value OrderByAsc(napi_env env, napi_callback_info info);
|
||||
static napi_value OrderByDesc(napi_env env, napi_callback_info info);
|
||||
static napi_value Distinct(napi_env env, napi_callback_info info);
|
||||
static napi_value Limit(napi_env env, napi_callback_info info);
|
||||
static napi_value Offset(napi_env env, napi_callback_info info);
|
||||
static napi_value GroupBy(napi_env env, napi_callback_info info);
|
||||
static napi_value IndexedBy(napi_env env, napi_callback_info info);
|
||||
static napi_value In(napi_env env, napi_callback_info info);
|
||||
static napi_value NotIn(napi_env env, napi_callback_info info);
|
||||
static napi_value Using(napi_env env, napi_callback_info info);
|
||||
static napi_value Clear(napi_env env, napi_callback_info info);
|
||||
static napi_value CrossJoin(napi_env env, napi_callback_info info);
|
||||
static napi_value LeftOuterJoin(napi_env env, napi_callback_info info);
|
||||
static napi_value GetJoinCount(napi_env env, napi_callback_info info);
|
||||
static napi_value SetJoinConditions(napi_env env, napi_callback_info info);
|
||||
static napi_value SetJoinTableNames(napi_env env, napi_callback_info info);
|
||||
static napi_value SetJoinTypes(napi_env env, napi_callback_info info);
|
||||
static napi_value SetJoinCount(napi_env env, napi_callback_info info);
|
||||
static napi_value GetJoinTypes(napi_env env, napi_callback_info info);
|
||||
static napi_value GetJoinTableNames(napi_env env, napi_callback_info info);
|
||||
static napi_value GetJoinConditions(napi_env env, napi_callback_info info);
|
||||
static napi_value InnerJoin(napi_env env, napi_callback_info info);
|
||||
static napi_value On(napi_env env, napi_callback_info info);
|
||||
static napi_value InDevices(napi_env env, napi_callback_info info);
|
||||
static napi_value InAllDevices(napi_env env, napi_callback_info info);
|
||||
|
||||
std::shared_ptr<NativeRdb::RdbPredicates> predicates_;
|
||||
};
|
||||
} // namespace RdbJsKit
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // RDB_JSKIT_NAPI_RDB_PREDICATES_H
|
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 DISTRIBUTEDDATAMGR_NAPI_RDB_TRACE_H
|
||||
#define DISTRIBUTEDDATAMGR_NAPI_RDB_TRACE_H
|
||||
|
||||
#define DO_NOTHING
|
||||
|
||||
#ifdef RDB_TRACE_ON
|
||||
#include "hitrace.h"
|
||||
#define DISTRIBUTED_DATA_HITRACE(trace) HiTrace hitrace(trace)
|
||||
#else
|
||||
#define DISTRIBUTED_DATA_HITRACE(trace) DO_NOTHING
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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 RDB_JSKIT_NAPI_RESULT_SET_H
|
||||
#define RDB_JSKIT_NAPI_RESULT_SET_H
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "abs_shared_result_set.h"
|
||||
#include "js_proxy.h"
|
||||
#include "napi/native_api.h"
|
||||
#include "napi/native_common.h"
|
||||
#include "napi/native_node_api.h"
|
||||
#include "napi_rdb_error.h"
|
||||
#include "result_set_bridge.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace RdbJsKit {
|
||||
class ResultSetProxy final : public JSProxy::JSEntity<NativeRdb::ResultSet, DataShare::ResultSetBridge> {
|
||||
public:
|
||||
ResultSetProxy() = default;
|
||||
~ResultSetProxy();
|
||||
ResultSetProxy(std::shared_ptr<NativeRdb::ResultSet> resultSet);
|
||||
ResultSetProxy &operator=(std::shared_ptr<NativeRdb::ResultSet> resultSet);
|
||||
static napi_value NewInstance(napi_env env, std::shared_ptr<NativeRdb::AbsSharedResultSet> resultSet,
|
||||
int version = AppDataMgrJsKit::APIVERSION_8);
|
||||
static napi_value NewInstance(napi_env env, std::shared_ptr<NativeRdb::ResultSet> resultSet,
|
||||
int version = AppDataMgrJsKit::APIVERSION_8);
|
||||
static std::shared_ptr<NativeRdb::AbsSharedResultSet> GetNativeObject(const napi_env env, const napi_value arg);
|
||||
static napi_value GetConstructor(napi_env env, int version);
|
||||
std::shared_ptr<DataShare::ResultSetBridge> Create() override;
|
||||
int apiversion = AppDataMgrJsKit::APIVERSION_8;
|
||||
|
||||
private:
|
||||
static ResultSetProxy *GetInnerResultSet(napi_env env, napi_callback_info info, int &version);
|
||||
static ResultSetProxy *ParseInt32FieldByName(
|
||||
napi_env env, napi_callback_info info, int32_t &field, const std::string& fieldName);
|
||||
static ResultSetProxy *ParseFieldByName(napi_env env, napi_callback_info info, std::string &field);
|
||||
|
||||
static napi_value InnerInitialize(
|
||||
napi_env env, napi_callback_info info, int version = AppDataMgrJsKit::APIVERSION_8);
|
||||
static napi_value Initialize(napi_env env, napi_callback_info info);
|
||||
static napi_value InitializeV9(napi_env env, napi_callback_info info);
|
||||
static napi_value GetAllColumnNames(napi_env env, napi_callback_info info);
|
||||
static napi_value GoToRow(napi_env env, napi_callback_info info);
|
||||
static napi_value GetColumnCount(napi_env env, napi_callback_info info);
|
||||
static napi_value GetLong(napi_env env, napi_callback_info info);
|
||||
static napi_value GetColumnType(napi_env env, napi_callback_info info);
|
||||
static napi_value GoTo(napi_env env, napi_callback_info info);
|
||||
static napi_value GetColumnIndex(napi_env env, napi_callback_info info);
|
||||
static napi_value GetInt(napi_env env, napi_callback_info info);
|
||||
static napi_value GetColumnName(napi_env env, napi_callback_info info);
|
||||
static napi_value Close(napi_env env, napi_callback_info info);
|
||||
static napi_value GetRowCount(napi_env env, napi_callback_info info);
|
||||
static napi_value GetRowIndex(napi_env env, napi_callback_info info);
|
||||
static napi_value IsEnded(napi_env env, napi_callback_info info);
|
||||
static napi_value IsBegin(napi_env env, napi_callback_info info);
|
||||
static napi_value GoToFirstRow(napi_env env, napi_callback_info info);
|
||||
static napi_value GoToLastRow(napi_env env, napi_callback_info info);
|
||||
static napi_value GoToNextRow(napi_env env, napi_callback_info info);
|
||||
static napi_value GoToPreviousRow(napi_env env, napi_callback_info info);
|
||||
static napi_value IsAtFirstRow(napi_env env, napi_callback_info info);
|
||||
static napi_value IsAtLastRow(napi_env env, napi_callback_info info);
|
||||
static napi_value GetBlob(napi_env env, napi_callback_info info);
|
||||
static napi_value GetString(napi_env env, napi_callback_info info);
|
||||
static napi_value GetDouble(napi_env env, napi_callback_info info);
|
||||
static napi_value IsColumnNull(napi_env env, napi_callback_info info);
|
||||
static napi_value IsClosed(napi_env env, napi_callback_info info);
|
||||
|
||||
static napi_value GetSharedBlockName(napi_env env, napi_callback_info info);
|
||||
static napi_value GetSharedBlockAshmemFd(napi_env env, napi_callback_info info);
|
||||
|
||||
std::shared_ptr<NativeRdb::AbsSharedResultSet> sharedResultSet_;
|
||||
|
||||
std::string sharedBlockName_;
|
||||
int32_t sharedBlockAshmemFd_ = -1;
|
||||
};
|
||||
} // namespace RdbJsKit
|
||||
} // namespace OHOS
|
||||
#endif // RDB_JSKIT_NAPI_RESULT_SET_H
|
716
frameworks/js/napi/featureAbility/data_ability/js_utils.cpp
Normal file
716
frameworks/js/napi/featureAbility/data_ability/js_utils.cpp
Normal file
@ -0,0 +1,716 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#define LOG_TAG "JSUtils"
|
||||
|
||||
#include "js_utils.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "js_native_api_types.h"
|
||||
#include "logger.h"
|
||||
#include "securec.h"
|
||||
using namespace OHOS::Rdb;
|
||||
|
||||
#define CHECK_RETURN_RET(assertion, message, revt) \
|
||||
do { \
|
||||
if (!(assertion)) { \
|
||||
LOG_WARN("assertion (" #assertion ") failed: " message); \
|
||||
return revt; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppDataMgrJsKit {
|
||||
namespace JSUtils {
|
||||
static int32_t g_hapVersion = -1; // the current apiVersion of hap
|
||||
}
|
||||
|
||||
static constexpr JSUtils::JsFeatureSpace FEATURE_NAME_SPACES[] = {
|
||||
{ "ohos.data.cloudData", "ZGF0YS5jbG91ZERhdGE=", true },
|
||||
{ "ohos.data.dataAbility", "ZGF0YS5kYXRhQWJpbGl0eQ==", true },
|
||||
{ "ohos.data.dataShare", "ZGF0YS5kYXRhU2hhcmU=", false },
|
||||
{ "ohos.data.distributedDataObject", "ZGF0YS5kaXN0cmlidXRlZERhdGFPYmplY3Q=", false },
|
||||
{ "ohos.data.distributedKVStore", "ZGF0YS5kaXN0cmlidXRlZEtWU3RvcmU=", false },
|
||||
{ "ohos.data.rdb", "ZGF0YS5yZGI=", true },
|
||||
{ "ohos.data.relationalStore", "ZGF0YS5yZWxhdGlvbmFsU3RvcmU=", true },
|
||||
};
|
||||
|
||||
void JSUtils::SetHapVersion(int32_t hapversion)
|
||||
{
|
||||
g_hapVersion = hapversion;
|
||||
}
|
||||
|
||||
int32_t JSUtils::GetHapVersion()
|
||||
{
|
||||
return g_hapVersion;
|
||||
}
|
||||
|
||||
const std::optional<JSUtils::JsFeatureSpace> JSUtils::GetJsFeatureSpace(const std::string &name)
|
||||
{
|
||||
auto jsFeature = JsFeatureSpace{ name.data(), nullptr, false };
|
||||
auto iter = std::lower_bound(FEATURE_NAME_SPACES,
|
||||
FEATURE_NAME_SPACES + sizeof(FEATURE_NAME_SPACES) / sizeof(FEATURE_NAME_SPACES[0]), jsFeature,
|
||||
[](const JsFeatureSpace &JsFeatureSpace1, const JsFeatureSpace &JsFeatureSpace2) {
|
||||
return strcmp(JsFeatureSpace1.spaceName, JsFeatureSpace2.spaceName) < 0;
|
||||
});
|
||||
if (iter < FEATURE_NAME_SPACES + sizeof(FEATURE_NAME_SPACES) / sizeof(FEATURE_NAME_SPACES[0]) &&
|
||||
strcmp(iter->spaceName, name.data()) == 0) {
|
||||
return *iter;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::pair<napi_status, napi_value> JSUtils::GetInnerValue(
|
||||
napi_env env, napi_value in, const std::string &prop, bool optional)
|
||||
{
|
||||
bool hasProp = false;
|
||||
napi_status status = napi_has_named_property(env, in, prop.c_str(), &hasProp);
|
||||
if (status != napi_ok) {
|
||||
return std::make_pair(napi_generic_failure, nullptr);
|
||||
}
|
||||
if (!hasProp) {
|
||||
status = optional ? napi_ok : napi_generic_failure;
|
||||
return std::make_pair(status, nullptr);
|
||||
}
|
||||
napi_value inner = nullptr;
|
||||
status = napi_get_named_property(env, in, prop.c_str(), &inner);
|
||||
if (status != napi_ok || inner == nullptr) {
|
||||
return std::make_pair(napi_generic_failure, nullptr);
|
||||
}
|
||||
if (optional && JSUtils::IsNull(env, inner)) {
|
||||
return std::make_pair(napi_ok, nullptr);
|
||||
}
|
||||
return std::make_pair(napi_ok, inner);
|
||||
}
|
||||
|
||||
std::string JSUtils::Convert2String(napi_env env, napi_value jsStr)
|
||||
{
|
||||
std::string value = ""; // TD: need to check everywhere in use whether empty is work well.
|
||||
JSUtils::Convert2Value(env, jsStr, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2ValueExt(napi_env env, napi_value jsValue, uint32_t &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_number) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
status = napi_get_value_uint32(env, jsValue, &output);
|
||||
if (status != napi_ok) {
|
||||
LOG_DEBUG("napi_get_value_uint32 failed, status = %{public}d", status);
|
||||
return status;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2ValueExt(napi_env env, napi_value jsValue, int32_t &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_number) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
status = napi_get_value_int32(env, jsValue, &output);
|
||||
if (status != napi_ok) {
|
||||
LOG_DEBUG("napi_get_value_int32 failed, status = %{public}d", status);
|
||||
return status;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, napi_value &output)
|
||||
{
|
||||
output = jsValue;
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, bool &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_boolean) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
bool bValue = false;
|
||||
status = napi_get_value_bool(env, jsValue, &bValue);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("napi_get_value_bool failed, status = %{public}d", status);
|
||||
return status;
|
||||
}
|
||||
output = bValue;
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2ValueExt(napi_env env, napi_value jsValue, int64_t &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_number) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
status = napi_get_value_int64(env, jsValue, &output);
|
||||
if (status != napi_ok) {
|
||||
LOG_DEBUG("napi_get_value_int64 failed, status = %{public}d", status);
|
||||
return status;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, double &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_number) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
double number = 0.0;
|
||||
status = napi_get_value_double(env, jsValue, &number);
|
||||
if (status != napi_ok) {
|
||||
LOG_DEBUG("napi_get_value_double failed, status = %{public}d", status);
|
||||
return status;
|
||||
}
|
||||
output = number;
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, int64_t &output)
|
||||
{
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::vector<float> &output)
|
||||
{
|
||||
bool isTypedArray = false;
|
||||
napi_is_typedarray(env, jsValue, &isTypedArray);
|
||||
if (!isTypedArray) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
napi_typedarray_type type;
|
||||
napi_value input_buffer = nullptr;
|
||||
size_t byte_offset = 0;
|
||||
size_t length = 0;
|
||||
void *tmp = nullptr;
|
||||
auto status = napi_get_typedarray_info(env, jsValue, &type, &length, &tmp, &input_buffer, &byte_offset);
|
||||
if (status != napi_ok || type != napi_float32_array) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
output = (tmp != nullptr
|
||||
? std::vector<float>(static_cast<float *>(tmp), static_cast<float *>(tmp) + length / sizeof(float))
|
||||
: std::vector<float>());
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::string &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_string) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
size_t buffSize = 0;
|
||||
napi_get_value_string_utf8(env, jsValue, nullptr, 0, &buffSize);
|
||||
|
||||
// cut down with 0 if more than MAX_VALUE_LENGTH
|
||||
if (buffSize >= JSUtils::MAX_VALUE_LENGTH - 1) {
|
||||
buffSize = JSUtils::MAX_VALUE_LENGTH - 1;
|
||||
}
|
||||
std::unique_ptr<char[]> buffer = std::make_unique<char[]>(buffSize + 1);
|
||||
if (!buffer) {
|
||||
LOG_ERROR("buffer data is nullptr.");
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
status = napi_get_value_string_utf8(env, jsValue, buffer.get(), buffSize + 1, &buffSize);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("napi_get_value_string_utf8 failed, status = %{public}d", status);
|
||||
return status;
|
||||
}
|
||||
output = std::string(buffer.get());
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::vector<uint8_t> &output)
|
||||
{
|
||||
bool isTypedArray = false;
|
||||
napi_is_typedarray(env, jsValue, &isTypedArray);
|
||||
if (!isTypedArray) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
napi_typedarray_type type;
|
||||
napi_value input_buffer = nullptr;
|
||||
size_t byte_offset = 0;
|
||||
size_t length = 0;
|
||||
void *tmp = nullptr;
|
||||
auto status = napi_get_typedarray_info(env, jsValue, &type, &length, &tmp, &input_buffer, &byte_offset);
|
||||
if (status != napi_ok || type != napi_uint8_array) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
output = (tmp != nullptr ? std::vector<uint8_t>(static_cast<uint8_t *>(tmp), static_cast<uint8_t *>(tmp) + length)
|
||||
: std::vector<uint8_t>());
|
||||
return status;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::monostate &value)
|
||||
{
|
||||
napi_value tempValue = nullptr;
|
||||
napi_get_null(env, &tempValue);
|
||||
bool equal = false;
|
||||
napi_strict_equals(env, jsValue, tempValue, &equal);
|
||||
if (equal) {
|
||||
value = std::monostate();
|
||||
return napi_ok;
|
||||
}
|
||||
LOG_DEBUG("jsValue is not null.");
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::map<std::string, int32_t> &output)
|
||||
{
|
||||
LOG_DEBUG("napi_value -> std::map<std::string, int32_t> ");
|
||||
output.clear();
|
||||
napi_value jsMapList = nullptr;
|
||||
uint32_t jsCount = 0;
|
||||
napi_status status = napi_get_property_names(env, jsValue, &jsMapList);
|
||||
CHECK_RETURN_RET(status == napi_ok, "get_property_names failed", napi_invalid_arg);
|
||||
status = napi_get_array_length(env, jsMapList, &jsCount);
|
||||
LOG_DEBUG("jsCOUNT: %{public}d", jsCount);
|
||||
CHECK_RETURN_RET(status == napi_ok && jsCount > 0, "get_map failed", napi_invalid_arg);
|
||||
napi_value jsKey = nullptr;
|
||||
napi_value jsVal = nullptr;
|
||||
for (uint32_t index = 0; index < jsCount; index++) {
|
||||
status = napi_get_element(env, jsMapList, index, &jsKey);
|
||||
CHECK_RETURN_RET(status == napi_ok && jsKey != nullptr, "no element", napi_invalid_arg);
|
||||
std::string key;
|
||||
int ret = Convert2Value(env, jsKey, key);
|
||||
CHECK_RETURN_RET(ret == napi_ok, "convert key failed", ret);
|
||||
status = napi_get_property(env, jsValue, jsKey, &jsVal);
|
||||
CHECK_RETURN_RET(status == napi_ok && jsVal != nullptr, "no element", napi_invalid_arg);
|
||||
int32_t val;
|
||||
ret = Convert2ValueExt(env, jsVal, val);
|
||||
CHECK_RETURN_RET(ret == napi_ok, "convert val failed", ret);
|
||||
output.insert(std::pair<std::string, int32_t>(key, val));
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2Value(napi_env env, napi_value jsValue, std::map<std::string, bool> &output)
|
||||
{
|
||||
LOG_DEBUG("napi_value -> std::map<std::string, bool> ");
|
||||
output.clear();
|
||||
napi_value jsMapList = nullptr;
|
||||
uint32_t jsCount = 0;
|
||||
napi_status status = napi_get_property_names(env, jsValue, &jsMapList);
|
||||
CHECK_RETURN_RET(status == napi_ok, "get_property_names failed", napi_invalid_arg);
|
||||
status = napi_get_array_length(env, jsMapList, &jsCount);
|
||||
LOG_DEBUG("jsCount: %{public}d", jsCount);
|
||||
CHECK_RETURN_RET(status == napi_ok && jsCount > 0, "get_map failed", napi_invalid_arg);
|
||||
napi_value jsKey = nullptr;
|
||||
napi_value jsVal = nullptr;
|
||||
for (uint32_t index = 0; index < jsCount; index++) {
|
||||
status = napi_get_element(env, jsMapList, index, &jsKey);
|
||||
CHECK_RETURN_RET(status == napi_ok && jsKey != nullptr, "no element", napi_invalid_arg);
|
||||
std::string key;
|
||||
int ret = Convert2Value(env, jsKey, key);
|
||||
CHECK_RETURN_RET(ret == napi_ok, "convert key failed", ret);
|
||||
status = napi_get_property(env, jsValue, jsKey, &jsVal);
|
||||
CHECK_RETURN_RET(status == napi_ok && jsVal != nullptr, "no element", napi_invalid_arg);
|
||||
bool val;
|
||||
ret = Convert2Value(env, jsVal, val);
|
||||
CHECK_RETURN_RET(ret == napi_ok, "convert val failed", ret);
|
||||
output.insert(std::pair<std::string, bool>(key, val));
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::string &value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
if (napi_create_string_utf8(env, value.c_str(), value.size(), &jsValue) != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::vector<uint8_t> &value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
void *native = nullptr;
|
||||
napi_value buffer = nullptr;
|
||||
napi_status status = napi_create_arraybuffer(env, value.size(), &native, &buffer);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
for (size_t i = 0; i < value.size(); i++) {
|
||||
*(static_cast<uint8_t *>(native) + i) = value[i];
|
||||
}
|
||||
status = napi_create_typedarray(env, napi_uint8_array, value.size(), buffer, 0, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, int32_t value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
napi_status status = napi_create_int32(env, value, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, uint32_t value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
napi_status status = napi_create_uint32(env, value, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, int64_t value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
napi_status status = napi_create_int64(env, value, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, double value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
napi_status status = napi_create_double(env, value, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, bool value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
napi_status status = napi_get_boolean(env, value, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::vector<float> &value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
float *native = nullptr;
|
||||
napi_value buffer = nullptr;
|
||||
napi_status status = napi_create_arraybuffer(env, value.size() * sizeof(float), (void **)&native, &buffer);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
if (native == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
for (size_t i = 0; i < value.size(); i++) {
|
||||
*(native + i) = value[i];
|
||||
}
|
||||
status = napi_create_typedarray(env, napi_float32_array, value.size(), buffer, 0, &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::map<std::string, int> &value)
|
||||
{
|
||||
napi_value jsValue = nullptr;
|
||||
napi_status status = napi_create_array_with_length(env, value.size(), &jsValue);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (const auto &[device, result] : value) {
|
||||
napi_value jsElement = nullptr;
|
||||
status = napi_create_array_with_length(env, SYNC_RESULT_ELEMENT_NUM, &jsElement);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
napi_set_element(env, jsElement, 0, Convert2JSValue(env, device));
|
||||
napi_set_element(env, jsElement, 1, Convert2JSValue(env, result));
|
||||
napi_set_element(env, jsValue, index++, jsElement);
|
||||
}
|
||||
|
||||
return jsValue;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2JSValue(napi_env env, std::string value, napi_value &output)
|
||||
{
|
||||
std::string tempStr = std::string(value);
|
||||
if (napi_create_string_utf8(env, tempStr.c_str(), tempStr.size(), &output) != napi_ok) {
|
||||
LOG_ERROR("Convert2JSValue create JS string failed.");
|
||||
return ERR;
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2JSValue(napi_env env, bool value, napi_value &output)
|
||||
{
|
||||
if (napi_get_boolean(env, value, &output) != napi_ok) {
|
||||
LOG_ERROR("Convert2JSValue create JS bool failed.");
|
||||
return ERR;
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
int32_t JSUtils::Convert2JSValue(napi_env env, double value, napi_value &output)
|
||||
{
|
||||
if (napi_create_double(env, value, &output) != napi_ok) {
|
||||
LOG_ERROR("Convert2JSValue create JS double failed.");
|
||||
return ERR;
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, const std::monostate &value)
|
||||
{
|
||||
napi_value result = nullptr;
|
||||
napi_get_null(env, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool JSUtils::IsNull(napi_env env, napi_value value)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, value, &type);
|
||||
return status == napi_ok && (type == napi_undefined || type == napi_null);
|
||||
}
|
||||
|
||||
napi_value JSUtils::DefineClass(napi_env env, const std::string &spaceName, const std::string &className,
|
||||
const Descriptor &descriptor, napi_callback ctor)
|
||||
{
|
||||
auto featureSpace = GetJsFeatureSpace(spaceName);
|
||||
if (!featureSpace.has_value() || !featureSpace->isComponent) {
|
||||
return nullptr;
|
||||
}
|
||||
auto constructor = GetClass(env, spaceName, className);
|
||||
if (constructor != nullptr) {
|
||||
return constructor;
|
||||
}
|
||||
auto rootPropName = std::string(featureSpace->nameBase64);
|
||||
napi_value root = nullptr;
|
||||
bool hasRoot = false;
|
||||
napi_value global = nullptr;
|
||||
napi_get_global(env, &global);
|
||||
napi_has_named_property(env, global, rootPropName.c_str(), &hasRoot);
|
||||
if (hasRoot) {
|
||||
napi_get_named_property(env, global, rootPropName.c_str(), &root);
|
||||
} else {
|
||||
napi_create_object(env, &root);
|
||||
napi_set_named_property(env, global, rootPropName.c_str(), root);
|
||||
}
|
||||
|
||||
std::string propName = "constructor_of_" + className;
|
||||
bool hasProp = false;
|
||||
napi_has_named_property(env, root, propName.c_str(), &hasProp);
|
||||
if (hasProp) {
|
||||
napi_get_named_property(env, root, propName.c_str(), &constructor);
|
||||
if (constructor != nullptr) {
|
||||
LOG_DEBUG("got %{public}s from %{public}s", propName.c_str(), featureSpace->spaceName);
|
||||
return constructor;
|
||||
}
|
||||
hasProp = false; // no constructor.
|
||||
}
|
||||
auto properties = descriptor();
|
||||
NAPI_CALL(env, napi_define_class(env, className.c_str(), className.size(), ctor, nullptr, properties.size(),
|
||||
properties.data(), &constructor));
|
||||
NAPI_ASSERT(env, constructor != nullptr, "napi_define_class failed!");
|
||||
|
||||
if (!hasProp) {
|
||||
napi_set_named_property(env, root, propName.c_str(), constructor);
|
||||
LOG_DEBUG("save %{public}s to %{public}s", propName.c_str(), featureSpace->spaceName);
|
||||
}
|
||||
return constructor;
|
||||
}
|
||||
|
||||
napi_value JSUtils::GetClass(napi_env env, const std::string &spaceName, const std::string &className)
|
||||
{
|
||||
auto featureSpace = GetJsFeatureSpace(spaceName);
|
||||
if (!featureSpace.has_value()) {
|
||||
return nullptr;
|
||||
}
|
||||
auto rootPropName = std::string(featureSpace->nameBase64);
|
||||
napi_value root = nullptr;
|
||||
napi_value global = nullptr;
|
||||
napi_get_global(env, &global);
|
||||
bool hasRoot;
|
||||
napi_has_named_property(env, global, rootPropName.c_str(), &hasRoot);
|
||||
if (!hasRoot) {
|
||||
return nullptr;
|
||||
}
|
||||
napi_get_named_property(env, global, rootPropName.c_str(), &root);
|
||||
std::string propName = "constructor_of_" + className;
|
||||
napi_value constructor = nullptr;
|
||||
bool hasProp = false;
|
||||
napi_has_named_property(env, root, propName.c_str(), &hasProp);
|
||||
if (!hasProp) {
|
||||
return nullptr;
|
||||
}
|
||||
napi_get_named_property(env, root, propName.c_str(), &constructor);
|
||||
if (constructor != nullptr) {
|
||||
LOG_DEBUG("got %{public}s from %{public}s", propName.c_str(), featureSpace->spaceName);
|
||||
return constructor;
|
||||
}
|
||||
hasProp = false; // no constructor.
|
||||
return constructor;
|
||||
}
|
||||
|
||||
bool JSUtils::Equal(napi_env env, napi_ref ref, napi_value value)
|
||||
{
|
||||
napi_value callback = nullptr;
|
||||
napi_get_reference_value(env, ref, &callback);
|
||||
|
||||
bool isEquals = false;
|
||||
napi_strict_equals(env, value, callback, &isEquals);
|
||||
return isEquals;
|
||||
}
|
||||
|
||||
napi_value JSUtils::ToJsObject(napi_env env, napi_value sendableValue)
|
||||
{
|
||||
LOG_DEBUG("sendableObject -> jsObject");
|
||||
napi_value keys = nullptr;
|
||||
napi_status status = napi_get_all_property_names(env, sendableValue, napi_key_own_only,
|
||||
static_cast<napi_key_filter>(napi_key_enumerable | napi_key_skip_symbols), napi_key_numbers_to_strings, &keys);
|
||||
ASSERT(status == napi_ok, "napi_get_all_property_names failed", nullptr);
|
||||
uint32_t length = 0;
|
||||
status = napi_get_array_length(env, keys, &length);
|
||||
ASSERT(status == napi_ok, "napi_get_array_length failed", nullptr);
|
||||
std::vector<napi_property_descriptor> descriptors;
|
||||
// keysHold guarantees that the string address is valid before create the sendable object.
|
||||
std::vector<std::string> keysHold(length, "");
|
||||
for (uint32_t i = 0; i < length; ++i) {
|
||||
napi_value key = nullptr;
|
||||
status = napi_get_element(env, keys, i, &key);
|
||||
ASSERT(status == napi_ok, "napi_get_element failed", nullptr);
|
||||
JSUtils::Convert2Value(env, key, keysHold[i]);
|
||||
napi_value value = nullptr;
|
||||
status = napi_get_named_property(env, sendableValue, keysHold[i].c_str(), &value);
|
||||
ASSERT(status == napi_ok, "napi_get_named_property failed", nullptr);
|
||||
descriptors.emplace_back(DECLARE_JS_PROPERTY(env, keysHold[i].c_str(), value));
|
||||
}
|
||||
napi_value jsObject = nullptr;
|
||||
status = napi_create_object_with_properties(env, &jsObject, descriptors.size(), descriptors.data());
|
||||
ASSERT(status == napi_ok, "napi_create_object_with_properties failed", nullptr);
|
||||
return jsObject;
|
||||
}
|
||||
|
||||
napi_value JSUtils::ToJsArray(napi_env env, napi_value sendableValue)
|
||||
{
|
||||
LOG_DEBUG("sendableArray -> jsArray");
|
||||
uint32_t arrLen = 0;
|
||||
napi_status status = napi_get_array_length(env, sendableValue, &arrLen);
|
||||
ASSERT(status == napi_ok, "napi_get_array_length failed", nullptr);
|
||||
napi_value jsArray = nullptr;
|
||||
status = napi_create_array_with_length(env, arrLen, &jsArray);
|
||||
ASSERT(status == napi_ok, "napi_create_array_with_length failed", nullptr);
|
||||
for (size_t i = 0; i < arrLen; ++i) {
|
||||
napi_value element;
|
||||
status = napi_get_element(env, sendableValue, i, &element);
|
||||
ASSERT(status == napi_ok, "napi_get_element failed", nullptr);
|
||||
status = napi_set_element(env, jsArray, i, Convert2JSValue(env, element));
|
||||
ASSERT(status == napi_ok, "napi_set_element failed", nullptr);
|
||||
}
|
||||
return jsArray;
|
||||
}
|
||||
|
||||
napi_value JSUtils::ToJsTypedArray(napi_env env, napi_value sendableValue)
|
||||
{
|
||||
LOG_DEBUG("sendableTypedArray -> jsTypedArray");
|
||||
napi_typedarray_type type;
|
||||
size_t length = 0;
|
||||
void *tmp = nullptr;
|
||||
napi_status status = napi_get_typedarray_info(env, sendableValue, &type, &length, &tmp, nullptr, nullptr);
|
||||
ASSERT(status == napi_ok, "napi_get_typedarray_info failed", nullptr);
|
||||
|
||||
if (type != napi_uint8_array && type != napi_float32_array) {
|
||||
LOG_ERROR("type is invalid %{public}d", type);
|
||||
return nullptr;
|
||||
}
|
||||
napi_value jsTypedArray = nullptr;
|
||||
void *native = nullptr;
|
||||
napi_value buffer = nullptr;
|
||||
status = napi_create_arraybuffer(env, length, (void **)&native, &buffer);
|
||||
ASSERT(status == napi_ok, "napi_create_arraybuffer failed", nullptr);
|
||||
if (length > 0) {
|
||||
errno_t result = memcpy_s(native, length, tmp, length);
|
||||
if (result != EOK) {
|
||||
LOG_ERROR("memcpy_s failed, result is %{public}d", result);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
auto size = (type == napi_uint8_array) ? length : length / sizeof(float);
|
||||
status = napi_create_typedarray(env, type, size, buffer, 0, &jsTypedArray);
|
||||
ASSERT(status == napi_ok, "napi_create_typedarray failed", nullptr);
|
||||
return jsTypedArray;
|
||||
}
|
||||
|
||||
napi_value JSUtils::Convert2JSValue(napi_env env, napi_value sendableValue)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, sendableValue, &type);
|
||||
ASSERT(status == napi_ok, "napi_typeof failed", nullptr);
|
||||
if (type != napi_object) {
|
||||
return sendableValue;
|
||||
}
|
||||
bool result = false;
|
||||
status = napi_is_sendable(env, sendableValue, &result);
|
||||
ASSERT(status == napi_ok, "napi_is_sendable failed", nullptr);
|
||||
if (!result) {
|
||||
return sendableValue;
|
||||
}
|
||||
|
||||
status = napi_is_array(env, sendableValue, &result);
|
||||
ASSERT(status == napi_ok, "napi_is_array failed", nullptr);
|
||||
if (result) {
|
||||
return ToJsArray(env, sendableValue);
|
||||
}
|
||||
status = napi_is_typedarray(env, sendableValue, &result);
|
||||
ASSERT(status == napi_ok, "napi_is_typedarray failed", nullptr);
|
||||
if (result) {
|
||||
return ToJsTypedArray(env, sendableValue);
|
||||
}
|
||||
return ToJsObject(env, sendableValue);
|
||||
}
|
||||
} // namespace AppDataMgrJsKit
|
||||
} // namespace OHOS
|
@ -0,0 +1,815 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#define LOG_TAG "DataAbilityPredicatesProxy"
|
||||
#include "napi_data_ability_predicates.h"
|
||||
|
||||
#include "js_utils.h"
|
||||
#include "logger.h"
|
||||
#include "napi_async_proxy.h"
|
||||
#include "napi_predicates_utils.h"
|
||||
|
||||
using namespace OHOS::Rdb;
|
||||
using namespace OHOS::NativeRdb;
|
||||
using namespace OHOS::AppDataMgrJsKit;
|
||||
|
||||
namespace OHOS {
|
||||
namespace DataAbilityJsKit {
|
||||
static __thread napi_ref constructor_ = nullptr;
|
||||
|
||||
void DataAbilityPredicatesProxy::Init(napi_env env, napi_value exports)
|
||||
{
|
||||
LOG_INFO("Init DataAbilityPredicatesProxy");
|
||||
napi_property_descriptor descriptors[] = {
|
||||
DECLARE_NAPI_FUNCTION("equalTo", EqualTo),
|
||||
DECLARE_NAPI_FUNCTION("notEqualTo", NotEqualTo),
|
||||
DECLARE_NAPI_FUNCTION("beginWrap", BeginWrap),
|
||||
DECLARE_NAPI_FUNCTION("endWrap", EndWrap),
|
||||
DECLARE_NAPI_FUNCTION("or", Or),
|
||||
DECLARE_NAPI_FUNCTION("and", And),
|
||||
DECLARE_NAPI_FUNCTION("contains", Contains),
|
||||
DECLARE_NAPI_FUNCTION("beginsWith", BeginsWith),
|
||||
DECLARE_NAPI_FUNCTION("endsWith", EndsWith),
|
||||
DECLARE_NAPI_FUNCTION("isNull", IsNull),
|
||||
DECLARE_NAPI_FUNCTION("isNotNull", IsNotNull),
|
||||
DECLARE_NAPI_FUNCTION("like", Like),
|
||||
DECLARE_NAPI_FUNCTION("glob", Glob),
|
||||
DECLARE_NAPI_FUNCTION("between", Between),
|
||||
DECLARE_NAPI_FUNCTION("notBetween", NotBetween),
|
||||
DECLARE_NAPI_FUNCTION("greaterThan", GreaterThan),
|
||||
DECLARE_NAPI_FUNCTION("lessThan", LessThan),
|
||||
DECLARE_NAPI_FUNCTION("greaterThanOrEqualTo", GreaterThanOrEqualTo),
|
||||
DECLARE_NAPI_FUNCTION("lessThanOrEqualTo", LessThanOrEqualTo),
|
||||
DECLARE_NAPI_FUNCTION("orderByAsc", OrderByAsc),
|
||||
DECLARE_NAPI_FUNCTION("orderByDesc", OrderByDesc),
|
||||
DECLARE_NAPI_FUNCTION("distinct", Distinct),
|
||||
DECLARE_NAPI_FUNCTION("limitAs", Limit),
|
||||
DECLARE_NAPI_FUNCTION("offsetAs", Offset),
|
||||
DECLARE_NAPI_FUNCTION("groupBy", GroupBy),
|
||||
DECLARE_NAPI_FUNCTION("indexedBy", IndexedBy),
|
||||
DECLARE_NAPI_FUNCTION("in", In),
|
||||
DECLARE_NAPI_FUNCTION("notIn", NotIn),
|
||||
DECLARE_NAPI_FUNCTION("clear", Clear),
|
||||
DECLARE_NAPI_FUNCTION("isRawSelection", IsRawSelection),
|
||||
DECLARE_NAPI_GETTER_SETTER("whereClause", GetWhereClause, SetWhereClause),
|
||||
DECLARE_NAPI_GETTER_SETTER("whereArgs", GetWhereArgs, SetWhereArgs),
|
||||
DECLARE_NAPI_GETTER_SETTER("order", GetOrder, SetOrder),
|
||||
DECLARE_NAPI_GETTER("limit", GetLimit),
|
||||
DECLARE_NAPI_GETTER("offset", GetOffset),
|
||||
DECLARE_NAPI_GETTER("isDistinct", IsDistinct),
|
||||
DECLARE_NAPI_GETTER("group", GetGroup),
|
||||
DECLARE_NAPI_GETTER("index", GetIndex),
|
||||
DECLARE_NAPI_GETTER("isNeedAnd", IsNeedAnd),
|
||||
DECLARE_NAPI_GETTER("isSorted", IsSorted),
|
||||
};
|
||||
|
||||
napi_value cons = nullptr;
|
||||
NAPI_CALL_RETURN_VOID(env, napi_define_class(env, "DataAbilityPredicates", NAPI_AUTO_LENGTH, New, nullptr,
|
||||
sizeof(descriptors) / sizeof(napi_property_descriptor), descriptors, &cons));
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env, napi_create_reference(env, cons, 1, &constructor_));
|
||||
|
||||
NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, exports, "DataAbilityPredicates", cons));
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::New(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value new_target = nullptr;
|
||||
NAPI_CALL(env, napi_get_new_target(env, info, &new_target));
|
||||
bool is_constructor = (new_target != nullptr);
|
||||
|
||||
napi_value thiz = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr));
|
||||
|
||||
if (is_constructor) {
|
||||
auto *proxy = new (std::nothrow) DataAbilityPredicatesProxy();
|
||||
if (proxy == nullptr) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy::New new failed, proxy is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
napi_status status = napi_wrap(env, thiz, proxy, DataAbilityPredicatesProxy::Destructor, nullptr, nullptr);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy::New napi_wrap failed! napi_status:%{public}d!", status);
|
||||
delete proxy;
|
||||
return nullptr;
|
||||
}
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value cons = nullptr;
|
||||
NAPI_CALL(env, napi_get_reference_value(env, constructor_, &cons));
|
||||
|
||||
napi_value output = nullptr;
|
||||
NAPI_CALL(env, napi_new_instance(env, cons, 0, nullptr, &output));
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::NewInstance(
|
||||
napi_env env, std::shared_ptr<NativeRdb::DataAbilityPredicates> value)
|
||||
{
|
||||
napi_value cons = nullptr;
|
||||
napi_status status = napi_get_reference_value(env, constructor_, &cons);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy get constructor failed! napi_status:%{public}d!", status);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value instance = nullptr;
|
||||
status = napi_new_instance(env, cons, 0, nullptr, &instance);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy napi_new_instance failed! napi_status:%{public}d!", status);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
DataAbilityPredicatesProxy *proxy = nullptr;
|
||||
status = napi_unwrap(env, instance, reinterpret_cast<void **>(&proxy));
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy native instance is nullptr! napi_status:%{public}d!", status);
|
||||
return instance;
|
||||
}
|
||||
proxy->predicates_ = std::move(value);
|
||||
return instance;
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> DataAbilityPredicatesProxy::GetNativePredicates(
|
||||
const napi_env env, const napi_value arg)
|
||||
{
|
||||
if (arg == nullptr) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy arg is null.");
|
||||
return nullptr;
|
||||
}
|
||||
DataAbilityPredicatesProxy *proxy = nullptr;
|
||||
napi_unwrap(env, arg, reinterpret_cast<void **>(&proxy));
|
||||
if (proxy == nullptr) {
|
||||
LOG_ERROR("DataAbilityPredicatesProxy proxy is null.");
|
||||
return nullptr;
|
||||
}
|
||||
return proxy->predicates_;
|
||||
}
|
||||
|
||||
void DataAbilityPredicatesProxy::Destructor(napi_env env, void *nativeObject, void *)
|
||||
{
|
||||
DataAbilityPredicatesProxy *proxy = static_cast<DataAbilityPredicatesProxy *>(nativeObject);
|
||||
delete proxy;
|
||||
}
|
||||
|
||||
DataAbilityPredicatesProxy::~DataAbilityPredicatesProxy()
|
||||
{
|
||||
}
|
||||
|
||||
DataAbilityPredicatesProxy::DataAbilityPredicatesProxy() : predicates_(new DataAbilityPredicates())
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> DataAbilityPredicatesProxy::GetNativePredicates(
|
||||
napi_env env, napi_callback_info info)
|
||||
{
|
||||
DataAbilityPredicatesProxy *predicatesProxy = nullptr;
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
napi_unwrap(env, thiz, reinterpret_cast<void **>(&predicatesProxy));
|
||||
if (predicatesProxy == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return predicatesProxy->predicates_;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::EqualTo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::EqualTo Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->EqualTo(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::NotEqualTo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::NotEqualTo Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->NotEqualTo(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::BeginWrap(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->BeginWrap();
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::EndWrap(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->EndWrap();
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Or(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Or();
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::And(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->And();
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Contains(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::Contains Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
std::string value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Contains(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::BeginsWith(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::BeginsWith Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
std::string value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->BeginsWith(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::EndsWith(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::EndsWith Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
std::string value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->EndsWith(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IsNull(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::IsNull Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->IsNull(field);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IsNotNull(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::IsNotNull Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->IsNotNull(field);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Like(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::Like Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
std::string value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Like(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Glob(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::Glob Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
std::string value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Glob(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Between(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 3;
|
||||
// 3 represents the number of parameters
|
||||
napi_value args[3] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::Between Invalid argvs!");
|
||||
std::string field;
|
||||
// args[0] represents the first parameter
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject low;
|
||||
// args[1] represents the second parameter
|
||||
JSUtils::Convert2Value(env, args[1], low);
|
||||
ValueObject high;
|
||||
// args[2] represents the third parameter
|
||||
JSUtils::Convert2Value(env, args[2], high);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Between(field, low, high);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::NotBetween(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 3;
|
||||
// 3 represents the number of parameters
|
||||
napi_value args[3] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::NotBetween Invalid argvs!");
|
||||
std::string field;
|
||||
// args[0] represents the first parameter
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject low;
|
||||
// args[1] represents the second parameter
|
||||
JSUtils::Convert2Value(env, args[1], low);
|
||||
ValueObject high;
|
||||
// args[2] represents the third parameter
|
||||
JSUtils::Convert2Value(env, args[2], high);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->NotBetween(field, low, high);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GreaterThan(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::GreaterThan Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->GreaterThan(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::LessThan(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::LessThan Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->LessThan(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GreaterThanOrEqualTo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::GreaterThanOrEqualTo Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->GreaterThanOrEqualTo(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::LessThanOrEqualTo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::LessThanOrEqualTo Invalid argvs!");
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
ValueObject value;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[1], value) == napi_ok, "the value is invalid");
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->LessThanOrEqualTo(field, value);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::OrderByAsc(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::OrderByAsc Invalid argvs!");
|
||||
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->OrderByAsc(field);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::OrderByDesc(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::OrderByDesc Invalid argvs!");
|
||||
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->OrderByDesc(field);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Distinct(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Distinct();
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Limit(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::Limit Invalid argvs!");
|
||||
|
||||
int32_t limit = 0;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2ValueExt(env, args[0], limit) == napi_ok, "the limit is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Limit(limit);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Offset(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::Offset Invalid argvs!");
|
||||
|
||||
int32_t offset = 0;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2ValueExt(env, args[0], offset) == napi_ok, "the offset is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Offset(offset);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GroupBy(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::GroupBy Invalid argvs!");
|
||||
|
||||
std::vector<std::string> fields = {};
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], fields) == napi_ok, "the fields is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->GroupBy(fields);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IndexedBy(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::IndexedBy Invalid argvs!");
|
||||
|
||||
std::string indexName;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], indexName) == napi_ok, "the indexName is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->IndexedBy(indexName);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::In(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::In Invalid argvs!");
|
||||
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
|
||||
std::vector<ValueObject> values;
|
||||
NAPI_ASSERT(env, JSUtils::Convert2Value(env, args[1], values) == napi_ok, "Invalid values!");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->In(field, values);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::NotIn(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 2;
|
||||
napi_value args[2] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::NotIn Invalid argvs!");
|
||||
|
||||
std::string field;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], field) == napi_ok, "the field is invalid");
|
||||
|
||||
std::vector<ValueObject> values;
|
||||
NAPI_ASSERT(env, JSUtils::Convert2Value(env, args[1], values) == napi_ok, "Invalid values");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->NotIn(field, values);
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::Clear(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->Clear();
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IsRawSelection(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr);
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
bool out = nativePredicates->IsRawSelection();
|
||||
return JSUtils::Convert2JSValue(env, out);
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeRdb::DataAbilityPredicates> DataAbilityPredicatesProxy::GetPredicates() const
|
||||
{
|
||||
return this->predicates_;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetWhereClause(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
auto ret = nativePredicates->GetWhereClause();
|
||||
return JSUtils::Convert2JSValue(env, ret);
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::SetWhereClause(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::SetWhereClause Invalid argvs!");
|
||||
|
||||
std::string whereClause;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], whereClause) == napi_ok, "whereClause is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->SetWhereClause(whereClause);
|
||||
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetWhereArgs(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
auto ret = nativePredicates->GetWhereArgs();
|
||||
return JSUtils::Convert2JSValue(env, ret);
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::SetWhereArgs(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::SetWhereArgs Invalid argvs!");
|
||||
|
||||
std::vector<std::string> whereArgs;
|
||||
NAPI_ASSERT(env, JSUtils::Convert2Value(env, args[0], whereArgs) == napi_ok, "Invalid whereArgs!");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->SetWhereArgs(whereArgs);
|
||||
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetOrder(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
auto ret = nativePredicates->GetOrder();
|
||||
return JSUtils::Convert2JSValue(env, ret);
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::SetOrder(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &thiz, nullptr);
|
||||
NAPI_ASSERT(env, argc > 0, "DataAbilityPredicatesProxy::SetOrder Invalid argvs!");
|
||||
|
||||
std::string order;
|
||||
RDB_CHECK_RETURN_NULLPTR(JSUtils::Convert2Value(env, args[0], order) != napi_ok, "the order is invalid");
|
||||
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
nativePredicates->SetOrder(order);
|
||||
|
||||
return thiz;
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetLimit(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
return JSUtils::Convert2JSValue(env, nativePredicates->GetLimit());
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetOffset(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
return JSUtils::Convert2JSValue(env, nativePredicates->GetOffset());
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IsDistinct(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
return JSUtils::Convert2JSValue(env, nativePredicates->IsDistinct());
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetGroup(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
auto ret = nativePredicates->GetGroup();
|
||||
return JSUtils::Convert2JSValue(env, ret);
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::GetIndex(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
auto ret = nativePredicates->GetIndex();
|
||||
return JSUtils::Convert2JSValue(env, ret);
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IsNeedAnd(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
return JSUtils::Convert2JSValue(env, nativePredicates->IsNeedAnd());
|
||||
}
|
||||
|
||||
napi_value DataAbilityPredicatesProxy::IsSorted(napi_env env, napi_callback_info info)
|
||||
{
|
||||
auto nativePredicates = GetNativePredicates(env, info);
|
||||
RDB_CHECK_RETURN_NULLPTR(nativePredicates != nullptr, "GetNativePredicates return nullptr");
|
||||
return JSUtils::Convert2JSValue(env, nativePredicates->IsSorted());
|
||||
}
|
||||
} // namespace DataAbilityJsKit
|
||||
} // namespace OHOS
|
||||
|
||||
EXTERN_C_START
|
||||
__attribute__((visibility("default")))
|
||||
napi_value NAPI_OHOS_Data_DataAbilityJsKit_DataAbilityPredicatesProxy_NewInstance(
|
||||
napi_env env, OHOS::NativeRdb::DataAbilityPredicates *predicates)
|
||||
{
|
||||
return OHOS::DataAbilityJsKit::DataAbilityPredicatesProxy::NewInstance(
|
||||
env, std::shared_ptr<OHOS::NativeRdb::DataAbilityPredicates>(predicates));
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) OHOS::NativeRdb::DataAbilityPredicates *
|
||||
NAPI_OHOS_Data_DataAbilityJsKit_DataAbilityPredicatesProxy_GetNativeObject(const napi_env env, const napi_value arg)
|
||||
{
|
||||
auto predicates = OHOS::DataAbilityJsKit::DataAbilityPredicatesProxy::GetNativePredicates(env, arg);
|
||||
return predicates.get();
|
||||
}
|
||||
EXTERN_C_END
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright (c) 2023 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.
|
||||
*/
|
||||
#define LOG_TAG "NapiRdbJsUtils"
|
||||
#include "napi_rdb_js_utils.h"
|
||||
|
||||
#include "logger.h"
|
||||
#include "result_set.h"
|
||||
|
||||
namespace OHOS::AppDataMgrJsKit {
|
||||
namespace JSUtils {
|
||||
using namespace OHOS::Rdb;
|
||||
using namespace NativeRdb;
|
||||
|
||||
template<>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, Asset &output)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_object) {
|
||||
LOG_DEBUG("napi_typeof failed status = %{public}d type = %{public}d", status, type);
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "version", output.version), napi_invalid_arg);
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "name", output.name), napi_invalid_arg);
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "uri", output.uri), napi_invalid_arg);
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "createTime", output.createTime), napi_invalid_arg);
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "modifyTime", output.modifyTime), napi_invalid_arg);
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "size", output.size), napi_invalid_arg);
|
||||
NAPI_CALL_BASE(env, GetNamedProperty(env, jsValue, "hash", output.hash), napi_invalid_arg);
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
template<>
|
||||
napi_value Convert2JSValue(napi_env env, const Asset &value)
|
||||
{
|
||||
napi_value object = nullptr;
|
||||
NAPI_CALL_BASE(env, napi_create_object(env, &object), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "version", value.version), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "name", value.name), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "uri", value.uri), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "createTime", value.createTime), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "modifyTime", value.modifyTime), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "size", value.size), object);
|
||||
NAPI_CALL_BASE(env, SetNamedProperty(env, object, "hash", value.hash), object);
|
||||
return object;
|
||||
}
|
||||
|
||||
template<>
|
||||
napi_value Convert2JSValue(napi_env env, const RowEntity &rowEntity)
|
||||
{
|
||||
napi_value ret = nullptr;
|
||||
NAPI_CALL(env, napi_create_object(env, &ret));
|
||||
auto &values = rowEntity.Get();
|
||||
for (auto const &[key, object] : values) {
|
||||
napi_value value = JSUtils::Convert2JSValue(env, object.value);
|
||||
NAPI_CALL(env, napi_set_named_property(env, ret, key.c_str(), value));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, ValueObject &valueObject)
|
||||
{
|
||||
auto status = Convert2Value(env, jsValue, valueObject.value);
|
||||
if (status != napi_ok) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
return napi_ok;
|
||||
}
|
||||
|
||||
template<>
|
||||
napi_value Convert2JSValue(napi_env env, const BigInt& value)
|
||||
{
|
||||
napi_value val = nullptr;
|
||||
napi_status status = napi_create_bigint_words(env, value.Sign(), value.Size(), value.TrueForm(), &val);
|
||||
if (status != napi_ok) {
|
||||
return nullptr;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
template<>
|
||||
int32_t Convert2Value(napi_env env, napi_value jsValue, BigInt& value)
|
||||
{
|
||||
napi_valuetype type = napi_undefined;
|
||||
napi_status status = napi_typeof(env, jsValue, &type);
|
||||
if (status != napi_ok || type != napi_bigint) {
|
||||
return napi_invalid_arg;
|
||||
}
|
||||
int sign = 0;
|
||||
size_t count = 0;
|
||||
status = napi_get_value_bigint_words(env, jsValue, nullptr, &count, nullptr);
|
||||
if (status != napi_ok) {
|
||||
return napi_bigint_expected;
|
||||
}
|
||||
std::vector<uint64_t> words(count, 0);
|
||||
status = napi_get_value_bigint_words(env, jsValue, &sign, &count, words.data());
|
||||
if (status != napi_ok) {
|
||||
return napi_bigint_expected;
|
||||
}
|
||||
value = BigInteger(sign, std::move(words));
|
||||
return napi_ok;
|
||||
}
|
||||
}; // namespace JSUtils
|
||||
} // namespace OHOS::AppDataMgrJsKit
|
@ -0,0 +1,640 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
#define LOG_TAG "ResultSetProxy"
|
||||
#include "napi_result_set.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "js_utils.h"
|
||||
#include "logger.h"
|
||||
#include "napi_rdb_error.h"
|
||||
#include "napi_rdb_trace.h"
|
||||
#include "rdb_errno.h"
|
||||
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
#include "abs_shared_result_set.h"
|
||||
#include "rdb_result_set_bridge.h"
|
||||
#include "shared_block.h"
|
||||
#include "string_ex.h"
|
||||
#endif
|
||||
|
||||
using namespace OHOS::Rdb;
|
||||
using namespace OHOS::NativeRdb;
|
||||
using namespace OHOS::AppDataMgrJsKit;
|
||||
|
||||
namespace OHOS {
|
||||
namespace RdbJsKit {
|
||||
static napi_ref __thread ctorRef_ = nullptr;
|
||||
static napi_ref __thread ctorRefV9_ = nullptr;
|
||||
static const int E_OK = 0;
|
||||
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
napi_value ResultSetProxy::NewInstance(napi_env env, std::shared_ptr<AbsSharedResultSet> resultSet, int version)
|
||||
{
|
||||
auto instance = NewInstance(env, std::static_pointer_cast<NativeRdb::ResultSet>(resultSet), version);
|
||||
ResultSetProxy *proxy = nullptr;
|
||||
auto status = napi_unwrap(env, instance, reinterpret_cast<void **>(&proxy));
|
||||
if (proxy == nullptr) {
|
||||
LOG_ERROR("NewInstance native instance is nullptr! code:%{public}d!", status);
|
||||
return instance;
|
||||
}
|
||||
|
||||
if (resultSet != nullptr && resultSet->GetBlock() != nullptr) {
|
||||
proxy->sharedBlockName_ = resultSet->GetBlock()->Name();
|
||||
proxy->sharedBlockAshmemFd_ = resultSet->GetBlock()->GetFd();
|
||||
}
|
||||
proxy->sharedResultSet_ = resultSet;
|
||||
return instance;
|
||||
}
|
||||
#endif
|
||||
|
||||
napi_value ResultSetProxy::NewInstance(napi_env env, std::shared_ptr<NativeRdb::ResultSet> resultSet, int version)
|
||||
{
|
||||
napi_value cons = GetConstructor(env, version);
|
||||
if (cons == nullptr) {
|
||||
LOG_ERROR("NewInstance GetConstructor is nullptr!");
|
||||
return nullptr;
|
||||
}
|
||||
napi_value instance = nullptr;
|
||||
napi_status status = napi_new_instance(env, cons, 0, nullptr, &instance);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("NewInstance napi_new_instance failed! code:%{public}d!", status);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ResultSetProxy *proxy = nullptr;
|
||||
status = napi_unwrap(env, instance, reinterpret_cast<void **>(&proxy));
|
||||
if (proxy == nullptr) {
|
||||
LOG_ERROR("NewInstance native instance is nullptr! code:%{public}d!", status);
|
||||
return instance;
|
||||
}
|
||||
*proxy = std::move(resultSet);
|
||||
return instance;
|
||||
}
|
||||
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
std::shared_ptr<NativeRdb::AbsSharedResultSet> ResultSetProxy::GetNativeObject(
|
||||
napi_env const env, napi_value const arg)
|
||||
{
|
||||
if (arg == nullptr) {
|
||||
LOG_ERROR("ResultSetProxy GetNativeObject arg is null.");
|
||||
return nullptr;
|
||||
}
|
||||
ResultSetProxy *proxy = nullptr;
|
||||
napi_unwrap(env, arg, reinterpret_cast<void **>(&proxy));
|
||||
if (proxy == nullptr || proxy->sharedResultSet_ == nullptr) {
|
||||
LOG_ERROR("ResultSetProxy GetNativeObject proxy or sharedResultSet_ is null.");
|
||||
return nullptr;
|
||||
}
|
||||
return proxy->sharedResultSet_;
|
||||
}
|
||||
|
||||
std::shared_ptr<DataShare::ResultSetBridge> ResultSetProxy::Create()
|
||||
{
|
||||
auto instance = GetInstance();
|
||||
if (instance == nullptr) {
|
||||
LOG_ERROR("resultSet_ is null.");
|
||||
return nullptr;
|
||||
}
|
||||
SetInstance(nullptr);
|
||||
return std::make_shared<RdbDataShareAdapter::RdbResultSetBridge>(instance);
|
||||
}
|
||||
#endif
|
||||
|
||||
napi_value ResultSetProxy::GetConstructor(napi_env env, int version)
|
||||
{
|
||||
napi_value cons = nullptr;
|
||||
if (version > APIVERSION_8 && ctorRefV9_ != nullptr) {
|
||||
NAPI_CALL(env, napi_get_reference_value(env, ctorRefV9_, &cons));
|
||||
return cons;
|
||||
}
|
||||
if (version == APIVERSION_8 && ctorRef_ != nullptr) {
|
||||
NAPI_CALL(env, napi_get_reference_value(env, ctorRef_, &cons));
|
||||
return cons;
|
||||
}
|
||||
|
||||
napi_property_descriptor clzDes[] = {
|
||||
DECLARE_NAPI_FUNCTION("goToRow", GoToRow),
|
||||
DECLARE_NAPI_FUNCTION("getLong", GetLong),
|
||||
DECLARE_NAPI_FUNCTION("getColumnType", GetColumnType),
|
||||
DECLARE_NAPI_FUNCTION("goTo", GoTo),
|
||||
DECLARE_NAPI_FUNCTION("getColumnIndex", GetColumnIndex),
|
||||
DECLARE_NAPI_FUNCTION("getInt", GetInt),
|
||||
DECLARE_NAPI_FUNCTION("getColumnName", GetColumnName),
|
||||
DECLARE_NAPI_FUNCTION("close", Close),
|
||||
DECLARE_NAPI_FUNCTION("goToFirstRow", GoToFirstRow),
|
||||
DECLARE_NAPI_FUNCTION("goToLastRow", GoToLastRow),
|
||||
DECLARE_NAPI_FUNCTION("goToNextRow", GoToNextRow),
|
||||
DECLARE_NAPI_FUNCTION("goToPreviousRow", GoToPreviousRow),
|
||||
DECLARE_NAPI_FUNCTION("getBlob", GetBlob),
|
||||
DECLARE_NAPI_FUNCTION("getString", GetString),
|
||||
DECLARE_NAPI_FUNCTION("getDouble", GetDouble),
|
||||
DECLARE_NAPI_FUNCTION("isColumnNull", IsColumnNull),
|
||||
|
||||
DECLARE_NAPI_GETTER("columnNames", GetAllColumnNames),
|
||||
DECLARE_NAPI_GETTER("columnCount", GetColumnCount),
|
||||
DECLARE_NAPI_GETTER("isEnded", IsEnded),
|
||||
DECLARE_NAPI_GETTER("isStarted", IsBegin),
|
||||
DECLARE_NAPI_GETTER("isClosed", IsClosed),
|
||||
DECLARE_NAPI_GETTER("rowCount", GetRowCount),
|
||||
DECLARE_NAPI_GETTER("rowIndex", GetRowIndex),
|
||||
DECLARE_NAPI_GETTER("isAtFirstRow", IsAtFirstRow),
|
||||
DECLARE_NAPI_GETTER("isAtLastRow", IsAtLastRow),
|
||||
};
|
||||
|
||||
if (version > APIVERSION_8) {
|
||||
NAPI_CALL(env, napi_define_class(env, "ResultSetV9", NAPI_AUTO_LENGTH, InitializeV9, nullptr,
|
||||
sizeof(clzDes) / sizeof(napi_property_descriptor), clzDes, &cons));
|
||||
NAPI_CALL(env, napi_create_reference(env, cons, 1, &ctorRefV9_));
|
||||
return cons;
|
||||
}
|
||||
|
||||
NAPI_CALL(env, napi_define_class(env, "ResultSet", NAPI_AUTO_LENGTH, Initialize, nullptr,
|
||||
sizeof(clzDes) / sizeof(napi_property_descriptor), clzDes, &cons));
|
||||
NAPI_CALL(env, napi_create_reference(env, cons, 1, &ctorRef_));
|
||||
return cons;
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::InnerInitialize(napi_env env, napi_callback_info info, int version)
|
||||
{
|
||||
napi_value self = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &self, nullptr));
|
||||
auto *proxy = new (std::nothrow) ResultSetProxy();
|
||||
if (proxy == nullptr) {
|
||||
LOG_ERROR("ResultSetProxy::InnerInitialize new failed, proxy is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
proxy->apiversion = version;
|
||||
auto finalize = [](napi_env env, void *data, void *hint) {
|
||||
ResultSetProxy *proxy = reinterpret_cast<ResultSetProxy *>(data);
|
||||
delete proxy;
|
||||
};
|
||||
napi_status status = napi_wrap(env, self, proxy, finalize, nullptr, nullptr);
|
||||
if (status != napi_ok) {
|
||||
LOG_ERROR("ResultSetProxy napi_wrap failed! code:%{public}d!, version:%{public}d.", status, version);
|
||||
finalize(env, proxy, nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::Initialize(napi_env env, napi_callback_info info)
|
||||
{
|
||||
return InnerInitialize(env, info, APIVERSION_8);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::InitializeV9(napi_env env, napi_callback_info info)
|
||||
{
|
||||
return InnerInitialize(env, info, APIVERSION_V9);
|
||||
}
|
||||
|
||||
ResultSetProxy::~ResultSetProxy()
|
||||
{
|
||||
LOG_DEBUG("ResultSetProxy destructor!");
|
||||
}
|
||||
|
||||
ResultSetProxy::ResultSetProxy(std::shared_ptr<ResultSet> resultSet)
|
||||
{
|
||||
if (GetInstance() == resultSet) {
|
||||
return;
|
||||
}
|
||||
SetInstance(std::move(resultSet));
|
||||
}
|
||||
|
||||
ResultSetProxy &ResultSetProxy::operator=(std::shared_ptr<ResultSet> resultSet)
|
||||
{
|
||||
if (GetInstance() == resultSet) {
|
||||
return *this;
|
||||
}
|
||||
SetInstance(std::move(resultSet));
|
||||
return *this;
|
||||
}
|
||||
|
||||
ResultSetProxy *ResultSetProxy::GetInnerResultSet(napi_env env, napi_callback_info info, int &version)
|
||||
{
|
||||
ResultSetProxy *resultSetProxy = nullptr;
|
||||
napi_value self = nullptr;
|
||||
napi_get_cb_info(env, info, nullptr, nullptr, &self, nullptr);
|
||||
napi_unwrap(env, self, reinterpret_cast<void **>(&resultSetProxy));
|
||||
RDB_NAPI_ASSERT_FROMV9(env, resultSetProxy && resultSetProxy->GetInstance(), std::make_shared<ResultGotoError>(),
|
||||
resultSetProxy->apiversion);
|
||||
|
||||
version = resultSetProxy->apiversion;
|
||||
return resultSetProxy;
|
||||
}
|
||||
|
||||
ResultSetProxy *ResultSetProxy::ParseInt32FieldByName(
|
||||
napi_env env, napi_callback_info info, int32_t &field, const std::string& name)
|
||||
{
|
||||
DISTRIBUTED_DATA_HITRACE(std::string(__FUNCTION__));
|
||||
napi_value self = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &self, nullptr);
|
||||
ResultSetProxy *resultSetProxy = nullptr;
|
||||
napi_unwrap(env, self, reinterpret_cast<void **>(&resultSetProxy));
|
||||
RDB_NAPI_ASSERT_FROMV9(env, resultSetProxy && resultSetProxy->GetInstance(),
|
||||
std::make_shared<ParamTypeError>("resultSet", "not null"), resultSetProxy->apiversion);
|
||||
RDB_NAPI_ASSERT_FROMV9(
|
||||
env, argc == 1, std::make_shared<ParamNumError>("1"), resultSetProxy->apiversion);
|
||||
|
||||
napi_status status = napi_get_value_int32(env, args[0], &field);
|
||||
RDB_NAPI_ASSERT_FROMV9(
|
||||
env, status == napi_ok, std::make_shared<ParamTypeError>(name, "a number."), resultSetProxy->apiversion);
|
||||
return resultSetProxy;
|
||||
}
|
||||
|
||||
ResultSetProxy *ResultSetProxy::ParseFieldByName(napi_env env, napi_callback_info info, std::string &field)
|
||||
{
|
||||
napi_value self = nullptr;
|
||||
size_t argc = 1;
|
||||
napi_value args[1] = { 0 };
|
||||
napi_get_cb_info(env, info, &argc, args, &self, nullptr);
|
||||
ResultSetProxy *resultSetProxy = nullptr;
|
||||
napi_unwrap(env, self, reinterpret_cast<void **>(&resultSetProxy));
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
RDB_NAPI_ASSERT_FROMV9(
|
||||
env, argc == 1, std::make_shared<ParamNumError>("1"), resultSetProxy->apiversion);
|
||||
|
||||
field = JSUtils::Convert2String(env, args[0]);
|
||||
return resultSetProxy;
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetAllColumnNames(napi_env env, napi_callback_info info)
|
||||
{
|
||||
std::vector<std::string> colNames;
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetAllColumnNames(colNames);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetAllColumnNames failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, colNames);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GoToRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t position;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, position, "position");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GoToRow(position);
|
||||
return JSUtils::Convert2JSValue(env, (errCode == E_OK));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetColumnCount(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t count = 0;
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetColumnCount(count);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetColumnCount failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, count);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetLong(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t columnIndex;
|
||||
int64_t result;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetLong(columnIndex, result);
|
||||
int version = resultSetProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGetError>(), version);
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetColumnType(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t columnIndex;
|
||||
ColumnType columnType;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetColumnType(columnIndex, columnType);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetColumnType failed code:%{public}d, version:%{public}d.", errCode, resultSetProxy->apiversion);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, int32_t(columnType));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GoTo(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t offset;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, offset, "offset");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GoTo(offset);
|
||||
return JSUtils::Convert2JSValue(env, (errCode == E_OK));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetColumnIndex(napi_env env, napi_callback_info info)
|
||||
{
|
||||
std::string input;
|
||||
int32_t result = -1;
|
||||
auto resultSetProxy = ParseFieldByName(env, info, input);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetColumnIndex(input, result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetColumnIndex failed code:%{public}d, version:%{public}d.", errCode, resultSetProxy->apiversion);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetInt(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t columnIndex;
|
||||
int32_t result;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetInt(columnIndex, result);
|
||||
int version = resultSetProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGetError>(), version);
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetColumnName(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t columnIndex;
|
||||
std::string result;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetColumnName(columnIndex, result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetColumnName failed code:%{public}d, version:%{public}d.", errCode, resultSetProxy->apiversion);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::Close(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->Close();
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGotoError>(), version);
|
||||
napi_value result = nullptr;
|
||||
napi_get_null(env, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetRowCount(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
ResultSetProxy *resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int32_t result;
|
||||
int errCode = resultSetProxy->GetInstance()->GetRowCount(result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetRowCount failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetRowIndex(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int32_t result;
|
||||
int errCode = resultSetProxy->GetInstance()->GetRowIndex(result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("GetRowIndex failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::IsEnded(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
bool result = false;
|
||||
int errCode = resultSetProxy->GetInstance()->IsEnded(result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("IsEnded failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
result = true;
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::IsBegin(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
bool result = false;
|
||||
int errCode = resultSetProxy->GetInstance()->IsStarted(result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("IsBegin failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GoToFirstRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GoToFirstRow();
|
||||
return JSUtils::Convert2JSValue(env, (errCode == E_OK));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GoToLastRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GoToLastRow();
|
||||
return JSUtils::Convert2JSValue(env, (errCode == E_OK));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GoToNextRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GoToNextRow();
|
||||
return JSUtils::Convert2JSValue(env, (errCode == E_OK));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GoToPreviousRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GoToPreviousRow();
|
||||
return JSUtils::Convert2JSValue(env, (errCode == E_OK));
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::IsAtFirstRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
bool result = false;
|
||||
int errCode = resultSetProxy->GetInstance()->IsAtFirstRow(result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("IsAtFirstRow failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::IsAtLastRow(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
bool result = false;
|
||||
int errCode = resultSetProxy->GetInstance()->IsAtLastRow(result);
|
||||
if (errCode != E_OK) {
|
||||
LOG_ERROR("IsAtLastRow failed code:%{public}d, version:%{public}d.", errCode, version);
|
||||
}
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetBlob(napi_env env, napi_callback_info info)
|
||||
{
|
||||
DISTRIBUTED_DATA_HITRACE(std::string(__FUNCTION__));
|
||||
int32_t columnIndex;
|
||||
std::vector<uint8_t> result;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetBlob(columnIndex, result);
|
||||
int version = resultSetProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGetError>(), version);
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetString(napi_env env, napi_callback_info info)
|
||||
{
|
||||
DISTRIBUTED_DATA_HITRACE(std::string(__FUNCTION__));
|
||||
int32_t columnIndex;
|
||||
std::string result;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetString(columnIndex, result);
|
||||
int version = resultSetProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGetError>(), version);
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetDouble(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t columnIndex;
|
||||
double result = 0.0;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->GetDouble(columnIndex, result);
|
||||
int version = resultSetProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGetError>(), version);
|
||||
return JSUtils::Convert2JSValue(env, result);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::IsColumnNull(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int32_t columnIndex;
|
||||
bool result = false;
|
||||
auto resultSetProxy = ParseInt32FieldByName(env, info, columnIndex, "columnIndex");
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int errCode = resultSetProxy->GetInstance()->IsColumnNull(columnIndex, result);
|
||||
int version = resultSetProxy->apiversion;
|
||||
RDB_NAPI_ASSERT_FROMV9(env, errCode == E_OK, std::make_shared<ResultGetError>(), version);
|
||||
napi_value output = nullptr;
|
||||
napi_get_boolean(env, result, &output);
|
||||
return output;
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::IsClosed(napi_env env, napi_callback_info info)
|
||||
{
|
||||
int version = 0;
|
||||
auto resultSetProxy = GetInnerResultSet(env, info, version);
|
||||
RDB_CHECK_RETURN_NULLPTR(resultSetProxy && resultSetProxy->GetInstance(), "Proxy or instance is nullptr");
|
||||
|
||||
int result = resultSetProxy->GetInstance()->IsClosed();
|
||||
napi_value output = nullptr;
|
||||
napi_get_boolean(env, result, &output);
|
||||
return output;
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetSharedBlockName(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr));
|
||||
|
||||
ResultSetProxy *proxy;
|
||||
NAPI_CALL(env, napi_unwrap(env, thiz, reinterpret_cast<void **>(&proxy)));
|
||||
RDB_CHECK_RETURN_NULLPTR(proxy != nullptr,
|
||||
"ResultSetProxy::GetSharedBlockName proxy is nullptr");
|
||||
|
||||
return JSUtils::Convert2JSValue(env, proxy->sharedBlockName_);
|
||||
}
|
||||
|
||||
napi_value ResultSetProxy::GetSharedBlockAshmemFd(napi_env env, napi_callback_info info)
|
||||
{
|
||||
napi_value thiz = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, nullptr, nullptr, &thiz, nullptr));
|
||||
|
||||
ResultSetProxy *proxy;
|
||||
NAPI_CALL(env, napi_unwrap(env, thiz, reinterpret_cast<void **>(&proxy)));
|
||||
RDB_CHECK_RETURN_NULLPTR(proxy != nullptr,
|
||||
"ResultSetProxy::GetSharedBlockAshmemFd proxy is nullptr");
|
||||
|
||||
return JSUtils::Convert2JSValue(env, proxy->sharedBlockAshmemFd_);
|
||||
}
|
||||
} // namespace RdbJsKit
|
||||
} // namespace OHOS
|
||||
|
||||
#if !defined(WINDOWS_PLATFORM) && !defined(MAC_PLATFORM)
|
||||
|
||||
__attribute__((visibility("default"))) napi_value NewCInstance(napi_env env,
|
||||
napi_value arg) asm("NAPI_OHOS_Data_RdbJsKit_ResultSetProxy_NewInstance");
|
||||
napi_value NewCInstance(napi_env env, std::shared_ptr<OHOS::NativeRdb::AbsSharedResultSet> resultSet)
|
||||
{
|
||||
return OHOS::RdbJsKit::ResultSetProxy::NewInstance(env, resultSet);
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) std::shared_ptr<OHOS::NativeRdb::AbsSharedResultSet> GetCObject(napi_env env,
|
||||
napi_value arg) asm("NAPI_OHOS_Data_RdbJsKit_ResultSetProxy_GetNativeObject");
|
||||
std::shared_ptr<OHOS::NativeRdb::AbsSharedResultSet> GetCObject(napi_env env, napi_value arg)
|
||||
{
|
||||
return OHOS::RdbJsKit::ResultSetProxy::GetNativeObject(env, arg);
|
||||
}
|
||||
#endif
|
@ -1714,7 +1714,7 @@ void UvWorkOnAbilityDisconnectDone(uv_work_t *work, int status)
|
||||
(abilityName == obj.first.want.GetElement().GetAbilityName());
|
||||
});
|
||||
if (item != connects_.end()) {
|
||||
// match deviceid & bundlename && abilityname
|
||||
// match deviceId & bundlename && abilityname
|
||||
connects_.erase(item);
|
||||
TAG_LOGI(AAFwkTag::JSNAPI, "erase connects_.size:%{public}zu", connects_.size());
|
||||
}
|
||||
|
@ -57,17 +57,12 @@ ohos_shared_library("napi_common") {
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
# "form_fwk:form_manager",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
# "image_framework:image_native",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"json:nlohmann_json_static",
|
||||
"libuv:uv",
|
||||
"napi:ace_napi",
|
||||
# "resource_management:global_resmgr",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
|
||||
public_external_deps = [
|
||||
|
@ -34,17 +34,12 @@ ohos_shared_library("childprocessmanager_napi") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
# "ability_base:session_info",
|
||||
# "ability_base:want",
|
||||
# "bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
# "jsoncpp:jsoncpp",
|
||||
"napi:ace_napi",
|
||||
# "resource_management:global_resmgr",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
|
@ -37,7 +37,6 @@ ohos_shared_library("dialogsession_napi") {
|
||||
}
|
||||
external_deps = [
|
||||
"ability_base:extractortool",
|
||||
# "ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
@ -45,19 +44,12 @@ ohos_shared_library("dialogsession_napi") {
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
"ffrt:libffrt",
|
||||
# "form_fwk:form_manager",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
# "image_framework:image_native",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
# "json:nlohmann_json_static",
|
||||
# "jsoncpp:jsoncpp",
|
||||
"napi:ace_napi",
|
||||
# "resource_management:global_resmgr",
|
||||
"samgr:samgr_proxy",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
|
||||
cflags_cc = []
|
||||
|
@ -284,7 +284,7 @@ enum ErrorCode {
|
||||
*/
|
||||
MISSION_FOR_CONTINUING_IS_NOT_ALIVE = 29360224,
|
||||
/*
|
||||
* Result(29360144) for get local deviceid fail.
|
||||
* Result(29360144) for get local deviceId fail.
|
||||
*/
|
||||
GET_LOCAL_DEVICE_ERR = 29360144,
|
||||
/**
|
||||
|
@ -18,10 +18,6 @@ ohos_shared_library("particleability") {
|
||||
include_dirs = [
|
||||
"${ability_runtime_napi_path}/featureAbility",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
"${relational_store_napi_path}/common/include",
|
||||
"${relational_store_napi_path}/dataability/include",
|
||||
"${relational_store_napi_path}/rdb/include",
|
||||
"${relational_store_base_path}/frameworks/common/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
@ -56,38 +52,33 @@ ohos_shared_library("particleability") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"jsoncpp:jsoncpp",
|
||||
"kv_store:distributeddata_inner",
|
||||
"data_share:datashare_provider",
|
||||
"libuv:uv",
|
||||
"napi:ace_napi",
|
||||
"node:node_header_notice",
|
||||
"relational_store:native_dataability",
|
||||
]
|
||||
|
||||
# if (ability_runtime_relational) {
|
||||
# include_dirs += [
|
||||
# "${relational_store_napi_path}/common/include",
|
||||
# "${relational_store_napi_path}/dataability/include",
|
||||
# "${relational_store_napi_path}/rdb/include",
|
||||
# ]
|
||||
# sources += [
|
||||
# "${relational_store_napi_path}/common/src/js_utils.cpp",
|
||||
# "${relational_store_napi_path}/dataability/src/napi_data_ability_predicates.cpp",
|
||||
# "${relational_store_napi_path}/rdb/src/napi_rdb_js_utils.cpp",
|
||||
# "${relational_store_napi_path}/rdb/src/napi_result_set.cpp",
|
||||
# ]
|
||||
# external_deps += [
|
||||
# "kv_store:distributeddata_mgr",
|
||||
# "relational_store:native_dataability",
|
||||
# "relational_store:native_rdb",
|
||||
# "relational_store:rdb_data_share_adapter",
|
||||
# ]
|
||||
# }
|
||||
if (ability_runtime_relational) {
|
||||
include_dirs += [ "../featureAbility/data_ability/include" ]
|
||||
sources += [
|
||||
"../featureAbility/data_ability/js_utils.cpp",
|
||||
"../featureAbility/data_ability/napi_data_ability_predicates.cpp",
|
||||
"../featureAbility/data_ability/napi_rdb_js_utils.cpp",
|
||||
"../featureAbility/data_ability/napi_result_set.cpp",
|
||||
]
|
||||
external_deps += [
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
"kv_store:distributeddata_mgr",
|
||||
"relational_store:native_appdatafwk",
|
||||
"relational_store:native_dataability",
|
||||
"relational_store:native_rdb",
|
||||
"relational_store:rdb_data_share_adapter",
|
||||
]
|
||||
}
|
||||
|
||||
cflags_cc = []
|
||||
if (os_dlp_part_enabled) {
|
||||
|
@ -87,16 +87,10 @@ ohos_shared_library("ability_context_native") {
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
"faultloggerd:libdfx_dumpcatcher",
|
||||
# "form_fwk:form_manager",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
# "image_framework:image_native",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
# "resource_management:global_resmgr",
|
||||
# "skia:skia_canvaskit",
|
||||
# "window_manager:libwm",
|
||||
]
|
||||
public_external_deps = [
|
||||
"ability_base:extractortool",
|
||||
|
@ -402,7 +402,7 @@ ErrCode AbilityContextImpl::ConnectAbility(const AAFwk::Want& want, const sptr<A
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGI(AAFwkTag::CONTEXT,
|
||||
"ConnectAbility called, caller:%{public}s, target:%{public}s",
|
||||
"ConnectAbility, caller:%{public}s, target:%{public}s",
|
||||
abilityInfo_ == nullptr ? "" : abilityInfo_->name.c_str(), want.GetElement().GetAbilityName().c_str());
|
||||
ErrCode ret = ConnectionManager::GetInstance().ConnectAbility(token_, want, connectCallback);
|
||||
if (ret != ERR_OK) {
|
||||
@ -440,7 +440,7 @@ void AbilityContextImpl::DisconnectAbility(const AAFwk::Want& want,
|
||||
const sptr<AbilityConnectCallback>& connectCallback, int32_t accountId)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "DisconnectAbility called, caller:%{public}s, target:%{public}s",
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "DisconnectAbility, caller:%{public}s, target:%{public}s",
|
||||
abilityInfo_ == nullptr ? "" : abilityInfo_->name.c_str(), want.GetElement().GetAbilityName().c_str());
|
||||
ErrCode ret =
|
||||
ConnectionManager::GetInstance().DisconnectAbility(token_, want, connectCallback, accountId);
|
||||
|
@ -137,12 +137,10 @@ ohos_shared_library("abilitykit_utils") {
|
||||
sources = [
|
||||
"${ability_runtime_native_path}/ability/native/ability_handler.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/ability_local_record.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/application_configuration_manager.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/configuration_utils.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/resource_config_helper.cpp",
|
||||
]
|
||||
|
||||
deps = []
|
||||
deps = [ ":configuration_helper" ]
|
||||
|
||||
configs = [ ":abilitykit_utils_exceptions" ]
|
||||
|
||||
@ -162,7 +160,6 @@ ohos_shared_library("abilitykit_utils") {
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
|
||||
public_external_deps = [
|
||||
@ -178,7 +175,6 @@ ohos_shared_library("abilitykit_utils") {
|
||||
"window_manager:libwm",
|
||||
]
|
||||
public_external_deps += [
|
||||
# "form_fwk:form_manager",
|
||||
"graphic_2d:color_manager",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libdm",
|
||||
@ -191,6 +187,68 @@ ohos_shared_library("abilitykit_utils") {
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
||||
ohos_shared_library("configuration_helper") {
|
||||
sanitize = {
|
||||
integer_overflow = true
|
||||
ubsan = true
|
||||
boundary_sanitize = true
|
||||
cfi = true
|
||||
cfi_cross_dso = true
|
||||
cfi_vcall_icall_only = true
|
||||
debug = false
|
||||
}
|
||||
|
||||
branch_protector_ret = "pac_ret"
|
||||
|
||||
include_dirs = [
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/app",
|
||||
"${ability_runtime_innerkits_path}/ability_manager/include",
|
||||
"${ability_runtime_innerkits_path}/wantagent/include",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"${ability_runtime_native_path}/ability/native/application_configuration_manager.cpp",
|
||||
"${ability_runtime_native_path}/ability/native/resource_config_helper.cpp",
|
||||
]
|
||||
|
||||
deps = []
|
||||
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_base:want",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"json:nlohmann_json_static",
|
||||
"jsoncpp:jsoncpp",
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [
|
||||
"ability_base:session_info",
|
||||
"graphic_2d:color_manager",
|
||||
"icu:shared_icuuc",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libdm",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libwmutil",
|
||||
]
|
||||
}
|
||||
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
||||
ohos_shared_library("abilitykit_native") {
|
||||
branch_protector_ret = "pac_ret"
|
||||
|
||||
@ -242,6 +300,7 @@ ohos_shared_library("abilitykit_native") {
|
||||
]
|
||||
|
||||
deps = [
|
||||
":configuration_helper",
|
||||
":continuation_ipc",
|
||||
":extension_blocklist_config",
|
||||
":ui_service_extension_connection",
|
||||
@ -358,7 +417,6 @@ ohos_shared_library("abilitykit_native") {
|
||||
]
|
||||
|
||||
public_external_deps += [
|
||||
# "form_fwk:form_manager",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
}
|
||||
@ -379,6 +437,7 @@ config("extensionkit_public_config") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/app",
|
||||
"${ability_runtime_innerkits_path}/app_manager/include/appmgr",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
@ -414,6 +473,7 @@ ohos_shared_library("extensionkit_native") {
|
||||
public_configs = [ ":extensionkit_public_config" ]
|
||||
|
||||
deps = [
|
||||
":configuration_helper",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_start_options",
|
||||
"${ability_runtime_innerkits_path}/runtime:runtime",
|
||||
@ -428,15 +488,12 @@ ohos_shared_library("extensionkit_native") {
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"json:nlohmann_json_static",
|
||||
"napi:ace_napi",
|
||||
# "resource_management:global_resmgr",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
|
||||
public_deps = [ ":abilitykit_utils" ]
|
||||
@ -450,7 +507,6 @@ ohos_shared_library("extensionkit_native") {
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [ "ability_base:session_info" ]
|
||||
public_external_deps += [
|
||||
# "form_fwk:form_manager",
|
||||
"graphic_2d:color_manager",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libdm",
|
||||
@ -493,16 +549,11 @@ ohos_shared_library("insight_intent_executor") {
|
||||
"c_utils:utils",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
# "form_fwk:form_manager",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
# "image_framework:image_native",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
# "resource_management:global_resmgr",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
|
||||
subsystem_name = "ability"
|
||||
@ -559,6 +610,7 @@ ohos_shared_library("uiabilitykit_native") {
|
||||
|
||||
deps = [
|
||||
":abilitykit_native",
|
||||
":configuration_helper",
|
||||
":continuation_ipc",
|
||||
":ui_extension",
|
||||
"${ability_runtime_innerkits_path}/ability_manager:ability_manager",
|
||||
@ -632,7 +684,6 @@ ohos_shared_library("uiabilitykit_native") {
|
||||
"window_manager:windowstage_kit",
|
||||
]
|
||||
public_external_deps += [
|
||||
# "form_fwk:form_manager",
|
||||
"graphic_2d:color_manager",
|
||||
"image_framework:image_native",
|
||||
"window_manager:libdm",
|
||||
@ -784,7 +835,6 @@ ohos_shared_library("form_extension_module") {
|
||||
if (ability_runtime_graphics) {
|
||||
public_external_deps = [
|
||||
"form_fwk:fmskit_provider_client",
|
||||
# "form_fwk:form_manager",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
}
|
||||
@ -1047,21 +1097,17 @@ ohos_shared_library("ui_service_extension_module") {
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [
|
||||
"ace_engine:ace_uicontent",
|
||||
# "form_fwk:form_manager",
|
||||
"image_framework:image",
|
||||
"window_manager:libdm",
|
||||
"window_manager:libwm",
|
||||
"window_manager:libwsutils",
|
||||
"window_manager:scene_session",
|
||||
"window_manager:session_manager_lite",
|
||||
# "window_manager:window_native_kit",
|
||||
# "window_manager:windowstage_kit",
|
||||
]
|
||||
|
||||
public_external_deps = [
|
||||
"form_fwk:fmskit_native",
|
||||
"form_fwk:fmskit_provider_client",
|
||||
# "form_fwk:form_manager",
|
||||
"window_manager:libdm",
|
||||
"window_manager:libwmutil",
|
||||
"window_manager:window_native_kit",
|
||||
@ -1107,19 +1153,13 @@ ohos_shared_library("continuation_ipc") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
# "ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
"ipc:ipc_core",
|
||||
# "json:nlohmann_json_static",
|
||||
# "node:node_header_notice",
|
||||
"resource_management:global_resmgr",
|
||||
# "skia:skia_canvaskit",
|
||||
# "window_manager:libwm",
|
||||
]
|
||||
public_external_deps = [
|
||||
# "accessibility:accessibility_common",
|
||||
@ -1181,7 +1221,6 @@ ohos_shared_library("data_ability_helper") {
|
||||
if (ability_runtime_graphics) {
|
||||
public_external_deps = [
|
||||
"form_fwk:fmskit_provider_client",
|
||||
# "form_fwk:form_manager",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
}
|
||||
@ -1225,7 +1264,6 @@ ohos_shared_library("service_extension_module") {
|
||||
]
|
||||
public_external_deps = [
|
||||
"form_fwk:fmskit_provider_client",
|
||||
# "form_fwk:form_manager",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
}
|
||||
@ -1435,7 +1473,6 @@ ohos_shared_library("ui_extension_module") {
|
||||
"window_manager:libwm",
|
||||
]
|
||||
if (ability_runtime_graphics) {
|
||||
# external_deps += [ "form_fwk:form_manager" ]
|
||||
external_deps += [ ]
|
||||
}
|
||||
|
||||
@ -1577,7 +1614,6 @@ ohos_shared_library("share_extension_module") {
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [
|
||||
# "form_fwk:form_manager",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
}
|
||||
@ -1643,7 +1679,6 @@ ohos_shared_library("action_extension_module") {
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [
|
||||
# "form_fwk:form_manager",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
}
|
||||
@ -1906,7 +1941,6 @@ ohos_shared_library("auto_fill_extension_module") {
|
||||
"window_manager:libwm",
|
||||
]
|
||||
if (ability_runtime_graphics) {
|
||||
# external_deps += [ "form_fwk:form_manager" ]
|
||||
external_deps += [ ]
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,6 @@
|
||||
namespace OHOS {
|
||||
using AbilityRuntime::FreezeUtil;
|
||||
namespace AppExecFwk {
|
||||
namespace {
|
||||
const std::string PERMISSION_KEY = "ohos.user.grant.permission";
|
||||
const std::string GRANTED_RESULT_KEY = "ohos.user.grant.permission.result";
|
||||
}
|
||||
|
||||
void AbilityImpl::Init(const std::shared_ptr<OHOSApplication> &application,
|
||||
const std::shared_ptr<AbilityLocalRecord> &record,
|
||||
std::shared_ptr<Ability> &ability,
|
||||
|
@ -19,8 +19,9 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
AbilityLocalRecord::AbilityLocalRecord(const std::shared_ptr<AbilityInfo> &info, const sptr<IRemoteObject> &token)
|
||||
: abilityInfo_(info), token_(token) {}
|
||||
AbilityLocalRecord::AbilityLocalRecord(const std::shared_ptr<AbilityInfo> &info, const sptr<IRemoteObject> &token,
|
||||
const std::shared_ptr<AAFwk::Want> &want, int32_t abilityRecordId)
|
||||
: abilityInfo_(info), token_(token), want_(want), abilityRecordId_(abilityRecordId) {}
|
||||
|
||||
AbilityLocalRecord::~AbilityLocalRecord() {}
|
||||
|
||||
@ -29,31 +30,16 @@ const std::shared_ptr<AbilityInfo> &AbilityLocalRecord::GetAbilityInfo()
|
||||
return abilityInfo_;
|
||||
}
|
||||
|
||||
const std::shared_ptr<EventHandler> &AbilityLocalRecord::GetEventHandler()
|
||||
{
|
||||
return handler_;
|
||||
}
|
||||
|
||||
void AbilityLocalRecord::SetEventHandler(const std::shared_ptr<EventHandler> &handler)
|
||||
{
|
||||
handler_ = handler;
|
||||
}
|
||||
|
||||
const std::shared_ptr<EventRunner> &AbilityLocalRecord::GetEventRunner()
|
||||
{
|
||||
return runner_;
|
||||
}
|
||||
|
||||
void AbilityLocalRecord::SetEventRunner(const std::shared_ptr<EventRunner> &runner)
|
||||
{
|
||||
runner_ = runner;
|
||||
}
|
||||
|
||||
const sptr<IRemoteObject> &AbilityLocalRecord::GetToken()
|
||||
{
|
||||
return token_;
|
||||
}
|
||||
|
||||
int32_t AbilityLocalRecord::GetAbilityRecordId() const
|
||||
{
|
||||
return abilityRecordId_;
|
||||
}
|
||||
|
||||
const sptr<AbilityThread> &AbilityLocalRecord::GetAbilityThread()
|
||||
{
|
||||
return abilityThread_;
|
||||
@ -64,11 +50,6 @@ void AbilityLocalRecord::SetAbilityThread(const sptr<AbilityThread> &abilityThre
|
||||
abilityThread_ = abilityThread;
|
||||
}
|
||||
|
||||
void AbilityLocalRecord::SetWant(const std::shared_ptr<AAFwk::Want> &want)
|
||||
{
|
||||
want_ = want;
|
||||
}
|
||||
|
||||
const std::shared_ptr<AAFwk::Want> &AbilityLocalRecord::GetWant()
|
||||
{
|
||||
return want_;
|
||||
|
@ -68,7 +68,7 @@ void ContinuationRegisterManager::Unregister(int token, const std::shared_ptr<Re
|
||||
* notify continuation status to controlcenter continuation register service.
|
||||
*
|
||||
* @param token token from register.
|
||||
* @param deviceId deviceid.
|
||||
* @param deviceId deviceId.
|
||||
* @param status device status.
|
||||
* @param requestCallback callback for this request, -1 means failed, otherwise successed.
|
||||
*/
|
||||
|
@ -79,7 +79,7 @@ bool RemoteRegisterServiceProxy::Unregister(int registerToken)
|
||||
* notify continuation status to controlcenter continuation register service.
|
||||
*
|
||||
* @param registerToken token from register.
|
||||
* @param deviceId deviceid.
|
||||
* @param deviceId deviceId.
|
||||
* @param status device status.
|
||||
*/
|
||||
bool RemoteRegisterServiceProxy::UpdateConnectStatus(int registerToken, const std::string &deviceId, int status)
|
||||
|
@ -211,7 +211,7 @@ void ExtensionAbilityThread::HandleAttach(const std::shared_ptr<AppExecFwk::OHOS
|
||||
return;
|
||||
}
|
||||
|
||||
TAG_LOGI(AAFwkTag::EXT, "Begin, extension: %{public}s", abilityName.c_str());
|
||||
TAG_LOGI(AAFwkTag::EXT, "HandleAttach, extension: %{public}s", abilityName.c_str());
|
||||
if (mainRunner == nullptr) {
|
||||
runner_ = AppExecFwk::EventRunner::Create(abilityName);
|
||||
if (runner_ == nullptr) {
|
||||
@ -239,8 +239,6 @@ void ExtensionAbilityThread::HandleAttach(const std::shared_ptr<AppExecFwk::OHOS
|
||||
}
|
||||
currentExtension_.reset(extension);
|
||||
token_ = abilityRecord->GetToken();
|
||||
abilityRecord->SetEventHandler(abilityHandler_);
|
||||
mainRunner == nullptr ? abilityRecord->SetEventRunner(runner_) : abilityRecord->SetEventRunner(mainRunner);
|
||||
abilityRecord->SetAbilityThread(this);
|
||||
HandleAttachInner(application, abilityRecord);
|
||||
}
|
||||
@ -267,7 +265,7 @@ void ExtensionAbilityThread::HandleExtensionTransaction(
|
||||
const Want &want, const LifeCycleStateInfo &lifeCycleStateInfo, sptr<AAFwk::SessionInfo> sessionInfo)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::EXT, "%{public}s Begin", __func__);
|
||||
TAG_LOGD(AAFwkTag::EXT, "%{public}s", __func__);
|
||||
if (extensionImpl_ == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::EXT, "null extensionImpl_");
|
||||
return;
|
||||
|
@ -285,8 +285,6 @@ void FAAbilityThread::Attach(const std::shared_ptr<AppExecFwk::OHOSApplication>
|
||||
}
|
||||
currentAbility_.reset(ability);
|
||||
token_ = abilityRecord->GetToken();
|
||||
abilityRecord->SetEventHandler(abilityHandler_);
|
||||
abilityRecord->SetEventRunner(mainRunner);
|
||||
abilityRecord->SetAbilityThread(this);
|
||||
std::shared_ptr<AppExecFwk::AbilityContext> abilityObject = currentAbility_;
|
||||
std::shared_ptr<AppExecFwk::ContextDeal> contextDeal =
|
||||
@ -356,8 +354,6 @@ void FAAbilityThread::AttachExtension(const std::shared_ptr<AppExecFwk::OHOSAppl
|
||||
|
||||
currentExtension_.reset(extension);
|
||||
token_ = abilityRecord->GetToken();
|
||||
abilityRecord->SetEventHandler(abilityHandler_);
|
||||
abilityRecord->SetEventRunner(mainRunner);
|
||||
abilityRecord->SetAbilityThread(this);
|
||||
extensionImpl_ = std::make_shared<ExtensionImpl>();
|
||||
if (extensionImpl_ == nullptr) {
|
||||
@ -405,8 +401,6 @@ void FAAbilityThread::AttachExtension(const std::shared_ptr<AppExecFwk::OHOSAppl
|
||||
|
||||
currentExtension_.reset(extension);
|
||||
token_ = abilityRecord->GetToken();
|
||||
abilityRecord->SetEventHandler(abilityHandler_);
|
||||
abilityRecord->SetEventRunner(runner_);
|
||||
abilityRecord->SetAbilityThread(this);
|
||||
extensionImpl_ = std::make_shared<ExtensionImpl>();
|
||||
if (extensionImpl_ == nullptr) {
|
||||
@ -460,8 +454,6 @@ void FAAbilityThread::Attach(const std::shared_ptr<AppExecFwk::OHOSApplication>
|
||||
}
|
||||
currentAbility_.reset(ability);
|
||||
token_ = abilityRecord->GetToken();
|
||||
abilityRecord->SetEventHandler(abilityHandler_);
|
||||
abilityRecord->SetEventRunner(runner_);
|
||||
abilityRecord->SetAbilityThread(this);
|
||||
std::shared_ptr<AppExecFwk::AbilityContext> abilityObject = currentAbility_;
|
||||
std::shared_ptr<AppExecFwk::ContextDeal> contextDeal =
|
||||
|
@ -25,13 +25,6 @@ namespace OHOS {
|
||||
using AbilityRuntime::FreezeUtil;
|
||||
namespace AppExecFwk {
|
||||
using AbilityManagerClient = OHOS::AAFwk::AbilityManagerClient;
|
||||
/**
|
||||
* @brief Handling the life cycle switching of NewAbility.
|
||||
*
|
||||
* @param want Indicates the structure containing information about the ability.
|
||||
* @param targetState The life cycle state to switch to.
|
||||
*
|
||||
*/
|
||||
|
||||
void NewAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState,
|
||||
sptr<AAFwk::SessionInfo> sessionInfo)
|
||||
@ -72,10 +65,10 @@ void NewAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::Lif
|
||||
|
||||
void NewAbilityImpl::HandleShareData(const int32_t &uniqueId)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITY, "begin sourceState:%{public}d", lifecycleState_);
|
||||
WantParams wantParam;
|
||||
int32_t resultCode = Share(wantParam);
|
||||
TAG_LOGI(AAFwkTag::ABILITY, "wantParam size: %{public}d", wantParam.Size());
|
||||
TAG_LOGI(AAFwkTag::ABILITY, "begin sourceState:%{public}d, wantParam size:%{public}d",
|
||||
lifecycleState_, wantParam.Size());
|
||||
AbilityManagerClient::GetInstance()->ShareDataDone(token_, resultCode, uniqueId, wantParam);
|
||||
}
|
||||
|
||||
@ -89,15 +82,6 @@ void NewAbilityImpl::AbilityTransactionCallback(const AbilityLifeCycleState &sta
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Handling the life cycle switching of NewAbility in switch.
|
||||
*
|
||||
* @param want Indicates the structure containing information about the ability.
|
||||
* @param targetState The life cycle state to switch to.
|
||||
*
|
||||
* @return return true if need notify ams, otherwise return false.
|
||||
*
|
||||
*/
|
||||
bool NewAbilityImpl::AbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
|
@ -140,8 +140,6 @@ void UIAbilityThread::Attach(const std::shared_ptr<AppExecFwk::OHOSApplication>
|
||||
ability->SetAbilityRecordId(abilityRecord->GetAbilityRecordId());
|
||||
currentAbility_.reset(ability);
|
||||
token_ = abilityRecord->GetToken();
|
||||
abilityRecord->SetEventHandler(abilityHandler_);
|
||||
abilityRecord->SetEventRunner(mainRunner);
|
||||
abilityRecord->SetAbilityThread(this);
|
||||
std::shared_ptr<AppExecFwk::AbilityContext> abilityObject = currentAbility_;
|
||||
std::shared_ptr<AppExecFwk::ContextDeal> contextDeal =
|
||||
@ -212,8 +210,6 @@ void UIAbilityThread::Attach(const std::shared_ptr<AppExecFwk::OHOSApplication>
|
||||
ability->SetAbilityRecordId(abilityRecord->GetAbilityRecordId());
|
||||
currentAbility_.reset(ability);
|
||||
token_ = abilityRecord->GetToken();
|
||||
abilityRecord->SetEventHandler(abilityHandler_);
|
||||
abilityRecord->SetEventRunner(runner_);
|
||||
abilityRecord->SetAbilityThread(this);
|
||||
std::shared_ptr<AppExecFwk::AbilityContext> abilityObject = currentAbility_;
|
||||
std::shared_ptr<AppExecFwk::ContextDeal> contextDeal =
|
||||
|
@ -158,6 +158,7 @@ ohos_shared_library("appkit_native") {
|
||||
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
|
||||
"${ability_runtime_native_path}/ability/native:ability_thread",
|
||||
"${ability_runtime_native_path}/ability/native:abilitykit_native",
|
||||
"${ability_runtime_native_path}/ability/native:configuration_helper",
|
||||
"${ability_runtime_native_path}/ability/native:uiabilitykit_native",
|
||||
"${ability_runtime_native_path}/appkit:app_context",
|
||||
"${ability_runtime_native_path}/appkit:app_context_utils",
|
||||
@ -313,11 +314,8 @@ ohos_shared_library("app_context") {
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
# "form_fwk:form_manager",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
# "image_framework:image_native",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
@ -325,7 +323,6 @@ ohos_shared_library("app_context") {
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
"samgr:samgr_proxy",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
public_external_deps = [
|
||||
"ability_base:configuration",
|
||||
@ -391,7 +388,6 @@ ohos_shared_library("app_context_utils") {
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
@ -400,7 +396,6 @@ ohos_shared_library("app_context_utils") {
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
"resource_management:resmgr_napi_core",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
public_external_deps = [ "ability_base:configuration" ]
|
||||
if (ability_runtime_graphics) {
|
||||
|
@ -196,6 +196,19 @@ ErrCode BundleMgrHelper::GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo,
|
||||
return bundleMgr->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo);
|
||||
}
|
||||
|
||||
std::string BundleMgrHelper::GetAppIdByBundleName(const std::string &bundleName, const int32_t userId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "GetAppIdByBundleName called");
|
||||
auto bundleMgr = Connect();
|
||||
if (bundleMgr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "Failed to connect.");
|
||||
return "";
|
||||
}
|
||||
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
return bundleMgr->GetAppIdByBundleName(bundleName, userId);
|
||||
}
|
||||
|
||||
sptr<IBundleMgr> BundleMgrHelper::Connect()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
|
@ -41,32 +41,6 @@ void AbilityRecordMgr::SetToken(const sptr<IRemoteObject> &token)
|
||||
tokens_ = token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the eventRunner of abilitythread to the AbilityRecordMgr.
|
||||
*
|
||||
* @param eventRunner The runner of the abilitythread.
|
||||
*
|
||||
*/
|
||||
void AbilityRecordMgr::SetEventRunner(const std::shared_ptr<EventRunner> &eventRunner)
|
||||
{
|
||||
if (eventRunner == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "eventRunner is nullptr");
|
||||
return;
|
||||
}
|
||||
sptr<IRemoteObject> token = GetToken();
|
||||
if (token == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "token is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
std::shared_ptr<AbilityLocalRecord> abilityInstance = GetAbilityItem(token);
|
||||
if (abilityInstance != nullptr) {
|
||||
abilityInstance->SetEventRunner(eventRunner);
|
||||
} else {
|
||||
TAG_LOGW(AAFwkTag::APPKIT, "ability record not exist");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Save the token and abilityRecord to the AbilityRecordMgr.
|
||||
*
|
||||
|
@ -44,7 +44,7 @@ static const int RESULT_ERR = -1;
|
||||
|
||||
static const char TASK_NAME[] = "ApplicationCleaner::ClearTempData";
|
||||
static constexpr uint64_t DELAY = 5000000; //5s
|
||||
constexpr int64_t ONEHUNDRED_MB = 50 * 1024;
|
||||
constexpr int64_t MAX_FILE_SIZE = 50 * 1024;
|
||||
} // namespace
|
||||
void ApplicationCleaner::RenameTempData()
|
||||
{
|
||||
@ -97,7 +97,7 @@ void ApplicationCleaner::ClearTempData()
|
||||
}
|
||||
};
|
||||
|
||||
if (CheckFileSize(rootDir, ONEHUNDRED_MB)) {
|
||||
if (CheckFileSize(rootDir)) {
|
||||
ffrt::submit(cleanTemp);
|
||||
} else {
|
||||
ffrt::task_attr attr;
|
||||
@ -107,7 +107,7 @@ void ApplicationCleaner::ClearTempData()
|
||||
}
|
||||
}
|
||||
|
||||
bool ApplicationCleaner::CheckFileSize(const std::vector<std::string> bundlePath, const int64_t maxFileSize)
|
||||
bool ApplicationCleaner::CheckFileSize(const std::vector<std::string> &bundlePath)
|
||||
{
|
||||
int64_t fileSize = 0;
|
||||
|
||||
@ -118,12 +118,7 @@ bool ApplicationCleaner::CheckFileSize(const std::vector<std::string> bundlePath
|
||||
}
|
||||
fileSize += fileInfo.st_size;
|
||||
}
|
||||
|
||||
if (fileSize > maxFileSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return (fileSize <= MAX_FILE_SIZE);
|
||||
}
|
||||
|
||||
int ApplicationCleaner::GetRootPath(std::vector<std::string> &rootPath)
|
||||
|
@ -706,9 +706,7 @@ void MainThread::ScheduleLaunchAbility(const AbilityInfo &info, const sptr<IRemo
|
||||
newWant.CloseAllFd();
|
||||
}
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>(info);
|
||||
auto abilityRecord = std::make_shared<AbilityLocalRecord>(abilityInfo, token);
|
||||
abilityRecord->SetWant(want);
|
||||
abilityRecord->SetAbilityRecordId(abilityRecordId);
|
||||
auto abilityRecord = std::make_shared<AbilityLocalRecord>(abilityInfo, token, want, abilityRecordId);
|
||||
auto tmpWatchdog = watchdog_;
|
||||
if (tmpWatchdog != nullptr) {
|
||||
tmpWatchdog->SetBgWorkingThreadStatus(IsBgWorkingThread(info));
|
||||
@ -1370,7 +1368,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
std::vector<std::string> localPaths;
|
||||
ChangeToLocalPath(bundleName, appInfo.moduleSourceDirs, localPaths);
|
||||
LoadAbilityLibrary(localPaths);
|
||||
LoadNativeLiabrary(bundleInfo, appInfo.nativeLibraryPath);
|
||||
LoadNativeLibrary(bundleInfo, appInfo.nativeLibraryPath);
|
||||
#ifdef SUPPORT_SCREEN
|
||||
} else if (Ace::AceForwardCompatibility::PipelineChanged()) {
|
||||
std::vector<std::string> localPaths;
|
||||
@ -1817,7 +1815,7 @@ void MainThread::CalcNativeLiabraryEntries(const BundleInfo &bundleInfo, std::st
|
||||
}
|
||||
}
|
||||
|
||||
void MainThread::LoadNativeLiabrary(const BundleInfo &bundleInfo, std::string &nativeLibraryPath)
|
||||
void MainThread::LoadNativeLibrary(const BundleInfo &bundleInfo, std::string &nativeLibraryPath)
|
||||
{
|
||||
CalcNativeLiabraryEntries(bundleInfo, nativeLibraryPath);
|
||||
if (nativeFileEntries_.empty()) {
|
||||
|
@ -41,19 +41,14 @@ ohos_shared_library("insightintentcontext") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
# "ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
# "image_framework:image_native",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_single",
|
||||
"napi:ace_napi",
|
||||
# "resource_management:global_resmgr",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
|
||||
subsystem_name = "ability"
|
||||
|
@ -54,6 +54,7 @@ public:
|
||||
static napi_value GetRunningProcessInformation(napi_env env, napi_callback_info info);
|
||||
static napi_value CreateJsApplicationContext(napi_env env, const std::shared_ptr<Context> &context);
|
||||
static napi_value SetSupportedProcessCacheSelf(napi_env env, napi_callback_info info);
|
||||
static napi_value SetColorMode(napi_env env, napi_callback_info info);
|
||||
|
||||
napi_value OnGetCacheDir(napi_env env, NapiCallbackInfo& info);
|
||||
napi_value OnGetTempDir(napi_env env, NapiCallbackInfo& info);
|
||||
|
@ -34,6 +34,11 @@ napi_value JsApplicationContextUtils::CreateBundleContext(napi_env env, napi_cal
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value JsApplicationContextUtils::SetColorMode(napi_env env, napi_callback_info info)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
napi_value JsApplicationContextUtils::SwitchArea(napi_env env, napi_callback_info info)
|
||||
{
|
||||
GET_NAPI_INFO_WITH_NAME_AND_CALL(env, info, JsApplicationContextUtils, OnSwitchArea, APPLICATION_CONTEXT_NAME);
|
||||
@ -355,6 +360,7 @@ void JsApplicationContextUtils::BindNativeApplicationContext(napi_env env, napi_
|
||||
JsApplicationContextUtils::GetRunningProcessInformation);
|
||||
BindNativeFunction(env, object, "getRunningProcessInformation", MD_NAME,
|
||||
JsApplicationContextUtils::GetRunningProcessInformation);
|
||||
BindNativeFunction(env, object, "setColorMode", MD_NAME, JsApplicationContextUtils::SetColorMode);
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -87,7 +87,7 @@ ohos_shared_library("ability_manager") {
|
||||
"${ability_runtime_services_path}/abilitymgr/src/insight_intent_execute_result.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/launch_param.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/lifecycle_state_info.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/mission_listener_stub.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/mission/mission_listener_stub.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/open_link/open_link_options.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/prepare_terminate_callback_proxy.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/prepare_terminate_callback_stub.cpp",
|
||||
@ -137,21 +137,14 @@ ohos_shared_library("ability_manager") {
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
"eventhandler:libeventhandler",
|
||||
# "form_fwk:form_manager",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
"hitrace:hitrace_meter",
|
||||
# "image_framework:image_native",
|
||||
# "input:libmmi-client",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"jsoncpp:jsoncpp",
|
||||
"relational_store:native_dataability",
|
||||
# "relational_store:native_rdb",
|
||||
# "resource_management:global_resmgr",
|
||||
"samgr:samgr_proxy",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
|
||||
if (host_cpu != "arm64") {
|
||||
@ -240,17 +233,15 @@ ohos_shared_library("mission_info") {
|
||||
branch_protector_ret = "pac_ret"
|
||||
|
||||
sources = [
|
||||
"${ability_runtime_services_path}/abilitymgr/src/mission_info.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/mission_snapshot.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/mission/mission_info.cpp",
|
||||
"${ability_runtime_services_path}/abilitymgr/src/mission/mission_snapshot.cpp",
|
||||
]
|
||||
|
||||
public_configs = [ ":ability_manager_public_config" ]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"ipc:ipc_core",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
public_external_deps = [
|
||||
"ability_base:configuration",
|
||||
@ -281,13 +272,9 @@ ohos_shared_library("ability_manager_c") {
|
||||
"ability_base:session_info",
|
||||
"c_utils:utils",
|
||||
"ets_runtime:libark_jsruntime",
|
||||
# "form_fwk:form_manager",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"image_framework:image_native",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
# "resource_management:global_resmgr",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
subsystem_name = "ability"
|
||||
|
@ -512,7 +512,7 @@ public:
|
||||
int32_t userId = DEFAULT_INVAL_VALUE);
|
||||
|
||||
/**
|
||||
* ConnectUIServiceExtesnionAbility, connect session with uiService ability.
|
||||
* ConnectUIServiceExtensionAbility, connect session with uiService ability.
|
||||
*
|
||||
* @param want, Special want for uiService type's ability.
|
||||
* @param connect, Callback used to notify caller the result of connecting or disconnecting.
|
||||
@ -672,7 +672,7 @@ public:
|
||||
/**
|
||||
* notify continuation complete to dms.
|
||||
* @param deviceId, source device which start a continuation.
|
||||
* @param sessionId, represent a continuaion.
|
||||
* @param sessionId, represent a continuation.
|
||||
* @param isSuccess, continuation result.
|
||||
* @return
|
||||
*/
|
||||
@ -721,7 +721,7 @@ public:
|
||||
void SetLockedState(int32_t sessionId, bool lockedState);
|
||||
|
||||
/**
|
||||
* @brief Register mission listener to ams.
|
||||
* @brief Register mission listener to ability mgr.
|
||||
* @param listener The handler of listener.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
@ -729,7 +729,7 @@ public:
|
||||
ErrCode RegisterMissionListener(sptr<IMissionListener> listener);
|
||||
|
||||
/**
|
||||
* @brief UnRegister mission listener from ams.
|
||||
* @brief UnRegister mission listener from ability mgr.
|
||||
* @param listener The handler of listener.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
@ -773,8 +773,8 @@ public:
|
||||
ErrCode UnRegisterMissionListener(const std::string &deviceId, sptr<IRemoteMissionListener> listener);
|
||||
|
||||
/**
|
||||
* @brief Get mission infos from ams.
|
||||
* @param deviceId local or remote deviceid.
|
||||
* @brief Get mission infos from ability mgr.
|
||||
* @param deviceId local or remote deviceId.
|
||||
* @param numMax max number of missions.
|
||||
* @param missionInfos mission info result.
|
||||
*
|
||||
@ -784,9 +784,9 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Get mission info by id.
|
||||
* @param deviceId local or remote deviceid.
|
||||
* @param deviceId local or remote deviceId.
|
||||
* @param missionId Id of target mission.
|
||||
* @param missionInfo mision info of target mission.
|
||||
* @param missionInfo mission info of target mission.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
@ -794,7 +794,7 @@ public:
|
||||
|
||||
/**
|
||||
* @brief Get the Mission Snapshot Info object
|
||||
* @param deviceId local or remote deviceid.
|
||||
* @param deviceId local or remote deviceId.
|
||||
* @param missionId Id of target mission.
|
||||
* @param snapshot snapshot of target mission.
|
||||
* @param isLowResolution get low resolution snapshot.
|
||||
@ -1022,7 +1022,7 @@ public:
|
||||
* PrepareTerminateAbilityBySCB, prepare to terminate ability by scb.
|
||||
*
|
||||
* @param sessionInfo the session info of the ability to terminate.
|
||||
* @param isPrepareTerminate the result of ability onPrepareToTermiante.
|
||||
* @param isPrepareTerminate the result of ability onPrepareToTerminate.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode PrepareTerminateAbilityBySCB(sptr<SessionInfo> sessionInfo, bool &isPrepareTerminate);
|
||||
@ -1030,7 +1030,7 @@ public:
|
||||
/**
|
||||
* Set mission continue state of this ability.
|
||||
*
|
||||
* @param token Indidate token of ability.
|
||||
* @param token Indicate token of ability.
|
||||
* @param state the mission continuation state of this ability.
|
||||
* @return Returns ERR_OK if success.
|
||||
*/
|
||||
@ -1041,8 +1041,8 @@ public:
|
||||
/**
|
||||
* Set mission label of this ability.
|
||||
*
|
||||
* @param abilityToken Indidate token of ability.
|
||||
* @param label Indidate the label showed of the ability in recent missions.
|
||||
* @param abilityToken Indicate token of ability.
|
||||
* @param label Indicate the label showed of the ability in recent missions.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode SetMissionLabel(sptr<IRemoteObject> abilityToken, const std::string &label);
|
||||
@ -1050,8 +1050,8 @@ public:
|
||||
/**
|
||||
* Set mission icon of this ability.
|
||||
*
|
||||
* @param abilityToken Indidate token of ability.
|
||||
* @param icon Indidate the icon showed of the ability in recent missions.
|
||||
* @param abilityToken Indicate token of ability.
|
||||
* @param icon Indicate the icon showed of the ability in recent missions.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode SetMissionIcon(sptr<IRemoteObject> abilityToken,
|
||||
@ -1060,7 +1060,7 @@ public:
|
||||
/**
|
||||
* Register the WindowManagerService handler
|
||||
*
|
||||
* @param handler Indidate handler of WindowManagerService.
|
||||
* @param handler Indicate handler of WindowManagerService.
|
||||
* @return ErrCode Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode RegisterWindowManagerServiceHandler(sptr<IWindowManagerServiceHandler> handler,
|
||||
@ -1069,14 +1069,14 @@ public:
|
||||
/**
|
||||
* WindowManager notification AbilityManager after the first frame is drawn.
|
||||
*
|
||||
* @param abilityToken Indidate token of ability.
|
||||
* @param abilityToken Indicate token of ability.
|
||||
*/
|
||||
void CompleteFirstFrameDrawing(sptr<IRemoteObject> abilityToken);
|
||||
|
||||
/**
|
||||
* WindowManager notification AbilityManager after the first frame is drawn.
|
||||
*
|
||||
* @param sessionId Indidate session id.
|
||||
* @param sessionId Indicate session id.
|
||||
*/
|
||||
void CompleteFirstFrameDrawing(int32_t sessionId);
|
||||
|
||||
@ -1596,6 +1596,16 @@ public:
|
||||
*/
|
||||
ErrCode BlockAllAppStart(bool flag);
|
||||
|
||||
/**
|
||||
* update associate config list by rss.
|
||||
*
|
||||
* @param configs The rss config info.
|
||||
* @param exportConfigs The rss export config info.
|
||||
* @param flag UPDATE_CONFIG_FLAG_COVER is cover config, UPDATE_CONFIG_FLAG_APPEND is append config.
|
||||
*/
|
||||
ErrCode UpdateAssociateConfigList(const std::map<std::string, std::list<std::string>>& configs,
|
||||
const std::list<std::string>& exportConfigs, int32_t flag);
|
||||
|
||||
private:
|
||||
AbilityManagerClient();
|
||||
DISALLOW_COPY_AND_MOVE(AbilityManagerClient);
|
||||
|
@ -336,7 +336,7 @@ public:
|
||||
* @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StartExtensionAbility(
|
||||
virtual int32_t StartExtensionAbility(
|
||||
const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE,
|
||||
@ -597,7 +597,7 @@ public:
|
||||
* @param userId, Designation User ID.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int ConnectAbility(
|
||||
virtual int32_t ConnectAbility(
|
||||
const Want &want,
|
||||
const sptr<IAbilityConnection> &connect,
|
||||
const sptr<IRemoteObject> &callerToken,
|
||||
@ -613,7 +613,7 @@ public:
|
||||
* @param userId, the service user ID.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int ConnectAbilityCommon(
|
||||
virtual int32_t ConnectAbilityCommon(
|
||||
const Want &want,
|
||||
const sptr<IAbilityConnection> &connect,
|
||||
const sptr<IRemoteObject> &callerToken,
|
||||
@ -863,36 +863,108 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register mission listener to ability mgr.
|
||||
* @param listener The handler of listener.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int RegisterMissionListener(const sptr<IMissionListener> &listener) = 0;
|
||||
|
||||
/**
|
||||
* @brief UnRegister mission listener from ability mgr.
|
||||
* @param listener The handler of listener.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int UnRegisterMissionListener(const sptr<IMissionListener> &listener) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get mission infos from ability mgr.
|
||||
* @param deviceId local or remote deviceId.
|
||||
* @param numMax max number of missions.
|
||||
* @param missionInfos mission info result.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetMissionInfos(
|
||||
const std::string &deviceId, int32_t numMax, std::vector<MissionInfo> &missionInfos) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get mission info by id.
|
||||
* @param deviceId local or remote deviceId.
|
||||
* @param missionId Id of target mission.
|
||||
* @param missionInfo mission info of target mission.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetMissionInfo(const std::string &deviceId, int32_t missionId, MissionInfo &missionInfo) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the Mission Snapshot Info object
|
||||
* @param deviceId local or remote deviceId.
|
||||
* @param missionId Id of target mission.
|
||||
* @param snapshot snapshot of target mission.
|
||||
* @param isLowResolution get low resolution snapshot.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetMissionSnapshot(const std::string& deviceId, int32_t missionId,
|
||||
MissionSnapshot& snapshot, bool isLowResolution) = 0;
|
||||
|
||||
/**
|
||||
* @brief Clean mission by id.
|
||||
* @param missionId Id of target mission.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int CleanMission(int32_t missionId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Clean all missions in system.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int CleanAllMissions() = 0;
|
||||
|
||||
virtual int MoveMissionToFront(int32_t missionId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Move a mission to front.
|
||||
* @param missionId Id of target mission.
|
||||
* @param startOptions Special startOptions for target mission.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) = 0;
|
||||
|
||||
/**
|
||||
* Move missions to front
|
||||
* @param missionIds Ids of target missions
|
||||
* @param topMissionId Indicate which mission will be moved to top, if set to -1, missions' order won't change
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move missions to background
|
||||
* @param missionIds Ids of target missions
|
||||
* @param result The result of move missions to background, and the array is sorted by zOrder
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int MoveMissionsToBackground(const std::vector<int32_t>& missionIds, std::vector<int32_t>& result)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Register session handler.
|
||||
* @param object The handler.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int RegisterSessionHandler(const sptr<IRemoteObject> &object)
|
||||
{
|
||||
return 0;
|
||||
@ -925,10 +997,29 @@ public:
|
||||
*/
|
||||
virtual int ReleaseCall(const sptr<IAbilityConnection> &connect, const AppExecFwk::ElementName &element) = 0;
|
||||
|
||||
/**
|
||||
* @brief start user.
|
||||
* @param accountId accountId.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StartUser(int userId, sptr<IUserCallback> callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief stop user.
|
||||
* @param accountId accountId.
|
||||
* @param callback callback.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StopUser(int userId, const sptr<IUserCallback> &callback) = 0;
|
||||
|
||||
/**
|
||||
* @brief logout user.
|
||||
* @param accountId accountId.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int LogoutUser(int32_t userId)
|
||||
{
|
||||
return 0;
|
||||
@ -956,7 +1047,7 @@ public:
|
||||
/**
|
||||
* Register the WindowManagerService handler
|
||||
*
|
||||
* @param handler Indidate handler of WindowManagerService.
|
||||
* @param handler Indicate handler of WindowManagerService.
|
||||
* @return ErrCode Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int RegisterWindowManagerServiceHandler(const sptr<IWindowManagerServiceHandler>& handler,
|
||||
@ -968,14 +1059,14 @@ public:
|
||||
/**
|
||||
* WindowManager notification AbilityManager after the first frame is drawn.
|
||||
*
|
||||
* @param abilityToken Indidate token of ability.
|
||||
* @param abilityToken Indicate token of ability.
|
||||
*/
|
||||
virtual void CompleteFirstFrameDrawing(const sptr<IRemoteObject> &abilityToken) = 0;
|
||||
|
||||
/**
|
||||
* WindowManager notification AbilityManager after the first frame is drawn.
|
||||
*
|
||||
* @param sessionId Indidate session id.
|
||||
* @param sessionId Indicate session id.
|
||||
*/
|
||||
virtual void CompleteFirstFrameDrawing(int32_t sessionId)
|
||||
{}
|
||||
@ -1025,11 +1116,29 @@ public:
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get the ability running information.
|
||||
*
|
||||
* @param info Ability running information.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get the extension running information.
|
||||
*
|
||||
* @param upperLimit The maximum limit of information wish to get.
|
||||
* @param info Extension running information.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetExtensionRunningInfos(int upperLimit, std::vector<ExtensionRunningInfo> &info) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get running process information.
|
||||
*
|
||||
* @param info Running process information.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> &info) = 0;
|
||||
|
||||
/**
|
||||
@ -1048,6 +1157,13 @@ public:
|
||||
*/
|
||||
virtual int StopSyncRemoteMissions(const std::string &devId) = 0;
|
||||
|
||||
/**
|
||||
* @brief Register mission listener to ability manager service.
|
||||
* @param deviceId The remote device Id.
|
||||
* @param listener The handler of listener.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int RegisterMissionListener(const std::string &deviceId, const sptr<IRemoteMissionListener> &listener) = 0;
|
||||
|
||||
virtual int RegisterOnListener(const std::string &type, const sptr<IRemoteOnListener> &listener)
|
||||
@ -1086,8 +1202,23 @@ public:
|
||||
*/
|
||||
virtual int RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler) = 0;
|
||||
|
||||
/**
|
||||
* @brief start user test.
|
||||
* @param want the want of the ability user test to start.
|
||||
* @param observer test observer callback.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StartUserTest(const Want &want, const sptr<IRemoteObject> &observer) = 0;
|
||||
|
||||
/**
|
||||
* @brief Finish user test.
|
||||
* @param msg user test message.
|
||||
* @param resultCode user test result Code.
|
||||
* @param bundleName user test bundleName.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int FinishUserTest(const std::string &msg, const int64_t &resultCode, const std::string &bundleName) = 0;
|
||||
|
||||
/**
|
||||
@ -1197,6 +1328,11 @@ public:
|
||||
virtual void ScheduleRecoverAbility(const sptr<IRemoteObject> &token, int32_t reason,
|
||||
const Want *want = nullptr) {};
|
||||
|
||||
/**
|
||||
* @brief Schedule clear recovery page stack.
|
||||
*
|
||||
* @param bundleName application bundleName.
|
||||
*/
|
||||
virtual void ScheduleClearRecoveryPageStack() {};
|
||||
|
||||
/**
|
||||
@ -1746,6 +1882,19 @@ public:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* update associate config list by rss.
|
||||
*
|
||||
* @param configs The rss config info.
|
||||
* @param exportConfigs The rss export config info.
|
||||
* @param flag UPDATE_CONFIG_FLAG_COVER is cover config, UPDATE_CONFIG_FLAG_APPEND is append config.
|
||||
*/
|
||||
virtual int32_t UpdateAssociateConfigList(const std::map<std::string, std::list<std::string>>& configs,
|
||||
const std::list<std::string>& exportConfigs, int32_t flag)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -558,6 +558,9 @@ enum class AbilityManagerInterfaceCode {
|
||||
|
||||
// ipc for block all apps from starting
|
||||
BLOCK_ALL_APP_START = 6119,
|
||||
|
||||
// update associate config list
|
||||
UPDATE_ASSOCIATE_CONFIG_LIST = 6120,
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
* notify continuation status to controlcenter continuation register service.
|
||||
*
|
||||
* @param registerToken token from register.
|
||||
* @param deviceId deviceid.
|
||||
* @param deviceId deviceId.
|
||||
* @param status device status.
|
||||
*/
|
||||
virtual bool UpdateConnectStatus(int registerToken, const std::string &deviceId, int status) = 0;
|
||||
|
@ -25,6 +25,7 @@ enum class ProcessMode {
|
||||
NEW_PROCESS_ATTACH_TO_PARENT = 1,
|
||||
NEW_PROCESS_ATTACH_TO_STATUS_BAR_ITEM = 2,
|
||||
ATTACH_TO_STATUS_BAR_ITEM = 3,
|
||||
NO_ATTACHMENT = 99,
|
||||
END
|
||||
};
|
||||
|
||||
@ -49,6 +50,7 @@ public:
|
||||
static bool IsNewProcessMode(ProcessMode value);
|
||||
static bool IsAttachToStatusBarMode(ProcessMode value);
|
||||
static bool IsValidProcessMode(ProcessMode value);
|
||||
static bool IsNoAttachmentMode(ProcessMode value);
|
||||
|
||||
ProcessMode processMode = ProcessMode::UNSPECIFIED;
|
||||
StartupVisibility startupVisibility = StartupVisibility::UNSPECIFIED;
|
||||
|
@ -151,7 +151,6 @@ ohos_shared_library("app_manager") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"image_framework:image_native",
|
||||
"relational_store:native_rdb",
|
||||
"skia:skia_canvaskit",
|
||||
]
|
||||
|
||||
if (background_task_mgr_continuous_task_enable) {
|
||||
|
@ -103,8 +103,19 @@ public:
|
||||
*/
|
||||
virtual void KillProcessesByUserId(int32_t userId) = 0;
|
||||
|
||||
/**
|
||||
* KillProcessesByPids, only in process call is allowed,
|
||||
* kill the processes by pid list given.
|
||||
*
|
||||
* @param pids, the pid list of processes are going to be killed.
|
||||
*/
|
||||
virtual void KillProcessesByPids(std::vector<int32_t> &pids) {}
|
||||
|
||||
/**
|
||||
* Set child and parent relationship
|
||||
* @param token child process
|
||||
* @param callerToken parent process
|
||||
*/
|
||||
virtual void AttachPidToParent(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &callerToken) {}
|
||||
|
||||
/**
|
||||
@ -174,23 +185,73 @@ public:
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ability attach timeout. If start ability encounter failure, attach timeout to terminate.
|
||||
*
|
||||
* @param token Ability identify.
|
||||
*/
|
||||
virtual void AbilityAttachTimeOut(const sptr<IRemoteObject> &token) = 0;
|
||||
|
||||
/**
|
||||
* Prepare terminate.
|
||||
*
|
||||
* @param token Ability identify.
|
||||
* @param clearMissionFlag Clear mission flag.
|
||||
*/
|
||||
virtual void PrepareTerminate(const sptr<IRemoteObject> &token, bool clearMissionFlag = false) = 0;
|
||||
|
||||
/**
|
||||
* Get running process information by ability token.
|
||||
*
|
||||
* @param token Ability identify.
|
||||
* @param info Running process info.
|
||||
*/
|
||||
virtual void GetRunningProcessInfoByToken(
|
||||
const sptr<IRemoteObject> &token, OHOS::AppExecFwk::RunningProcessInfo &info) = 0;
|
||||
|
||||
/**
|
||||
* Set AbilityForegroundingFlag of an app-record to true.
|
||||
*
|
||||
* @param pid, pid.
|
||||
*
|
||||
*/
|
||||
virtual void SetAbilityForegroundingFlagToAppRecord(const pid_t pid) = 0;
|
||||
|
||||
/**
|
||||
* Start specified ability.
|
||||
*
|
||||
* @param want Want contains information of the ability to start.
|
||||
* @param abilityInfo Ability information.
|
||||
* @param requestId request id to callback
|
||||
*/
|
||||
virtual void StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo,
|
||||
int32_t requestId = 0) = 0;
|
||||
|
||||
/**
|
||||
* Register response of start specified ability.
|
||||
*
|
||||
* @param response Response of start specified ability.
|
||||
*/
|
||||
virtual void RegisterStartSpecifiedAbilityResponse(const sptr<IStartSpecifiedAbilityResponse> &response) = 0;
|
||||
|
||||
/**
|
||||
* Start specified process.
|
||||
*
|
||||
* @param want Want contains information wish to start.
|
||||
* @param abilityInfo Ability information.
|
||||
* @param requestId for callback
|
||||
*/
|
||||
virtual void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo,
|
||||
int32_t requestId = 0) = 0;
|
||||
|
||||
/**
|
||||
* Get application info by process id.
|
||||
*
|
||||
* @param pid Process id.
|
||||
* @param application Application information got.
|
||||
* @param debug Whether IsDebugApp.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug) = 0;
|
||||
|
||||
/**
|
||||
@ -307,6 +368,7 @@ public:
|
||||
* @brief Set resident process enable status.
|
||||
* @param bundleName The application bundle name.
|
||||
* @param enable The current updated enable status.
|
||||
* @param uid indicates user, 0 for all users
|
||||
*/
|
||||
virtual void SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid) {};
|
||||
|
||||
@ -318,8 +380,8 @@ public:
|
||||
virtual void ClearProcessByToken(sptr<IRemoteObject> token) {}
|
||||
|
||||
/**
|
||||
* whether memory size is sufficent.
|
||||
* @return Returns true is sufficent memory size, others return false.
|
||||
* whether memory size is sufficient.
|
||||
* @return Returns true is sufficient memory size, others return false.
|
||||
*/
|
||||
virtual bool IsMemorySizeSufficent() = 0;
|
||||
|
||||
@ -368,6 +430,9 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a process is attached, refer to AttachApplication
|
||||
*/
|
||||
virtual bool IsProcessAttached(sptr<IRemoteObject> token)
|
||||
{
|
||||
return false;
|
||||
|
@ -93,8 +93,19 @@ public:
|
||||
*/
|
||||
virtual void KillProcessesByUserId(int32_t userId) override;
|
||||
|
||||
/**
|
||||
* KillProcessesByPids, only in process call is allowed,
|
||||
* kill the processes by pid list given.
|
||||
*
|
||||
* @param pids, the pid list of processes are going to be killed.
|
||||
*/
|
||||
virtual void KillProcessesByPids(std::vector<int32_t> &pids) override;
|
||||
|
||||
/**
|
||||
* Set child and parent relationship
|
||||
* @param token child process
|
||||
* @param callerToken parent process
|
||||
*/
|
||||
virtual void AttachPidToParent(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &callerToken) override;
|
||||
|
||||
/**
|
||||
@ -157,15 +168,47 @@ public:
|
||||
|
||||
virtual int KillApplicationSelf(const bool clearPageStack = false) override;
|
||||
|
||||
/**
|
||||
* Get application info by process id.
|
||||
*
|
||||
* @param pid Process id.
|
||||
* @param application Application information got.
|
||||
* @param debug Whether IsDebugApp.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application,
|
||||
bool &debug) override;
|
||||
|
||||
/**
|
||||
* Record process exit reason to appRunningRecord
|
||||
* @param pid pid
|
||||
* @param reason reason enum
|
||||
* @param exitMsg exitMsg
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t NotifyAppMgrRecordExitReason(int32_t pid, int32_t reason, const std::string &exitMsg) override;
|
||||
|
||||
/**
|
||||
* Ability attach timeout. If start ability encounter failure, attach timeout to terminate.
|
||||
*
|
||||
* @param token Ability identify.
|
||||
*/
|
||||
virtual void AbilityAttachTimeOut(const sptr<IRemoteObject> &token) override;
|
||||
|
||||
/**
|
||||
* Prepare terminate.
|
||||
*
|
||||
* @param token Ability identify.
|
||||
* @param clearMissionFlag Clear mission flag.
|
||||
*/
|
||||
virtual void PrepareTerminate(const sptr<IRemoteObject> &token, bool clearMissionFlag = false) override;
|
||||
|
||||
/**
|
||||
* Get running process information by ability token.
|
||||
*
|
||||
* @param token Ability identify.
|
||||
* @param info Running process info.
|
||||
*/
|
||||
void GetRunningProcessInfoByToken(const sptr<IRemoteObject> &token, AppExecFwk::RunningProcessInfo &info) override;
|
||||
|
||||
/**
|
||||
@ -176,11 +219,30 @@ public:
|
||||
*/
|
||||
void SetAbilityForegroundingFlagToAppRecord(const pid_t pid) override;
|
||||
|
||||
/**
|
||||
* Start specified ability.
|
||||
*
|
||||
* @param want Want contains information of the ability to start.
|
||||
* @param abilityInfo Ability information.
|
||||
* @param requestId request id to callback
|
||||
*/
|
||||
virtual void StartSpecifiedAbility(
|
||||
const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo, int32_t requestId = 0) override;
|
||||
|
||||
/**
|
||||
* Register response of start specified ability.
|
||||
*
|
||||
* @param response Response of start specified ability.
|
||||
*/
|
||||
virtual void RegisterStartSpecifiedAbilityResponse(const sptr<IStartSpecifiedAbilityResponse> &response) override;
|
||||
|
||||
/**
|
||||
* Start specified process.
|
||||
*
|
||||
* @param want Want contains information wish to start.
|
||||
* @param abilityInfo Ability information.
|
||||
* @param requestId for callback
|
||||
*/
|
||||
virtual void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo,
|
||||
int32_t requestId = 0) override;
|
||||
|
||||
@ -268,6 +330,7 @@ public:
|
||||
* @brief Set resident process enable status.
|
||||
* @param bundleName The application bundle name.
|
||||
* @param enable The current updated enable status.
|
||||
* @param uid indicates user, 0 for all users
|
||||
*/
|
||||
void SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid) override;
|
||||
|
||||
@ -279,8 +342,8 @@ public:
|
||||
virtual void ClearProcessByToken(sptr<IRemoteObject> token) override;
|
||||
|
||||
/**
|
||||
* whether memory size is sufficent.
|
||||
* @return Returns true is sufficent memory size, others return false.
|
||||
* whether memory size is sufficient.
|
||||
* @return Returns true is sufficient memory size, others return false.
|
||||
*/
|
||||
virtual bool IsMemorySizeSufficent() override;
|
||||
|
||||
@ -320,6 +383,9 @@ public:
|
||||
*/
|
||||
virtual bool IsProcessContainsOnlyUIAbility(const pid_t pid) override;
|
||||
|
||||
/**
|
||||
* Whether a process is attached, refer to AttachApplication
|
||||
*/
|
||||
virtual bool IsProcessAttached(sptr<IRemoteObject> token) override;
|
||||
|
||||
virtual bool IsAppKilling(sptr<IRemoteObject> token) override;
|
||||
|
@ -126,8 +126,19 @@ public:
|
||||
*/
|
||||
virtual AppMgrResultCode KillProcessesByUserId(int32_t userId);
|
||||
|
||||
/**
|
||||
* KillProcessesByPids, only in process call is allowed,
|
||||
* kill the processes by pid list given.
|
||||
*
|
||||
* @param pids, the pid list of processes are going to be killed.
|
||||
*/
|
||||
virtual AppMgrResultCode KillProcessesByPids(std::vector<int32_t> &pids);
|
||||
|
||||
/**
|
||||
* Set child and parent relationship
|
||||
* @param token child process
|
||||
* @param callerToken parent process
|
||||
*/
|
||||
virtual AppMgrResultCode AttachPidToParent(const sptr<IRemoteObject> &token,
|
||||
const sptr<IRemoteObject> &callerToken);
|
||||
|
||||
@ -236,10 +247,10 @@ public:
|
||||
|
||||
/**
|
||||
* GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project.
|
||||
* Obtains running isntance keys of multi-instance app that are running on the device.
|
||||
* Obtains running instance keys of multi-instance app that are running on the device.
|
||||
*
|
||||
* @param bundlename, bundle name in Application record.
|
||||
* @param instanceKeys, output instance keys of the multi-insatnce app.
|
||||
* @param instanceKeys, output instance keys of the multi-instance app.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual AppMgrResultCode GetAllRunningInstanceKeysByBundleName(const std::string &bundleName,
|
||||
@ -303,7 +314,7 @@ public:
|
||||
/**
|
||||
* GetConfiguration
|
||||
*
|
||||
* @param info, configuration.
|
||||
* @param info to retrieve configuration data.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual AppMgrResultCode GetConfiguration(Configuration& config);
|
||||
@ -362,7 +373,7 @@ public:
|
||||
/**
|
||||
* Update config by bundle name.
|
||||
*
|
||||
* @param config Application enviroment change parameters.
|
||||
* @param config Application environment change parameters.
|
||||
* @param name Application bundle name.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
@ -403,8 +414,9 @@ public:
|
||||
/**
|
||||
* Start specified ability.
|
||||
*
|
||||
* @param want Want contains information wish to start.
|
||||
* @param want Want contains information of the ability to start.
|
||||
* @param abilityInfo Ability information.
|
||||
* @param requestId request id to callback
|
||||
*/
|
||||
virtual void StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo,
|
||||
int32_t requestId = 0);
|
||||
@ -421,6 +433,7 @@ public:
|
||||
*
|
||||
* @param want Want contains information wish to start.
|
||||
* @param abilityInfo Ability information.
|
||||
* @param requestId for callback
|
||||
*/
|
||||
virtual void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo,
|
||||
int32_t requestId = 0);
|
||||
@ -453,10 +466,10 @@ public:
|
||||
/**
|
||||
* Start nweb render process, called by nweb host.
|
||||
*
|
||||
* @param renderParam, params passed to renderprocess.
|
||||
* @param ipcFd, ipc file descriptior for web browser and render process.
|
||||
* @param sharedFd, shared memory file descriptior.
|
||||
* @param crashFd, crash signal file descriptior.
|
||||
* @param renderParam, params passed to renderProcess.
|
||||
* @param ipcFd, ipc file descriptor for web browser and render process.
|
||||
* @param sharedFd, shared memory file descriptor.
|
||||
* @param crashFd, crash signal file descriptor.
|
||||
* @param renderPid, created render pid.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
@ -465,7 +478,7 @@ public:
|
||||
int32_t crashFd, pid_t &renderPid, bool isGPU = false);
|
||||
|
||||
/**
|
||||
* Render process call this to attach app manager service.
|
||||
* Render process call this to attach to app manager service.
|
||||
*
|
||||
* @param renderScheduler, scheduler of render process.
|
||||
*/
|
||||
@ -491,12 +504,9 @@ public:
|
||||
int GetApplicationInfoByProcessID(const int pid, AppExecFwk::ApplicationInfo &application, bool &debug);
|
||||
|
||||
/**
|
||||
* Get application info by process id.
|
||||
* start native process for debugger.
|
||||
*
|
||||
* @param pid Process id.
|
||||
* @param application Application information got.
|
||||
* @param debug Whether IsDebugApp.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
* @param want param to start a process.
|
||||
*/
|
||||
int32_t StartNativeProcessForDebugger(const AAFwk::Want &want);
|
||||
|
||||
@ -646,6 +656,7 @@ public:
|
||||
* @brief Set resident process enable status.
|
||||
* @param bundleName The application bundle name.
|
||||
* @param enable The current updated enable status.
|
||||
* @param uid indicates user, 0 for all users
|
||||
*/
|
||||
void SetKeepAliveEnableState(const std::string &bundleName, bool enable, int32_t uid);
|
||||
|
||||
@ -711,12 +722,34 @@ public:
|
||||
*/
|
||||
bool IsFinalAppProcess();
|
||||
|
||||
/**
|
||||
* Register render state observer.
|
||||
* @param observer Render process state observer.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t RegisterRenderStateObserver(const sptr<IRenderStateObserver> &observer);
|
||||
|
||||
/**
|
||||
* Unregister render state observer.
|
||||
* @param observer Render process state observer.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t UnregisterRenderStateObserver(const sptr<IRenderStateObserver> &observer);
|
||||
|
||||
/**
|
||||
* Update render state.
|
||||
* @param renderPid Render pid.
|
||||
* @param state foreground or background state.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t UpdateRenderState(pid_t renderPid, int32_t state);
|
||||
|
||||
/**
|
||||
* Get appRunningUniqueId by pid.
|
||||
* @param pid pid.
|
||||
* @param appRunningUniqueId appRunningUniqueId.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t GetAppRunningUniqueIdByPid(pid_t pid, std::string &appRunningUniqueId);
|
||||
|
||||
/**
|
||||
@ -738,15 +771,15 @@ public:
|
||||
int32_t GetAllUIExtensionProviderPid(pid_t hostPid, std::vector<pid_t> &providerPids);
|
||||
|
||||
/**
|
||||
* @brief Notify memory size state changed to sufficient or insufficent.
|
||||
* @param isMemorySizeSufficent Indicates the memory size state.
|
||||
* @brief Notify memory size state changed to sufficient or insufficient.
|
||||
* @param isMemorySizeSufficient Indicates the memory size state.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent);
|
||||
int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficient);
|
||||
|
||||
/**
|
||||
* whether memory size is sufficent.
|
||||
* @return Returns true is sufficent memory size, others return false.
|
||||
* whether memory size is sufficient.
|
||||
* @return Returns true is sufficient memory size, others return false.
|
||||
*/
|
||||
bool IsMemorySizeSufficent() const;
|
||||
|
||||
@ -771,10 +804,16 @@ public:
|
||||
virtual int32_t PreloadApplication(const std::string &bundleName, int32_t userId,
|
||||
AppExecFwk::PreloadMode preloadMode, int32_t appIndex = 0);
|
||||
|
||||
/**
|
||||
* @brief set support process cache by self
|
||||
*/
|
||||
int32_t SetSupportedProcessCacheSelf(bool isSupport);
|
||||
|
||||
int32_t SetSupportedProcessCache(int32_t pid, bool isSupport);
|
||||
|
||||
/**
|
||||
* set browser channel for caller
|
||||
*/
|
||||
void SaveBrowserChannel(sptr<IRemoteObject> browser);
|
||||
|
||||
/**
|
||||
@ -793,8 +832,14 @@ public:
|
||||
*/
|
||||
virtual AppMgrResultCode AttachedToStatusBar(const sptr<IRemoteObject> &token);
|
||||
|
||||
/**
|
||||
* Notify that the process depends on web by itself.
|
||||
*/
|
||||
int32_t NotifyProcessDependedOnWeb();
|
||||
|
||||
/**
|
||||
* Kill process depended on web by sa.
|
||||
*/
|
||||
void KillProcessDependedOnWeb();
|
||||
|
||||
/**
|
||||
@ -826,6 +871,9 @@ public:
|
||||
*/
|
||||
bool IsProcessContainsOnlyUIAbility(const pid_t pid);
|
||||
|
||||
/**
|
||||
* Whether a process is attached, refer to AttachApplication
|
||||
*/
|
||||
bool IsProcessAttached(sptr<IRemoteObject> token) const;
|
||||
|
||||
bool IsAppKilling(sptr<IRemoteObject> token) const;
|
||||
|
@ -160,10 +160,10 @@ public:
|
||||
|
||||
/**
|
||||
* GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project.
|
||||
* Obtains running isntance keys of multi-instance app that are running on the device.
|
||||
* Obtains running instance keys of multi-instance app that are running on the device.
|
||||
*
|
||||
* @param bundlename, bundle name in Application record.
|
||||
* @param instanceKeys, output instance keys of the multi-insatnce app.
|
||||
* @param instanceKeys, output instance keys of the multi-instance app.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual int32_t GetAllRunningInstanceKeysByBundleName(const std::string &bundleName,
|
||||
@ -332,6 +332,13 @@ public:
|
||||
*/
|
||||
virtual int FinishUserTest(const std::string &msg, const int64_t &resultCode, const std::string &bundleName) = 0;
|
||||
|
||||
/**
|
||||
* Schedule accept want done.
|
||||
*
|
||||
* @param recordId Application record.
|
||||
* @param want Want.
|
||||
* @param flag flag get from OnAcceptWant.
|
||||
*/
|
||||
virtual void ScheduleAcceptWantDone(const int32_t recordId, const AAFwk::Want &want, const std::string &flag) = 0;
|
||||
|
||||
virtual void ScheduleNewProcessRequestDone(const int32_t recordId, const AAFwk::Want &want,
|
||||
@ -356,10 +363,10 @@ public:
|
||||
/**
|
||||
* Start nweb render process, called by nweb host.
|
||||
*
|
||||
* @param renderParam, params passed to renderprocess.
|
||||
* @param ipcFd, ipc file descriptior for web browser and render process.
|
||||
* @param sharedFd, shared memory file descriptior.
|
||||
* @param crashFd, crash signal file descriptior.
|
||||
* @param renderParam, params passed to renderProcess.
|
||||
* @param ipcFd, ipc file descriptor for web browser and render process.
|
||||
* @param sharedFd, shared memory file descriptor.
|
||||
* @param crashFd, crash signal file descriptor.
|
||||
* @param renderPid, created render pid.
|
||||
* @param isGPU, is or not gpu process
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
@ -384,14 +391,46 @@ public:
|
||||
*/
|
||||
virtual int GetRenderProcessTerminationStatus(pid_t renderPid, int &status) = 0;
|
||||
|
||||
/**
|
||||
* GetConfiguration
|
||||
*
|
||||
* @param info to retrieve configuration data.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual int32_t GetConfiguration(Configuration& config) = 0;
|
||||
|
||||
/**
|
||||
* UpdateConfiguration, ANotify application update system environment changes.
|
||||
*
|
||||
* @param config System environment change parameters.
|
||||
* @param userId configuration for the user
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t UpdateConfiguration(const Configuration &config, const int32_t userId = -1) = 0;
|
||||
|
||||
/**
|
||||
* Update config by bundle name.
|
||||
*
|
||||
* @param config Application environment change parameters.
|
||||
* @param name Application bundle name.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t UpdateConfigurationByBundleName(const Configuration &config, const std::string &name) = 0;
|
||||
|
||||
/**
|
||||
* Register configuration observer.
|
||||
*
|
||||
* @param observer Configuration observer. When configuration changed, observer will be called.
|
||||
* @return Returns RESULT_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t RegisterConfigurationObserver(const sptr<IConfigurationObserver> &observer) = 0;
|
||||
|
||||
/**
|
||||
* Unregister configuration observer.
|
||||
*
|
||||
* @param observer Configuration observer.
|
||||
* @return Returns RESULT_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t UnregisterConfigurationObserver(const sptr<IConfigurationObserver> &observer) = 0;
|
||||
|
||||
/**
|
||||
@ -407,7 +446,7 @@ public:
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @param callback called when LoadPatch finished.
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
* @return Returns ERR_OK on success, error code on failure.
|
||||
*/
|
||||
virtual int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) = 0;
|
||||
|
||||
@ -416,7 +455,7 @@ public:
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @param callback called when HotReload finished.
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
* @return Returns ERR_OK on success, error code on failure.
|
||||
*/
|
||||
virtual int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) = 0;
|
||||
|
||||
@ -425,7 +464,7 @@ public:
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @param callback called when UnloadPatch finished.
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
* @return Returns ERR_OK on success, error code on failure.
|
||||
*/
|
||||
virtual int32_t NotifyUnLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) = 0;
|
||||
|
||||
@ -476,6 +515,11 @@ public:
|
||||
*/
|
||||
virtual bool IsSharedBundleRunning(const std::string &bundleName, uint32_t versionCode) = 0;
|
||||
|
||||
/**
|
||||
* start native process for debugger.
|
||||
*
|
||||
* @param want param to start a process.
|
||||
*/
|
||||
virtual int32_t StartNativeProcessForDebugger(const AAFwk::Want &want) = 0;
|
||||
|
||||
/**
|
||||
@ -673,6 +717,12 @@ public:
|
||||
*/
|
||||
virtual int32_t UpdateRenderState(pid_t renderPid, int32_t state) = 0;
|
||||
|
||||
/**
|
||||
* @brief mark a process which is going restart.
|
||||
* @param bundleName the bundleName of the process.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t SignRestartAppFlag(const std::string &bundleName)
|
||||
{
|
||||
return 0;
|
||||
@ -694,7 +744,7 @@ public:
|
||||
* If specified pid mismatch UIExtensionAbility type, return empty vector.
|
||||
* @param pid Process id.
|
||||
* @param hostPids All host process id.
|
||||
* @return Returns 0 on success, others on failure.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t GetAllUIExtensionRootHostPid(pid_t pid, std::vector<pid_t> &hostPids)
|
||||
{
|
||||
@ -706,7 +756,7 @@ public:
|
||||
* If specified hostPid didn't start any UIExtensionAbility, return empty vector.
|
||||
* @param hostPid Host process id.
|
||||
* @param providerPids All provider process id started by specified hostPid.
|
||||
* @return Returns 0 on success, others on failure.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t GetAllUIExtensionProviderPid(pid_t hostPid, std::vector<pid_t> &providerPids)
|
||||
{
|
||||
@ -714,17 +764,20 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Notify memory size state changed to sufficient or insufficent.
|
||||
* @param isMemorySizeSufficent Indicates the memory size state.
|
||||
* @brief Notify memory size state changed to sufficient or insufficient.
|
||||
* @param isMemorySizeSufficient Indicates the memory size state.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent)
|
||||
virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficient)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief set support process cache by self
|
||||
*/
|
||||
virtual int32_t SetSupportedProcessCacheSelf(bool isSupport) = 0;
|
||||
|
||||
|
||||
virtual int32_t SetSupportedProcessCache(int32_t pid, bool isSupport) = 0;
|
||||
|
||||
/**
|
||||
@ -744,6 +797,9 @@ public:
|
||||
virtual int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount,
|
||||
const sptr<IRemoteObject> &callback) = 0;
|
||||
|
||||
/**
|
||||
* set browser channel for caller
|
||||
*/
|
||||
virtual void SaveBrowserChannel(sptr<IRemoteObject> browser) = 0;
|
||||
|
||||
/**
|
||||
|
@ -137,10 +137,10 @@ public:
|
||||
|
||||
/**
|
||||
* GetAllRunningInstanceKeysByBundleName, call GetAllRunningInstanceKeysByBundleName() through proxy project.
|
||||
* Obtains running isntance keys of multi-instance app that are running on the device.
|
||||
* Obtains running instance keys of multi-instance app that are running on the device.
|
||||
*
|
||||
* @param bundlename, bundle name in Application record.
|
||||
* @param instanceKeys, output instance keys of the multi-insatnce app.
|
||||
* @param instanceKeys, output instance keys of the multi-instance app.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
virtual int32_t GetAllRunningInstanceKeysByBundleName(const std::string &bundleName,
|
||||
@ -309,6 +309,13 @@ public:
|
||||
virtual int FinishUserTest(
|
||||
const std::string &msg, const int64_t &resultCode, const std::string &bundleName) override;
|
||||
|
||||
/**
|
||||
* Schedule accept want done.
|
||||
*
|
||||
* @param recordId Application record.
|
||||
* @param want Want.
|
||||
* @param flag flag get from OnAcceptWant.
|
||||
*/
|
||||
virtual void ScheduleAcceptWantDone(
|
||||
const int32_t recordId, const AAFwk::Want &want, const std::string &flag) override;
|
||||
|
||||
@ -334,10 +341,10 @@ public:
|
||||
/**
|
||||
* Start nweb render process, called by nweb host.
|
||||
*
|
||||
* @param renderParam, params passed to renderprocess.
|
||||
* @param ipcFd, ipc file descriptior for web browser and render process.
|
||||
* @param sharedFd, shared memory file descriptior.
|
||||
* @param crashFd, crash signal file descriptior.
|
||||
* @param renderParam, params passed to renderProcess.
|
||||
* @param ipcFd, ipc file descriptor for web browser and render process.
|
||||
* @param sharedFd, shared memory file descriptor.
|
||||
* @param crashFd, crash signal file descriptor.
|
||||
* @param renderPid, created render pid.
|
||||
* @param isGPU, is or not GPU process
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
@ -396,8 +403,21 @@ public:
|
||||
|
||||
virtual int32_t UnregisterConfigurationObserver(const sptr<IConfigurationObserver> &observer) override;
|
||||
|
||||
/**
|
||||
* @brief Get the running state of application by bundle name.
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @return Returns true if process is running, false if process isn't running.
|
||||
*/
|
||||
bool GetAppRunningStateByBundleName(const std::string &bundleName) override;
|
||||
|
||||
/**
|
||||
* @brief Notify application load patch.
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @param callback called when LoadPatch finished.
|
||||
* @return Returns ERR_OK on success, error code on failure.
|
||||
*/
|
||||
int32_t NotifyLoadRepairPatch(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override;
|
||||
|
||||
int32_t NotifyHotReloadPage(const std::string &bundleName, const sptr<IQuickFixCallback> &callback) override;
|
||||
@ -417,6 +437,11 @@ public:
|
||||
*/
|
||||
virtual bool IsSharedBundleRunning(const std::string &bundleName, uint32_t versionCode) override;
|
||||
|
||||
/**
|
||||
* start native process for debugger.
|
||||
*
|
||||
* @param want param to start a process.
|
||||
*/
|
||||
virtual int32_t StartNativeProcessForDebugger(const AAFwk::Want &want) override;
|
||||
|
||||
/**
|
||||
@ -603,8 +628,20 @@ public:
|
||||
*/
|
||||
virtual int32_t UpdateRenderState(pid_t renderPid, int32_t state) override;
|
||||
|
||||
/**
|
||||
* @brief mark a process which is going restart.
|
||||
* @param bundleName the bundleName of the process.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t SignRestartAppFlag(const std::string &bundleName) override;
|
||||
|
||||
/**
|
||||
* Get appRunningUniqueId by pid.
|
||||
* @param pid pid.
|
||||
* @param appRunningUniqueId appRunningUniqueId.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t GetAppRunningUniqueIdByPid(pid_t pid, std::string &appRunningUniqueId) override;
|
||||
|
||||
/*
|
||||
@ -626,11 +663,11 @@ public:
|
||||
int32_t GetAllUIExtensionProviderPid(pid_t hostPid, std::vector<pid_t> &providerPids) override;
|
||||
|
||||
/**
|
||||
* @brief Notify memory size state changed to sufficient or insufficent.
|
||||
* @param isMemorySizeSufficent Indicates the memory size state.
|
||||
* @brief Notify memory size state changed to sufficient or insufficient.
|
||||
* @param isMemorySizeSufficient Indicates the memory size state.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) override;
|
||||
virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficient) override;
|
||||
|
||||
/**
|
||||
* Set application assertion pause state.
|
||||
@ -639,10 +676,16 @@ public:
|
||||
*/
|
||||
void SetAppAssertionPauseState(bool flag) override;
|
||||
|
||||
/**
|
||||
* @brief set support process cache by self
|
||||
*/
|
||||
int32_t SetSupportedProcessCacheSelf(bool isSupport) override;
|
||||
|
||||
int32_t SetSupportedProcessCache(int32_t pid, bool isSupport) override;
|
||||
|
||||
/**
|
||||
* set browser channel for caller
|
||||
*/
|
||||
virtual void SaveBrowserChannel(sptr<IRemoteObject> browser) override;
|
||||
|
||||
/**
|
||||
@ -663,10 +706,19 @@ public:
|
||||
int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount,
|
||||
const sptr<IRemoteObject> &callback) override;
|
||||
|
||||
/**
|
||||
* Notify that the process depends on web by itself.
|
||||
*/
|
||||
virtual int32_t NotifyProcessDependedOnWeb() override;
|
||||
|
||||
/**
|
||||
* Kill process depended on web by sa.
|
||||
*/
|
||||
virtual void KillProcessDependedOnWeb() override;
|
||||
|
||||
/**
|
||||
* Restart resident process depended on web.
|
||||
*/
|
||||
virtual void RestartResidentProcessDependedOnWeb() override;
|
||||
|
||||
/**
|
||||
|
@ -134,6 +134,14 @@ public:
|
||||
*/
|
||||
virtual void ScheduleAbilityStage(const HapModuleInfo &) = 0;
|
||||
|
||||
/**
|
||||
* Notify application to launch ability.
|
||||
*
|
||||
* @param ability The ability info.
|
||||
* @param token The ability token.
|
||||
* @param want The want to start the ability.
|
||||
* @param token The ability token.
|
||||
*/
|
||||
virtual void ScheduleLaunchAbility(const AbilityInfo &, const sptr<IRemoteObject> &,
|
||||
const std::shared_ptr<AAFwk::Want> &want, int32_t abilityRecordId) = 0;
|
||||
|
||||
@ -172,8 +180,19 @@ public:
|
||||
*/
|
||||
virtual void ScheduleProcessSecurityExit() = 0;
|
||||
|
||||
/**
|
||||
* scheduleClearPageStack, call scheduleClearPageStack() through proxy project,
|
||||
* Notify application clear recovery page stack.
|
||||
*
|
||||
*/
|
||||
virtual void ScheduleClearPageStack() = 0;
|
||||
|
||||
/**
|
||||
* @brief Schedule the given module the onAcceptWant lifecycle call.
|
||||
*
|
||||
* @param want the param passed to onAcceptWant lifecycle.
|
||||
* @param want the moduleName of which being scheduled.
|
||||
*/
|
||||
virtual void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) = 0;
|
||||
|
||||
virtual void ScheduleNewProcessRequest(const AAFwk::Want &want, const std::string &moduleName) = 0;
|
||||
@ -183,6 +202,7 @@ public:
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @param callback called when LoadPatch finished.
|
||||
* @param recordId callback data
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
*/
|
||||
virtual int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName,
|
||||
@ -192,6 +212,7 @@ public:
|
||||
* @brief Notify application reload page.
|
||||
*
|
||||
* @param callback called when HotReload finished.
|
||||
* @param recordId callback data
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
*/
|
||||
virtual int32_t ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback, const int32_t recordId) = 0;
|
||||
@ -201,6 +222,7 @@ public:
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @param callback called when UnloadPatch finished.
|
||||
* @param recordId callback data
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
*/
|
||||
virtual int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName,
|
||||
@ -264,6 +286,11 @@ public:
|
||||
*/
|
||||
virtual int32_t ScheduleDumpIpcStat(std::string& result) = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Notify application to prepare for process caching.
|
||||
*
|
||||
*/
|
||||
virtual void ScheduleCacheProcess() = 0;
|
||||
|
||||
/**
|
||||
|
@ -173,25 +173,80 @@ public:
|
||||
*/
|
||||
virtual void ScheduleProcessSecurityExit() override;
|
||||
|
||||
/**
|
||||
* scheduleClearPageStack, call scheduleClearPageStack() through proxy project,
|
||||
* Notify application clear recovery page stack.
|
||||
*
|
||||
*/
|
||||
virtual void ScheduleClearPageStack() override;
|
||||
|
||||
/**
|
||||
* @brief Schedule the given module the onAcceptWant lifecycle call.
|
||||
*
|
||||
* @param want the param passed to onAcceptWant lifecycle.
|
||||
* @param want the moduleName of which being scheduled.
|
||||
*/
|
||||
virtual void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) override;
|
||||
|
||||
virtual void ScheduleNewProcessRequest(const AAFwk::Want &want, const std::string &moduleName) override;
|
||||
|
||||
/**
|
||||
* @brief Notify application load patch.
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @param callback called when LoadPatch finished.
|
||||
* @param recordId callback data
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
*/
|
||||
int32_t ScheduleNotifyLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback, const int32_t recordId) override;
|
||||
|
||||
/**
|
||||
* @brief Notify application reload page.
|
||||
*
|
||||
* @param callback called when HotReload finished.
|
||||
* @param recordId callback data
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
*/
|
||||
int32_t ScheduleNotifyHotReloadPage(const sptr<IQuickFixCallback> &callback, const int32_t recordId) override;
|
||||
|
||||
/**
|
||||
* @brief Notify application unload patch.
|
||||
*
|
||||
* @param bundleName Bundle name
|
||||
* @param callback called when UnloadPatch finished.
|
||||
* @param recordId callback data
|
||||
* @return Returns 0 on success, error code on failure.
|
||||
*/
|
||||
int32_t ScheduleNotifyUnLoadRepairPatch(const std::string &bundleName,
|
||||
const sptr<IQuickFixCallback> &callback, const int32_t recordId) override;
|
||||
|
||||
/**
|
||||
* @brief Schedule Notify App Fault Data.
|
||||
*
|
||||
* @param faultData fault data
|
||||
* @return Returns ERR_OK on success, error code on failure.
|
||||
*/
|
||||
int32_t ScheduleNotifyAppFault(const FaultData &faultData) override;
|
||||
|
||||
/**
|
||||
* @brief Notify NativeEngine GC of status change.
|
||||
*
|
||||
* @param state GC state
|
||||
* @param pid pid
|
||||
*
|
||||
* @return Is the status change completed.
|
||||
*/
|
||||
virtual int32_t ScheduleChangeAppGcState(int32_t state) override;
|
||||
|
||||
/**
|
||||
* @brief Attach app debug.
|
||||
*/
|
||||
void AttachAppDebug() override;
|
||||
|
||||
/**
|
||||
* @brief Detach app debug.
|
||||
*/
|
||||
void DetachAppDebug() override;
|
||||
|
||||
/**
|
||||
@ -224,6 +279,9 @@ public:
|
||||
*/
|
||||
virtual int32_t ScheduleDumpIpcStat(std::string& result) override;
|
||||
|
||||
/**
|
||||
* @brief Notify application to prepare for process caching.
|
||||
*/
|
||||
virtual void ScheduleCacheProcess() override;
|
||||
|
||||
/**
|
||||
|
@ -100,6 +100,11 @@ public:
|
||||
*/
|
||||
virtual void OnAppStateChanged(const AppStateData &appStateData) override;
|
||||
|
||||
/**
|
||||
* Called when one process is reused.
|
||||
*
|
||||
* @param processData Process data.
|
||||
*/
|
||||
virtual void OnProcessReused(const ProcessData &processData) override;
|
||||
|
||||
/**
|
||||
|
@ -101,6 +101,11 @@ public:
|
||||
*/
|
||||
virtual void OnAppStateChanged(const AppStateData &appStateData) {}
|
||||
|
||||
/**
|
||||
* Called when one process is reused.
|
||||
*
|
||||
* @param processData Process data.
|
||||
*/
|
||||
virtual void OnProcessReused(const ProcessData &processData) {}
|
||||
|
||||
/**
|
||||
|
@ -31,9 +31,9 @@ public:
|
||||
/**
|
||||
* Notify Browser's fd to render process.
|
||||
*
|
||||
* @param ipcFd, ipc file descriptior for web browser and render process.
|
||||
* @param sharedFd, shared memory file descriptior.
|
||||
* @param crashFd, crash signal file descriptior.
|
||||
* @param ipcFd, ipc file descriptor for web browser and render process.
|
||||
* @param sharedFd, shared memory file descriptor.
|
||||
* @param crashFd, crash signal file descriptor.
|
||||
*/
|
||||
virtual void NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd,
|
||||
int32_t crashFd, sptr<IRemoteObject> browser) = 0;
|
||||
|
@ -25,6 +25,11 @@ class IRenderStateObserver : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.IRenderStateObserver");
|
||||
|
||||
/**
|
||||
* Called when one render process's state changes.
|
||||
*
|
||||
* @param renderStateData retrieved state data.
|
||||
*/
|
||||
virtual void OnRenderStateChanged(const RenderStateData &renderStateData) = 0;
|
||||
|
||||
enum {
|
||||
|
@ -26,8 +26,19 @@ class IStartSpecifiedAbilityResponse : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.startSpecifiedAbilityResponse");
|
||||
|
||||
/**
|
||||
* @brief called when the module's onAcceptWant done to notify ability mgr to continue
|
||||
* @param want request param being accepted
|
||||
* @param flag specified flag return by application
|
||||
* @param requestId a number represents a request
|
||||
*/
|
||||
virtual void OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag, int32_t requestId) = 0;
|
||||
|
||||
/**
|
||||
* @brief called when the module's onAcceptWant happens time out
|
||||
* @param want request param
|
||||
* @param requestId a number represents a request
|
||||
*/
|
||||
virtual void OnTimeoutResponse(const AAFwk::Want &want, int32_t requestId) = 0;
|
||||
|
||||
virtual void OnNewProcessRequestResponse(const AAFwk::Want &want, const std::string &flag,
|
||||
|
@ -35,9 +35,9 @@ public:
|
||||
/**
|
||||
* Notify Browser's fd to render process.
|
||||
*
|
||||
* @param ipcFd, ipc file descriptior for web browser and render process.
|
||||
* @param sharedFd, shared memory file descriptior.
|
||||
* @param crashFd, crash signal file descriptior.
|
||||
* @param ipcFd, ipc file descriptor for web browser and render process.
|
||||
* @param sharedFd, shared memory file descriptor.
|
||||
* @param crashFd, crash signal file descriptor.
|
||||
*/
|
||||
virtual void NotifyBrowserFd(int32_t ipcFd, int32_t sharedFd,
|
||||
int32_t crashFd, sptr<IRemoteObject> browser) override;
|
||||
|
@ -26,6 +26,11 @@ public:
|
||||
explicit RenderStateObserverProxy(const sptr<IRemoteObject> &impl);
|
||||
virtual ~RenderStateObserverProxy() = default;
|
||||
|
||||
/**
|
||||
* Called when one render process's state changes.
|
||||
*
|
||||
* @param renderStateData retrieved state data.
|
||||
*/
|
||||
virtual void OnRenderStateChanged(const RenderStateData &renderStateData) override;
|
||||
private:
|
||||
bool WriteInterfaceToken(MessageParcel &data);
|
||||
|
@ -25,9 +25,20 @@ public:
|
||||
explicit StartSpecifiedAbilityResponseProxy(const sptr<IRemoteObject> &impl);
|
||||
virtual ~StartSpecifiedAbilityResponseProxy() = default;
|
||||
|
||||
/**
|
||||
* @brief called when the module's onAcceptWant done to notify ability mgr to continue
|
||||
* @param want request param being accepted
|
||||
* @param flag specified flag return by application
|
||||
* @param requestId a number represents a request
|
||||
*/
|
||||
virtual void OnAcceptWantResponse(const AAFwk::Want &want, const std::string &flag,
|
||||
int32_t requestId) override;
|
||||
|
||||
/**
|
||||
* @brief called when the module's onAcceptWant happens time out
|
||||
* @param want request param
|
||||
* @param requestId a number represents a request
|
||||
*/
|
||||
virtual void OnTimeoutResponse(const AAFwk::Want &want, int32_t requestId) override;
|
||||
|
||||
virtual void OnNewProcessRequestResponse(const AAFwk::Want &want, const std::string &flag,
|
||||
|
@ -1197,14 +1197,14 @@ int32_t AppMgrClient::GetAllUIExtensionProviderPid(pid_t hostPid, std::vector<pi
|
||||
return service->GetAllUIExtensionProviderPid(hostPid, providerPids);
|
||||
}
|
||||
|
||||
int32_t AppMgrClient::NotifyMemorySizeStateChanged(bool isMemorySizeSufficent)
|
||||
int32_t AppMgrClient::NotifyMemorySizeStateChanged(bool isMemorySizeSufficient)
|
||||
{
|
||||
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
|
||||
if (service == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Service is nullptr.");
|
||||
return AppMgrResultCode::ERROR_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
return service->NotifyMemorySizeStateChanged(isMemorySizeSufficent);
|
||||
return service->NotifyMemorySizeStateChanged(isMemorySizeSufficient);
|
||||
}
|
||||
|
||||
bool AppMgrClient::IsMemorySizeSufficent() const
|
||||
|
@ -1826,13 +1826,13 @@ int32_t AppMgrProxy::GetAllUIExtensionProviderPid(pid_t hostPid, std::vector<pid
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AppMgrProxy::NotifyMemorySizeStateChanged(bool isMemorySizeSufficent)
|
||||
int32_t AppMgrProxy::NotifyMemorySizeStateChanged(bool isMemorySizeSufficient)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return ERR_INVALID_DATA;
|
||||
}
|
||||
PARCEL_UTIL_WRITE_RET_INT(data, Bool, isMemorySizeSufficent);
|
||||
PARCEL_UTIL_WRITE_RET_INT(data, Bool, isMemorySizeSufficient);
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
@ -1540,8 +1540,8 @@ int32_t AppMgrStub::HandleGetAllUIExtensionProviderPid(MessageParcel &data, Mess
|
||||
|
||||
int32_t AppMgrStub::HandleNotifyMemorySizeStateChanged(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
bool isMemorySizeSufficent = data.ReadBool();
|
||||
int result = NotifyMemorySizeStateChanged(isMemorySizeSufficent);
|
||||
bool isMemorySizeSufficient = data.ReadBool();
|
||||
int result = NotifyMemorySizeStateChanged(isMemorySizeSufficient);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write result error.");
|
||||
return ERR_INVALID_VALUE;
|
||||
|
@ -88,7 +88,7 @@ void AppStateCallbackProxy::NotifyConfigurationChange(const AppExecFwk::Configur
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Write interface token failed.");
|
||||
return;
|
||||
@ -112,7 +112,7 @@ void AppStateCallbackProxy::NotifyStartResidentProcess(std::vector<AppExecFwk::B
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed");
|
||||
return;
|
||||
@ -141,7 +141,7 @@ void AppStateCallbackProxy::OnAppRemoteDied(const std::vector<sptr<IRemoteObject
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed");
|
||||
return;
|
||||
@ -170,7 +170,7 @@ void AppStateCallbackProxy::NotifyAppPreCache(int32_t pid, int32_t userId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "WriteInterfaceToken failed");
|
||||
return;
|
||||
|
@ -29,10 +29,6 @@
|
||||
#endif
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class Ability;
|
||||
class AbilityHandler;
|
||||
class ApplicationImpl;
|
||||
class AbilityLocalRecord;
|
||||
class AbilityLifecycleCallbacks;
|
||||
class OHOSApplication;
|
||||
class AbilityImpl : public std::enable_shared_from_this<AbilityImpl> {
|
||||
@ -491,15 +487,6 @@ protected:
|
||||
std::mutex notifyForegroundLock_;
|
||||
|
||||
private:
|
||||
typedef enum {
|
||||
START,
|
||||
INACTIVE,
|
||||
ACTIVE,
|
||||
BACKGROUND,
|
||||
FOREGROUND,
|
||||
STOP,
|
||||
} Action;
|
||||
|
||||
std::shared_ptr<ApplicationImpl> applicationImpl_;
|
||||
std::shared_ptr<ContextDeal> contextDeal_;
|
||||
bool hasSaveData_ = false;
|
||||
|
@ -19,16 +19,13 @@
|
||||
#include <string>
|
||||
|
||||
#include "iremote_object.h"
|
||||
#include "event_runner.h"
|
||||
#include "ability_info.h"
|
||||
#include "application_info.h"
|
||||
#include "refbase.h"
|
||||
#include "want.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class AbilityThread;
|
||||
class AbilityImpl;
|
||||
class AbilityLocalRecord {
|
||||
public:
|
||||
/**
|
||||
@ -36,7 +33,8 @@ public:
|
||||
* default constructor
|
||||
*
|
||||
*/
|
||||
AbilityLocalRecord(const std::shared_ptr<AbilityInfo> &info, const sptr<IRemoteObject> &token);
|
||||
AbilityLocalRecord(const std::shared_ptr<AbilityInfo> &info, const sptr<IRemoteObject> &token,
|
||||
const std::shared_ptr<AAFwk::Want> &want, int32_t abilityRecordId);
|
||||
|
||||
/**
|
||||
*
|
||||
@ -52,48 +50,13 @@ public:
|
||||
*/
|
||||
const std::shared_ptr<AbilityInfo> &GetAbilityInfo();
|
||||
|
||||
/**
|
||||
* @description: Get an EventHandler in an ability.
|
||||
*
|
||||
* @return Returns a pointer to EventHandler
|
||||
*/
|
||||
const std::shared_ptr<EventHandler> &GetEventHandler();
|
||||
|
||||
/**
|
||||
* @description: Set an EventHandler in an ability.
|
||||
* @param handler EventHandler object
|
||||
* @return None.
|
||||
*/
|
||||
void SetEventHandler(const std::shared_ptr<EventHandler> &handler);
|
||||
|
||||
/**
|
||||
* @description: Get an EventRunner in an ability.
|
||||
*
|
||||
* @return Returns a pointer to EventRunner
|
||||
*/
|
||||
const std::shared_ptr<EventRunner> &GetEventRunner();
|
||||
|
||||
/**
|
||||
* @description: Set an EventRunner in an ability.
|
||||
* @param runner EventHandler object
|
||||
* @return None.
|
||||
*/
|
||||
void SetEventRunner(const std::shared_ptr<EventRunner> &runner);
|
||||
|
||||
/**
|
||||
* @description: Gets the identity of the ability
|
||||
* @return return the identity of the ability.
|
||||
*/
|
||||
const sptr<IRemoteObject> &GetToken();
|
||||
|
||||
int32_t GetAbilityRecordId() const
|
||||
{
|
||||
return abilityRecordId_;
|
||||
}
|
||||
void SetAbilityRecordId(int32_t abilityRecordId)
|
||||
{
|
||||
abilityRecordId_ = abilityRecordId;
|
||||
}
|
||||
int32_t GetAbilityRecordId() const;
|
||||
|
||||
/**
|
||||
* @description: Obtains the information based on ability thread.
|
||||
@ -113,14 +76,11 @@ public:
|
||||
const std::shared_ptr<AAFwk::Want> &GetWant();
|
||||
private:
|
||||
std::shared_ptr<AbilityInfo> abilityInfo_ = nullptr;
|
||||
sptr<IRemoteObject> token_;
|
||||
int32_t abilityRecordId_ = 0;
|
||||
std::shared_ptr<EventRunner> runner_ = nullptr;
|
||||
std::shared_ptr<EventHandler> handler_ = nullptr;
|
||||
std::shared_ptr<AbilityImpl> abilityImpl_ = nullptr; // store abilityImpl
|
||||
sptr<AbilityThread> abilityThread_;
|
||||
sptr<IRemoteObject> token_ = nullptr;
|
||||
std::shared_ptr<AAFwk::Want> want_ = nullptr;
|
||||
int32_t abilityRecordId_ = 0;
|
||||
sptr<AbilityThread> abilityThread_;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_ABILITY_LOCAL_RECORD_H
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_ABILITY_LOCAL_RECORD_H
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "ability_scheduler_stub.h"
|
||||
#include "context.h"
|
||||
#include "event_runner.h"
|
||||
#include "ohos_application.h"
|
||||
|
||||
namespace OHOS {
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
* notify continuation status to controlcenter continuation register service.
|
||||
*
|
||||
* @param token token from register.
|
||||
* @param deviceId deviceid.
|
||||
* @param deviceId deviceId.
|
||||
* @param status device status.
|
||||
* @param requestCallback callback for this request, -1 means failed, otherwise successed.
|
||||
*/
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
* notify continuation status to controlcenter continuation register service.
|
||||
*
|
||||
* @param registerToken token from register.
|
||||
* @param deviceId deviceid.
|
||||
* @param deviceId deviceId.
|
||||
* @param status device status.
|
||||
*/
|
||||
virtual bool UpdateConnectStatus(int registerToken, const std::string &deviceId, int status) override;
|
||||
|
@ -20,10 +20,6 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class Ability;
|
||||
class AbilityHandler;
|
||||
class AbilityLocalRecord;
|
||||
class AbilityImpl;
|
||||
class NewAbilityImpl final : public AbilityImpl {
|
||||
public:
|
||||
/**
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
ErrCode GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo, int32_t appIndex, int32_t userId,
|
||||
HapModuleInfo &hapModuleInfo);
|
||||
bool GetBundleInfo(const std::string &bundleName, int32_t flags, BundleInfo &bundleInfo, int32_t userId);
|
||||
std::string GetAppIdByBundleName(const std::string &bundleName, const int32_t userId);
|
||||
bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo);
|
||||
std::string GetAbilityLabel(const std::string &bundleName, const std::string &abilityName);
|
||||
std::string GetAppType(const std::string &bundleName);
|
||||
|
@ -28,14 +28,6 @@ public:
|
||||
AbilityRecordMgr() = default;
|
||||
~AbilityRecordMgr() = default;
|
||||
|
||||
/**
|
||||
* @brief Set the eventRunner of abilitythread to the AbilityRecordMgr.
|
||||
*
|
||||
* @param eventRunner The runner of the abilitythread.
|
||||
*
|
||||
*/
|
||||
void SetEventRunner(const std::shared_ptr<EventRunner> &eventRunner);
|
||||
|
||||
/**
|
||||
* @brief Get the token witch is set to the AbilityRecordMgr.
|
||||
*
|
||||
|
@ -42,7 +42,7 @@ private:
|
||||
int GetObsoleteBundleTempPath(const std::vector<std::string> &rootPath, std::vector<std::string> &tempPath);
|
||||
bool RemoveDir(const std::string &tempPath);
|
||||
void TraverseObsoleteTempDirectory(const std::string ¤tPath, std::vector<std::string> &tempDirs);
|
||||
bool CheckFileSize(const std::vector<std::string> bundlePath, const int64_t maxFileSize);
|
||||
bool CheckFileSize(const std::vector<std::string> &bundlePath);
|
||||
|
||||
private:
|
||||
std::shared_ptr<AbilityRuntime::ApplicationContext> context_ = nullptr;
|
||||
|
@ -674,7 +674,7 @@ private:
|
||||
void LoadAceAbilityLibrary();
|
||||
|
||||
void CalcNativeLiabraryEntries(const BundleInfo &bundleInfo, std::string &nativeLibraryPath);
|
||||
void LoadNativeLiabrary(const BundleInfo &bundleInfo, std::string &nativeLibraryPath);
|
||||
void LoadNativeLibrary(const BundleInfo &bundleInfo, std::string &nativeLibraryPath);
|
||||
|
||||
void LoadAppDetailAbilityLibrary(std::string &nativeLibraryPath);
|
||||
|
||||
|
@ -63,14 +63,12 @@ ohos_shared_library("libsrms") {
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
# "graphic_2d:2d_graphics",
|
||||
"hilog:libhilog",
|
||||
"image_framework:image_native",
|
||||
"ipc:ipc_single",
|
||||
"os_account:os_account_innerkits",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
# "skia:skia_canvaskit",
|
||||
]
|
||||
|
||||
defines = [ "ACCOUNT_ENABLE" ]
|
||||
|
@ -33,6 +33,7 @@ config("abilityms_config") {
|
||||
"include/",
|
||||
"include/data_ability",
|
||||
"include/dialog_session/",
|
||||
"include/mission/",
|
||||
"include/rdb/",
|
||||
"include/screen_lock/",
|
||||
"include/utils/",
|
||||
@ -111,6 +112,7 @@ ohos_shared_library("abilityms") {
|
||||
include_dirs = [
|
||||
"${ability_runtime_services_path}/appdfr/include",
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native/ui_service_extension_ability/connection",
|
||||
"${ability_runtime_services_path}/abilitymgr/include/mission",
|
||||
]
|
||||
deps = [
|
||||
":wantagent_manager",
|
||||
@ -156,7 +158,6 @@ ohos_shared_library("abilityms") {
|
||||
"dsoftbus:softbus_client",
|
||||
"eventhandler:libeventhandler",
|
||||
"ffrt:libffrt",
|
||||
# "graphic_2d:color_manager",
|
||||
"hicollie:libhicollie",
|
||||
"hilog:libhilog",
|
||||
"hisysevent:libhisysevent",
|
||||
@ -171,7 +172,6 @@ ohos_shared_library("abilityms") {
|
||||
"relational_store:native_appdatafwk",
|
||||
"relational_store:native_dataability",
|
||||
"relational_store:native_rdb",
|
||||
# "resource_management:global_resmgr",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
"window_manager:libmodal_system_ui_extension_client",
|
||||
@ -337,6 +337,7 @@ ohos_shared_library("mission_list") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper",
|
||||
"${ability_runtime_services_path}/abilitymgr/data_ability/include",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"${ability_runtime_services_path}/abilitymgr/include/mission",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
"${ability_runtime_services_path}/appdfr/include",
|
||||
"${ability_runtime_utils_path}/global/constant",
|
||||
@ -362,11 +363,11 @@ ohos_shared_library("mission_list") {
|
||||
}
|
||||
|
||||
sources = [
|
||||
"src/mission.cpp",
|
||||
"src/mission_data_storage.cpp",
|
||||
"src/mission_info_mgr.cpp",
|
||||
"src/mission_list.cpp",
|
||||
"src/mission_list_manager.cpp",
|
||||
"src/mission/mission.cpp",
|
||||
"src/mission/mission_data_storage.cpp",
|
||||
"src/mission/mission_info_mgr.cpp",
|
||||
"src/mission/mission_list.cpp",
|
||||
"src/mission/mission_list_manager.cpp",
|
||||
"src/task_data_persistence_mgr.cpp",
|
||||
]
|
||||
|
||||
|
@ -85,8 +85,8 @@ abilityms_files = [
|
||||
"src/call_container.cpp",
|
||||
"src/call_record.cpp",
|
||||
"src/inner_mission_info.cpp",
|
||||
"src/mission_listener_controller.cpp",
|
||||
"src/mission_listener_proxy.cpp",
|
||||
"src/mission/mission_listener_controller.cpp",
|
||||
"src/mission/mission_listener_proxy.cpp",
|
||||
"src/rdb/ability_resident_process_rdb.cpp",
|
||||
"src/rdb/parser_util.cpp",
|
||||
"src/rdb/rdb_data_manager.cpp",
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
* @param abilityRequest, the request of the service ability to start.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int StartAbility(const AbilityRequest &abilityRequest);
|
||||
int32_t StartAbility(const AbilityRequest &abilityRequest);
|
||||
|
||||
/**
|
||||
* TerminateAbility with token and result want.
|
||||
@ -97,7 +97,7 @@ public:
|
||||
* @param connectInfo the connect info.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int ConnectAbilityLocked(const AbilityRequest &abilityRequest, const sptr<IAbilityConnection> &connect,
|
||||
int32_t ConnectAbilityLocked(const AbilityRequest &abilityRequest, const sptr<IAbilityConnection> &connect,
|
||||
const sptr<IRemoteObject> &callerToken, sptr<SessionInfo> sessionInfo = nullptr,
|
||||
sptr<UIExtensionAbilityConnectInfo> connectInfo = nullptr);
|
||||
|
||||
@ -207,12 +207,12 @@ public:
|
||||
AbilityCommand abilityCmd);
|
||||
|
||||
/**
|
||||
* GetUIExtensioBySessionInfo.
|
||||
* GetUIExtensionBySessionInfo.
|
||||
*
|
||||
* @param sessionToken, service ability's session token.
|
||||
* @return Returns AbilityRecord shared_ptr.
|
||||
*/
|
||||
std::shared_ptr<AbilityRecord> GetUIExtensioBySessionInfo(const sptr<SessionInfo> &sessionInfo);
|
||||
std::shared_ptr<AbilityRecord> GetUIExtensionBySessionInfo(const sptr<SessionInfo> &sessionInfo);
|
||||
|
||||
std::shared_ptr<AbilityRecord> GetExtensionByTokenFromServiceMap(const sptr<IRemoteObject> &token);
|
||||
std::shared_ptr<AbilityRecord> GetExtensionByTokenFromAbilityCache(const sptr<IRemoteObject> &token);
|
||||
@ -340,7 +340,7 @@ private:
|
||||
* @param abilityRequest, the request of the service ability to start.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int StartAbilityLocked(const AbilityRequest &abilityRequest);
|
||||
int32_t StartAbilityLocked(const AbilityRequest &abilityRequest);
|
||||
|
||||
/**
|
||||
* TerminateAbilityLocked with token and result want.
|
||||
@ -577,7 +577,7 @@ private:
|
||||
void HandleUIExtWindowDiedTask(const sptr<IRemoteObject> &remote);
|
||||
|
||||
/**
|
||||
* Post an extension's disconnect task, auto disconnect when extension conected timeout.
|
||||
* Post an extension's disconnect task, auto disconnect when extension connected timeout.
|
||||
*/
|
||||
void PostExtensionDelayDisconnectTask(const std::shared_ptr<ConnectionRecord> &connectRecord);
|
||||
|
||||
|
@ -255,7 +255,7 @@ public:
|
||||
* @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StartExtensionAbility(
|
||||
virtual int32_t StartExtensionAbility(
|
||||
const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE,
|
||||
@ -695,26 +695,84 @@ public:
|
||||
|
||||
virtual void SetLockedState(int32_t sessionId, bool lockedState) override;
|
||||
|
||||
/**
|
||||
* @brief Register mission listener to ability mgr.
|
||||
* @param listener The handler of listener.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int RegisterMissionListener(const sptr<IMissionListener> &listener) override;
|
||||
|
||||
/**
|
||||
* @brief UnRegister mission listener from ability mgr.
|
||||
* @param listener The handler of listener.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int UnRegisterMissionListener(const sptr<IMissionListener> &listener) override;
|
||||
|
||||
/**
|
||||
* @brief Get mission infos from ability mgr.
|
||||
* @param deviceId local or remote deviceId.
|
||||
* @param numMax max number of missions.
|
||||
* @param missionInfos mission info result.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetMissionInfos(const std::string& deviceId, int32_t numMax,
|
||||
std::vector<MissionInfo> &missionInfos) override;
|
||||
|
||||
/**
|
||||
* @brief Get mission info by id.
|
||||
* @param deviceId local or remote deviceId.
|
||||
* @param missionId Id of target mission.
|
||||
* @param missionInfo mission info of target mission.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetMissionInfo(const std::string& deviceId, int32_t missionId,
|
||||
MissionInfo &missionInfos) override;
|
||||
|
||||
/**
|
||||
* @brief Clean mission by id.
|
||||
* @param missionId Id of target mission.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int CleanMission(int32_t missionId) override;
|
||||
|
||||
/**
|
||||
* @brief Clean all missions in system.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int CleanAllMissions() override;
|
||||
|
||||
virtual int MoveMissionToFront(int32_t missionId) override;
|
||||
|
||||
/**
|
||||
* @brief Move a mission to front.
|
||||
* @param missionId Id of target mission.
|
||||
* @param startOptions Special startOptions for target mission.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override;
|
||||
|
||||
/**
|
||||
* Move missions to front
|
||||
* @param missionIds Ids of target missions
|
||||
* @param topMissionId Indicate which mission will be moved to top, if set to -1, missions' order won't change
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId) override;
|
||||
|
||||
/**
|
||||
* Move missions to background
|
||||
* @param missionIds Ids of target missions
|
||||
* @param result The result of move missions to background, and the array is sorted by zOrder
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int MoveMissionsToBackground(const std::vector<int32_t>& missionIds,
|
||||
std::vector<int32_t>& result) override;
|
||||
|
||||
@ -747,10 +805,29 @@ public:
|
||||
virtual int ReleaseCall(
|
||||
const sptr<IAbilityConnection> &connect, const AppExecFwk::ElementName &element) override;
|
||||
|
||||
/**
|
||||
* @brief start user.
|
||||
* @param accountId accountId.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StartUser(int userId, sptr<IUserCallback> callback) override;
|
||||
|
||||
/**
|
||||
* @brief stop user.
|
||||
* @param accountId accountId.
|
||||
* @param callback callback.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StopUser(int userId, const sptr<IUserCallback> &callback) override;
|
||||
|
||||
/**
|
||||
* @brief logout user.
|
||||
* @param accountId accountId.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int LogoutUser(int32_t userId) override;
|
||||
|
||||
virtual int SetMissionContinueState(const sptr<IRemoteObject> &token, const AAFwk::ContinueState &state) override;
|
||||
@ -781,13 +858,38 @@ public:
|
||||
virtual int UnregisterAbilityFirstFrameStateObserver(
|
||||
const sptr<IAbilityFirstFrameStateObserver> &observer) override;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Get the ability running information.
|
||||
*
|
||||
* @param info Ability running information.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetAbilityRunningInfos(std::vector<AbilityRunningInfo> &info) override;
|
||||
|
||||
/**
|
||||
* @brief Get the extension running information.
|
||||
*
|
||||
* @param upperLimit The maximum limit of information wish to get.
|
||||
* @param info Extension running information.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetExtensionRunningInfos(int upperLimit, std::vector<ExtensionRunningInfo> &info) override;
|
||||
|
||||
/**
|
||||
* @brief Get running process information.
|
||||
*
|
||||
* @param info Running process information.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> &info) override;
|
||||
|
||||
/**
|
||||
* @brief Register mission listener to ability manager service.
|
||||
* @param deviceId The remote device Id.
|
||||
* @param listener The handler of listener.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int RegisterMissionListener(const std::string &deviceId,
|
||||
const sptr<IRemoteMissionListener> &listener) override;
|
||||
|
||||
@ -816,13 +918,41 @@ public:
|
||||
*/
|
||||
virtual bool IsRunningInStabilityTest() override;
|
||||
|
||||
/**
|
||||
* @brief Register the snapshot handler
|
||||
* @param handler snapshot handler
|
||||
* @return ErrCode Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int RegisterSnapshotHandler(const sptr<ISnapshotHandler>& handler) override;
|
||||
|
||||
/**
|
||||
* @brief Get the Mission Snapshot Info object
|
||||
* @param deviceId local or remote deviceId.
|
||||
* @param missionId Id of target mission.
|
||||
* @param snapshot snapshot of target mission.
|
||||
* @param isLowResolution get low resolution snapshot.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int GetMissionSnapshot(const std::string& deviceId, int32_t missionId,
|
||||
MissionSnapshot& snapshot, bool isLowResolution) override;
|
||||
|
||||
/**
|
||||
* @brief start user test.
|
||||
* @param want the want of the ability user test to start.
|
||||
* @param observer test observer callback.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StartUserTest(const Want &want, const sptr<IRemoteObject> &observer) override;
|
||||
|
||||
/**
|
||||
* @brief Finish user test.
|
||||
* @param msg user test message.
|
||||
* @param resultCode user test result Code.
|
||||
* @param bundleName user test bundleName.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int FinishUserTest(
|
||||
const std::string &msg, const int64_t &resultCode, const std::string &bundleName) override;
|
||||
|
||||
@ -929,6 +1059,11 @@ public:
|
||||
virtual void ScheduleRecoverAbility(const sptr<IRemoteObject> &token, int32_t reason,
|
||||
const Want *want = nullptr) override;
|
||||
|
||||
/**
|
||||
* @brief Schedule clear recovery page stack.
|
||||
*
|
||||
* @param bundleName application bundleName.
|
||||
*/
|
||||
virtual void ScheduleClearRecoveryPageStack() override;
|
||||
|
||||
/**
|
||||
@ -1086,10 +1221,17 @@ public:
|
||||
* PrepareTerminateAbilityBySCB, prepare to terminate ability by scb.
|
||||
*
|
||||
* @param sessionInfo the session info of the ability to start.
|
||||
* @param isPrepareTerminate the result of ability onPrepareToTermiante.
|
||||
* @param isPrepareTerminate the result of ability onPrepareToTerminate.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int PrepareTerminateAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool &isPrepareTerminate) override;
|
||||
|
||||
/**
|
||||
* @brief Register session handler.
|
||||
* @param object The handler.
|
||||
*
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int RegisterSessionHandler(const sptr<IRemoteObject> &object) override;
|
||||
|
||||
/**
|
||||
@ -1347,6 +1489,16 @@ public:
|
||||
*/
|
||||
virtual int32_t BlockAllAppStart(bool flag) override;
|
||||
|
||||
/**
|
||||
* update associate config list by rss.
|
||||
*
|
||||
* @param configs The rss config info.
|
||||
* @param exportConfigs The rss export config info.
|
||||
* @param flag UPDATE_CONFIG_FLAG_COVER is cover config, UPDATE_CONFIG_FLAG_APPEND is append config.
|
||||
*/
|
||||
virtual int32_t UpdateAssociateConfigList(const std::map<std::string, std::list<std::string>>& configs,
|
||||
const std::list<std::string>& exportConfigs, int32_t flag) override;
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
int GetParcelableInfos(MessageParcel &reply, std::vector<T> &parcelableInfos);
|
||||
@ -1357,6 +1509,8 @@ private:
|
||||
MessageOption& option);
|
||||
int CheckUISessionParams(MessageParcel &data, const sptr<IRemoteObject> &callerToken,
|
||||
const sptr<SessionInfo> &sessionInfo, int32_t userId, int requestCode);
|
||||
bool UpdateAssociateConfigInner(const std::map<std::string, std::list<std::string>>& configs,
|
||||
MessageParcel& data);
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<AbilityManagerProxy> delegator_;
|
||||
|
@ -85,7 +85,6 @@ constexpr int32_t U0_USER_ID = 0;
|
||||
constexpr int32_t INVALID_USER_ID = -1;
|
||||
constexpr const char* KEY_SESSION_ID = "com.ohos.param.sessionId";
|
||||
using OHOS::AppExecFwk::IAbilityController;
|
||||
class PendingWantManager;
|
||||
struct StartAbilityInfo;
|
||||
class WindowFocusChangedListener;
|
||||
|
||||
@ -400,14 +399,14 @@ public:
|
||||
* @param extensionType If an ExtensionAbilityType is set, only extension of that type can be started.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int StartExtensionAbility(
|
||||
virtual int32_t StartExtensionAbility(
|
||||
const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE,
|
||||
AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::UNSPECIFIED) override;
|
||||
|
||||
/**
|
||||
* Requset modal UIExtension with want, send want to ability manager service.
|
||||
* Request modal UIExtension with want, send want to ability manager service.
|
||||
*
|
||||
* @param want, the want contains ability info about caller and called.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
@ -583,13 +582,13 @@ public:
|
||||
* @param userId, Designation User ID.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int ConnectAbility(
|
||||
virtual int32_t ConnectAbility(
|
||||
const Want &want,
|
||||
const sptr<IAbilityConnection> &connect,
|
||||
const sptr<IRemoteObject> &callerToken,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE) override;
|
||||
|
||||
virtual int ConnectAbilityCommon(
|
||||
virtual int32_t ConnectAbilityCommon(
|
||||
const Want &want,
|
||||
const sptr<IAbilityConnection> &connect,
|
||||
const sptr<IRemoteObject> &callerToken,
|
||||
@ -653,7 +652,7 @@ public:
|
||||
/**
|
||||
* NotifyCompleteContinuation, notify continuation complete to dms.
|
||||
* @param deviceId, source device which start a continuation.
|
||||
* @param sessionId, represent a continuaion.
|
||||
* @param sessionId, represent a continuation.
|
||||
* @param isSuccess, continuation result.
|
||||
* @return
|
||||
*/
|
||||
@ -1032,7 +1031,7 @@ public:
|
||||
bool isImplicit = false,
|
||||
bool isUIAbilityOnly = false);
|
||||
|
||||
int StartExtensionAbilityInner(
|
||||
int32_t StartExtensionAbilityInner(
|
||||
const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken,
|
||||
int32_t userId,
|
||||
@ -1558,7 +1557,7 @@ public:
|
||||
* PrepareTerminateAbilityBySCB, prepare to terminate ability by scb.
|
||||
*
|
||||
* @param sessionInfo the session info of the ability to start.
|
||||
* @param isTerminate the result of ability onPrepareToTermiante.
|
||||
* @param isTerminate the result of ability onPrepareToTerminate.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int PrepareTerminateAbilityBySCB(const sptr<SessionInfo> &sessionInfo, bool &isTerminate) override;
|
||||
@ -1787,6 +1786,9 @@ public:
|
||||
|
||||
int32_t TerminateMission(int32_t missionId) override;
|
||||
|
||||
int32_t UpdateAssociateConfigList(const std::map<std::string, std::list<std::string>>& configs,
|
||||
const std::list<std::string>& exportConfigs, int32_t flag) override;
|
||||
|
||||
int32_t BlockAllAppStart(bool flag) override;
|
||||
|
||||
int32_t StartUIAbilityBySCBDefaultCommon(AbilityRequest &abilityRequest, sptr<SessionInfo> sessionInfo,
|
||||
@ -1838,8 +1840,17 @@ protected:
|
||||
|
||||
void NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos) override;
|
||||
|
||||
/**
|
||||
* @brief Notify abilityms app process pre cache
|
||||
* @param pid process pid.
|
||||
* @param userId userId Designation User ID.
|
||||
*/
|
||||
void NotifyAppPreCache(int32_t pid, int32_t userId) override;
|
||||
|
||||
/**
|
||||
* @brief Notify abilityms app process OnRemoteDied
|
||||
* @param abilityTokens abilities in died process.
|
||||
*/
|
||||
void OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens) override;
|
||||
|
||||
private:
|
||||
@ -1862,7 +1873,7 @@ private:
|
||||
*/
|
||||
void StartHighestPriorityAbility(int32_t userId, bool isBoot);
|
||||
/**
|
||||
* connet bms.
|
||||
* connect bms.
|
||||
*
|
||||
*/
|
||||
void ConnectBmsService();
|
||||
@ -1888,7 +1899,7 @@ private:
|
||||
int32_t PreStartInner(const FreeInstallInfo& taskInfo);
|
||||
void RemovePreStartSession(const std::string& sessionId);
|
||||
|
||||
int ConnectLocalAbility(
|
||||
int32_t ConnectLocalAbility(
|
||||
const Want &want,
|
||||
const int32_t userId,
|
||||
const sptr<IAbilityConnection> &connect,
|
||||
@ -1928,7 +1939,7 @@ private:
|
||||
int StartRemoteAbilityByCall(const Want &want, const sptr<IRemoteObject> &callerToken,
|
||||
const sptr<IRemoteObject> &connect);
|
||||
int ReleaseRemoteAbility(const sptr<IRemoteObject> &connect, const AppExecFwk::ElementName &element);
|
||||
void ForceTerminateSerivceExtensionByPid(int32_t pid, int32_t userId);
|
||||
void ForceTerminateServiceExtensionByPid(int32_t pid, int32_t userId);
|
||||
|
||||
void DumpInner(const std::string &args, std::vector<std::string> &info);
|
||||
void DumpMissionInner(const std::string &args, std::vector<std::string> &info);
|
||||
@ -2284,16 +2295,16 @@ private:
|
||||
|
||||
void ReportCleanSession(const sptr<SessionInfo> &sessionInfo,
|
||||
const std::shared_ptr<AbilityRecord> &abilityRecord, int32_t errCode);
|
||||
|
||||
|
||||
void SendStartAbilityOtherExtensionEvent(const AppExecFwk::AbilityInfo& abilityInfo,
|
||||
const Want& want, uint32_t specifyTokenId);
|
||||
|
||||
|
||||
void SetMinimizedDuringFreeInstall(const sptr<SessionInfo>& sessionInfo);
|
||||
|
||||
/**
|
||||
* @brief Check debug app in developer mode.
|
||||
* @param applicationInfo. The application info.
|
||||
* @return Returns ture or false.
|
||||
* @return Returns true or false.
|
||||
*/
|
||||
bool CheckDebugAppNotInDeveloperMode(const AppExecFwk::ApplicationInfo &applicationInfo);
|
||||
|
||||
@ -2305,7 +2316,6 @@ private:
|
||||
void ShowDeveloperModeDialog(const std::string &bundleName, const std::string &abilityName);
|
||||
|
||||
constexpr static int REPOLL_TIME_MICRO_SECONDS = 1000000;
|
||||
constexpr static int WAITING_BOOT_ANIMATION_TIMER = 5;
|
||||
|
||||
std::shared_ptr<TaskHandlerWrap> taskHandler_;
|
||||
std::shared_ptr<AbilityEventHandler> eventHandler_;
|
||||
@ -2359,6 +2369,7 @@ private:
|
||||
|
||||
std::shared_ptr<AbilityAutoStartupService> abilityAutoStartupService_;
|
||||
|
||||
std::mutex whiteListMutex_;
|
||||
std::map<std::string, std::list<std::string>> whiteListMap_;
|
||||
|
||||
std::list<std::string> exportWhiteList_;
|
||||
|
@ -350,6 +350,7 @@ private:
|
||||
int32_t OpenLinkInner(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t TerminateMissionInner(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t BlockAllAppStartInner(MessageParcel &data, MessageParcel &reply);
|
||||
int32_t UpdateAssociateConfigListInner(MessageParcel &data, MessageParcel &reply);
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -596,10 +596,12 @@ public:
|
||||
|
||||
bool GrantUriPermissionForServiceExtension();
|
||||
|
||||
bool GrantUriPermissionForUIExtension();
|
||||
|
||||
/**
|
||||
* check whether the ability is launcher.
|
||||
*
|
||||
* @return true : lanucher ,false: not lanucher
|
||||
* @return true : launcher ,false: not launcher
|
||||
*/
|
||||
bool IsLauncherAbility() const;
|
||||
|
||||
@ -921,7 +923,7 @@ public:
|
||||
void DumpService(std::vector<std::string> &info, std::vector<std::string> ¶ms, bool isClient = false) const;
|
||||
|
||||
/**
|
||||
* set aconnect remote object.
|
||||
* set connect remote object.
|
||||
*
|
||||
*/
|
||||
void SetConnRemoteObject(const sptr<IRemoteObject> &remoteObject);
|
||||
@ -1159,8 +1161,6 @@ private:
|
||||
|
||||
void DumpUIExtensionPid(std::vector<std::string> &info, bool isUIExtension) const;
|
||||
|
||||
bool GetUriListFromWant(Want &want, std::vector<std::string> &uriVec);
|
||||
|
||||
void PublishFileOpenEvent(const Want &want);
|
||||
|
||||
void SetDebugAppByWaitingDebugFlag();
|
||||
@ -1194,7 +1194,7 @@ private:
|
||||
|
||||
void StartingWindowTask(bool isRecent, bool isCold, const AbilityRequest &abilityRequest,
|
||||
std::shared_ptr<StartOptions> &startOptions);
|
||||
void StartingWindowColdTask(bool isRecnet, const AbilityRequest &abilityRequest,
|
||||
void StartingWindowColdTask(bool isRecent, const AbilityRequest &abilityRequest,
|
||||
std::shared_ptr<StartOptions> &startOptions);
|
||||
void PostCancelStartingWindowColdTask();
|
||||
void StartingWindowHot(const std::shared_ptr<StartOptions> &startOptions, const std::shared_ptr<Want> &want,
|
||||
@ -1242,14 +1242,14 @@ private:
|
||||
*/
|
||||
bool isAbilityForegrounding_ = false;
|
||||
|
||||
// service(ability) can be connected by multi-pages(abilites), so need to store this service's connections
|
||||
// service(ability) can be connected by multi-pages(abilities), so need to store this service's connections
|
||||
mutable ffrt::mutex connRecordListMutex_;
|
||||
std::list<std::shared_ptr<ConnectionRecord>> connRecordList_ = {};
|
||||
// service(ability) onConnect() return proxy of service ability
|
||||
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
|
||||
// page(ability) can be started by multi-pages(abilities), so need to store this ability's caller
|
||||
std::list<std::shared_ptr<CallerRecord>> callerList_ = {};
|
||||
|
||||
bool isUninstall_ = false;
|
||||
|
@ -94,8 +94,17 @@ public:
|
||||
|
||||
virtual void NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos) {}
|
||||
|
||||
/**
|
||||
* @brief Notify abilityms app process pre cache
|
||||
* @param pid process pid.
|
||||
* @param userId userId Designation User ID.
|
||||
*/
|
||||
virtual void NotifyAppPreCache(int32_t pid, int32_t userId) {}
|
||||
|
||||
/**
|
||||
* @brief Notify abilityms app process OnRemoteDied
|
||||
* @param abilityTokens abilities in died process.
|
||||
*/
|
||||
virtual void OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens) {}
|
||||
};
|
||||
|
||||
@ -197,8 +206,19 @@ public:
|
||||
*/
|
||||
void KillProcessesByUserId(int32_t userId);
|
||||
|
||||
/**
|
||||
* KillProcessesByPids, only in process call is allowed,
|
||||
* kill the processes by pid list given.
|
||||
*
|
||||
* @param pids, the pid list of processes are going to be killed.
|
||||
*/
|
||||
void KillProcessesByPids(std::vector<int32_t> &pids);
|
||||
|
||||
/**
|
||||
* Set child and parent relationship
|
||||
* @param token child process
|
||||
* @param callerToken parent process
|
||||
*/
|
||||
void AttachPidToParent(const sptr<IRemoteObject> &token, const sptr<IRemoteObject> &callerToken);
|
||||
|
||||
/**
|
||||
@ -259,12 +279,36 @@ public:
|
||||
*/
|
||||
int UpdateApplicationInfoInstalled(const std::string &bundleName, const int32_t uid);
|
||||
|
||||
/**
|
||||
* Ability attach timeout. If start ability encounter failure, attach timeout to terminate.
|
||||
*
|
||||
* @param token Ability identify.
|
||||
*/
|
||||
void AttachTimeOut(const sptr<IRemoteObject> &token);
|
||||
|
||||
/**
|
||||
* Prepare terminate.
|
||||
*
|
||||
* @param token Ability identify.
|
||||
* @param clearMissionFlag Clear mission flag.
|
||||
*/
|
||||
void PrepareTerminate(const sptr<IRemoteObject> &token, bool clearMissionFlag = false);
|
||||
|
||||
/**
|
||||
* Get running process information by ability token.
|
||||
*
|
||||
* @param token Ability identify.
|
||||
* @param info Running process info.
|
||||
*/
|
||||
void GetRunningProcessInfoByToken(const sptr<IRemoteObject> &token, AppExecFwk::RunningProcessInfo &info);
|
||||
|
||||
/**
|
||||
* Get running process information by pid.
|
||||
*
|
||||
* @param pid process id.
|
||||
* @param info Output parameters, return runningProcessInfo.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
void GetRunningProcessInfoByPid(const pid_t pid, OHOS::AppExecFwk::RunningProcessInfo &info) const;
|
||||
|
||||
/**
|
||||
@ -280,10 +324,31 @@ public:
|
||||
*/
|
||||
void StartupResidentProcess(const std::vector<AppExecFwk::BundleInfo> &bundleInfos);
|
||||
|
||||
/**
|
||||
* Start specified ability.
|
||||
*
|
||||
* @param want Want contains information of the ability to start.
|
||||
* @param abilityInfo Ability information.
|
||||
* @param requestId request id to callback
|
||||
*/
|
||||
void StartSpecifiedAbility(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo,
|
||||
int32_t requestId = 0);
|
||||
|
||||
/**
|
||||
* @brief Get running process information.
|
||||
*
|
||||
* @param info Running process information.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int GetProcessRunningInfos(std::vector<AppExecFwk::RunningProcessInfo> &info);
|
||||
|
||||
/**
|
||||
* Start specified process.
|
||||
*
|
||||
* @param want Want contains information wish to start.
|
||||
* @param abilityInfo Ability information.
|
||||
* @param requestId for callback
|
||||
*/
|
||||
void StartSpecifiedProcess(const AAFwk::Want &want, const AppExecFwk::AbilityInfo &abilityInfo,
|
||||
int32_t requestId = 0);
|
||||
|
||||
@ -303,6 +368,14 @@ public:
|
||||
*/
|
||||
int FinishUserTest(const std::string &msg, const int64_t &resultCode, const std::string &bundleName);
|
||||
|
||||
/**
|
||||
* GetProcessRunningInfosByUserId, call GetProcessRunningInfosByUserId() through proxy project.
|
||||
* Obtains information about application processes that are running on the device.
|
||||
*
|
||||
* @param info, app name in Application record.
|
||||
* @param userId, user Id in Application record.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
int GetProcessRunningInfosByUserId(std::vector<AppExecFwk::RunningProcessInfo> &info, int32_t userId);
|
||||
std::string ConvertAppState(const AppState &state);
|
||||
|
||||
@ -314,6 +387,12 @@ public:
|
||||
*/
|
||||
int UpdateConfiguration(const AppExecFwk::Configuration &config);
|
||||
|
||||
/**
|
||||
* GetConfiguration
|
||||
*
|
||||
* @param info to retrieve configuration data.
|
||||
* @return ERR_OK ,return back success,others fail.
|
||||
*/
|
||||
int GetConfiguration(AppExecFwk::Configuration &config);
|
||||
|
||||
/**
|
||||
@ -438,8 +517,8 @@ public:
|
||||
void ClearProcessByToken(sptr<IRemoteObject> token) const;
|
||||
|
||||
/**
|
||||
* whether memory size is sufficent.
|
||||
* @return Returns true is sufficent memory size, others return false.
|
||||
* whether memory size is sufficient.
|
||||
* @return Returns true is sufficient memory size, others return false.
|
||||
*/
|
||||
virtual bool IsMemorySizeSufficent() const;
|
||||
|
||||
@ -450,6 +529,11 @@ public:
|
||||
*/
|
||||
void AttachedToStatusBar(const sptr<IRemoteObject> &token);
|
||||
|
||||
/**
|
||||
* Temporarily block the process cache feature.
|
||||
*
|
||||
* @param pids the pids of the processes that should be blocked.
|
||||
*/
|
||||
void BlockProcessCacheByPids(const std::vector<int32_t>& pids);
|
||||
|
||||
/**
|
||||
@ -460,6 +544,12 @@ public:
|
||||
*/
|
||||
bool CleanAbilityByUserRequest(const sptr<IRemoteObject> &token);
|
||||
|
||||
/**
|
||||
* whether killed for upgrade web.
|
||||
*
|
||||
* @param bundleName the bundle name is killed for upgrade web.
|
||||
* @return Returns true is killed for upgrade web, others return false.
|
||||
*/
|
||||
bool IsKilledForUpgradeWeb(const std::string &bundleName);
|
||||
|
||||
/**
|
||||
@ -501,8 +591,17 @@ protected:
|
||||
*/
|
||||
virtual void NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos) override;
|
||||
|
||||
/**
|
||||
* @brief Notify abilityms app process OnRemoteDied
|
||||
* @param abilityTokens abilities in died process.
|
||||
*/
|
||||
virtual void OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens) override;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Notify abilityms app process pre cache
|
||||
* @param pid process pid.
|
||||
* @param userId userId Designation User ID.
|
||||
*/
|
||||
virtual void NotifyAppPreCache(int32_t pid, int32_t userId) override;
|
||||
|
||||
private:
|
||||
|
@ -47,16 +47,37 @@ public:
|
||||
*/
|
||||
void Activate(const Want &want, LifeCycleStateInfo &stateInfo);
|
||||
void Inactivate(const Want &want, LifeCycleStateInfo &stateInfo, sptr<SessionInfo> sessionInfo = nullptr);
|
||||
/**
|
||||
* schedule ability life cycle to background
|
||||
*/
|
||||
void MoveToBackground(const Want &want, LifeCycleStateInfo &stateInfo);
|
||||
/**
|
||||
* schedule ability onConnect
|
||||
*/
|
||||
void ConnectAbility(const Want &want);
|
||||
/**
|
||||
* schedule ability onDisconnect
|
||||
*/
|
||||
void DisconnectAbility(const Want &want);
|
||||
/**
|
||||
* schedule ability onDestroy
|
||||
*/
|
||||
void Terminate(const Want &want, LifeCycleStateInfo &stateInfo, sptr<SessionInfo> sessionInfo = nullptr);
|
||||
/**
|
||||
* schedule ability onRequest
|
||||
*/
|
||||
void CommandAbility(const Want &want, bool reStart, int startId);
|
||||
void CommandAbilityWindow(const Want &want, const sptr<SessionInfo> &sessionInfo, WindowCommand winCmd);
|
||||
void SaveAbilityState();
|
||||
void RestoreAbilityState(const PacMap &inState);
|
||||
/**
|
||||
* schedule ability life cycle to foreground
|
||||
*/
|
||||
void ForegroundNew(const Want &want, LifeCycleStateInfo &stateInfo,
|
||||
sptr<SessionInfo> sessionInfo = nullptr);
|
||||
/**
|
||||
* schedule ability life cycle to background
|
||||
*/
|
||||
void BackgroundNew(const Want &want, LifeCycleStateInfo &stateInfo,
|
||||
sptr<SessionInfo> sessionInfo = nullptr);
|
||||
void ContinueAbility(const std::string& deviceId, uint32_t versionCode);
|
||||
|
@ -66,12 +66,33 @@ public:
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int32_t SetResidentProcessEnabled(const std::string &bundleName, const std::string &callerName, bool updateEnable);
|
||||
|
||||
/**
|
||||
* start empty resident processes.
|
||||
*
|
||||
* @param bundleInfos bundles of resident processes.
|
||||
*/
|
||||
void StartResidentProcess(const std::vector<AppExecFwk::BundleInfo> &bundleInfos);
|
||||
/**
|
||||
* If bundle has right main element, start the main element
|
||||
*/
|
||||
void StartResidentProcessWithMainElement(std::vector<AppExecFwk::BundleInfo> &bundleInfos, int32_t userId);
|
||||
/**
|
||||
* Once one process created, query keepalive status from db and update then
|
||||
*/
|
||||
void OnAppStateChanged(const AppInfo &info);
|
||||
/**
|
||||
* Before starting a resident element, store it.
|
||||
*/
|
||||
int32_t PutResidentAbility(const std::string &bundleName, const std::string &abilityName, int32_t userId);
|
||||
bool IsResidentAbility(const std::string &bundleName, const std::string &abilityName, int32_t userId);
|
||||
/**
|
||||
* After a resident element being started, remove it
|
||||
*/
|
||||
void RemoveResidentAbility(int32_t residentId);
|
||||
/**
|
||||
* query resident bundles for user
|
||||
*/
|
||||
bool GetResidentBundleInfosForUser(std::vector<AppExecFwk::BundleInfo> &bundleInfos, int32_t userId);
|
||||
void StartFailedResidentAbilities();
|
||||
private:
|
||||
|
@ -37,6 +37,12 @@ public:
|
||||
std::vector<Uri> GetPermissionedUriList(const std::vector<std::string> &uriVec,
|
||||
const std::vector<bool> &checkResults, Want &want);
|
||||
|
||||
bool GetUriListFromWant(Want &want, std::vector<std::string> &uriVec);
|
||||
|
||||
bool IsGrantUriPermissionFlag(const Want &want);
|
||||
|
||||
void CheckUriPermissionForServiceExtension(Want &want, AppExecFwk::ExtensionAbilityType extensionAbilityType);
|
||||
|
||||
private:
|
||||
UriUtils();
|
||||
~UriUtils();
|
||||
|
@ -66,6 +66,7 @@ const int32_t AUTO_DISCONNECT_INFINITY = -1;
|
||||
constexpr const char* FROZEN_WHITE_DIALOG = "com.huawei.hmos.huaweicast";
|
||||
constexpr char BUNDLE_NAME_DIALOG[] = "com.ohos.amsdialog";
|
||||
constexpr char ABILITY_NAME_ASSERT_FAULT_DIALOG[] = "AssertFaultDialog";
|
||||
constexpr const char* WANT_PARAMS_APP_RESTART_FLAG = "ohos.aafwk.app.restart";
|
||||
|
||||
const std::string XIAOYI_BUNDLE_NAME = "com.huawei.hmos.vassistant";
|
||||
|
||||
@ -807,7 +808,6 @@ int AbilityConnectManager::AttachAbilityThreadLocked(
|
||||
void AbilityConnectManager::OnAbilityRequestDone(const sptr<IRemoteObject> &token, const int32_t state)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "state: %{public}d", state);
|
||||
std::lock_guard guard(serialMutex_);
|
||||
AppAbilityState abilityState = DelayedSingleton<AppScheduler>::GetInstance()->ConvertToAppAbilityState(state);
|
||||
if (abilityState == AppAbilityState::ABILITY_STATE_FOREGROUND) {
|
||||
auto abilityRecord = GetExtensionByTokenFromServiceMap(token);
|
||||
@ -822,6 +822,8 @@ void AbilityConnectManager::OnAbilityRequestDone(const sptr<IRemoteObject> &toke
|
||||
}
|
||||
std::string element = abilityRecord->GetURI();
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Ability is %{public}s, start to foreground.", element.c_str());
|
||||
abilityRecord->GrantUriPermissionForUIExtension();
|
||||
std::lock_guard guard(serialMutex_);
|
||||
abilityRecord->ForegroundUIExtensionAbility();
|
||||
}
|
||||
}
|
||||
@ -1209,6 +1211,7 @@ void AbilityConnectManager::CompleteCommandAbility(std::shared_ptr<AbilityRecord
|
||||
// manage queued request
|
||||
CompleteStartServiceReq(abilityRecord->GetURI());
|
||||
if (abilityRecord->NeedConnectAfterCommand()) {
|
||||
abilityRecord->UpdateConnectWant();
|
||||
ConnectAbility(abilityRecord);
|
||||
}
|
||||
}
|
||||
@ -1307,7 +1310,7 @@ std::shared_ptr<AbilityRecord> AbilityConnectManager::GetExtensionByIdFromTermin
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<AbilityRecord> AbilityConnectManager::GetUIExtensioBySessionInfo(
|
||||
std::shared_ptr<AbilityRecord> AbilityConnectManager::GetUIExtensionBySessionInfo(
|
||||
const sptr<SessionInfo> &sessionInfo)
|
||||
{
|
||||
CHECK_POINTER_AND_RETURN(sessionInfo, nullptr);
|
||||
@ -2353,6 +2356,8 @@ void AbilityConnectManager::RestartAbility(const std::shared_ptr<AbilityRecord>
|
||||
return;
|
||||
}
|
||||
|
||||
requestInfo.want.SetParam(WANT_PARAMS_APP_RESTART_FLAG, true);
|
||||
|
||||
// restart other resident ability
|
||||
if (abilityRecord->CanRestartResident()) {
|
||||
requestInfo.restartCount = abilityRecord->GetRestartCount();
|
||||
|
@ -2036,5 +2036,14 @@ ErrCode AbilityManagerClient::BlockAllAppStart(bool flag)
|
||||
CHECK_POINTER_RETURN_INVALID_VALUE(abms);
|
||||
return abms->BlockAllAppStart(flag);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::UpdateAssociateConfigList(const std::map<std::string, std::list<std::string>>& configs,
|
||||
const std::list<std::string>& exportConfigs, int32_t flag)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "call.");
|
||||
auto abms = GetAbilityManager();
|
||||
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
|
||||
return abms->UpdateAssociateConfigList(configs, exportConfigs, flag);
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -35,6 +35,7 @@ namespace {
|
||||
using AutoStartupInfo = AbilityRuntime::AutoStartupInfo;
|
||||
constexpr int32_t CYCLE_LIMIT = 1000;
|
||||
constexpr int32_t MAX_AUTO_STARTUP_COUNT = 100;
|
||||
constexpr int32_t MAX_UPDATE_CONFIG_SIZE = 100;
|
||||
bool AbilityManagerProxy::WriteInterfaceToken(MessageParcel &data)
|
||||
{
|
||||
if (!data.WriteInterfaceToken(AbilityManagerProxy::GetDescriptor())) {
|
||||
@ -610,7 +611,7 @@ int AbilityManagerProxy::StartAbilityOnlyUIAbility(const Want &want, const sptr<
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int AbilityManagerProxy::StartExtensionAbility(const Want &want, const sptr<IRemoteObject> &callerToken,
|
||||
int32_t AbilityManagerProxy::StartExtensionAbility(const Want &want, const sptr<IRemoteObject> &callerToken,
|
||||
int32_t userId, AppExecFwk::ExtensionAbilityType extensionType)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
@ -5611,5 +5612,82 @@ int32_t AbilityManagerProxy::BlockAllAppStart(bool flag)
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AbilityManagerProxy::UpdateAssociateConfigList(const std::map<std::string, std::list<std::string>>& configs,
|
||||
const std::list<std::string>& exportConfigs, int32_t flag)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return IPC_PROXY_ERR;
|
||||
}
|
||||
|
||||
if (!UpdateAssociateConfigInner(configs, data)) {
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
int32_t size = static_cast<int32_t>(exportConfigs.size());
|
||||
if (size > MAX_UPDATE_CONFIG_SIZE) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "export configs size too large");
|
||||
return INNER_ERR;
|
||||
}
|
||||
if (!data.WriteInt32(size)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "write export configs size fail");
|
||||
return INNER_ERR;
|
||||
}
|
||||
for (const auto& config : exportConfigs) {
|
||||
if (!data.WriteString(config)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "write export config item fail");
|
||||
return INNER_ERR;
|
||||
}
|
||||
}
|
||||
if (!data.WriteInt32(flag)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "write flag fail");
|
||||
return INNER_ERR;
|
||||
}
|
||||
auto error = SendRequest(AbilityManagerInterfaceCode::UPDATE_ASSOCIATE_CONFIG_LIST, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "request error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
bool AbilityManagerProxy::UpdateAssociateConfigInner(const std::map<std::string, std::list<std::string>>& configs,
|
||||
MessageParcel& data)
|
||||
{
|
||||
int32_t size = static_cast<int32_t>(configs.size());
|
||||
if (size > MAX_UPDATE_CONFIG_SIZE) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "configs size too large");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(size)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "write configs size fail");
|
||||
return false;
|
||||
}
|
||||
for (const auto& config : configs) {
|
||||
if (!data.WriteString(config.first)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "write config key fail");
|
||||
return false;
|
||||
}
|
||||
size = static_cast<int32_t>(config.second.size());
|
||||
if (size > MAX_UPDATE_CONFIG_SIZE) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "config size too large");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteInt32(size)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "write config item size fail");
|
||||
return false;
|
||||
}
|
||||
for (const auto& item : config.second) {
|
||||
if (!data.WriteString(item)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "write config item fail");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user