mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 15:20:34 +00:00
Merge branch 'master' of gitee.com:openharmony/ability_ability_runtime into master
Signed-off-by: jerry <sijunjie@huawei.com>
This commit is contained in:
commit
1933d4f02b
@ -19,8 +19,6 @@ ability_runtime_innerkits_path = "${ability_runtime_path}/interfaces/inner_api"
|
||||
ability_runtime_native_path = "${ability_runtime_path}/frameworks/native"
|
||||
ability_runtime_services_path = "${ability_runtime_path}/services"
|
||||
ability_runtime_test_path = "${ability_runtime_path}/test"
|
||||
ability_runtime_system_test_app_path =
|
||||
"${ability_runtime_path}/test/resource/amssystemtestability/abilitySrc"
|
||||
ace_engine_path = "//foundation/arkui/ace_engine"
|
||||
arkui_path = "//foundation/arkui"
|
||||
|
||||
@ -33,9 +31,6 @@ windowmanager_path = "//foundation/window/window_manager"
|
||||
graphic_path = "//foundation/graphic/graphic_2d"
|
||||
global_path = "//base/global"
|
||||
distributedschedule_path = "//foundation/systemabilitymgr"
|
||||
notification_path = "//base/notification"
|
||||
ans_core_path =
|
||||
"${notification_path}/distributed_notification_service/frameworks/core"
|
||||
eventhandler_path = "//base/notification/eventhandler"
|
||||
distributeddatamgr_path = "//foundation/distributeddatamgr"
|
||||
form_fwk_napi_path = "${form_fwk_path}/frameworks/js/napi"
|
||||
|
18
bundle.json
18
bundle.json
@ -95,7 +95,7 @@
|
||||
"//foundation/ability/ability_runtime/service_router_framework:srms_target",
|
||||
"//foundation/ability/ability_runtime/service_router_framework:jsapi_target"
|
||||
],
|
||||
"inner_kits": [
|
||||
"inner_api": [
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/inner_api/deps_wrapper/include",
|
||||
@ -228,14 +228,6 @@
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/interfaces/inner_api/connectionobs_manager:connection_obs_manager"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/",
|
||||
"header_files": [
|
||||
]
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:static_subscriber_extension"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/",
|
||||
@ -245,14 +237,6 @@
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:service_extension"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/",
|
||||
"header_files": [
|
||||
]
|
||||
},
|
||||
"name": "//foundation/ability/ability_runtime/frameworks/native/ability/native:ui_extension"
|
||||
},
|
||||
{
|
||||
"header": {
|
||||
"header_base": "//foundation/ability/ability_runtime/interfaces/kits/native/ability/native/",
|
||||
|
@ -135,10 +135,6 @@ class AbilityContext extends Context {
|
||||
return this.__context_impl__.terminateSelfWithResult(abilityResult, callback)
|
||||
}
|
||||
|
||||
requestPermissionsFromUser(permissions, resultCallback) {
|
||||
return this.__context_impl__.requestPermissionsFromUser(permissions, resultCallback)
|
||||
}
|
||||
|
||||
restoreWindowStage(contentStorage) {
|
||||
return this.__context_impl__.restoreWindowStage(contentStorage)
|
||||
}
|
||||
|
@ -107,7 +107,10 @@ private:
|
||||
void JsFeatureAbility::Finalizer(NativeEngine *engine, void *data, void *hint)
|
||||
{
|
||||
HILOG_DEBUG("JsFeatureAbility::Finalizer is called");
|
||||
std::unique_ptr<JsFeatureAbility>(static_cast<JsFeatureAbility*>(data));
|
||||
auto pthis = std::unique_ptr<JsFeatureAbility>(static_cast<JsFeatureAbility*>(data));
|
||||
if (pthis) {
|
||||
pthis->RemoveAllCallbacksLocked();
|
||||
}
|
||||
}
|
||||
|
||||
NativeValue* JsFeatureAbilityInit(NativeEngine *engine, NativeValue *exports)
|
||||
|
@ -127,6 +127,7 @@ public:
|
||||
std::string ConvertErrorCode(int32_t errCode);
|
||||
void AddFreeInstallObserver(NativeEngine& engine, const AAFwk::Want &want, NativeValue* callback);
|
||||
sptr<NAPIAbilityConnection> FindConnectionLocked(const Want &want, int64_t &id);
|
||||
void RemoveAllCallbacksLocked();
|
||||
bool CreateConnectionAndConnectAbilityLocked(
|
||||
std::shared_ptr<ConnectionCallback> callback, const Want &want, int64_t &id);
|
||||
void RemoveConnectionLocked(const Want &want);
|
||||
|
@ -3278,6 +3278,23 @@ size_t NAPIAbilityConnection::GetCallbackSize()
|
||||
return callbacks_.size();
|
||||
}
|
||||
|
||||
size_t NAPIAbilityConnection::ReomveAllCallbacks(ConnectRemoveKeyType key)
|
||||
{
|
||||
size_t result = 0;
|
||||
std::lock_guard<std::mutex> guard(lock_);
|
||||
for (auto it = callbacks_.begin(); it != callbacks_.end();) {
|
||||
auto callback = *it;
|
||||
if (callback && callback->removeKey == key) {
|
||||
it = callbacks_.erase(it);
|
||||
result++;
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
HILOG_INFO("ReomveAllCallbacks removed size:%{public}zu, left size:%{public}zu", result, callbacks_.size());
|
||||
return result;
|
||||
}
|
||||
|
||||
void UvWorkOnAbilityConnectDone(uv_work_t *work, int status)
|
||||
{
|
||||
HILOG_INFO("UvWorkOnAbilityConnectDone, uv_queue_work");
|
||||
@ -3983,7 +4000,7 @@ NativeValue* JsNapiCommon::JsConnectAbility(
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
auto connectionCallback = std::make_shared<ConnectionCallback>(env, secondParam);
|
||||
auto connectionCallback = std::make_shared<ConnectionCallback>(env, secondParam, this);
|
||||
bool result = false;
|
||||
int32_t errorVal = static_cast<int32_t>(NAPI_ERR_NO_ERROR);
|
||||
int64_t id = 0;
|
||||
@ -4154,6 +4171,26 @@ sptr<NAPIAbilityConnection> JsNapiCommon::FindConnectionLocked(const Want &want,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void JsNapiCommon::RemoveAllCallbacksLocked()
|
||||
{
|
||||
HILOG_DEBUG("RemoveAllCallbacksLocked begin");
|
||||
std::lock_guard<std::recursive_mutex> lock(connectionsLock_);
|
||||
for (auto it = connects_.begin(); it != connects_.end();) {
|
||||
auto connection = it->second;
|
||||
if (!connection) {
|
||||
HILOG_ERROR("connection is nullptr");
|
||||
it = connects_.erase(it);
|
||||
continue;
|
||||
}
|
||||
connection->ReomveAllCallbacks(this);
|
||||
if (connection->GetCallbackSize() == 0) {
|
||||
it = connects_.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JsNapiCommon::RemoveConnectionLocked(const Want &want)
|
||||
{
|
||||
std::string deviceId = want.GetElement().GetDeviceID();
|
||||
|
@ -219,8 +219,10 @@ enum {
|
||||
CONNECTION_STATE_CONNECTING = 1
|
||||
};
|
||||
|
||||
class JsNapiCommon;
|
||||
using ConnectRemoveKeyType = JsNapiCommon*;
|
||||
struct ConnectionCallback {
|
||||
ConnectionCallback(napi_env env, napi_value cbInfo)
|
||||
ConnectionCallback(napi_env env, napi_value cbInfo, ConnectRemoveKeyType key)
|
||||
{
|
||||
this->env = env;
|
||||
napi_value jsMethod = nullptr;
|
||||
@ -230,16 +232,19 @@ struct ConnectionCallback {
|
||||
napi_create_reference(env, jsMethod, 1, &disconnectCallbackRef);
|
||||
napi_get_named_property(env, cbInfo, "onFailed", &jsMethod);
|
||||
napi_create_reference(env, jsMethod, 1, &failedCallbackRef);
|
||||
removeKey = key;
|
||||
}
|
||||
ConnectionCallback(ConnectionCallback &) = delete;
|
||||
ConnectionCallback(ConnectionCallback &&other)
|
||||
: env(other.env), connectCallbackRef(other.connectCallbackRef),
|
||||
disconnectCallbackRef(other.disconnectCallbackRef), failedCallbackRef(other.failedCallbackRef)
|
||||
disconnectCallbackRef(other.disconnectCallbackRef), failedCallbackRef(other.failedCallbackRef),
|
||||
removeKey(other.removeKey)
|
||||
{
|
||||
other.env = nullptr;
|
||||
other.connectCallbackRef = nullptr;
|
||||
other.disconnectCallbackRef = nullptr;
|
||||
other.failedCallbackRef = nullptr;
|
||||
other.removeKey = nullptr;
|
||||
}
|
||||
const ConnectionCallback &operator=(ConnectionCallback &) = delete;
|
||||
const ConnectionCallback &operator=(ConnectionCallback &&other)
|
||||
@ -253,6 +258,7 @@ struct ConnectionCallback {
|
||||
other.connectCallbackRef = nullptr;
|
||||
other.disconnectCallbackRef = nullptr;
|
||||
other.failedCallbackRef = nullptr;
|
||||
other.removeKey = nullptr;
|
||||
return *this;
|
||||
}
|
||||
~ConnectionCallback()
|
||||
@ -276,12 +282,14 @@ struct ConnectionCallback {
|
||||
}
|
||||
env = nullptr;
|
||||
}
|
||||
removeKey = nullptr;
|
||||
}
|
||||
|
||||
napi_env env = nullptr;
|
||||
napi_ref connectCallbackRef = nullptr;
|
||||
napi_ref disconnectCallbackRef = nullptr;
|
||||
napi_ref failedCallbackRef = nullptr;
|
||||
ConnectRemoveKeyType removeKey = nullptr;
|
||||
};
|
||||
|
||||
class NAPIAbilityConnection : public AAFwk::AbilityConnectionStub {
|
||||
@ -295,6 +303,7 @@ public:
|
||||
int GetConnectionState() const;
|
||||
void SetConnectionState(int connectionState);
|
||||
size_t GetCallbackSize();
|
||||
size_t ReomveAllCallbacks(ConnectRemoveKeyType key);
|
||||
|
||||
private:
|
||||
std::list<std::shared_ptr<ConnectionCallback>> callbacks_;
|
||||
|
@ -44,6 +44,7 @@ NativeValue* CreateJsMissionInfo(NativeEngine &engine, const AAFwk::MissionInfo
|
||||
object->SetProperty("want", CreateJsWant(engine, missionInfo.want));
|
||||
object->SetProperty("label", CreateJsValue(engine, missionInfo.label));
|
||||
object->SetProperty("iconPath", CreateJsValue(engine, missionInfo.iconPath));
|
||||
object->SetProperty("abilityState", CreateJsValue(engine, missionInfo.abilityState));
|
||||
return objValue;
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "js_runtime_utils.h"
|
||||
#include "mission_snapshot.h"
|
||||
#include "napi_common_start_options.h"
|
||||
#include "native_engine/native_value.h"
|
||||
#include "permission_constants.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "pixel_map_napi.h"
|
||||
@ -119,6 +120,18 @@ public:
|
||||
return (me != nullptr) ? me->OnMoveMissionToFront(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
static NativeValue* MoveMissionsToForeground(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsMissionManager* me = CheckParamsAndGetThis<JsMissionManager>(engine, info);
|
||||
return (me != nullptr) ? me->OnMoveMissionsToForeground(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
static NativeValue* MoveMissionsToBackground(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsMissionManager* me = CheckParamsAndGetThis<JsMissionManager>(engine, info);
|
||||
return (me != nullptr) ? me->OnMoveMissionsToBackground(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
NativeValue* OnRegisterMissionListener(NativeEngine &engine, NativeCallbackInfo &info)
|
||||
{
|
||||
@ -522,6 +535,112 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue *OnMoveMissionsToForeground(NativeEngine &engine, NativeCallbackInfo &info)
|
||||
{
|
||||
HILOG_INFO("%{public}s is called", __FUNCTION__);
|
||||
std::vector<int32_t> missionIds;
|
||||
if (info.argc < ARGC_ONE) {
|
||||
HILOG_ERROR("OnMoveMissionsToForeground Not enough params");
|
||||
ThrowTooFewParametersError(engine);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
NativeArray *nativeArray = ConvertNativeValueTo<NativeArray>(info.argv[0]);
|
||||
if (nativeArray == nullptr) {
|
||||
HILOG_ERROR("OnMoveMissionsToForeground Parse missionIds array failed");
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
for (uint32_t i = 0; i < nativeArray->GetLength(); i++) {
|
||||
int32_t missionId;
|
||||
if (!ConvertFromJsValue(engine, nativeArray->GetElement(i), missionId)) {
|
||||
HILOG_ERROR("OnMoveMissionsToForeground Parse missionId failed");
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
missionIds.push_back(missionId);
|
||||
}
|
||||
|
||||
int topMissionId = -1;
|
||||
decltype(info.argc) unwrapArgc = 1;
|
||||
if (info.argc > ARGC_ONE && info.argv[1]->TypeOf() == NATIVE_NUMBER) {
|
||||
if (!ConvertFromJsValue(engine, info.argv[1], topMissionId)) {
|
||||
HILOG_ERROR("OnMoveMissionsToForeground Parse topMissionId failed");
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
unwrapArgc++;
|
||||
}
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[missionIds, topMissionId](NativeEngine &engine, AsyncTask &task, int32_t status) {
|
||||
auto ret =
|
||||
AAFwk::AbilityManagerClient::GetInstance()->MoveMissionsToForeground(missionIds, topMissionId);
|
||||
if (ret == 0) {
|
||||
task.ResolveWithNoError(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
task.Reject(engine,
|
||||
CreateJsErrorByNativeErr(engine, ret, PermissionConstants::PERMISSION_MANAGE_MISSION));
|
||||
}
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc > unwrapArgc) ? info.argv[unwrapArgc] : nullptr;
|
||||
NativeValue *result = nullptr;
|
||||
AsyncTask::Schedule("MissioManager::OnMoveMissionsToForeground", engine,
|
||||
CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue* OnMoveMissionsToBackground(NativeEngine &engine, NativeCallbackInfo &info)
|
||||
{
|
||||
HILOG_INFO("%{public}s is called", __FUNCTION__);
|
||||
std::vector<int32_t> missionIds;
|
||||
|
||||
if (info.argc < ARGC_ONE) {
|
||||
HILOG_ERROR("OnMoveMissionsToBackground Not enough params");
|
||||
ThrowTooFewParametersError(engine);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
NativeArray *nativeArray = ConvertNativeValueTo<NativeArray>(info.argv[0]);
|
||||
if (nativeArray == nullptr) {
|
||||
HILOG_ERROR("OnMoveMissionsToBackground Parse missionIds array failed");
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
for (uint32_t i = 0; i < nativeArray->GetLength(); i++) {
|
||||
int32_t missionId;
|
||||
if (!ConvertFromJsValue(engine, nativeArray->GetElement(i), missionId)) {
|
||||
HILOG_ERROR("OnMoveMissionsToBackground Parse topMissionId failed");
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
missionIds.push_back(missionId);
|
||||
}
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[missionIds](NativeEngine &engine, AsyncTask &task, int32_t status) {
|
||||
std::vector<int32_t> resultMissionIds;
|
||||
auto ret = AbilityManagerClient::GetInstance()->MoveMissionsToBackground(missionIds, resultMissionIds);
|
||||
if (ret == 0) {
|
||||
NativeValue* arrayValue = engine.CreateArray(resultMissionIds.size());
|
||||
NativeArray* array = ConvertNativeValueTo<NativeArray>(arrayValue);
|
||||
uint32_t index = 0;
|
||||
for (const auto &missionId : resultMissionIds) {
|
||||
array->SetElement(index++, CreateJsValue(engine, missionId));
|
||||
}
|
||||
task.ResolveWithNoError(engine, arrayValue);
|
||||
} else {
|
||||
task.Reject(engine,
|
||||
CreateJsErrorByNativeErr(engine, ret, PermissionConstants::PERMISSION_MANAGE_MISSION));
|
||||
}
|
||||
};
|
||||
|
||||
NativeValue* lastParam = (info.argc <= 1) ? nullptr : info.argv[1];
|
||||
NativeValue* result = nullptr;
|
||||
AsyncTask::Schedule("MissioManager::OnMoveMissionsToBackground",
|
||||
engine, CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, std::move(complete), &result));
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
bool CheckOnOffType(NativeEngine &engine, NativeCallbackInfo &info)
|
||||
{
|
||||
@ -583,6 +702,10 @@ NativeValue* JsMissionManagerInit(NativeEngine* engine, NativeValue* exportObj)
|
||||
BindNativeFunction(*engine, *object, "clearMission", moduleName, JsMissionManager::ClearMission);
|
||||
BindNativeFunction(*engine, *object, "clearAllMissions", moduleName, JsMissionManager::ClearAllMissions);
|
||||
BindNativeFunction(*engine, *object, "moveMissionToFront", moduleName, JsMissionManager::MoveMissionToFront);
|
||||
BindNativeFunction(*engine, *object,
|
||||
"moveMissionsToForeground", moduleName, JsMissionManager::MoveMissionsToForeground);
|
||||
BindNativeFunction(*engine, *object,
|
||||
"moveMissionsToBackground", moduleName, JsMissionManager::MoveMissionsToBackground);
|
||||
return engine->CreateUndefined();
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
|
@ -18,34 +18,18 @@
|
||||
#include <native_engine/native_engine.h>
|
||||
|
||||
#include "ability_manager_client.h"
|
||||
#include "accesstoken_kit.h"
|
||||
#include "authorization_result.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "connection_manager.h"
|
||||
#include "dialog_request_callback_impl.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "permission_list_state.h"
|
||||
#include "remote_object_wrapper.h"
|
||||
#include "request_constants.h"
|
||||
#include "string_wrapper.h"
|
||||
#include "want_params_wrapper.h"
|
||||
|
||||
using OHOS::Security::AccessToken::AccessTokenKit;
|
||||
using OHOS::Security::AccessToken::PermissionListState;
|
||||
using OHOS::Security::AccessToken::TypePermissionOper;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
const size_t AbilityContext::CONTEXT_TYPE_ID(std::hash<const char*> {} ("AbilityContext"));
|
||||
const std::string GRANT_ABILITY_BUNDLE_NAME = "com.ohos.permissionmanager";
|
||||
const std::string GRANT_ABILITY_ABILITY_NAME = "com.ohos.permissionmanager.GrantAbility";
|
||||
const std::string PERMISSION_KEY = "ohos.user.grant.permission";
|
||||
const std::string STATE_KEY = "ohos.user.grant.permission.state";
|
||||
const std::string TOKEN_KEY = "ohos.ability.params.token";
|
||||
const std::string CALLBACK_KEY = "ohos.ability.params.callback";
|
||||
|
||||
std::mutex AbilityContextImpl::mutex_;
|
||||
std::map<int, PermissionRequestTask> AbilityContextImpl::permissionRequestCallbacks;
|
||||
|
||||
struct RequestResult {
|
||||
int32_t resultCode {0};
|
||||
@ -432,135 +416,6 @@ sptr<IRemoteObject> AbilityContextImpl::GetToken()
|
||||
return token_;
|
||||
}
|
||||
|
||||
void AbilityContextImpl::RequestPermissionsFromUser(NativeEngine& engine, const std::vector<std::string>& permissions,
|
||||
int requestCode, PermissionRequestTask&& task)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
if (permissions.empty()) {
|
||||
HILOG_ERROR("%{public}s. The params are invalid.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<PermissionListState> permList;
|
||||
for (const auto& permission : permissions) {
|
||||
HILOG_DEBUG("%{public}s. permission: %{public}s.", __func__, permission.c_str());
|
||||
PermissionListState permState;
|
||||
permState.permissionName = permission;
|
||||
permState.state = -1;
|
||||
permList.emplace_back(permState);
|
||||
}
|
||||
HILOG_DEBUG("%{public}s. permList size: %{public}zu, permissions size: %{public}zu.",
|
||||
__func__, permList.size(), permissions.size());
|
||||
|
||||
auto ret = AccessTokenKit::GetSelfPermissionsState(permList);
|
||||
if (permList.size() != permissions.size()) {
|
||||
HILOG_ERROR("%{public}s. Returned permList size: %{public}zu.", __func__, permList.size());
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<int> permissionsState;
|
||||
for (const auto& permState : permList) {
|
||||
HILOG_DEBUG("%{public}s. permissions: %{public}s. permissionsState: %{public}u",
|
||||
__func__, permState.permissionName.c_str(), permState.state);
|
||||
permissionsState.emplace_back(permState.state);
|
||||
}
|
||||
HILOG_DEBUG("%{public}s. permissions size: %{public}zu. permissionsState size: %{public}zu",
|
||||
__func__, permissions.size(), permissionsState.size());
|
||||
|
||||
if (ret == TypePermissionOper::DYNAMIC_OPER) {
|
||||
StartGrantExtension(engine, permissions, permissionsState, requestCode, std::move(task));
|
||||
} else {
|
||||
HILOG_DEBUG("%{public}s. No dynamic popup required.", __func__);
|
||||
if (task) {
|
||||
task(permissions, permissionsState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AbilityContextImpl::StartGrantExtension(NativeEngine& engine, const std::vector<std::string>& permissions,
|
||||
const std::vector<int>& permissionsState, int requestCode, PermissionRequestTask&& task)
|
||||
{
|
||||
AAFwk::Want want;
|
||||
want.SetElementName(GRANT_ABILITY_BUNDLE_NAME, GRANT_ABILITY_ABILITY_NAME);
|
||||
want.SetParam(PERMISSION_KEY, permissions);
|
||||
want.SetParam(STATE_KEY, permissionsState);
|
||||
want.SetParam(TOKEN_KEY, token_);
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
permissionRequestCallbacks.insert(make_pair(requestCode, std::move(task)));
|
||||
}
|
||||
auto resultTask =
|
||||
[&engine, requestCode](const std::vector<std::string>& permissions, const std::vector<int>& grantResults) {
|
||||
auto retCB = new ResultCallback();
|
||||
retCB->permissions_ = permissions;
|
||||
retCB->grantResults_ = grantResults;
|
||||
retCB->requestCode_ = requestCode;
|
||||
|
||||
auto loop = engine.GetUVLoop();
|
||||
if (loop == nullptr) {
|
||||
HILOG_ERROR("StartGrantExtension, fail to get uv loop.");
|
||||
return;
|
||||
}
|
||||
auto work = new uv_work_t;
|
||||
work->data = static_cast<void*>(retCB);
|
||||
int rev = uv_queue_work(
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t* work) {},
|
||||
ResultCallbackJSThreadWorker);
|
||||
if (rev != 0) {
|
||||
if (retCB != nullptr) {
|
||||
delete retCB;
|
||||
retCB = nullptr;
|
||||
}
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
sptr<IRemoteObject> remoteObject = new AuthorizationResult(std::move(resultTask));
|
||||
want.SetParam(CALLBACK_KEY, remoteObject);
|
||||
|
||||
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, token_, -1);
|
||||
HILOG_DEBUG("%{public}s. End calling StartExtension. ret=%{public}d", __func__, err);
|
||||
}
|
||||
|
||||
void AbilityContextImpl::ResultCallbackJSThreadWorker(uv_work_t* work, int status)
|
||||
{
|
||||
HILOG_DEBUG("ResultCallbackJSThreadWorker is called.");
|
||||
if (work == nullptr) {
|
||||
HILOG_ERROR("ResultCallbackJSThreadWorker, uv_queue_work input work is nullptr");
|
||||
return;
|
||||
}
|
||||
ResultCallback* retCB = static_cast<ResultCallback*>(work->data);
|
||||
if (retCB == nullptr) {
|
||||
HILOG_ERROR("ResultCallbackJSThreadWorker, retCB is nullptr");
|
||||
delete work;
|
||||
work = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
auto requestCode = retCB->requestCode_;
|
||||
auto iter = permissionRequestCallbacks.find(requestCode);
|
||||
if (iter != permissionRequestCallbacks.end() && iter->second) {
|
||||
auto task = iter->second;
|
||||
if (task) {
|
||||
HILOG_DEBUG("%{public}s. calling js task.", __func__);
|
||||
task(retCB->permissions_, retCB->grantResults_);
|
||||
}
|
||||
permissionRequestCallbacks.erase(iter);
|
||||
}
|
||||
|
||||
delete retCB;
|
||||
retCB = nullptr;
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
|
||||
ErrCode AbilityContextImpl::RestoreWindowStage(NativeEngine& engine, NativeValue* contentStorage)
|
||||
{
|
||||
HILOG_INFO("%{public}s begin.", __func__);
|
||||
|
@ -286,6 +286,7 @@ ohos_shared_library("abilitykit_native") {
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi_common",
|
||||
"relational_store:native_rdb",
|
||||
"resource_management:global_resmgr",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
|
@ -165,12 +165,6 @@ NativeValue* JsAbilityContext::TerminateSelfWithResult(NativeEngine* engine, Nat
|
||||
return (me != nullptr) ? me->OnTerminateSelfWithResult(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::RequestPermissionsFromUser(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsAbilityContext* me = CheckParamsAndGetThis<JsAbilityContext>(engine, info);
|
||||
return (me != nullptr) ? me->OnRequestPermissionsFromUser(*engine, *info) : nullptr;
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::RestoreWindowStage(NativeEngine* engine, NativeCallbackInfo* info)
|
||||
{
|
||||
JsAbilityContext* me = CheckParamsAndGetThis<JsAbilityContext>(engine, info);
|
||||
@ -1081,56 +1075,6 @@ NativeValue* JsAbilityContext::OnTerminateSelf(NativeEngine& engine, NativeCallb
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::OnRequestPermissionsFromUser(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
HILOG_INFO("OnRequestPermissionsFromUser is called");
|
||||
|
||||
if (info.argc < ARGC_ONE) {
|
||||
HILOG_ERROR("Not enough params");
|
||||
ThrowTooFewParametersError(engine);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
std::vector<std::string> permissionList;
|
||||
if (!OHOS::AppExecFwk::UnwrapArrayStringFromJS(reinterpret_cast<napi_env>(&engine),
|
||||
reinterpret_cast<napi_value>(info.argv[0]), permissionList)) {
|
||||
HILOG_ERROR("%{public}s called, the first parameter is invalid.", __func__);
|
||||
ThrowError(engine, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
|
||||
if (permissionList.size() == 0) {
|
||||
HILOG_ERROR("%{public}s called, params do not meet specification.", __func__);
|
||||
}
|
||||
|
||||
NativeValue* lastParam = (info.argc == ARGC_ONE) ? nullptr : info.argv[ARGC_ONE];
|
||||
NativeValue* result = nullptr;
|
||||
auto uasyncTask = CreateAsyncTaskWithLastParam(engine, lastParam, nullptr, nullptr, &result);
|
||||
std::shared_ptr<AsyncTask> asyncTask = std::move(uasyncTask);
|
||||
PermissionRequestTask task =
|
||||
[&engine, asyncTask](const std::vector<std::string> &permissions, const std::vector<int> &grantResults) {
|
||||
HILOG_INFO("OnRequestPermissionsFromUser async callback is called");
|
||||
NativeValue* requestResult = JsAbilityContext::WrapPermissionRequestResult(engine, permissions, grantResults);
|
||||
if (requestResult == nullptr) {
|
||||
HILOG_WARN("wrap requestResult failed");
|
||||
asyncTask->Reject(engine, CreateJsError(engine, AbilityErrorCode::ERROR_CODE_INNER));
|
||||
} else {
|
||||
asyncTask->Resolve(engine, requestResult);
|
||||
}
|
||||
HILOG_INFO("OnRequestPermissionsFromUser async callback is called end");
|
||||
};
|
||||
auto context = context_.lock();
|
||||
if (context == nullptr) {
|
||||
HILOG_WARN("context is released");
|
||||
asyncTask->Reject(engine, CreateJsError(engine, AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT));
|
||||
} else {
|
||||
curRequestCode_ = (curRequestCode_ == INT_MAX) ? 0 : (curRequestCode_ + 1);
|
||||
context->RequestPermissionsFromUser(engine, permissionList, curRequestCode_, std::move(task));
|
||||
}
|
||||
HILOG_INFO("OnRequestPermissionsFromUser is called end");
|
||||
return result;
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::OnRestoreWindowStage(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
HILOG_INFO("OnRestoreWindowStage is called, argc = %{public}d", static_cast<int>(info.argc));
|
||||
@ -1279,16 +1223,6 @@ NativeValue* JsAbilityContext::WrapAbilityResult(NativeEngine& engine, const int
|
||||
return jAbilityResult;
|
||||
}
|
||||
|
||||
NativeValue* JsAbilityContext::WrapPermissionRequestResult(NativeEngine& engine,
|
||||
const std::vector<std::string> &permissions, const std::vector<int> &grantResults)
|
||||
{
|
||||
NativeValue* jsPermissionRequestResult = engine.CreateObject();
|
||||
NativeObject* permissionRequestResult = ConvertNativeValueTo<NativeObject>(jsPermissionRequestResult);
|
||||
permissionRequestResult->SetProperty("permissions", CreateNativeArray(engine, permissions));
|
||||
permissionRequestResult->SetProperty("authResults", CreateNativeArray(engine, grantResults));
|
||||
return jsPermissionRequestResult;
|
||||
}
|
||||
|
||||
void JsAbilityContext::InheritWindowMode(AAFwk::Want &want)
|
||||
{
|
||||
HILOG_INFO("%{public}s called.", __func__);
|
||||
@ -1407,8 +1341,6 @@ NativeValue* CreateJsAbilityContext(NativeEngine& engine, std::shared_ptr<Abilit
|
||||
BindNativeFunction(engine, *object, "terminateSelf", moduleName, JsAbilityContext::TerminateSelf);
|
||||
BindNativeFunction(engine, *object, "terminateSelfWithResult", moduleName,
|
||||
JsAbilityContext::TerminateSelfWithResult);
|
||||
BindNativeFunction(engine, *object, "requestPermissionsFromUser", moduleName,
|
||||
JsAbilityContext::RequestPermissionsFromUser);
|
||||
BindNativeFunction(engine, *object, "restoreWindowStage", moduleName, JsAbilityContext::RestoreWindowStage);
|
||||
BindNativeFunction(engine, *object, "isTerminating", moduleName, JsAbilityContext::IsTerminating);
|
||||
BindNativeFunction(engine, *object, "startRecentAbility", moduleName,
|
||||
|
@ -129,13 +129,12 @@ ohos_shared_library("appkit_native") {
|
||||
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",
|
||||
]
|
||||
|
||||
public_deps =
|
||||
[ "${global_path}/resource_management/frameworks/resmgr:global_resmgr" ]
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_base:extractresourcemanager",
|
||||
"ability_base:string_utils",
|
||||
"ability_base:want",
|
||||
"ability_runtime:ability_deps_wrapper",
|
||||
"ability_runtime:ability_manager",
|
||||
"ability_runtime:abilitykit_native",
|
||||
"ability_runtime:app_manager",
|
||||
@ -154,13 +153,14 @@ ohos_shared_library("appkit_native") {
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"resource_management:global_resmgr",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
deps += [ "//third_party/icu/icu4c:shared_icuuc" ]
|
||||
public_deps += [ "${global_path}/i18n/frameworks/intl:intl_util" ]
|
||||
external_deps += [ "i18n:intl_util" ]
|
||||
}
|
||||
|
||||
defines = []
|
||||
@ -169,7 +169,7 @@ ohos_shared_library("appkit_native") {
|
||||
}
|
||||
|
||||
if (defined(global_parts_info.web_webview)) {
|
||||
public_deps += [ "${webview_path}/ohos_adapter:nweb_ohos_adapter" ]
|
||||
deps += [ "${webview_path}/ohos_adapter:nweb_ohos_adapter" ]
|
||||
|
||||
include_dirs += [ "${webview_path}/ohos_adapter/interfaces" ]
|
||||
|
||||
@ -208,9 +208,6 @@ ohos_shared_library("app_context") {
|
||||
}
|
||||
deps = []
|
||||
|
||||
public_deps =
|
||||
[ "${global_path}/resource_management/frameworks/resmgr:global_resmgr" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_base:want",
|
||||
@ -225,12 +222,13 @@ ohos_shared_library("app_context") {
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
deps += [ "//third_party/icu/icu4c:shared_icuuc" ]
|
||||
public_deps += [ "${global_path}/i18n/frameworks/intl:intl_util" ]
|
||||
external_deps += [ "i18n:intl_util" ]
|
||||
}
|
||||
|
||||
subsystem_name = "ability"
|
||||
@ -263,9 +261,6 @@ ohos_shared_library("app_context_utils") {
|
||||
"${ability_runtime_native_path}/appkit:application_context_manager",
|
||||
]
|
||||
|
||||
public_deps =
|
||||
[ "${global_path}/resource_management/frameworks/resmgr:global_resmgr" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:ability_runtime_error_util",
|
||||
"ability_runtime:app_manager",
|
||||
@ -277,12 +272,13 @@ ohos_shared_library("app_context_utils") {
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
"resource_management:global_resmgr",
|
||||
"resource_management:resmgr_napi_core",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
deps += [ "//third_party/icu/icu4c:shared_icuuc" ]
|
||||
public_deps += [ "${global_path}/i18n/frameworks/intl:intl_util" ]
|
||||
external_deps += [ "i18n:intl_util" ]
|
||||
}
|
||||
|
||||
subsystem_name = "ability"
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -28,13 +28,8 @@ namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
// for api7 demo special
|
||||
constexpr int CURRENT_ACCOUNT_ID = 100;
|
||||
/**
|
||||
* Attaches a Context object to the current ability.
|
||||
* Generally, this method is called after Ability is loaded to provide the application context for the current ability.
|
||||
*
|
||||
* @param base Indicates a Context object.
|
||||
*/
|
||||
void ContextContainer::AttachBaseContext(const std::shared_ptr<Context> &base)
|
||||
|
||||
void ContextContainer::AttachBaseContext(const std::shared_ptr<ContextDeal> &base)
|
||||
{
|
||||
if (base == nullptr) {
|
||||
HILOG_ERROR("ContextDeal::AttachBaseContext failed, base is nullptr");
|
||||
@ -51,11 +46,6 @@ void ContextContainer::DetachBaseContext()
|
||||
baseContext_ = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when getting the ProcessInfo
|
||||
*
|
||||
* @return ProcessInfo
|
||||
*/
|
||||
std::shared_ptr<ProcessInfo> ContextContainer::GetProcessInfo() const
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -64,12 +54,6 @@ std::shared_ptr<ProcessInfo> ContextContainer::GetProcessInfo() const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains information about the current application. The returned application information includes basic
|
||||
* information such as the application name and application permissions.
|
||||
*
|
||||
* @return Returns the ApplicationInfo for the current application.
|
||||
*/
|
||||
std::shared_ptr<ApplicationInfo> ContextContainer::GetApplicationInfo() const
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -80,11 +64,6 @@ std::shared_ptr<ApplicationInfo> ContextContainer::GetApplicationInfo() const
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the Context object of the application.
|
||||
*
|
||||
* @return Returns the Context object of the application.
|
||||
*/
|
||||
std::shared_ptr<Context> ContextContainer::GetApplicationContext() const
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -95,12 +74,6 @@ std::shared_ptr<Context> ContextContainer::GetApplicationContext() const
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the path of the package containing the current ability. The returned path contains the resources,
|
||||
* source code, and configuration files of a module.
|
||||
*
|
||||
* @return Returns the path of the package file.
|
||||
*/
|
||||
std::string ContextContainer::GetBundleCodePath()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -111,12 +84,6 @@ std::string ContextContainer::GetBundleCodePath()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains information about the current ability.
|
||||
* The returned information includes the class name, bundle name, and other information about the current ability.
|
||||
*
|
||||
* @return Returns the AbilityInfo object for the current ability.
|
||||
*/
|
||||
const std::shared_ptr<AbilityInfo> ContextContainer::GetAbilityInfo()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -127,11 +94,6 @@ const std::shared_ptr<AbilityInfo> ContextContainer::GetAbilityInfo()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the Context object of the application.
|
||||
*
|
||||
* @return Returns the Context object of the application.
|
||||
*/
|
||||
std::shared_ptr<Context> ContextContainer::GetContext()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -142,12 +104,6 @@ std::shared_ptr<Context> ContextContainer::GetContext()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains an IBundleMgr instance.
|
||||
* You can use this instance to obtain information about the application bundle.
|
||||
*
|
||||
* @return Returns an IBundleMgr instance.
|
||||
*/
|
||||
sptr<IBundleMgr> ContextContainer::GetBundleManager() const
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -158,11 +114,6 @@ sptr<IBundleMgr> ContextContainer::GetBundleManager() const
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains a resource manager.
|
||||
*
|
||||
* @return Returns a ResourceManager object.
|
||||
*/
|
||||
std::shared_ptr<Global::Resource::ResourceManager> ContextContainer::GetResourceManager() const
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -173,13 +124,6 @@ std::shared_ptr<Global::Resource::ResourceManager> ContextContainer::GetResource
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deletes the specified private file associated with the application.
|
||||
*
|
||||
* @param fileName Indicates the name of the file to delete. The file name cannot contain path separators.
|
||||
*
|
||||
* @return Returns true if the file is deleted successfully; returns false otherwise.
|
||||
*/
|
||||
bool ContextContainer::DeleteFile(const std::string &fileName)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -190,13 +134,6 @@ bool ContextContainer::DeleteFile(const std::string &fileName)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the application-specific cache directory on the device's internal storage. The system
|
||||
* automatically deletes files from the cache directory if disk space is required elsewhere on the device.
|
||||
* Older files are always deleted first.
|
||||
*
|
||||
* @return Returns the application-specific cache directory.
|
||||
*/
|
||||
std::string ContextContainer::GetCacheDir()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -207,13 +144,6 @@ std::string ContextContainer::GetCacheDir()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the application-specific code-cache directory on the device's internal storage.
|
||||
* The system will delete any files stored in this location both when your specific application is upgraded,
|
||||
* and when the entire platform is upgraded.
|
||||
*
|
||||
* @return Returns the application-specific code-cache directory.
|
||||
*/
|
||||
std::string ContextContainer::GetCodeCacheDir()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -224,12 +154,6 @@ std::string ContextContainer::GetCodeCacheDir()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the local database path.
|
||||
* If the local database path does not exist, the system creates one and returns the created path.
|
||||
*
|
||||
* @return Returns the local database file.
|
||||
*/
|
||||
std::string ContextContainer::GetDatabaseDir()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -240,11 +164,6 @@ std::string ContextContainer::GetDatabaseDir()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the absolute path where all private data files of this application are stored.
|
||||
*
|
||||
* @return Returns the absolute path storing all private data files of this application.
|
||||
*/
|
||||
std::string ContextContainer::GetDataDir()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -255,17 +174,6 @@ std::string ContextContainer::GetDataDir()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the directory for storing custom data files of the application.
|
||||
* You can use the returned File object to create and access files in this directory. The files
|
||||
* can be accessible only by the current application.
|
||||
*
|
||||
* @param name Indicates the name of the directory to retrieve. This directory is created as part
|
||||
* of your application data.
|
||||
* @param mode Indicates the file operating mode. The value can be 0 or a combination of MODE_PRIVATE.
|
||||
*
|
||||
* @return Returns a File object for the requested directory.
|
||||
*/
|
||||
std::string ContextContainer::GetDir(const std::string &name, int mode)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -276,47 +184,6 @@ std::string ContextContainer::GetDir(const std::string &name, int mode)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the absolute path to the application-specific cache directory
|
||||
* on the primary external or shared storage device.
|
||||
*
|
||||
* @return Returns the absolute path to the application-specific cache directory on the external or
|
||||
* shared storage device; returns null if the external or shared storage device is temporarily unavailable.
|
||||
*/
|
||||
std::string ContextContainer::GetExternalCacheDir()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
return baseContext_->GetExternalCacheDir();
|
||||
} else {
|
||||
HILOG_ERROR("ContextContainer::GetExternalCacheDir baseContext_ is nullptr");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the absolute path to the directory for storing files for the application on the
|
||||
* primary external or shared storage device.
|
||||
*
|
||||
* @param type Indicates the type of the file directory to return
|
||||
*
|
||||
* @return Returns the absolute path to the application file directory on the external or shared storage
|
||||
* device; returns null if the external or shared storage device is temporarily unavailable.
|
||||
*/
|
||||
std::string ContextContainer::GetExternalFilesDir(std::string &type)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
return baseContext_->GetExternalFilesDir(type);
|
||||
} else {
|
||||
HILOG_ERROR("ContextContainer::GetExternalFilesDir baseContext_ is nullptr");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the directory for storing files for the application on the device's internal storage.
|
||||
*
|
||||
* @return Returns the application file directory.
|
||||
*/
|
||||
std::string ContextContainer::GetFilesDir()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -327,13 +194,6 @@ std::string ContextContainer::GetFilesDir()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the absolute path which app created and will be excluded from automatic backup to remote storage.
|
||||
* The returned path maybe changed if the application is moved to an adopted storage device.
|
||||
*
|
||||
* @return The path of the directory holding application files that will not be automatically backed up to remote
|
||||
* storage.
|
||||
*/
|
||||
std::string ContextContainer::GetNoBackupFilesDir()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -344,31 +204,6 @@ std::string ContextContainer::GetNoBackupFilesDir()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks whether the current process has the given permission.
|
||||
* You need to call requestPermissionsFromUser(std::vector<std::string>,std::vector<int>, int) to request a permission
|
||||
* only if the current process does not have the specific permission.
|
||||
*
|
||||
* @param permission Indicates the permission to check. This parameter cannot be null.
|
||||
*
|
||||
* @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission;
|
||||
* returns -1 (IBundleManager.PERMISSION_DENIED) otherwise.
|
||||
*/
|
||||
int ContextContainer::VerifySelfPermission(const std::string &permission)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
return baseContext_->VerifySelfPermission(permission);
|
||||
} else {
|
||||
HILOG_ERROR("ContextContainer::VerifySelfPermission baseContext_ is nullptr");
|
||||
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the bundle name of the current ability.
|
||||
*
|
||||
* @return Returns the bundle name of the current ability.
|
||||
*/
|
||||
std::string ContextContainer::GetBundleName() const
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -379,11 +214,6 @@ std::string ContextContainer::GetBundleName() const
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the path of the OHOS Ability Package (HAP} containing this ability.
|
||||
*
|
||||
* @return Returns the path of the HAP containing this ability.
|
||||
*/
|
||||
std::string ContextContainer::GetBundleResourcePath()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -394,29 +224,6 @@ std::string ContextContainer::GetBundleResourcePath()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remove permissions for all users who have access to specific permissions
|
||||
*
|
||||
* @param permission Indicates the permission to unauth. This parameter cannot be null.
|
||||
* @param uri Indicates the URI to unauth. This parameter cannot be null.
|
||||
* @param uid Indicates the UID of the unauth to check.
|
||||
*
|
||||
*/
|
||||
void ContextContainer::UnauthUriPermission(const std::string &permission, const Uri &uri, int uid)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
baseContext_->UnauthUriPermission(permission, uri, uid);
|
||||
} else {
|
||||
HILOG_ERROR("ContextContainer::UnauthUriPermission baseContext_ is nullptr");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains an ability manager.
|
||||
* The ability manager provides information about running processes and memory usage of an application.
|
||||
*
|
||||
* @return Returns an IAbilityManager instance.
|
||||
*/
|
||||
sptr<AAFwk::IAbilityManager> ContextContainer::GetAbilityManager()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -427,14 +234,6 @@ sptr<AAFwk::IAbilityManager> ContextContainer::GetAbilityManager()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the type of this application.
|
||||
*
|
||||
* @return Returns system if this application is a system application;
|
||||
* returns normal if it is released in OHOS AppGallery;
|
||||
* returns other if it is released by a third-party vendor;
|
||||
* returns an empty string if the query fails.
|
||||
*/
|
||||
std::string ContextContainer::GetAppType()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -445,32 +244,6 @@ std::string ContextContainer::GetAppType()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Query whether the application of the specified PID and UID has been granted a certain permission
|
||||
*
|
||||
* @param permissions Indicates the list of permissions to be requested. This parameter cannot be null.
|
||||
* @param pid Process id
|
||||
* @param uid
|
||||
* @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission;
|
||||
* returns -1 (IBundleManager.PERMISSION_DENIED) otherwise.
|
||||
*/
|
||||
int ContextContainer::VerifyPermission(const std::string &permission, int pid, int uid)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
return baseContext_->VerifyPermission(permission, pid, uid);
|
||||
} else {
|
||||
HILOG_ERROR("ContextContainer::VerifyPermission baseContext_ is nullptr");
|
||||
return AppExecFwk::Constants::PERMISSION_NOT_GRANTED;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the distributed file path.
|
||||
* If the distributed file path does not exist, the system creates one and returns the created path. This method is
|
||||
* applicable only to the context of an ability rather than that of an application.
|
||||
*
|
||||
* @return Returns the distributed file.
|
||||
*/
|
||||
std::string ContextContainer::GetDistributedDir()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -480,11 +253,7 @@ std::string ContextContainer::GetDistributedDir()
|
||||
return "";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief Sets the pattern of this Context based on the specified pattern ID.
|
||||
*
|
||||
* @param patternId Indicates the resource ID of the pattern to set.
|
||||
*/
|
||||
|
||||
void ContextContainer::SetPattern(int patternId)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -494,26 +263,6 @@ void ContextContainer::SetPattern(int patternId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the Context object of this ability.
|
||||
*
|
||||
* @return Returns the Context object of this ability.
|
||||
*/
|
||||
std::shared_ptr<Context> ContextContainer::GetAbilityPackageContext()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
return baseContext_->GetAbilityPackageContext();
|
||||
} else {
|
||||
HILOG_ERROR("ContextContainer::GetAbilityPackageContext baseContext_ is nullptr");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the HapModuleInfo object of the application.
|
||||
*
|
||||
* @return Returns the HapModuleInfo object of the application.
|
||||
*/
|
||||
std::shared_ptr<HapModuleInfo> ContextContainer::GetHapModuleInfo()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -524,11 +273,6 @@ std::shared_ptr<HapModuleInfo> ContextContainer::GetHapModuleInfo()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the name of the current process.
|
||||
*
|
||||
* @return Returns the current process name.
|
||||
*/
|
||||
std::string ContextContainer::GetProcessName()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -539,25 +283,6 @@ std::string ContextContainer::GetProcessName()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Requests certain permissions from the system.
|
||||
* This method is called for permission request. This is an asynchronous method. When it is executed,
|
||||
* the task will be called back.
|
||||
*
|
||||
* @param permissions Indicates the list of permissions to be requested. This parameter cannot be null.
|
||||
* @param permissionsState Indicates the list of permissions' state to be requested. This parameter cannot be null.
|
||||
* @param task The callback or promise fo js interface.
|
||||
*/
|
||||
void ContextContainer::RequestPermissionsFromUser(std::vector<std::string> &permissions,
|
||||
std::vector<int> &permissionsState, PermissionRequestTask &&task)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
baseContext_->RequestPermissionsFromUser(permissions, permissionsState, std::move(task));
|
||||
} else {
|
||||
HILOG_ERROR("ContextContainer::RequestPermissionsFromUser baseContext_ is nullptr");
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Context> ContextContainer::CreateBundleContext(std::string bundleName, int flag, int accountId)
|
||||
{
|
||||
if (bundleName.empty()) {
|
||||
@ -646,11 +371,7 @@ void ContextContainer::InitResourceManager(BundleInfo &bundleInfo, std::shared_p
|
||||
resourceManager->UpdateResConfig(*resConfig);
|
||||
deal->initResourceManager(resourceManager);
|
||||
}
|
||||
/**
|
||||
* @brief Obtains information about the caller of this ability.
|
||||
*
|
||||
* @return Returns the caller information.
|
||||
*/
|
||||
|
||||
Uri ContextContainer::GetCaller()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -662,13 +383,6 @@ Uri ContextContainer::GetCaller()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the string of this Context based on the specified resource ID.
|
||||
*
|
||||
* @param resId Indicates the resource ID of the string to get.
|
||||
*
|
||||
* @return Returns the string of this Context.
|
||||
*/
|
||||
std::string ContextContainer::GetString(int resId)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -680,13 +394,6 @@ std::string ContextContainer::GetString(int resId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the string array of this Context based on the specified resource ID.
|
||||
*
|
||||
* @param resId Indicates the resource ID of the string array to get.
|
||||
*
|
||||
* @return Returns the string array of this Context.
|
||||
*/
|
||||
std::vector<std::string> ContextContainer::GetStringArray(int resId)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -697,13 +404,6 @@ std::vector<std::string> ContextContainer::GetStringArray(int resId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the integer array of this Context based on the specified resource ID.
|
||||
*
|
||||
* @param resId Indicates the resource ID of the integer array to get.
|
||||
*
|
||||
* @return Returns the integer array of this Context.
|
||||
*/
|
||||
std::vector<int> ContextContainer::GetIntArray(int resId)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -714,11 +414,6 @@ std::vector<int> ContextContainer::GetIntArray(int resId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the theme of this Context.
|
||||
*
|
||||
* @return theme Returns the theme of this Context.
|
||||
*/
|
||||
std::map<std::string, std::string> ContextContainer::GetTheme()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -729,11 +424,6 @@ std::map<std::string, std::string> ContextContainer::GetTheme()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the theme of this Context based on the specified theme ID.
|
||||
*
|
||||
* @param themeId Indicates the resource ID of the theme to set.
|
||||
*/
|
||||
void ContextContainer::SetTheme(int themeId)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -743,11 +433,6 @@ void ContextContainer::SetTheme(int themeId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the pattern of this Context.
|
||||
*
|
||||
* @return getPattern in interface Context
|
||||
*/
|
||||
std::map<std::string, std::string> ContextContainer::GetPattern()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -758,13 +443,6 @@ std::map<std::string, std::string> ContextContainer::GetPattern()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the color of this Context based on the specified resource ID.
|
||||
*
|
||||
* @param resId Indicates the resource ID of the color to get.
|
||||
*
|
||||
* @return Returns the color value of this Context.
|
||||
*/
|
||||
int ContextContainer::GetColor(int resId)
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -775,11 +453,6 @@ int ContextContainer::GetColor(int resId)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the theme id of this Context.
|
||||
*
|
||||
* @return int Returns the theme id of this Context.
|
||||
*/
|
||||
int ContextContainer::GetThemeId()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -790,11 +463,6 @@ int ContextContainer::GetThemeId()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the current display orientation of this ability.
|
||||
*
|
||||
* @return Returns the current display orientation.
|
||||
*/
|
||||
int ContextContainer::GetDisplayOrientation()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -805,12 +473,6 @@ int ContextContainer::GetDisplayOrientation()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the path storing the preference file of the application.
|
||||
* If the preference file path does not exist, the system creates one and returns the created path.
|
||||
*
|
||||
* @return Returns the preference file path .
|
||||
*/
|
||||
std::string ContextContainer::GetPreferencesDir()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -821,11 +483,6 @@ std::string ContextContainer::GetPreferencesDir()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set color mode
|
||||
*
|
||||
* @param the value of color mode.
|
||||
*/
|
||||
void ContextContainer::SetColorMode(int mode)
|
||||
{
|
||||
if (baseContext_ == nullptr) {
|
||||
@ -836,11 +493,6 @@ void ContextContainer::SetColorMode(int mode)
|
||||
baseContext_->SetColorMode(mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains color mode.
|
||||
*
|
||||
* @return Returns the color mode value.
|
||||
*/
|
||||
int ContextContainer::GetColorMode()
|
||||
{
|
||||
if (baseContext_ == nullptr) {
|
||||
@ -851,11 +503,6 @@ int ContextContainer::GetColorMode()
|
||||
return baseContext_->GetColorMode();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the unique ID of the mission containing this ability.
|
||||
*
|
||||
* @return Returns the unique mission ID.
|
||||
*/
|
||||
int ContextContainer::GetMissionId()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
@ -865,21 +512,5 @@ int ContextContainer::GetMissionId()
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
bool ContextContainer::IsUpdatingConfigurations()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
return baseContext_->IsUpdatingConfigurations();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ContextContainer::PrintDrawnCompleted()
|
||||
{
|
||||
if (baseContext_ != nullptr) {
|
||||
return baseContext_->PrintDrawnCompleted();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,10 +15,11 @@
|
||||
|
||||
#include "main_thread.h"
|
||||
|
||||
#include <malloc.h>
|
||||
#include <new>
|
||||
#include <regex>
|
||||
#include <sys/prctl.h>
|
||||
#include <unistd.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#include "constants.h"
|
||||
#include "ability_delegator.h"
|
||||
@ -1360,6 +1361,11 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
HILOG_ERROR("HandleLaunchApplication app or appmgr is null");
|
||||
return;
|
||||
}
|
||||
|
||||
if (prctl(PR_SET_NAME, "preStartNWeb") < 0) {
|
||||
HILOG_WARN("Set thread name failed with %{public}d", errno);
|
||||
}
|
||||
|
||||
std::string nwebPath = app->GetAppContext()->GetCacheDir() + "/web";
|
||||
bool isFirstStartUpWeb = (access(nwebPath.c_str(), F_OK) != 0);
|
||||
if (!isFirstStartUpWeb) {
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
std::string TranslateBySourceMap(const std::string& stackStr) override;
|
||||
|
||||
private:
|
||||
std::string hapPath_;
|
||||
const std::string hapPath_;
|
||||
bool isModular_ = false;
|
||||
std::shared_ptr<JsEnv::SourceMap> bindSourceMaps_ = nullptr;
|
||||
};
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <condition_variable>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <sys/prctl.h>
|
||||
#include <thread>
|
||||
#include <unordered_map>
|
||||
|
||||
@ -169,6 +170,11 @@ bool SimulatorImpl::Initialize(const Options& options)
|
||||
if (nativeEngine_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (prctl(PR_SET_NAME, "simulatorInit") < 0) {
|
||||
HILOG_WARN("Set thread name failed with %{public}d", errno);
|
||||
}
|
||||
|
||||
bool initResult = OnInit();
|
||||
if (!initResult) {
|
||||
waiter.NotifyResult(false);
|
||||
|
@ -620,6 +620,22 @@ public:
|
||||
ErrCode MoveMissionToFront(int32_t missionId);
|
||||
ErrCode MoveMissionToFront(int32_t missionId, const StartOptions &startOptions);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
ErrCode MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
ErrCode MoveMissionsToBackground(const std::vector<int32_t>& missionIds, std::vector<int32_t>& result);
|
||||
|
||||
/**
|
||||
* @brief Get mission id by ability token.
|
||||
*
|
||||
|
@ -564,6 +564,16 @@ public:
|
||||
|
||||
virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) = 0;
|
||||
|
||||
virtual int MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int MoveMissionsToBackground(const std::vector<int32_t>& missionIds, std::vector<int32_t>& result)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start Ability, connect session with common ability.
|
||||
*
|
||||
@ -1155,6 +1165,8 @@ public:
|
||||
REGISTER_SNAPSHOT_HANDLER = 1114,
|
||||
GET_MISSION_SNAPSHOT_INFO = 1115,
|
||||
UPDATE_MISSION_SNAPSHOT = 1116,
|
||||
MOVE_MISSIONS_TO_FOREGROUND = 1117,
|
||||
MOVE_MISSIONS_TO_BACKGROUND = 1118,
|
||||
|
||||
// ipc id for user test(1120)
|
||||
START_USER_TEST = 1120,
|
||||
|
@ -40,6 +40,7 @@ struct MissionInfo : public Parcelable {
|
||||
std::string label;
|
||||
std::string iconPath;
|
||||
Want want;
|
||||
int32_t abilityState = -1;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -44,6 +44,10 @@ public:
|
||||
|
||||
virtual void NotifyAnimationAbilityDied(sptr<AbilityTransitionInfo> info) = 0;
|
||||
|
||||
virtual int32_t MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId) = 0;
|
||||
|
||||
virtual int32_t MoveMissionsToBackground(const std::vector<int32_t>& missionIds, std::vector<int32_t>& result) = 0;
|
||||
|
||||
enum WMSCmd {
|
||||
// ipc id for NotifyWindowTransition
|
||||
ON_NOTIFY_WINDOW_TRANSITION,
|
||||
@ -62,6 +66,12 @@ public:
|
||||
|
||||
// ipc id for NotifyAnimationAbilityDied
|
||||
ON_NOTIFY_ANIMATION_ABILITY_DIED,
|
||||
|
||||
// ipc id for MoveMissionsToForeground
|
||||
ON_MOVE_MISSINONS_TO_FOREGROUND,
|
||||
|
||||
// ipc id for MoveMissionsToBackground
|
||||
ON_MOVE_MISSIONS_TO_BACKGROUND,
|
||||
};
|
||||
};
|
||||
} // namespace AAFwk
|
||||
|
@ -41,6 +41,11 @@ public:
|
||||
|
||||
virtual void NotifyAnimationAbilityDied(sptr<AbilityTransitionInfo> info) override;
|
||||
|
||||
virtual int32_t MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId) override;
|
||||
|
||||
virtual int32_t MoveMissionsToBackground(const std::vector<int32_t>& missionIds,
|
||||
std::vector<int32_t>& result) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<WindowManagerServiceHandlerProxy> delegator_;
|
||||
};
|
||||
|
@ -42,6 +42,8 @@ private:
|
||||
int StartingWindowHot(MessageParcel &data, MessageParcel &reply);
|
||||
int CancelStartingWindowInner(MessageParcel &data, MessageParcel &reply);
|
||||
int NotifyAnimationAbilityDiedInner(MessageParcel &data, MessageParcel &reply);
|
||||
int MoveMissionsToForegroundInner(MessageParcel &data, MessageParcel &reply);
|
||||
int MoveMissionsToBackgroundInner(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
using RequestFuncType = int (WindowManagerServiceHandlerStub::*)(MessageParcel &data, MessageParcel &reply);
|
||||
std::map<uint32_t, RequestFuncType> requestFuncMap_;
|
||||
|
@ -177,6 +177,78 @@ void WindowManagerServiceHandlerProxy::NotifyAnimationAbilityDied(sptr<AbilityTr
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t WindowManagerServiceHandlerProxy::MoveMissionsToForeground(const std::vector<int32_t>& missionIds,
|
||||
int32_t topMissionId)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32Vector(missionIds)) {
|
||||
HILOG_ERROR("Write missionIds failed");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(topMissionId)) {
|
||||
HILOG_ERROR("Write TopMissionId failed");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("remote is nullptr.");
|
||||
return ERR_INVALID_CONTINUATION_FLAG;
|
||||
}
|
||||
int error = remote->SendRequest(WMSCmd::ON_MOVE_MISSINONS_TO_FOREGROUND, data, reply, option);
|
||||
if (error != ERR_NONE) {
|
||||
HILOG_ERROR("SendoRequest failed, error: %{public}d", error);
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t WindowManagerServiceHandlerProxy::MoveMissionsToBackground(const std::vector<int32_t>& missionIds,
|
||||
std::vector<int32_t>& result)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
|
||||
if (!data.WriteInterfaceToken(IWindowManagerServiceHandler::GetDescriptor())) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32Vector(missionIds)) {
|
||||
HILOG_ERROR("Write missionIds failed");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("remote is nullptr.");
|
||||
return ERR_INVALID_CONTINUATION_FLAG;
|
||||
}
|
||||
int error = remote->SendRequest(WMSCmd::ON_MOVE_MISSIONS_TO_BACKGROUND, data, reply, option);
|
||||
if (error != ERR_NONE) {
|
||||
HILOG_ERROR("SendoRequest failed, error: %{public}d", error);
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
}
|
||||
if (!reply.ReadInt32Vector(&result)) {
|
||||
HILOG_ERROR("Read hide result failed");
|
||||
return ERR_AAFWK_PARCEL_FAIL;
|
||||
};
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
@ -40,6 +40,8 @@ void WindowManagerServiceHandlerStub::Init()
|
||||
requestFuncMap_[ON_CANCEL_STARTING_WINDOW] = &WindowManagerServiceHandlerStub::CancelStartingWindowInner;
|
||||
requestFuncMap_[ON_NOTIFY_ANIMATION_ABILITY_DIED] =
|
||||
&WindowManagerServiceHandlerStub::NotifyAnimationAbilityDiedInner;
|
||||
requestFuncMap_[ON_MOVE_MISSINONS_TO_FOREGROUND] = &WindowManagerServiceHandlerStub::MoveMissionsToForegroundInner;
|
||||
requestFuncMap_[ON_MOVE_MISSIONS_TO_BACKGROUND] = &WindowManagerServiceHandlerStub::MoveMissionsToBackgroundInner;
|
||||
}
|
||||
|
||||
int WindowManagerServiceHandlerStub::OnRemoteRequest(
|
||||
@ -165,6 +167,29 @@ int WindowManagerServiceHandlerStub::NotifyAnimationAbilityDiedInner(MessageParc
|
||||
NotifyAnimationAbilityDied(info);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int WindowManagerServiceHandlerStub::MoveMissionsToForegroundInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
std::vector<int32_t> missionIds;
|
||||
data.ReadInt32Vector(&missionIds);
|
||||
int32_t topMissionId = data.ReadInt32();
|
||||
auto errCode = MoveMissionsToForeground(missionIds, topMissionId);
|
||||
reply.WriteInt32(errCode);
|
||||
return errCode;
|
||||
}
|
||||
|
||||
int WindowManagerServiceHandlerStub::MoveMissionsToBackgroundInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
std::vector<int32_t> missionIds;
|
||||
std::vector<int32_t> result;
|
||||
data.ReadInt32Vector(&missionIds);
|
||||
auto errCode = MoveMissionsToBackground(missionIds, result);
|
||||
reply.WriteInt32Vector(result);
|
||||
return errCode;
|
||||
}
|
||||
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
#endif
|
||||
|
@ -31,7 +31,10 @@ config("ability_deps_wrapper_config") {
|
||||
}
|
||||
|
||||
ohos_shared_library("ability_deps_wrapper") {
|
||||
sources = [ "src/os_account_manager_wrapper.cpp" ]
|
||||
sources = [
|
||||
"src/os_account_manager_wrapper.cpp",
|
||||
"src/sa_mgr_client.cpp",
|
||||
]
|
||||
|
||||
public_configs = [ ":ability_deps_wrapper_config" ]
|
||||
|
||||
@ -40,6 +43,7 @@ ohos_shared_library("ability_deps_wrapper") {
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
if (os_account_part_enabled) {
|
||||
|
@ -96,6 +96,8 @@ public:
|
||||
bool NotifyHotReloadPage() override;
|
||||
void RegisterUncaughtExceptionHandler(JsEnv::UncaughtExceptionInfo uncaughtExceptionInfo);
|
||||
bool LoadScript(const std::string& path, std::vector<uint8_t>* buffer = nullptr, bool isBundle = false);
|
||||
bool StartDebugMode(const std::string& bundleName, bool needBreakPoint, uint32_t instanceId,
|
||||
const DebuggerPostTask& debuggerPostTask = {});
|
||||
|
||||
NativeEngine* GetNativeEnginePointer() const;
|
||||
panda::ecmascript::EcmaVM* GetEcmaVm() const;
|
||||
@ -137,8 +139,6 @@ private:
|
||||
void PreloadAce(const Options& options);
|
||||
bool InitLoop(const std::shared_ptr<AppExecFwk::EventRunner>& eventRunner);
|
||||
inline bool IsUseAbilityRuntime(const Options& options) const;
|
||||
bool StartDebugMode(const std::string& bundleName, bool needBreakPoint, uint32_t instanceId,
|
||||
const DebuggerPostTask& debuggerPostTask = {});
|
||||
void FreeNativeReference(std::unique_ptr<NativeReference> uniqueNativeRef,
|
||||
std::shared_ptr<NativeReference>&& sharedNativeRef);
|
||||
};
|
||||
|
@ -203,17 +203,6 @@ public:
|
||||
|
||||
virtual ErrCode CloseAbility() = 0;
|
||||
|
||||
/**
|
||||
* @brief Requests certain permissions from the system.
|
||||
* This method is called for permission request. This is an asynchronous method. When it is executed,
|
||||
* the task will be called back.
|
||||
*
|
||||
* @param permissions Indicates the list of permissions to be requested. This parameter cannot be null.
|
||||
* @param task The callback or promise fo js interface.
|
||||
*/
|
||||
virtual void RequestPermissionsFromUser(NativeEngine& engine, const std::vector<std::string> &permissions,
|
||||
int requestCode, PermissionRequestTask &&task) = 0;
|
||||
|
||||
/**
|
||||
* @brief Get ContentStorage.
|
||||
*
|
||||
|
@ -87,9 +87,6 @@ public:
|
||||
|
||||
sptr<IRemoteObject> GetToken() override;
|
||||
|
||||
void RequestPermissionsFromUser(NativeEngine& engine, const std::vector<std::string> &permissions, int requestCode,
|
||||
PermissionRequestTask &&task) override;
|
||||
|
||||
ErrCode RestoreWindowStage(NativeEngine& engine, NativeValue* contentStorage) override;
|
||||
|
||||
void SetStageContext(const std::shared_ptr<AbilityRuntime::Context> &stageContext);
|
||||
@ -201,8 +198,6 @@ public:
|
||||
#endif
|
||||
|
||||
private:
|
||||
static std::mutex mutex_;
|
||||
static std::map<int, PermissionRequestTask> permissionRequestCallbacks;
|
||||
sptr<IRemoteObject> token_ = nullptr;
|
||||
std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo_ = nullptr;
|
||||
std::shared_ptr<AbilityRuntime::Context> stageContext_ = nullptr;
|
||||
@ -214,17 +209,8 @@ private:
|
||||
bool isTerminating_ = false;
|
||||
int32_t missionId_ = -1;
|
||||
|
||||
static void ResultCallbackJSThreadWorker(uv_work_t* work, int status);
|
||||
static void RequestDialogResultJSThreadWorker(uv_work_t* work, int status);
|
||||
void OnAbilityResultInner(int requestCode, int resultCode, const AAFwk::Want &resultData);
|
||||
void StartGrantExtension(NativeEngine& engine, const std::vector<std::string>& permissions,
|
||||
const std::vector<int>& permissionsState, int requestCode, PermissionRequestTask &&task);
|
||||
|
||||
struct ResultCallback {
|
||||
std::vector<std::string> permissions_;
|
||||
std::vector<int> grantResults_;
|
||||
int requestCode_;
|
||||
};
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
@ -55,7 +55,6 @@ public:
|
||||
static NativeValue* DisconnectAbility(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* TerminateSelf(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* TerminateSelfWithResult(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* RequestPermissionsFromUser(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* RestoreWindowStage(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* RequestDialogService(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
static NativeValue* IsTerminating(NativeEngine* engine, NativeCallbackInfo* info);
|
||||
@ -94,7 +93,6 @@ private:
|
||||
NativeValue* OnConnectAbilityWithAccount(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnDisconnectAbility(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnTerminateSelf(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnRequestPermissionsFromUser(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnRestoreWindowStage(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnRequestDialogService(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
NativeValue* OnIsTerminating(NativeEngine& engine, NativeCallbackInfo& info);
|
||||
@ -103,8 +101,6 @@ private:
|
||||
static NativeValue* WrapWant(NativeEngine& engine, const AAFwk::Want& want);
|
||||
static bool UnWrapAbilityResult(NativeEngine& engine, NativeValue* argv, int& resultCode, AAFwk::Want& want);
|
||||
static NativeValue* WrapAbilityResult(NativeEngine& engine, const int& resultCode, const AAFwk::Want& want);
|
||||
static NativeValue* WrapPermissionRequestResult(NativeEngine& engine,
|
||||
const std::vector<std::string> &permissions, const std::vector<int> &grantResults);
|
||||
void InheritWindowMode(AAFwk::Want &want);
|
||||
static NativeValue* WrapRequestDialogResult(NativeEngine& engine, int32_t resultCode);
|
||||
void AddFreeInstallObserver(NativeEngine& engine, const AAFwk::Want &want, NativeValue* callback,
|
||||
|
@ -197,7 +197,10 @@ public:
|
||||
* @return Returns the absolute path to the application-specific cache directory on the external or
|
||||
* shared storage device; returns null if the external or shared storage device is temporarily unavailable.
|
||||
*/
|
||||
virtual std::string GetExternalCacheDir() = 0;
|
||||
virtual std::string GetExternalCacheDir()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the absolute path to the directory for storing files for the application on the
|
||||
@ -208,7 +211,10 @@ public:
|
||||
* @return Returns the absolute path to the application file directory on the external or shared storage
|
||||
* device; returns null if the external or shared storage device is temporarily unavailable.
|
||||
*/
|
||||
virtual std::string GetExternalFilesDir(std::string &type) = 0;
|
||||
virtual std::string GetExternalFilesDir(std::string &type)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the directory for storing files for the application on the device's internal storage.
|
||||
@ -236,7 +242,10 @@ public:
|
||||
* @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission;
|
||||
* returns -1 (IBundleManager.PERMISSION_DENIED) otherwise.
|
||||
*/
|
||||
virtual int VerifySelfPermission(const std::string &permission) = 0;
|
||||
virtual int VerifySelfPermission(const std::string &permission)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the bundle name of the current ability.
|
||||
@ -277,7 +286,8 @@ public:
|
||||
* @param uid Indicates the UID of the unauth to check.
|
||||
*
|
||||
*/
|
||||
virtual void UnauthUriPermission(const std::string &permission, const Uri &uri, int uid) = 0;
|
||||
virtual void UnauthUriPermission(const std::string &permission, const Uri &uri, int uid)
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief Obtains an ability manager.
|
||||
@ -324,7 +334,10 @@ public:
|
||||
* @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission;
|
||||
* returns -1 (IBundleManager.PERMISSION_DENIED) otherwise.
|
||||
*/
|
||||
virtual int VerifyPermission(const std::string &permission, int pid, int uid) = 0;
|
||||
virtual int VerifyPermission(const std::string &permission, int pid, int uid)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the distributed file path.
|
||||
@ -347,7 +360,10 @@ public:
|
||||
*
|
||||
* @return Returns the Context object of this ability.
|
||||
*/
|
||||
virtual std::shared_ptr<Context> GetAbilityPackageContext() = 0;
|
||||
virtual std::shared_ptr<Context> GetAbilityPackageContext()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Obtains the HapModuleInfo object of the application.
|
||||
@ -383,7 +399,8 @@ public:
|
||||
* @param task The callback or promise fo js interface.
|
||||
*/
|
||||
virtual void RequestPermissionsFromUser(std::vector<std::string> &permissions, std::vector<int> &permissionsState,
|
||||
PermissionRequestTask &&task) = 0;
|
||||
PermissionRequestTask &&task)
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief Starts a new ability with special ability start setting.
|
||||
@ -554,14 +571,20 @@ public:
|
||||
*
|
||||
* @return Returns true if the configuration of this ability is changing and false otherwise.
|
||||
*/
|
||||
virtual bool IsUpdatingConfigurations() = 0;
|
||||
virtual bool IsUpdatingConfigurations()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Informs the system of the time required for drawing this Page ability.
|
||||
*
|
||||
* @return Returns the notification is successful or fail
|
||||
*/
|
||||
virtual bool PrintDrawnCompleted() = 0;
|
||||
virtual bool PrintDrawnCompleted()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
friend DataAbilityHelperImpl;
|
||||
friend OHOS::DataShare::DataShareHelper;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -32,7 +32,7 @@ public:
|
||||
*
|
||||
* @param base Indicates a Context object.
|
||||
*/
|
||||
void AttachBaseContext(const std::shared_ptr<Context> &base);
|
||||
void AttachBaseContext(const std::shared_ptr<ContextDeal> &base);
|
||||
|
||||
/**
|
||||
* @brief Detach a attatched context.
|
||||
@ -78,20 +78,6 @@ public:
|
||||
*/
|
||||
virtual const std::shared_ptr<AbilityInfo> GetAbilityInfo() override;
|
||||
|
||||
/**
|
||||
* @brief Checks whether the configuration of this ability is changing.
|
||||
*
|
||||
* @return Returns true if the configuration of this ability is changing and false otherwise.
|
||||
*/
|
||||
virtual bool IsUpdatingConfigurations() override;
|
||||
|
||||
/**
|
||||
* @brief Informs the system of the time required for drawing this Page ability.
|
||||
*
|
||||
* @return Returns the notification is successful or fail
|
||||
*/
|
||||
virtual bool PrintDrawnCompleted() override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the Context object of the application.
|
||||
*
|
||||
@ -169,26 +155,6 @@ public:
|
||||
*/
|
||||
std::string GetDir(const std::string &name, int mode) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the absolute path to the application-specific cache directory
|
||||
* on the primary external or shared storage device.
|
||||
*
|
||||
* @return Returns the absolute path to the application-specific cache directory on the external or
|
||||
* shared storage device; returns null if the external or shared storage device is temporarily unavailable.
|
||||
*/
|
||||
std::string GetExternalCacheDir() override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the absolute path to the directory for storing files for the application on the
|
||||
* primary external or shared storage device.
|
||||
*
|
||||
* @param type Indicates the type of the file directory to return
|
||||
*
|
||||
* @return Returns the absolute path to the application file directory on the external or shared storage
|
||||
* device; returns null if the external or shared storage device is temporarily unavailable.
|
||||
*/
|
||||
std::string GetExternalFilesDir(std::string &type) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the directory for storing files for the application on the device's internal storage.
|
||||
*
|
||||
@ -205,18 +171,6 @@ public:
|
||||
*/
|
||||
std::string GetNoBackupFilesDir() override;
|
||||
|
||||
/**
|
||||
* @brief Checks whether the current process has the given permission.
|
||||
* You need to call requestPermissionsFromUser(java.lang.std::string[],int) to request a permission only
|
||||
* if the current process does not have the specific permission.
|
||||
*
|
||||
* @param permission Indicates the permission to check. This parameter cannot be null.
|
||||
*
|
||||
* @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission;
|
||||
* returns -1 (IBundleManager.PERMISSION_DENIED) otherwise.
|
||||
*/
|
||||
int VerifySelfPermission(const std::string &permission) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the bundle name of the current ability.
|
||||
*
|
||||
@ -231,16 +185,6 @@ public:
|
||||
*/
|
||||
std::string GetBundleResourcePath() override;
|
||||
|
||||
/**
|
||||
* @brief Remove permissions for all users who have access to specific permissions
|
||||
*
|
||||
* @param permission Indicates the permission to unauth. This parameter cannot be null.
|
||||
* @param uri Indicates the URI to unauth. This parameter cannot be null.
|
||||
* @param uid Indicates the UID of the unauth to check.
|
||||
*
|
||||
*/
|
||||
void UnauthUriPermission(const std::string &permission, const Uri &uri, int uid) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains an ability manager.
|
||||
* The ability manager provides information about running processes and memory usage of an application.
|
||||
@ -259,17 +203,6 @@ public:
|
||||
*/
|
||||
std::string GetAppType() override;
|
||||
|
||||
/**
|
||||
* @brief Query whether the application of the specified PID and UID has been granted a certain permission
|
||||
*
|
||||
* @param permissions Indicates the list of permissions to be requested. This parameter cannot be null.
|
||||
* @param pid Process id
|
||||
* @param uid
|
||||
* @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission;
|
||||
* returns -1 (IBundleManager.PERMISSION_DENIED) otherwise.
|
||||
*/
|
||||
int VerifyPermission(const std::string &permission, int pid, int uid) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the distributed file path.
|
||||
* If the distributed file path does not exist, the system creates one and returns the created path. This method is
|
||||
@ -286,13 +219,6 @@ public:
|
||||
*/
|
||||
void SetPattern(int patternId) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the Context object of this ability.
|
||||
*
|
||||
* @return Returns the Context object of this ability.
|
||||
*/
|
||||
std::shared_ptr<Context> GetAbilityPackageContext() override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the HapModuleInfo object of the application.
|
||||
*
|
||||
@ -307,18 +233,6 @@ public:
|
||||
*/
|
||||
std::string GetProcessName() override;
|
||||
|
||||
/**
|
||||
* @brief Requests certain permissions from the system.
|
||||
* This method is called for permission request. This is an asynchronous method. When it is executed,
|
||||
* the task will be called back.
|
||||
*
|
||||
* @param permissions Indicates the list of permissions to be requested. This parameter cannot be null.
|
||||
* @param permissionsState Indicates the list of permissions' state to be requested. This parameter cannot be null.
|
||||
* @param task The callback or promise fo js interface.
|
||||
*/
|
||||
void RequestPermissionsFromUser(std::vector<std::string> &permissions, std::vector<int> &permissionsState,
|
||||
PermissionRequestTask &&task) override;
|
||||
|
||||
/**
|
||||
* @brief Creates a Context object for an application with the given bundle name.
|
||||
*
|
||||
@ -448,7 +362,7 @@ public:
|
||||
int GetMissionId() override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Context> baseContext_;
|
||||
std::shared_ptr<ContextDeal> baseContext_;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-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
|
||||
@ -23,7 +23,7 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class ContextDeal : public Context, public std::enable_shared_from_this<ContextDeal> {
|
||||
class ContextDeal : public std::enable_shared_from_this<ContextDeal> {
|
||||
public:
|
||||
ContextDeal() = default;
|
||||
explicit ContextDeal(bool isCreateBySystemApp);
|
||||
@ -34,7 +34,7 @@ public:
|
||||
*
|
||||
* @return ProcessInfo
|
||||
*/
|
||||
std::shared_ptr<ProcessInfo> GetProcessInfo() const override;
|
||||
std::shared_ptr<ProcessInfo> GetProcessInfo() const;
|
||||
|
||||
/**
|
||||
* Called when setting the ProcessInfo
|
||||
@ -49,7 +49,7 @@ public:
|
||||
*
|
||||
* @return Returns the ApplicationInfo for the current application.
|
||||
*/
|
||||
std::shared_ptr<ApplicationInfo> GetApplicationInfo() const override;
|
||||
std::shared_ptr<ApplicationInfo> GetApplicationInfo() const;
|
||||
|
||||
/**
|
||||
* @brief Set ApplicationInfo
|
||||
@ -63,7 +63,7 @@ public:
|
||||
*
|
||||
* @return Returns the Context object of the application.
|
||||
*/
|
||||
std::shared_ptr<Context> GetApplicationContext() const override;
|
||||
std::shared_ptr<Context> GetApplicationContext() const;
|
||||
|
||||
/**
|
||||
* @brief Set ApplicationContext
|
||||
@ -78,7 +78,7 @@ public:
|
||||
*
|
||||
* @return Returns the path of the package file.
|
||||
*/
|
||||
std::string GetBundleCodePath() override;
|
||||
std::string GetBundleCodePath();
|
||||
|
||||
/**
|
||||
* @brief SetBundleCodePath
|
||||
@ -93,7 +93,7 @@ public:
|
||||
*
|
||||
* @return Returns the AbilityInfo object for the current ability.
|
||||
*/
|
||||
const std::shared_ptr<AbilityInfo> GetAbilityInfo() override;
|
||||
const std::shared_ptr<AbilityInfo> GetAbilityInfo();
|
||||
|
||||
/**
|
||||
* @brief Set AbilityInfo
|
||||
@ -107,7 +107,7 @@ public:
|
||||
*
|
||||
* @return Returns the Context object of the ability.
|
||||
*/
|
||||
std::shared_ptr<Context> GetContext() override;
|
||||
std::shared_ptr<Context> GetContext();
|
||||
|
||||
/**
|
||||
* @brief Set Ability context
|
||||
@ -122,14 +122,14 @@ public:
|
||||
*
|
||||
* @return Returns an IBundleMgr instance.
|
||||
*/
|
||||
sptr<IBundleMgr> GetBundleManager() const override;
|
||||
sptr<IBundleMgr> GetBundleManager() const;
|
||||
|
||||
/**
|
||||
* @brief Obtains a resource manager.
|
||||
*
|
||||
* @return Returns a ResourceManager object.
|
||||
*/
|
||||
std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager() const override;
|
||||
std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager() const;
|
||||
|
||||
/**
|
||||
* @brief Set Profile instance.
|
||||
@ -152,19 +152,7 @@ public:
|
||||
*
|
||||
* @return Returns true if the file is deleted successfully; returns false otherwise.
|
||||
*/
|
||||
bool DeleteFile(const std::string &fileName) override;
|
||||
|
||||
/**
|
||||
* @brief Destroys another ability that uses the AbilityInfo.AbilityType.SERVICE template.
|
||||
* The current ability using either the AbilityInfo.AbilityType.SERVICE or AbilityInfo.AbilityType.PAGE
|
||||
* template can call this method to destroy another ability that uses the AbilityInfo.AbilityType.SERVICE
|
||||
* template. The current ability itself can be destroyed by calling the terminateAbility() method.
|
||||
*
|
||||
* @param want Indicates the Want containing information about the ability to destroy.
|
||||
*
|
||||
* @return Returns true if the ability is destroyed successfully; returns false otherwise.
|
||||
*/
|
||||
bool StopAbility(const AAFwk::Want &want) override;
|
||||
bool DeleteFile(const std::string &fileName);
|
||||
|
||||
/**
|
||||
* @brief Obtains the application-specific cache directory on the device's internal storage. The system
|
||||
@ -173,21 +161,7 @@ public:
|
||||
*
|
||||
* @return Returns the application-specific cache directory.
|
||||
*/
|
||||
std::string GetCacheDir() override;
|
||||
|
||||
/**
|
||||
* @brief Checks whether the configuration of this ability is changing.
|
||||
*
|
||||
* @return Returns true if the configuration of this ability is changing and false otherwise.
|
||||
*/
|
||||
bool IsUpdatingConfigurations() override;
|
||||
|
||||
/**
|
||||
* @brief Informs the system of the time required for drawing this Page ability.
|
||||
*
|
||||
* @return Returns the notification is successful or fail
|
||||
*/
|
||||
bool PrintDrawnCompleted() override;
|
||||
std::string GetCacheDir();
|
||||
|
||||
/**
|
||||
* @brief Obtains the application-specific code-cache directory on the device's internal storage.
|
||||
@ -196,7 +170,7 @@ public:
|
||||
*
|
||||
* @return Returns the application-specific code-cache directory.
|
||||
*/
|
||||
std::string GetCodeCacheDir() override;
|
||||
std::string GetCodeCacheDir();
|
||||
|
||||
/**
|
||||
* @brief Obtains the local database path.
|
||||
@ -204,14 +178,14 @@ public:
|
||||
*
|
||||
* @return Returns the local database file.
|
||||
*/
|
||||
std::string GetDatabaseDir() override;
|
||||
std::string GetDatabaseDir();
|
||||
|
||||
/**
|
||||
* @brief Obtains the absolute path where all private data files of this application are stored.
|
||||
*
|
||||
* @return Returns the absolute path storing all private data files of this application.
|
||||
*/
|
||||
std::string GetDataDir() override;
|
||||
std::string GetDataDir();
|
||||
|
||||
/**
|
||||
* @brief Obtains the directory for storing custom data files of the application.
|
||||
@ -224,34 +198,14 @@ public:
|
||||
*
|
||||
* @return Returns a File object for the requested directory.
|
||||
*/
|
||||
std::string GetDir(const std::string &name, int mode) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the absolute path to the application-specific cache directory
|
||||
* on the primary external or shared storage device.
|
||||
*
|
||||
* @return Returns the absolute path to the application-specific cache directory on the external or
|
||||
* shared storage device; returns null if the external or shared storage device is temporarily unavailable.
|
||||
*/
|
||||
std::string GetExternalCacheDir() override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the absolute path to the directory for storing files for the application on the
|
||||
* primary external or shared storage device.
|
||||
*
|
||||
* @param type Indicates the type of the file directory to return
|
||||
*
|
||||
* @return Returns the absolute path to the application file directory on the external or shared storage
|
||||
* device; returns null if the external or shared storage device is temporarily unavailable.
|
||||
*/
|
||||
std::string GetExternalFilesDir(std::string &type) override;
|
||||
std::string GetDir(const std::string &name, int mode);
|
||||
|
||||
/**
|
||||
* @brief Obtains the directory for storing files for the application on the device's internal storage.
|
||||
*
|
||||
* @return Returns the application file directory.
|
||||
*/
|
||||
std::string GetFilesDir() override;
|
||||
std::string GetFilesDir();
|
||||
|
||||
/**
|
||||
* @brief Obtains the absolute path which app created and will be excluded from automatic backup to remote storage.
|
||||
@ -260,60 +214,21 @@ public:
|
||||
* @return The path of the directory holding application files that will not be automatically backed up to remote
|
||||
* storage.
|
||||
*/
|
||||
std::string GetNoBackupFilesDir() override;
|
||||
|
||||
/**
|
||||
* @brief Checks whether the current process has the given permission.
|
||||
* You need to call requestPermissionsFromUser(std::vector<std::string>,std::vector<int>, int) to request
|
||||
* a permission only if the current process does not have the specific permission.
|
||||
*
|
||||
* @param permission Indicates the permission to check. This parameter cannot be null.
|
||||
*
|
||||
* @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission;
|
||||
* returns -1 (IBundleManager.PERMISSION_DENIED) otherwise.
|
||||
*/
|
||||
int VerifySelfPermission(const std::string &permission) override;
|
||||
std::string GetNoBackupFilesDir();
|
||||
|
||||
/**
|
||||
* @brief Obtains the bundle name of the current ability.
|
||||
*
|
||||
* @return Returns the bundle name of the current ability.
|
||||
*/
|
||||
std::string GetBundleName() const override;
|
||||
std::string GetBundleName() const;
|
||||
|
||||
/**
|
||||
* @brief Obtains the path of the OHOS Ability Package (HAP} containing this ability.
|
||||
*
|
||||
* @return Returns the path of the HAP containing this ability.
|
||||
*/
|
||||
std::string GetBundleResourcePath() override;
|
||||
|
||||
/**
|
||||
* @brief Starts a new ability.
|
||||
* An ability using the AbilityInfo.AbilityType.SERVICE or AbilityInfo.AbilityType.PAGE template uses this method
|
||||
* to start a specific ability. The system locates the target ability from installed abilities based on the value
|
||||
* of the want parameter and then starts it. You can specify the ability to start using the want parameter.
|
||||
*
|
||||
* @param want Indicates the Want containing information about the target ability to start.
|
||||
*
|
||||
* @param requestCode Indicates the request code returned after the ability using the AbilityInfo.AbilityType.PAGE
|
||||
* template is started. You can define the request code to identify the results returned by abilities. The value
|
||||
* ranges from 0 to 65535. This parameter takes effect only on abilities using the AbilityInfo.AbilityType.PAGE
|
||||
* template.
|
||||
*
|
||||
* @return errCode ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode StartAbility(const AAFwk::Want &want, int requestCode) override;
|
||||
|
||||
/**
|
||||
* @brief Remove permissions for all users who have access to specific permissions
|
||||
*
|
||||
* @param permission Indicates the permission to unauth. This parameter cannot be null.
|
||||
* @param uri Indicates the URI to unauth. This parameter cannot be null.
|
||||
* @param uid Indicates the UID of the unauth to check.
|
||||
*
|
||||
*/
|
||||
void UnauthUriPermission(const std::string &permission, const Uri &uri, int uid) override;
|
||||
std::string GetBundleResourcePath();
|
||||
|
||||
/**
|
||||
* @brief Obtains an ability manager.
|
||||
@ -321,7 +236,7 @@ public:
|
||||
*
|
||||
* @return Returns an IAbilityManager instance.
|
||||
*/
|
||||
sptr<AAFwk::IAbilityManager> GetAbilityManager() override;
|
||||
sptr<AAFwk::IAbilityManager> GetAbilityManager();
|
||||
|
||||
/**
|
||||
* @brief Obtains the type of this application.
|
||||
@ -331,29 +246,7 @@ public:
|
||||
* returns other if it is released by a third-party vendor;
|
||||
* returns an empty string if the query fails.
|
||||
*/
|
||||
std::string GetAppType() override;
|
||||
|
||||
/**
|
||||
* @brief Destroys another ability you had previously started by calling Ability.startAbilityForResult
|
||||
* (ohos.aafwk.content.Want, int, ohos.aafwk.ability.startsetting.AbilityStartSetting) with the same requestCode
|
||||
* passed.
|
||||
*
|
||||
* @param requestCode Indicates the request code passed for starting the ability.
|
||||
*
|
||||
* @return errCode ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode TerminateAbility(int requestCode) override;
|
||||
|
||||
/**
|
||||
* @brief Query whether the application of the specified PID and UID has been granted a certain permission
|
||||
*
|
||||
* @param permissions Indicates the list of permissions to be requested. This parameter cannot be null.
|
||||
* @param pid Process id
|
||||
* @param uid
|
||||
* @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission;
|
||||
* returns -1 (IBundleManager.PERMISSION_DENIED) otherwise.
|
||||
*/
|
||||
virtual int VerifyPermission(const std::string &permission, int pid, int uid) override;
|
||||
std::string GetAppType();
|
||||
|
||||
/**
|
||||
* @brief Obtains the distributed file path.
|
||||
@ -362,97 +255,28 @@ public:
|
||||
*
|
||||
* @return Returns the distributed file.
|
||||
*/
|
||||
std::string GetDistributedDir() override;
|
||||
std::string GetDistributedDir();
|
||||
|
||||
/**
|
||||
* @brief Sets the pattern of this Context based on the specified pattern ID.
|
||||
*
|
||||
* @param patternId Indicates the resource ID of the pattern to set.
|
||||
*/
|
||||
void SetPattern(int patternId) override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the Context object of this ability.
|
||||
*
|
||||
* @return Returns the Context object of this ability.
|
||||
*/
|
||||
std::shared_ptr<Context> GetAbilityPackageContext() override;
|
||||
void SetPattern(int patternId);
|
||||
|
||||
/**
|
||||
* @brief Obtains the HapModuleInfo object of the application.
|
||||
*
|
||||
* @return Returns the HapModuleInfo object of the application.
|
||||
*/
|
||||
std::shared_ptr<HapModuleInfo> GetHapModuleInfo() override;
|
||||
std::shared_ptr<HapModuleInfo> GetHapModuleInfo();
|
||||
|
||||
/**
|
||||
* @brief Obtains the name of the current process.
|
||||
*
|
||||
* @return Returns the current process name.
|
||||
*/
|
||||
std::string GetProcessName() override;
|
||||
|
||||
/**
|
||||
* @brief Obtains the bundle name of the ability that called the current ability.
|
||||
* You can use the obtained bundle name to check whether the calling ability is allowed to receive the data you will
|
||||
* send. If you did not use Ability.startAbilityForResult(ohos.aafwk.content.Want, int,
|
||||
* ohos.aafwk.ability.startsetting.AbilityStartSetting) to start the calling ability, null is returned.
|
||||
*
|
||||
* @return Returns the bundle name of the calling ability; returns null if no calling ability is available.
|
||||
*/
|
||||
std::string GetCallingBundle() override;
|
||||
|
||||
/**
|
||||
* @brief Requests certain permissions from the system.
|
||||
* This method is called for permission request. This is an asynchronous method. When it is executed,
|
||||
* the task will be called back.
|
||||
*
|
||||
* @param permissions Indicates the list of permissions to be requested. This parameter cannot be null.
|
||||
* @param permissionsState Indicates the list of permissions' state to be requested. This parameter cannot be null.
|
||||
* @param task The callback or promise fo js interface.
|
||||
*/
|
||||
void RequestPermissionsFromUser(std::vector<std::string> &permissions, std::vector<int> &permissionsState,
|
||||
PermissionRequestTask &&task) override;
|
||||
|
||||
/**
|
||||
* @brief Starts a new ability with special ability start setting.
|
||||
*
|
||||
* @param want Indicates the Want containing information about the target ability to start.
|
||||
* @param requestCode Indicates the request code returned after the ability is started. You can define the request
|
||||
* code to identify the results returned by abilities. The value ranges from 0 to 65535.
|
||||
* @param abilityStartSetting Indicates the special start setting used in starting ability.
|
||||
*
|
||||
* @return errCode ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode StartAbility(const Want &want, int requestCode, const AbilityStartSetting &abilityStartSetting) override;
|
||||
|
||||
/**
|
||||
* @brief Destroys the current ability.
|
||||
*
|
||||
* @return errCode ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode TerminateAbility() override;
|
||||
|
||||
/**
|
||||
* @brief Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template.
|
||||
*
|
||||
* @param want Indicates the want containing information about the ability to connect
|
||||
*
|
||||
* @param conn Indicates the callback object when the target ability is connected.
|
||||
*
|
||||
* @return True means success and false means failure
|
||||
*/
|
||||
bool ConnectAbility(const Want &want, const sptr<AAFwk::IAbilityConnection> &conn) override;
|
||||
|
||||
/**
|
||||
* @brief Disconnects the current ability from an ability
|
||||
*
|
||||
* @param conn Indicates the IAbilityConnection callback object passed by connectAbility after the connection
|
||||
* is set up. The IAbilityConnection object uniquely identifies a connection between two abilities.
|
||||
*
|
||||
* @return errCode ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode DisconnectAbility(const sptr<AAFwk::IAbilityConnection> &conn) override;
|
||||
std::string GetProcessName();
|
||||
|
||||
/**
|
||||
* @brief init the ResourceManager for ContextDeal.
|
||||
@ -467,7 +291,7 @@ public:
|
||||
*
|
||||
* @return Returns the caller information.
|
||||
*/
|
||||
Uri GetCaller() override;
|
||||
Uri GetCaller();
|
||||
|
||||
/**
|
||||
* @brief SerUriString
|
||||
@ -481,7 +305,7 @@ public:
|
||||
*
|
||||
* @return Returns the string of this Context.
|
||||
*/
|
||||
std::string GetString(int resId) override;
|
||||
std::string GetString(int resId);
|
||||
|
||||
/**
|
||||
* @brief Get the string array of this Context based on the specified resource ID.
|
||||
@ -490,7 +314,7 @@ public:
|
||||
*
|
||||
* @return Returns the string array of this Context.
|
||||
*/
|
||||
std::vector<std::string> GetStringArray(int resId) override;
|
||||
std::vector<std::string> GetStringArray(int resId);
|
||||
|
||||
/**
|
||||
* @brief Get the integer array of this Context based on the specified resource ID.
|
||||
@ -499,28 +323,28 @@ public:
|
||||
*
|
||||
* @return Returns the integer array of this Context.
|
||||
*/
|
||||
std::vector<int> GetIntArray(int resId) override;
|
||||
std::vector<int> GetIntArray(int resId);
|
||||
|
||||
/**
|
||||
* @brief Obtains the theme of this Context.
|
||||
*
|
||||
* @return theme Returns the theme of this Context.
|
||||
*/
|
||||
std::map<std::string, std::string> GetTheme() override;
|
||||
std::map<std::string, std::string> GetTheme();
|
||||
|
||||
/**
|
||||
* @brief Sets the theme of this Context based on the specified theme ID.
|
||||
*
|
||||
* @param themeId Indicates the resource ID of the theme to set.
|
||||
*/
|
||||
void SetTheme(int themeId) override;
|
||||
void SetTheme(int themeId);
|
||||
|
||||
/**
|
||||
* @brief Obtains the pattern of this Context.
|
||||
*
|
||||
* @return getPattern in interface Context
|
||||
*/
|
||||
std::map<std::string, std::string> GetPattern() override;
|
||||
std::map<std::string, std::string> GetPattern();
|
||||
|
||||
/**
|
||||
* @brief Get the color of this Context based on the specified resource ID.
|
||||
@ -529,38 +353,21 @@ public:
|
||||
*
|
||||
* @return Returns the color value of this Context.
|
||||
*/
|
||||
int GetColor(int resId) override;
|
||||
int GetColor(int resId);
|
||||
|
||||
/**
|
||||
* @brief Obtains the theme id of this Context.
|
||||
*
|
||||
* @return int Returns the theme id of this Context.
|
||||
*/
|
||||
int GetThemeId() override;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
* Destroys this Service ability if the number of times it has been started equals the number represented by the
|
||||
* given {@code startId}. This method is the same as calling {@link #terminateAbility} to destroy this Service
|
||||
* ability, except that this method helps you avoid destroying it if a client has requested a Service
|
||||
* ability startup in {@link ohos.aafwk.ability.Ability#onCommand} but you are unaware of it.
|
||||
*
|
||||
* @param startId Indicates the number of startup times of this Service ability passed to
|
||||
* {@link ohos.aafwk.ability.Ability#onCommand}. The {@code startId} is
|
||||
* incremented by 1 every time this ability is started. For example,
|
||||
* if this ability has been started for six times, the value of {@code startId} is {@code 6}.
|
||||
*
|
||||
* @return Returns {@code true} if the {@code startId} matches the number of startup times
|
||||
* and this Service ability will be destroyed; returns {@code false} otherwise.
|
||||
*/
|
||||
bool TerminateAbilityResult(int startId) override;
|
||||
int GetThemeId();
|
||||
|
||||
/**
|
||||
* @brief Obtains the current display orientation of this ability.
|
||||
*
|
||||
* @return Returns the current display orientation.
|
||||
*/
|
||||
int GetDisplayOrientation() override;
|
||||
int GetDisplayOrientation();
|
||||
|
||||
/**
|
||||
* @brief Obtains the path storing the preference file of the application.
|
||||
@ -568,21 +375,21 @@ public:
|
||||
*
|
||||
* @return Returns the preference file path .
|
||||
*/
|
||||
std::string GetPreferencesDir() override;
|
||||
std::string GetPreferencesDir();
|
||||
|
||||
/**
|
||||
* @brief Set color mode
|
||||
*
|
||||
* @param the value of color mode.
|
||||
*/
|
||||
void SetColorMode(int mode) override;
|
||||
void SetColorMode(int mode);
|
||||
|
||||
/**
|
||||
* @brief Obtains color mode.
|
||||
*
|
||||
* @return Returns the color mode value.
|
||||
*/
|
||||
int GetColorMode() override;
|
||||
int GetColorMode();
|
||||
|
||||
/**
|
||||
* @brief Set the LifeCycleStateInfo to the deal.
|
||||
@ -596,14 +403,7 @@ public:
|
||||
*
|
||||
* @return Returns the unique mission ID.
|
||||
*/
|
||||
int GetMissionId() override;
|
||||
|
||||
/**
|
||||
* @brief Starts multiple abilities.
|
||||
*
|
||||
* @param wants Indicates the Want containing information array about the target ability to start.
|
||||
*/
|
||||
void StartAbilities(const std::vector<AAFwk::Want> &wants) override;
|
||||
int GetMissionId();
|
||||
|
||||
/**
|
||||
* @brief Set EventRunner for main thread.
|
||||
@ -648,7 +448,6 @@ public:
|
||||
int flags_ = 0x00000000;
|
||||
|
||||
protected:
|
||||
sptr<IRemoteObject> GetToken() override;
|
||||
bool HapModuleInfoRequestInit();
|
||||
|
||||
private:
|
||||
|
@ -166,7 +166,6 @@ void SourceMap::SplitSourceMap(const std::string& sourceMapData)
|
||||
size_t rightBracket = 0;
|
||||
std::string value;
|
||||
while ((leftBracket = sourceMapData.find(": {", rightBracket)) != std::string::npos) {
|
||||
std::string left = sourceMapData.substr(leftBracket);
|
||||
rightBracket = sourceMapData.find("},", leftBracket);
|
||||
uint32_t subLeftBracket = leftBracket;
|
||||
uint32_t subRightBracket = rightBracket;
|
||||
|
@ -36,6 +36,7 @@ config("abilityms_config") {
|
||||
"${ability_runtime_innerkits_path}/ability_manager/include",
|
||||
"${ability_runtime_innerkits_path}/app_manager/include",
|
||||
"${ability_runtime_innerkits_path}/connectionobs_manager/include",
|
||||
"${ability_runtime_innerkits_path}/deps_wrapper/include",
|
||||
"${ability_base_path}/interfaces/inner_api/base/include",
|
||||
"${ability_base_kits_path}/extractortool/include",
|
||||
"${ability_base_kits_path}/uri/include",
|
||||
@ -108,7 +109,6 @@ config("abilityms_config") {
|
||||
ohos_shared_library("abilityms") {
|
||||
shlib_type = "sa"
|
||||
sources = abilityms_files
|
||||
sources += [ "src/sa_mgr_client.cpp" ]
|
||||
cflags_cc = []
|
||||
configs = [
|
||||
":abilityms_config",
|
||||
@ -175,13 +175,13 @@ ohos_shared_library("abilityms") {
|
||||
"//third_party/icu/icu4c:shared_icuuc",
|
||||
"//third_party/libjpeg-turbo:turbojpeg_static",
|
||||
]
|
||||
public_deps =
|
||||
[ "${global_path}/resource_management/frameworks/resmgr:global_resmgr" ]
|
||||
|
||||
external_deps += [
|
||||
"ability_base:session_info",
|
||||
"i18n:intl_util",
|
||||
"input:libmmi-client",
|
||||
"multimedia_image_framework:image_native",
|
||||
"resource_management:global_resmgr",
|
||||
"window_manager:libdm",
|
||||
]
|
||||
}
|
||||
|
@ -485,6 +485,11 @@ public:
|
||||
|
||||
virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override;
|
||||
|
||||
virtual int MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId) override;
|
||||
|
||||
virtual int MoveMissionsToBackground(const std::vector<int32_t>& missionIds,
|
||||
std::vector<int32_t>& result) override;
|
||||
|
||||
/**
|
||||
* Start Ability, connect session with common ability.
|
||||
*
|
||||
|
@ -591,6 +591,11 @@ public:
|
||||
|
||||
virtual int MoveMissionToFront(int32_t missionId, const StartOptions &startOptions) override;
|
||||
|
||||
virtual int MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId) override;
|
||||
|
||||
virtual int MoveMissionsToBackground(const std::vector<int32_t>& missionIds,
|
||||
std::vector<int32_t>& result) override;
|
||||
|
||||
virtual int32_t GetMissionIdByToken(const sptr<IRemoteObject> &token) override;
|
||||
|
||||
virtual int StartSyncRemoteMissions(const std::string& devId, bool fixConflict, int64_t tag) override;
|
||||
|
@ -137,6 +137,8 @@ private:
|
||||
int CleanMissionInner(MessageParcel &data, MessageParcel &reply);
|
||||
int CleanAllMissionsInner(MessageParcel &data, MessageParcel &reply);
|
||||
int MoveMissionToFrontInner(MessageParcel &data, MessageParcel &reply);
|
||||
int MoveMissionsToForegroundInner(MessageParcel &data, MessageParcel &reply);
|
||||
int MoveMissionsToBackgroundInner(MessageParcel &data, MessageParcel &reply);
|
||||
int GetMissionIdByTokenInner(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
// for new version ability (call ability)
|
||||
|
@ -923,6 +923,7 @@ private:
|
||||
const AbilityRequest &abilityRequest);
|
||||
void InitColdStartingWindowResource(const std::shared_ptr<Global::Resource::ResourceManager> &resourceMgr);
|
||||
void GetColdStartingWindowResource(std::shared_ptr<Media::PixelMap> &bg, uint32_t &bgColor);
|
||||
void SetAbilityStateInner(AbilityState state);
|
||||
#endif
|
||||
|
||||
static int64_t abilityRecordId;
|
||||
|
@ -49,14 +49,6 @@ const std::string JUMP_INTERCEPTOR_DIALOG_CALLER_PKG = "interceptor_callerPkg";
|
||||
// dlp White list
|
||||
const std::unordered_set<std::string> WHITE_LIST_DLP_SET = { BUNDLE_NAME_SELECTOR_DIALOG };
|
||||
|
||||
static constexpr unsigned int CHANGE_CONFIG_ALL_CHANGED = 0xFFFFFFFF;
|
||||
static constexpr unsigned int CHANGE_CONFIG_NONE = 0x00000000;
|
||||
static constexpr unsigned int CHANGE_CONFIG_LOCALE = 0x00000001;
|
||||
static constexpr unsigned int CHANGE_CONFIG_LAYOUT = 0x00000002;
|
||||
static constexpr unsigned int CHANGE_CONFIG_FONTSIZE = 0x00000004;
|
||||
static constexpr unsigned int CHANGE_CONFIG_ORIENTATION = 0x00000008;
|
||||
static constexpr unsigned int CHANGE_CONFIG_DENSITY = 0x00000010;
|
||||
|
||||
#define CHECK_POINTER_CONTINUE(object) \
|
||||
if (!object) { \
|
||||
HILOG_ERROR("pointer is nullptr."); \
|
||||
@ -182,20 +174,6 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi
|
||||
return iface_cast<AppExecFwk::IBundleMgr>(bundleObj);
|
||||
}
|
||||
|
||||
[[maybe_unused]] static sptr<AppExecFwk::IEcologicalRuleManager> GetEcologicalRuleMgr()
|
||||
{
|
||||
// should remove when AG SA online
|
||||
int32_t ECOLOGICAL_RULE_SA_ID = 9999;
|
||||
auto remoteObject =
|
||||
OHOS::DelayedSingleton<SaMgrClient>::GetInstance()->GetSystemAbility(ECOLOGICAL_RULE_SA_ID);
|
||||
if (remoteObject == nullptr) {
|
||||
HILOG_ERROR("%{public}s error, failed to get ecological rule manager service.", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return iface_cast<AppExecFwk::IEcologicalRuleManager>(remoteObject);
|
||||
}
|
||||
|
||||
[[maybe_unused]] static sptr<AppExecFwk::IEcologicalRuleManager> CheckEcologicalRuleMgr()
|
||||
{
|
||||
// should remove when AG SA online
|
||||
@ -274,7 +252,7 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi
|
||||
return false;
|
||||
}
|
||||
|
||||
[[maybe_unused]] static bool IsStartIncludeAtomicService(const Want &want, const int32_t callerUid)
|
||||
[[maybe_unused]] static bool IsStartIncludeAtomicService(const Want &want, const int32_t userId)
|
||||
{
|
||||
auto bms = GetBundleManager();
|
||||
if (!bms) {
|
||||
@ -285,7 +263,7 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi
|
||||
std::string targetBundleName = want.GetBundle();
|
||||
AppExecFwk::ApplicationInfo targetAppInfo;
|
||||
bool getTargetResult = IN_PROCESS_CALL(bms->GetApplicationInfo(targetBundleName,
|
||||
AppExecFwk::ApplicationFlag::GET_BASIC_APPLICATION_INFO, callerUid, targetAppInfo));
|
||||
AppExecFwk::ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, targetAppInfo));
|
||||
if (!getTargetResult) {
|
||||
HILOG_ERROR("Get targetAppInfo failed in check atomic service.");
|
||||
return false;
|
||||
@ -295,6 +273,7 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi
|
||||
return true;
|
||||
}
|
||||
|
||||
int callerUid = IPCSkeleton::GetCallingUid();
|
||||
std::string callerBundleName;
|
||||
ErrCode err = IN_PROCESS_CALL(bms->GetNameForUid(callerUid, callerBundleName));
|
||||
if (err != ERR_OK) {
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
#include "ability_state.h"
|
||||
#include "inner_mission_info.h"
|
||||
#include "mission_listener_controller.h"
|
||||
#include "mission_snapshot.h"
|
||||
@ -121,6 +122,15 @@ public:
|
||||
*/
|
||||
int UpdateMissionLabel(int32_t missionId, const std::string& label);
|
||||
|
||||
/**
|
||||
* @brief Set mission abilityState.
|
||||
*
|
||||
* @param missionId indicates this mission id.
|
||||
* @param abilityState indicates this mission abilityState.
|
||||
* @return 0 if success.
|
||||
*/
|
||||
void SetMissionAbilityState(int32_t missionId, AbilityState state);
|
||||
|
||||
/**
|
||||
* @brief dump mission info
|
||||
*
|
||||
|
@ -62,7 +62,6 @@
|
||||
*PendingWantManager*;
|
||||
*PendingWantRecord*;
|
||||
*ResidentProcessManager*;
|
||||
*SaMgrClient*;
|
||||
*StartOptions*;
|
||||
*SystemDialogScheduler*;
|
||||
*TaskDataPersistenceMgr*;
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <chrono>
|
||||
|
||||
#include "ability_info.h"
|
||||
#include "ability_manager_errors.h"
|
||||
#include "accesstoken_kit.h"
|
||||
#include "app_jump_control_rule.h"
|
||||
@ -225,8 +226,11 @@ AbilityJumpInterceptor::~AbilityJumpInterceptor()
|
||||
|
||||
ErrCode AbilityJumpInterceptor::DoProcess(const Want &want, int requestCode, int32_t userId, bool isForeground)
|
||||
{
|
||||
int callerUid = IPCSkeleton::GetCallingUid();
|
||||
bool isStartIncludeAtomicService = AbilityUtil::IsStartIncludeAtomicService(want, callerUid);
|
||||
if (!isForeground) {
|
||||
HILOG_INFO("This startup is not foreground, keep going.");
|
||||
return ERR_OK;
|
||||
}
|
||||
bool isStartIncludeAtomicService = AbilityUtil::IsStartIncludeAtomicService(want, userId);
|
||||
if (isStartIncludeAtomicService) {
|
||||
HILOG_INFO("This startup contain atomic service, keep going.");
|
||||
return ERR_OK;
|
||||
@ -237,6 +241,13 @@ ErrCode AbilityJumpInterceptor::DoProcess(const Want &want, int requestCode, int
|
||||
HILOG_ERROR("GetBundleManager failed");
|
||||
return ERR_OK;
|
||||
}
|
||||
AppExecFwk::AbilityInfo targetAbilityInfo;
|
||||
IN_PROCESS_CALL_WITHOUT_RET(bms->QueryAbilityInfo(want,
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION, userId, targetAbilityInfo));
|
||||
if (targetAbilityInfo.type != AppExecFwk::AbilityType::PAGE) {
|
||||
HILOG_INFO("Target is not page Ability, keep going, abilityType:%{public}d", targetAbilityInfo.type);
|
||||
return ERR_OK;
|
||||
}
|
||||
AppExecFwk::AppJumpControlRule controlRule;
|
||||
if (CheckControl(bms, want, userId, controlRule)) {
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
@ -272,6 +283,10 @@ bool AbilityJumpInterceptor::CheckControl(sptr<AppExecFwk::IBundleMgr> &bms, con
|
||||
HILOG_ERROR("GetBundleNameForUid from bms fail.");
|
||||
return false;
|
||||
}
|
||||
if (controlRule.callerPkg.empty() || controlRule.targetPkg.empty()) {
|
||||
HILOG_INFO("This startup is not explicitly, keep going.");
|
||||
return false;
|
||||
}
|
||||
if (controlRule.callerPkg == controlRule.targetPkg) {
|
||||
HILOG_INFO("jump within the same app.");
|
||||
return false;
|
||||
|
@ -744,6 +744,23 @@ ErrCode AbilityManagerClient::MoveMissionToFront(int32_t missionId, const StartO
|
||||
return abms->MoveMissionToFront(missionId, startOptions);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId)
|
||||
{
|
||||
HILOG_INFO("MoveMissionsToForeground begin.");
|
||||
auto abms = GetAbilityManager();
|
||||
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
|
||||
return abms->MoveMissionsToForeground(missionIds, topMissionId);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::MoveMissionsToBackground(const std::vector<int32_t>& missionIds,
|
||||
std::vector<int32_t>& result)
|
||||
{
|
||||
HILOG_INFO("MoveMissionsToBackground begin.");
|
||||
auto abms = GetAbilityManager();
|
||||
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
|
||||
return abms->MoveMissionsToBackground(missionIds, result);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::GetMissionIdByToken(const sptr<IRemoteObject> &token, int32_t &missionId)
|
||||
{
|
||||
auto abms = GetAbilityManager();
|
||||
|
@ -2352,6 +2352,73 @@ int AbilityManagerProxy::MoveMissionToFront(int32_t missionId, const StartOption
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int AbilityManagerProxy::MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32Vector(missionIds)) {
|
||||
HILOG_ERROR("mission id write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32(topMissionId)) {
|
||||
HILOG_ERROR("top mission id write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("%{public}s remote is null", __func__);
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
auto error = remote->SendRequest(IAbilityManager::MOVE_MISSIONS_TO_FOREGROUND, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("query front missionInfo failed: send request error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int AbilityManagerProxy::MoveMissionsToBackground(const std::vector<int32_t>& missionIds, std::vector<int32_t>& result)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
if (!data.WriteInt32Vector(missionIds)) {
|
||||
HILOG_ERROR("mission id write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("%{public}s remote is null", __func__);
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
auto error = remote->SendRequest(IAbilityManager::MOVE_MISSIONS_TO_BACKGROUND, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("query front missionInfo failed: send request error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
|
||||
if (!reply.ReadInt32Vector(&result)) {
|
||||
HILOG_ERROR("read result failed");
|
||||
return INNER_ERR;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int AbilityManagerProxy::StartUser(int userId)
|
||||
{
|
||||
int error;
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "ability_manager_errors.h"
|
||||
#include "ability_util.h"
|
||||
#include "application_util.h"
|
||||
#include "errors.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "bundle_mgr_client.h"
|
||||
#include "distributed_client.h"
|
||||
@ -43,6 +44,7 @@
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "in_process_call_wrapper.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "ipc_types.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "itest_observer.h"
|
||||
#include "mission_info_mgr.h"
|
||||
@ -2608,6 +2610,45 @@ int AbilityManagerService::MoveMissionToFront(int32_t missionId, const StartOpti
|
||||
return currentMissionListManager_->MoveMissionToFront(missionId, options);
|
||||
}
|
||||
|
||||
int AbilityManagerService::MoveMissionsToForeground(const std::vector<int32_t>& missionIds, int32_t topMissionId)
|
||||
{
|
||||
CHECK_CALLER_IS_SYSTEM_APP;
|
||||
if (!PermissionVerification::GetInstance()->VerifyMissionPermission()) {
|
||||
HILOG_ERROR("%{public}s: Permission verification failed", __func__);
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
if (wmsHandler_) {
|
||||
auto ret = wmsHandler_->MoveMissionsToForeground(missionIds, topMissionId);
|
||||
if (ret) {
|
||||
HILOG_ERROR("MoveMissionsToForeground failed, missiondIds may be invalid");
|
||||
return ERR_INVALID_VALUE;
|
||||
} else {
|
||||
return NO_ERROR;
|
||||
}
|
||||
}
|
||||
return ERR_NO_INIT;
|
||||
}
|
||||
|
||||
int AbilityManagerService::MoveMissionsToBackground(const std::vector<int32_t>& missionIds,
|
||||
std::vector<int32_t>& result)
|
||||
{
|
||||
CHECK_CALLER_IS_SYSTEM_APP;
|
||||
if (!PermissionVerification::GetInstance()->VerifyMissionPermission()) {
|
||||
HILOG_ERROR("%{public}s: Permission verification failed", __func__);
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
if (wmsHandler_) {
|
||||
auto ret = wmsHandler_->MoveMissionsToBackground(missionIds, result);
|
||||
if (ret) {
|
||||
HILOG_ERROR("MoveMissionsToBackground failed, missiondIds may be invalid");
|
||||
return ERR_INVALID_VALUE;
|
||||
} else {
|
||||
return NO_ERROR;
|
||||
}
|
||||
}
|
||||
return ERR_NO_INIT;
|
||||
}
|
||||
|
||||
int32_t AbilityManagerService::GetMissionIdByToken(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
HILOG_INFO("request GetMissionIdByToken.");
|
||||
@ -3767,13 +3808,7 @@ int AbilityManagerService::UninstallApp(const std::string &bundleName, int32_t u
|
||||
sptr<AppExecFwk::IBundleMgr> AbilityManagerService::GetBundleManager()
|
||||
{
|
||||
if (iBundleManager_ == nullptr) {
|
||||
auto bundleObj =
|
||||
OHOS::DelayedSingleton<SaMgrClient>::GetInstance()->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
if (bundleObj == nullptr) {
|
||||
HILOG_ERROR("Failed to get bundle manager service.");
|
||||
return nullptr;
|
||||
}
|
||||
iBundleManager_ = iface_cast<AppExecFwk::IBundleMgr>(bundleObj);
|
||||
iBundleManager_ = AbilityUtil::GetBundleManager();
|
||||
}
|
||||
return iBundleManager_;
|
||||
}
|
||||
@ -4732,6 +4767,10 @@ void AbilityManagerService::ScheduleRecoverAbility(const sptr<IRemoteObject>& to
|
||||
return;
|
||||
} else {
|
||||
auto bms = GetBundleManager();
|
||||
if (bms == nullptr) {
|
||||
HILOG_ERROR("bms is nullptr");
|
||||
return;
|
||||
}
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
auto bundleName = want->GetElement().GetBundleName();
|
||||
int32_t userId = GetUserId();
|
||||
|
@ -112,6 +112,8 @@ void AbilityManagerStub::SecondStepInit()
|
||||
requestFuncMap_[CLEAN_ALL_MISSIONS] = &AbilityManagerStub::CleanAllMissionsInner;
|
||||
requestFuncMap_[MOVE_MISSION_TO_FRONT] = &AbilityManagerStub::MoveMissionToFrontInner;
|
||||
requestFuncMap_[MOVE_MISSION_TO_FRONT_BY_OPTIONS] = &AbilityManagerStub::MoveMissionToFrontByOptionsInner;
|
||||
requestFuncMap_[MOVE_MISSIONS_TO_FOREGROUND] = &AbilityManagerStub::MoveMissionsToForegroundInner;
|
||||
requestFuncMap_[MOVE_MISSIONS_TO_BACKGROUND] = &AbilityManagerStub::MoveMissionsToBackgroundInner;
|
||||
requestFuncMap_[START_CALL_ABILITY] = &AbilityManagerStub::StartAbilityByCallInner;
|
||||
requestFuncMap_[CALL_REQUEST_DONE] = &AbilityManagerStub::CallRequestDoneInner;
|
||||
requestFuncMap_[RELEASE_CALL_ABILITY] = &AbilityManagerStub::ReleaseCallInner;
|
||||
@ -1154,6 +1156,38 @@ int AbilityManagerStub::MoveMissionToFrontByOptionsInner(MessageParcel &data, Me
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int AbilityManagerStub::MoveMissionsToForegroundInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
std::vector<int32_t> missionIds;
|
||||
data.ReadInt32Vector(&missionIds);
|
||||
int32_t topMissionId = data.ReadInt32();
|
||||
int32_t errCode = MoveMissionsToForeground(missionIds, topMissionId);
|
||||
if (!reply.WriteInt32(errCode)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return errCode;
|
||||
}
|
||||
|
||||
int AbilityManagerStub::MoveMissionsToBackgroundInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s is called.", __func__);
|
||||
std::vector<int32_t> missionIds;
|
||||
std::vector<int32_t> result;
|
||||
|
||||
data.ReadInt32Vector(&missionIds);
|
||||
int32_t errCode = MoveMissionsToBackground(missionIds, result);
|
||||
HILOG_DEBUG("%{public}s is called. resultSize: %{public}zu", __func__, result.size());
|
||||
if (!reply.WriteInt32Vector(result)) {
|
||||
HILOG_ERROR("%{public}s is called. WriteInt32Vector Failed", __func__);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (!reply.WriteInt32(errCode)) {
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int AbilityManagerStub::StartAbilityByCallInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("AbilityManagerStub::StartAbilityByCallInner begin.");
|
||||
|
@ -329,7 +329,7 @@ void AbilityRecord::ForegroundAbility(uint32_t sceneFlag)
|
||||
|
||||
// schedule active after updating AbilityState and sending timeout message to avoid ability async callback
|
||||
// earlier than above actions.
|
||||
currentState_ = AbilityState::FOREGROUNDING;
|
||||
SetAbilityStateInner(AbilityState::FOREGROUNDING);
|
||||
foregroundingTime_ = AbilityUtil::SystemTimeMillis();
|
||||
lifeCycleStateInfo_.sceneFlag = sceneFlag;
|
||||
lifecycleDeal_->ForegroundNew(want_, lifeCycleStateInfo_, sessionInfo_);
|
||||
@ -1012,7 +1012,7 @@ void AbilityRecord::BackgroundAbility(const Closure &task)
|
||||
|
||||
// schedule background after updating AbilityState and sending timeout message to avoid ability async callback
|
||||
// earlier than above actions.
|
||||
currentState_ = AbilityState::BACKGROUNDING;
|
||||
SetAbilityStateInner(AbilityState::BACKGROUNDING);
|
||||
lifecycleDeal_->BackgroundNew(want_, lifeCycleStateInfo_, sessionInfo_);
|
||||
}
|
||||
|
||||
@ -1053,9 +1053,15 @@ bool AbilityRecord::IsForeground() const
|
||||
return currentState_ == AbilityState::FOREGROUND || currentState_ == AbilityState::FOREGROUNDING;
|
||||
}
|
||||
|
||||
void AbilityRecord::SetAbilityState(AbilityState state)
|
||||
void AbilityRecord::SetAbilityStateInner(AbilityState state)
|
||||
{
|
||||
currentState_ = state;
|
||||
DelayedSingleton<MissionInfoMgr>::GetInstance()->SetMissionAbilityState(missionId_, currentState_);
|
||||
}
|
||||
|
||||
void AbilityRecord::SetAbilityState(AbilityState state)
|
||||
{
|
||||
SetAbilityStateInner(state);
|
||||
if (state == AbilityState::FOREGROUND || state == AbilityState::ACTIVE || state == AbilityState::BACKGROUND) {
|
||||
SetRestarting(false);
|
||||
}
|
||||
@ -1191,7 +1197,7 @@ void AbilityRecord::Activate()
|
||||
|
||||
// schedule active after updating AbilityState and sending timeout message to avoid ability async callback
|
||||
// earlier than above actions.
|
||||
currentState_ = AbilityState::ACTIVATING;
|
||||
SetAbilityStateInner(AbilityState::ACTIVATING);
|
||||
lifecycleDeal_->Activate(want_, lifeCycleStateInfo_);
|
||||
|
||||
// update ability state to appMgr service when restart
|
||||
@ -1216,7 +1222,7 @@ void AbilityRecord::Inactivate()
|
||||
|
||||
// schedule inactive after updating AbilityState and sending timeout message to avoid ability async callback
|
||||
// earlier than above actions.
|
||||
currentState_ = AbilityState::INACTIVATING;
|
||||
SetAbilityStateInner(AbilityState::INACTIVATING);
|
||||
lifecycleDeal_->Inactivate(want_, lifeCycleStateInfo_, sessionInfo_);
|
||||
}
|
||||
|
||||
@ -1241,7 +1247,7 @@ void AbilityRecord::Terminate(const Closure &task)
|
||||
}
|
||||
// schedule background after updating AbilityState and sending timeout message to avoid ability async callback
|
||||
// earlier than above actions.
|
||||
currentState_ = AbilityState::TERMINATING;
|
||||
SetAbilityStateInner(AbilityState::TERMINATING);
|
||||
lifecycleDeal_->Terminate(want_, lifeCycleStateInfo_);
|
||||
}
|
||||
|
||||
|
@ -107,8 +107,8 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_
|
||||
return ret;
|
||||
}
|
||||
if (dialogAllAppInfos.size() == 0) {
|
||||
Want want = sysDialogScheduler->GetTipsDialogWant(request.callerToken);
|
||||
abilityMgr->StartAbility(want);
|
||||
Want dialogWant = sysDialogScheduler->GetTipsDialogWant(request.callerToken);
|
||||
abilityMgr->StartAbility(dialogWant);
|
||||
return ERR_IMPLICIT_START_ABILITY_FAIL;
|
||||
}
|
||||
want = sysDialogScheduler->GetPcSelectorDialogWant(dialogAllAppInfos, request.want,
|
||||
@ -314,13 +314,7 @@ int ImplicitStartProcessor::CallStartAbilityInner(int32_t userId,
|
||||
sptr<AppExecFwk::IBundleMgr> ImplicitStartProcessor::GetBundleManager()
|
||||
{
|
||||
if (iBundleManager_ == nullptr) {
|
||||
auto bundleObj =
|
||||
OHOS::DelayedSingleton<SaMgrClient>::GetInstance()->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
if (bundleObj == nullptr) {
|
||||
HILOG_ERROR("Failed to get bundle manager service.");
|
||||
return nullptr;
|
||||
}
|
||||
iBundleManager_ = iface_cast<AppExecFwk::IBundleMgr>(bundleObj);
|
||||
iBundleManager_ = AbilityUtil::GetBundleManager();
|
||||
}
|
||||
return iBundleManager_;
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ bool MissionInfo::ReadFromParcel(Parcel &parcel)
|
||||
return false;
|
||||
}
|
||||
want = *parcelWant;
|
||||
abilityState = parcel.ReadInt32();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -78,6 +79,9 @@ bool MissionInfo::Marshalling(Parcel &parcel) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parcel.WriteInt32(abilityState)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -349,6 +349,22 @@ int MissionInfoMgr::UpdateMissionLabel(int32_t missionId, const std::string& lab
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MissionInfoMgr::SetMissionAbilityState(int32_t missionId, AbilityState state)
|
||||
{
|
||||
if (missionId <= 0) {
|
||||
return;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
auto it = find_if(missionInfoList_.begin(), missionInfoList_.end(), [missionId](const InnerMissionInfo &info) {
|
||||
return missionId == info.missionInfo.id;
|
||||
});
|
||||
if (it == missionInfoList_.end()) {
|
||||
HILOG_ERROR("SetMissionAbilityState failed, missionId %{public}d not exists", missionId);
|
||||
return;
|
||||
}
|
||||
it->missionInfo.abilityState = state;
|
||||
}
|
||||
|
||||
bool MissionInfoMgr::LoadAllMissionInfo()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
|
@ -529,6 +529,10 @@ void MissionListManager::GetTargetMissionAndAbility(const AbilityRequest &abilit
|
||||
}
|
||||
HILOG_DEBUG("Make new mission data.");
|
||||
targetRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
if (targetRecord == nullptr) {
|
||||
HILOG_ERROR("targetRecord is nullptr");
|
||||
return;
|
||||
}
|
||||
targetMission = std::make_shared<Mission>(info.missionInfo.id, targetRecord,
|
||||
info.missionName, info.startMethod);
|
||||
targetRecord->UpdateRecoveryInfo(info.hasRecoverInfo);
|
||||
|
@ -444,13 +444,7 @@ void SystemDialogScheduler::GetAppNameFromResource(int32_t labelId,
|
||||
sptr<AppExecFwk::IBundleMgr> SystemDialogScheduler::GetBundleManager()
|
||||
{
|
||||
if (iBundleManager_ == nullptr) {
|
||||
auto bundleObj =
|
||||
OHOS::DelayedSingleton<SaMgrClient>::GetInstance()->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
if (bundleObj == nullptr) {
|
||||
HILOG_ERROR("Failed to get bundle manager service.");
|
||||
return nullptr;
|
||||
}
|
||||
iBundleManager_ = iface_cast<AppExecFwk::IBundleMgr>(bundleObj);
|
||||
iBundleManager_ = AbilityUtil::GetBundleManager();
|
||||
}
|
||||
return iBundleManager_;
|
||||
}
|
||||
|
@ -1662,8 +1662,8 @@ void AppMgrServiceInner::StartProcess(const std::string &appName, const std::str
|
||||
std::vector<OverlayModuleInfo> overlayModuleInfo;
|
||||
HILOG_DEBUG("Check overlay app begin.");
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, "BMS->GetOverlayModuleInfoForTarget");
|
||||
auto ret = IN_PROCESS_CALL(overlayMgrProxy->GetOverlayModuleInfoForTarget(bundleName, "", overlayModuleInfo, userId));
|
||||
if (ret == ERR_OK && overlayModuleInfo.size() != 0) {
|
||||
auto targetRet = IN_PROCESS_CALL(overlayMgrProxy->GetOverlayModuleInfoForTarget(bundleName, "", overlayModuleInfo, userId));
|
||||
if (targetRet == ERR_OK && overlayModuleInfo.size() != 0) {
|
||||
HILOG_DEBUG("Start an overlay app process.");
|
||||
startMsg.flags = startMsg.flags | OVERLAY_FLAG;
|
||||
}
|
||||
|
@ -779,6 +779,10 @@ bool AppRunningManager::IsApplicationBackground(const std::string &bundleName)
|
||||
std::lock_guard<std::recursive_mutex> guard(lock_);
|
||||
for (const auto &item : appRunningRecordMap_) {
|
||||
const auto &appRecord = item.second;
|
||||
if (appRecord == nullptr) {
|
||||
HILOG_ERROR("appRecord is nullptr");
|
||||
return false;
|
||||
}
|
||||
auto state = appRecord->GetState();
|
||||
if (appRecord && appRecord->GetBundleName() == bundleName &&
|
||||
state == ApplicationState::APP_STATE_FOREGROUND) {
|
||||
|
@ -25,11 +25,9 @@ using HiSysEvent = OHOS::HiviewDFX::HiSysEvent;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
|
||||
struct EventInfo {
|
||||
int32_t pid = -1;
|
||||
int32_t userId = -1;
|
||||
int64_t formId = -1;
|
||||
int32_t extensionType = -1;
|
||||
uint32_t versionCode = 0;
|
||||
int32_t errCode = -1;
|
||||
@ -71,19 +69,6 @@ enum class EventName {
|
||||
CONNECT_SERVICE,
|
||||
DISCONNECT_SERVICE,
|
||||
|
||||
// form behavior event
|
||||
ADD_FORM,
|
||||
REQUEST_FORM,
|
||||
DELETE_FORM,
|
||||
CASTTEMP_FORM,
|
||||
ACQUIREFORMSTATE_FORM,
|
||||
MESSAGE_EVENT_FORM,
|
||||
ROUTE_EVENT_FORM,
|
||||
BACKGROUND_EVENT_FORM,
|
||||
RELEASE_FORM,
|
||||
DELETE_INVALID_FORM,
|
||||
SET_NEXT_REFRESH_TIME_FORM,
|
||||
|
||||
// app behavior event
|
||||
APP_ATTACH,
|
||||
APP_LAUNCH,
|
||||
@ -96,14 +81,10 @@ enum class EventName {
|
||||
|
||||
class EventReport {
|
||||
public:
|
||||
static void SendAppEvent(const EventName &eventName, HiSysEventType type,
|
||||
const EventInfo& eventInfo);
|
||||
static void SendAbilityEvent(const EventName &eventName, HiSysEventType type,
|
||||
const EventInfo& eventInfo);
|
||||
static void SendExtensionEvent(const EventName &eventName, HiSysEventType type,
|
||||
const EventInfo& eventInfo);
|
||||
static void SendFormEvent(const EventName &eventName, HiSysEventType type,
|
||||
const EventInfo& eventInfo);
|
||||
static void SendAppEvent(const EventName &eventName, HiSysEventType type, const EventInfo &eventInfo);
|
||||
static void SendAbilityEvent(const EventName &eventName, HiSysEventType type, const EventInfo &eventInfo);
|
||||
static void SendExtensionEvent(const EventName &eventName, HiSysEventType type, const EventInfo &eventInfo);
|
||||
|
||||
private:
|
||||
static std::string ConvertEventName(const EventName &eventName);
|
||||
};
|
||||
|
@ -22,29 +22,27 @@ namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace {
|
||||
// event params
|
||||
const std::string TYPE = "TYPE";
|
||||
const std::string EVENT_KEY_APP_PID = "APP_PID";
|
||||
const std::string EVENT_KEY_USERID = "USER_ID";
|
||||
const std::string EVENT_KEY_FORM_ID = "FORM_ID";
|
||||
const std::string EVENT_KEY_ERROR_CODE = "ERROR_CODE";
|
||||
const std::string EVENT_KEY_BUNDLE_NAME = "BUNDLE_NAME";
|
||||
const std::string EVENT_KEY_MODULE_NAME = "MODULE_NAME";
|
||||
const std::string EVENT_KEY_ABILITY_NAME = "ABILITY_NAME";
|
||||
const std::string EVENT_KEY_ABILITY_TYPE = "ABILITY_TYPE";
|
||||
const std::string EVENT_KEY_VERSION_NAME = "VERSION_NAME";
|
||||
const std::string EVENT_KEY_VERSION_CODE = "VERSION_CODE";
|
||||
const std::string EVENT_KEY_PROCESS_NAME = "PROCESS_NAME";
|
||||
const std::string EVENT_KEY_EXTENSION_TYPE = "EXTENSION_TYPE";
|
||||
const std::string EVENT_KEY_STARTUP_TIME = "STARTUP_TIME";
|
||||
const std::string EVENT_KEY_STARTUP_ABILITY_TYPE = "STARTUP_ABILITY_TYPE";
|
||||
const std::string EVENT_KEY_STARTUP_EXTENSION_TYPE = "STARTUP_EXTENSION_TYPE";
|
||||
const std::string EVENT_KEY_CALLER_BUNDLE_NAME = "CALLER_BUNDLE_NAME";
|
||||
const std::string EVENT_KEY_CALLER_UID = "CALLER_UID";
|
||||
const std::string EVENT_KEY_CALLER_PROCESS_NAME = "CALLER_PROCESS_NAME";
|
||||
const std::string EVENT_KEY_EXIT_TIME = "EXIT_TIME";
|
||||
const std::string EVENT_KEY_EXIT_RESULT = "EXIT_RESULT";
|
||||
const std::string EVENT_KEY_EXIT_PID = "EXIT_PID";
|
||||
const std::string EVENT_KEY_BUNDLE_TYPE = "BUNDLE_TYPE";
|
||||
constexpr const char *EVENT_KEY_APP_PID = "APP_PID";
|
||||
constexpr const char *EVENT_KEY_USERID = "USER_ID";
|
||||
constexpr const char *EVENT_KEY_ERROR_CODE = "ERROR_CODE";
|
||||
constexpr const char *EVENT_KEY_BUNDLE_NAME = "BUNDLE_NAME";
|
||||
constexpr const char *EVENT_KEY_MODULE_NAME = "MODULE_NAME";
|
||||
constexpr const char *EVENT_KEY_ABILITY_NAME = "ABILITY_NAME";
|
||||
constexpr const char *EVENT_KEY_ABILITY_TYPE = "ABILITY_TYPE";
|
||||
constexpr const char *EVENT_KEY_VERSION_NAME = "VERSION_NAME";
|
||||
constexpr const char *EVENT_KEY_VERSION_CODE = "VERSION_CODE";
|
||||
constexpr const char *EVENT_KEY_PROCESS_NAME = "PROCESS_NAME";
|
||||
constexpr const char *EVENT_KEY_EXTENSION_TYPE = "EXTENSION_TYPE";
|
||||
constexpr const char *EVENT_KEY_STARTUP_TIME = "STARTUP_TIME";
|
||||
constexpr const char *EVENT_KEY_STARTUP_ABILITY_TYPE = "STARTUP_ABILITY_TYPE";
|
||||
constexpr const char *EVENT_KEY_STARTUP_EXTENSION_TYPE = "STARTUP_EXTENSION_TYPE";
|
||||
constexpr const char *EVENT_KEY_CALLER_BUNDLE_NAME = "CALLER_BUNDLE_NAME";
|
||||
constexpr const char *EVENT_KEY_CALLER_UID = "CALLER_UID";
|
||||
constexpr const char *EVENT_KEY_CALLER_PROCESS_NAME = "CALLER_PROCESS_NAME";
|
||||
constexpr const char *EVENT_KEY_EXIT_TIME = "EXIT_TIME";
|
||||
constexpr const char *EVENT_KEY_EXIT_RESULT = "EXIT_RESULT";
|
||||
constexpr const char *EVENT_KEY_EXIT_PID = "EXIT_PID";
|
||||
constexpr const char *EVENT_KEY_BUNDLE_TYPE = "BUNDLE_TYPE";
|
||||
const std::map<EventName, std::string> eventNameToStrMap_ = {
|
||||
std::map<EventName, std::string>::value_type(EventName::START_ABILITY_ERROR, "START_ABILITY_ERROR"),
|
||||
std::map<EventName, std::string>::value_type(EventName::TERMINATE_ABILITY_ERROR, "TERMINATE_ABILITY_ERROR"),
|
||||
@ -63,18 +61,6 @@ const std::map<EventName, std::string> eventNameToStrMap_ = {
|
||||
std::map<EventName, std::string>::value_type(EventName::STOP_SERVICE, "STOP_SERVICE"),
|
||||
std::map<EventName, std::string>::value_type(EventName::CONNECT_SERVICE, "CONNECT_SERVICE"),
|
||||
std::map<EventName, std::string>::value_type(EventName::DISCONNECT_SERVICE, "DISCONNECT_SERVICE"),
|
||||
std::map<EventName, std::string>::value_type(EventName::ADD_FORM, "ADD_FORM"),
|
||||
std::map<EventName, std::string>::value_type(EventName::REQUEST_FORM, "REQUEST_FORM"),
|
||||
std::map<EventName, std::string>::value_type(EventName::REQUEST_FORM, "REQUEST_FORM"),
|
||||
std::map<EventName, std::string>::value_type(EventName::DELETE_FORM, "DELETE_FORM"),
|
||||
std::map<EventName, std::string>::value_type(EventName::CASTTEMP_FORM, "CASTTEMP_FORM"),
|
||||
std::map<EventName, std::string>::value_type(EventName::ACQUIREFORMSTATE_FORM, "ACQUIREFORMSTATE_FORM"),
|
||||
std::map<EventName, std::string>::value_type(EventName::MESSAGE_EVENT_FORM, "MESSAGE_EVENT_FORM"),
|
||||
std::map<EventName, std::string>::value_type(EventName::ROUTE_EVENT_FORM, "ROUTE_EVENT_FORM"),
|
||||
std::map<EventName, std::string>::value_type(EventName::BACKGROUND_EVENT_FORM, "BACKGROUND_EVENT_FORM"),
|
||||
std::map<EventName, std::string>::value_type(EventName::RELEASE_FORM, "RELEASE_FORM"),
|
||||
std::map<EventName, std::string>::value_type(EventName::DELETE_INVALID_FORM, "DELETE_INVALID_FORM"),
|
||||
std::map<EventName, std::string>::value_type(EventName::SET_NEXT_REFRESH_TIME_FORM, "SET_NEXT_REFRESH_TIME_FORM"),
|
||||
std::map<EventName, std::string>::value_type(EventName::APP_ATTACH, "APP_ATTACH"),
|
||||
std::map<EventName, std::string>::value_type(EventName::APP_LAUNCH, "APP_LAUNCH"),
|
||||
std::map<EventName, std::string>::value_type(EventName::APP_FOREGROUND, "APP_FOREGROUND"),
|
||||
@ -85,8 +71,7 @@ const std::map<EventName, std::string> eventNameToStrMap_ = {
|
||||
};
|
||||
}
|
||||
|
||||
void EventReport::SendAppEvent(const EventName &eventName, HiSysEventType type,
|
||||
const EventInfo& eventInfo)
|
||||
void EventReport::SendAppEvent(const EventName &eventName, HiSysEventType type, const EventInfo &eventInfo)
|
||||
{
|
||||
constexpr int32_t defaultVal = -1;
|
||||
std::string name = ConvertEventName(eventName);
|
||||
@ -140,6 +125,7 @@ void EventReport::SendAppEvent(const EventName &eventName, HiSysEventType type,
|
||||
EVENT_KEY_PROCESS_NAME, eventInfo.processName,
|
||||
EVENT_KEY_BUNDLE_TYPE, eventInfo.bundleType,
|
||||
EVENT_KEY_CALLER_BUNDLE_NAME, eventInfo.callerBundleName);
|
||||
break;
|
||||
case EventName::APP_BACKGROUND:
|
||||
HiSysEventWrite(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
@ -151,6 +137,7 @@ void EventReport::SendAppEvent(const EventName &eventName, HiSysEventType type,
|
||||
EVENT_KEY_VERSION_CODE, eventInfo.versionCode,
|
||||
EVENT_KEY_PROCESS_NAME, eventInfo.processName,
|
||||
EVENT_KEY_BUNDLE_TYPE, eventInfo.bundleType);
|
||||
break;
|
||||
default:
|
||||
HiSysEventWrite(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
@ -165,8 +152,7 @@ void EventReport::SendAppEvent(const EventName &eventName, HiSysEventType type,
|
||||
}
|
||||
}
|
||||
|
||||
void EventReport::SendAbilityEvent(const EventName &eventName, HiSysEventType type,
|
||||
const EventInfo& eventInfo)
|
||||
void EventReport::SendAbilityEvent(const EventName &eventName, HiSysEventType type, const EventInfo &eventInfo)
|
||||
{
|
||||
std::string name = ConvertEventName(eventName);
|
||||
if (name == "INVALIDEVENTNAME") {
|
||||
@ -244,8 +230,7 @@ void EventReport::SendAbilityEvent(const EventName &eventName, HiSysEventType ty
|
||||
}
|
||||
}
|
||||
|
||||
void EventReport::SendExtensionEvent(const EventName &eventName, HiSysEventType type,
|
||||
const EventInfo& eventInfo)
|
||||
void EventReport::SendExtensionEvent(const EventName &eventName, HiSysEventType type, const EventInfo &eventInfo)
|
||||
{
|
||||
std::string name = ConvertEventName(eventName);
|
||||
if (name == "INVALIDEVENTNAME") {
|
||||
@ -299,53 +284,6 @@ void EventReport::SendExtensionEvent(const EventName &eventName, HiSysEventType
|
||||
}
|
||||
}
|
||||
|
||||
void EventReport::SendFormEvent(const EventName &eventName, HiSysEventType type,
|
||||
const EventInfo& eventInfo)
|
||||
{
|
||||
std::string name = ConvertEventName(eventName);
|
||||
if (name == "INVALIDEVENTNAME") {
|
||||
HILOG_ERROR("invalid eventName");
|
||||
return;
|
||||
}
|
||||
switch (eventName) {
|
||||
case EventName::DELETE_INVALID_FORM:
|
||||
HiSysEventWrite(HiSysEvent::Domain::AAFWK, name, type);
|
||||
break;
|
||||
case EventName::ACQUIREFORMSTATE_FORM:
|
||||
case EventName::MESSAGE_EVENT_FORM:
|
||||
HiSysEventWrite(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
name,
|
||||
type,
|
||||
EVENT_KEY_BUNDLE_NAME, eventInfo.bundleName,
|
||||
EVENT_KEY_MODULE_NAME, eventInfo.moduleName,
|
||||
EVENT_KEY_ABILITY_NAME, eventInfo.abilityName);
|
||||
break;
|
||||
case EventName::ADD_FORM:
|
||||
case EventName::REQUEST_FORM:
|
||||
case EventName::BACKGROUND_EVENT_FORM:
|
||||
case EventName::ROUTE_EVENT_FORM:
|
||||
HiSysEventWrite(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
name,
|
||||
type,
|
||||
EVENT_KEY_FORM_ID, eventInfo.formId,
|
||||
EVENT_KEY_BUNDLE_NAME, eventInfo.bundleName,
|
||||
EVENT_KEY_MODULE_NAME, eventInfo.moduleName,
|
||||
EVENT_KEY_ABILITY_NAME, eventInfo.abilityName);
|
||||
break;
|
||||
case EventName::DELETE_FORM:
|
||||
case EventName::CASTTEMP_FORM:
|
||||
case EventName::RELEASE_FORM:
|
||||
case EventName::SET_NEXT_REFRESH_TIME_FORM:
|
||||
HiSysEventWrite(
|
||||
HiSysEvent::Domain::AAFWK, name, type, EVENT_KEY_FORM_ID, eventInfo.formId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::string EventReport::ConvertEventName(const EventName &eventName)
|
||||
{
|
||||
auto it = eventNameToStrMap_.find(eventName);
|
||||
|
@ -35,7 +35,7 @@ DataAbilityObserverStub::~DataAbilityObserverStub() {}
|
||||
int DataAbilityObserverStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
|
||||
MessageOption &option)
|
||||
{
|
||||
HILOG_INFO("code: %{public}d, flags: %{public}d, callingPid:%{public}d", code, option.GetFlags(),
|
||||
HILOG_DEBUG("code: %{public}d, flags: %{public}d, callingPid:%{public}d", code, option.GetFlags(),
|
||||
IPCSkeleton::GetCallingPid());
|
||||
std::u16string descriptor = DataAbilityObserverStub::GetDescriptor();
|
||||
std::u16string remoteDescriptor = data.ReadInterfaceToken();
|
||||
|
@ -94,7 +94,7 @@ Status DataObsMgrInnerExt::HandleNotifyChange(const ChangeInfo &changeInfo)
|
||||
}
|
||||
}
|
||||
if (changeRes.empty()) {
|
||||
HILOG_ERROR("no obs for this uris, changeType:%{public}ud, num of uris:%{public}zu, data is "
|
||||
HILOG_DEBUG("no obs for this uris, changeType:%{public}ud, num of uris:%{public}zu, data is "
|
||||
"nullptr:%{public}d, size:%{public}ud",
|
||||
changeInfo.changeType_, changeInfo.uris_.size(), changeInfo.data_ == nullptr, changeInfo.size_);
|
||||
return NO_OBS_FOR_URI;
|
||||
|
@ -13,11 +13,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
interface TipBtn {
|
||||
color:string
|
||||
}
|
||||
|
||||
@Entry
|
||||
@Component
|
||||
struct JumpInterceptorDialog {
|
||||
@State private deviceType: string = "phone";
|
||||
@State private btn: any = { color: "#FFFFFF" }
|
||||
@State private btn: TipBtn = { color: "#FFFFFF" }
|
||||
private TAG = "JumpInterceptorDialog_Page"
|
||||
|
||||
aboutToAppear() {
|
||||
|
@ -51,6 +51,7 @@ ohos_fuzztest("AbilityConnectManagerFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -93,7 +93,7 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
std::string abilityName(data, size);
|
||||
std::string moduleName(data, size);
|
||||
abilityContext.SetCallingContext(deviceId, bundleName, abilityName, moduleName);
|
||||
std::shared_ptr<Context> base = nullptr;
|
||||
std::shared_ptr<ContextDeal> base = nullptr;
|
||||
abilityContext.AttachBaseContext(base);
|
||||
std::string type(data, size);
|
||||
abilityContext.GetExternalFilesDir(type);
|
||||
|
@ -55,6 +55,7 @@ ohos_fuzztest("AbilityEventHandlerFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -46,6 +46,7 @@ ohos_fuzztest("AbilityMgrRestFuzzTest") {
|
||||
"ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:ability_deps_wrapper",
|
||||
"appspawn:appspawn_socket_client",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
|
@ -51,6 +51,7 @@ ohos_fuzztest("AbilityTransitionDoneFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ipc:ipc_core",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
@ -52,6 +52,7 @@ ohos_fuzztest("AttachAbilityThreadFuzzTest") {
|
||||
"ability_runtime:app_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -50,6 +50,7 @@ ohos_fuzztest("BlockAbilityFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -52,6 +52,7 @@ ohos_fuzztest("BlockAmsServiceFuzzTest") {
|
||||
"ability_runtime:app_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -51,6 +51,7 @@ ohos_fuzztest("BlockAppServiceFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -50,6 +50,7 @@ ohos_fuzztest("CloseAbilityFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ipc:ipc_core",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
@ -51,6 +51,7 @@ ohos_fuzztest("CompleteFirstFrameDrawingFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -57,6 +57,7 @@ ohos_fuzztest("ConnectAbilityFuzzTest") {
|
||||
"ability_runtime:ability_manager",
|
||||
"appspawn:appspawn_socket_client",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ipc:ipc_core",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
@ -50,6 +50,7 @@ ohos_fuzztest("DelegatorDoAbilityBackgroundFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -50,6 +50,7 @@ ohos_fuzztest("DelegatorDoAbilityForegroundFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -50,6 +50,7 @@ ohos_fuzztest("DoAbilityBackgroundFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -50,6 +50,7 @@ ohos_fuzztest("DoAbilityForegroundFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -51,6 +51,7 @@ ohos_fuzztest("DumpAbilityInfoDoneFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -51,6 +51,7 @@ ohos_fuzztest("DumpStateFuzzTest") {
|
||||
"ability_runtime:app_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -51,6 +51,7 @@ ohos_fuzztest("DumpSysStateFuzzTest") {
|
||||
"ability_runtime:app_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -52,6 +52,7 @@ ohos_fuzztest("ForceTimeoutForTestFuzzTest") {
|
||||
"ability_runtime:app_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -50,6 +50,7 @@ ohos_fuzztest("FreeInstallAbilityFromRemoteFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -49,6 +49,7 @@ ohos_fuzztest("GetMissionIdByTokenFuzzTest") {
|
||||
"ability_runtime:app_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -51,6 +51,7 @@ ohos_fuzztest("GetMissionSnapshotFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -49,6 +49,7 @@ ohos_fuzztest("GetTopAbilityFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"appspawn:appspawn_socket_client",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
]
|
||||
|
@ -50,6 +50,7 @@ ohos_fuzztest("HandleDlpAppFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -52,6 +52,7 @@ ohos_fuzztest("MinimizeAbilityFuzzTest") {
|
||||
"ability_runtime:app_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -55,6 +55,7 @@ ohos_fuzztest("PendingWantManagerFuzzTest") {
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"ability_runtime:ability_deps_wrapper",
|
||||
"ability_runtime:connection_obs_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
|
@ -42,6 +42,7 @@ ohos_fuzztest("RegisterAbilityLifecycleCallbackFuzzTest") {
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,7 @@ ohos_fuzztest("RegisterEnvironmentCallbackFuzzTest") {
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -52,6 +52,7 @@ ohos_fuzztest("ReleaseDataAbilityFuzzTest") {
|
||||
"ability_runtime:app_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -51,6 +51,7 @@ ohos_fuzztest("ScheduleCommandAbilityDoneFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ipc:ipc_core",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
@ -51,6 +51,7 @@ ohos_fuzztest("ScheduleConnectAbilityDoneFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ipc:ipc_core",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
@ -50,6 +50,7 @@ ohos_fuzztest("ScheduleDisconnectAbilityDoneFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ipc:ipc_core",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
@ -51,6 +51,7 @@ ohos_fuzztest("SendResultToAbilityFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"ipc:ipc_core",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
@ -51,6 +51,7 @@ ohos_fuzztest("SetAbilityControllerFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
@ -52,6 +52,7 @@ ohos_fuzztest("StartAbilityFuzzTest") {
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -49,6 +49,7 @@ ohos_fuzztest("StartAbilityByCallFuzzTest") {
|
||||
"ability_runtime:app_manager",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"relational_store:native_dataability",
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user