mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-27 01:10:52 +00:00
Merge branch 'master' of gitee.com:openharmony/ability_ability_runtime into master
Signed-off-by: wangdantong <wangdantong@huawei.com>
This commit is contained in:
commit
f394187c65
@ -43,7 +43,6 @@
|
||||
"bundle_framework",
|
||||
"common",
|
||||
"common_event_service",
|
||||
"data_object",
|
||||
"dsoftbus",
|
||||
"eventhandler",
|
||||
"faultloggerd",
|
||||
|
@ -20,7 +20,7 @@ const ERROR_CODE_INNER_ERROR = 16000050;
|
||||
const ERROR_MSG_INVALID_PARAM = 'Invalid input parameter.';
|
||||
const ERROR_MSG_INNER_ERROR = 'Inner Error.';
|
||||
|
||||
var errMap = new Map();
|
||||
let errMap = new Map();
|
||||
errMap.set(ERROR_CODE_INVALID_PARAM, ERROR_MSG_INVALID_PARAM);
|
||||
errMap.set(ERROR_CODE_INNER_ERROR, ERROR_MSG_INNER_ERROR);
|
||||
|
||||
@ -73,7 +73,7 @@ let dataUriUtils = {
|
||||
if (index === -1) {
|
||||
throw new DataUriError(ERROR_CODE_INVALID_PARAM);
|
||||
}
|
||||
var id = uri.substring(index + 1);
|
||||
let id = uri.substring(index + 1);
|
||||
if (id === '' || isNaN(Number(id))) {
|
||||
throw new DataUriError(ERROR_CODE_INVALID_PARAM);
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ class AbilityContext extends Context {
|
||||
}
|
||||
|
||||
try {
|
||||
var callee = await this.__context_impl__.startAbilityByCall(want);
|
||||
let callee = await this.__context_impl__.startAbilityByCall(want);
|
||||
} catch (error) {
|
||||
console.log('AbilityContext::startAbilityByCall Obtain remoteObject failed');
|
||||
reject(error);
|
||||
@ -84,7 +84,7 @@ class AbilityContext extends Context {
|
||||
}
|
||||
|
||||
try {
|
||||
var callee = await this.__context_impl__.startAbilityByCall(want, accountId);
|
||||
let callee = await this.__context_impl__.startAbilityByCall(want, accountId);
|
||||
} catch (error) {
|
||||
console.log('AbilityContext::startAbilityByCall With accountId Obtain remoteObject failed');
|
||||
reject(error);
|
||||
|
@ -1089,8 +1089,7 @@ NativeValue *JSAbilityDelegator::ParseTimeoutCallbackPara(
|
||||
if (info.argc >= ARGC_TWO) {
|
||||
if (!ConvertFromJsValue(engine, info.argv[INDEX_ONE], timeout)) {
|
||||
if (info.argv[INDEX_ONE] == nullptr || info.argv[INDEX_ONE]->TypeOf() != NativeValueType::NATIVE_FUNCTION) {
|
||||
HILOG_ERROR("Parse parameter argv[1] failed");
|
||||
return nullptr;
|
||||
return engine.CreateNull();
|
||||
}
|
||||
opt.hasCallbackPara = true;
|
||||
return engine.CreateNull();
|
||||
@ -1099,8 +1098,7 @@ NativeValue *JSAbilityDelegator::ParseTimeoutCallbackPara(
|
||||
|
||||
if (info.argc > ARGC_TWO) {
|
||||
if (info.argv[INDEX_TWO]->TypeOf() != NativeValueType::NATIVE_FUNCTION) {
|
||||
HILOG_ERROR("Parse parameter argv[2] failed");
|
||||
return nullptr;
|
||||
return engine.CreateNull();
|
||||
}
|
||||
opt.hasCallbackPara = true;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ class EventHub {
|
||||
if (!this.eventMap[event]) {
|
||||
this.eventMap[event] = [];
|
||||
}
|
||||
if (this.eventMap[event].indexOf(callback) == -1) {
|
||||
if (this.eventMap[event].indexOf(callback) === -1) {
|
||||
this.eventMap[event].push(callback);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ const ERROR_MSG_FUNC_REGISTERED = 'Method registered. The method has registered.
|
||||
const ERROR_MSG_FUNC_NOT_EXIST = 'Method not registered. The method has not registered.';
|
||||
const ERROR_MSG_INNER_ERROR = 'Inner Error.';
|
||||
|
||||
var errMap = new Map();
|
||||
let errMap = new Map();
|
||||
errMap.set(ERROR_CODE_INVALID_PARAM, ERROR_MSG_INVALID_PARAM);
|
||||
errMap.set(ERROR_CODE_FUNC_REGISTERED, ERROR_MSG_FUNC_REGISTERED);
|
||||
errMap.set(ERROR_CODE_FUNC_NOT_EXIST, ERROR_MSG_FUNC_NOT_EXIST);
|
||||
|
@ -27,7 +27,7 @@ const ERROR_MSG_CALLER_RELEASED = 'Caller released. The caller has been released
|
||||
const ERROR_MSG_CLAAEE_INVALID = 'Callee invalid. The callee does not exist.';
|
||||
const ERROR_MSG_INNER_ERROR = 'Inner Error.';
|
||||
|
||||
var errMap = new Map();
|
||||
let errMap = new Map();
|
||||
errMap.set(ERROR_CODE_INVALID_PARAM, ERROR_MSG_INVALID_PARAM);
|
||||
errMap.set(ERROR_CODE_CALLER_RELEASED, ERROR_MSG_CALLER_RELEASED);
|
||||
errMap.set(ERROR_CODE_CLAAEE_INVALID, ERROR_MSG_CLAAEE_INVALID);
|
||||
|
@ -50,7 +50,7 @@ let dataUriUtils = {
|
||||
if (index === -1) {
|
||||
return uri;
|
||||
}
|
||||
var id = uri.substring(index + 1);
|
||||
let id = uri.substring(index + 1);
|
||||
if (id === '' || isNaN(Number(id))) {
|
||||
return uri;
|
||||
}
|
||||
|
@ -4062,6 +4062,8 @@ NativeValue* JsNapiCommon::JsConnectAbility(
|
||||
engine.CreateUndefined());
|
||||
NAPI_CALL_BASE(env, napi_call_function(env, undefined, callback, ARGS_ONE, &resultVal, &callResult),
|
||||
engine.CreateUndefined());
|
||||
NAPI_CALL_BASE(env, napi_delete_reference(env, connectionCallback->failedCallbackRef),
|
||||
engine.CreateUndefined());
|
||||
RemoveConnectionLocked(want);
|
||||
}
|
||||
return CreateJsValue(engine, id);
|
||||
|
@ -114,7 +114,7 @@ class ServiceExtensionContext extends ExtensionContext {
|
||||
}
|
||||
|
||||
try {
|
||||
var callee = await this.__context_impl__.startAbilityByCall(want);
|
||||
let callee = await this.__context_impl__.startAbilityByCall(want);
|
||||
} catch (error) {
|
||||
console.log('ServiceExtensionContext::startAbilityByCall Obtain remoteObject failed');
|
||||
reject(error);
|
||||
@ -136,7 +136,7 @@ class ServiceExtensionContext extends ExtensionContext {
|
||||
}
|
||||
|
||||
try {
|
||||
var callee = await this.__context_impl__.startAbilityByCall(want, accountId);
|
||||
let callee = await this.__context_impl__.startAbilityByCall(want, accountId);
|
||||
} catch (error) {
|
||||
console.log('ServiceExtensionContext::startAbilityByCall With accountId Obtain remoteObject failed');
|
||||
reject(error);
|
||||
|
@ -26,7 +26,7 @@ class UIExtensionAbility extends ExtensionAbility {
|
||||
|
||||
onLoadContent() {
|
||||
console.log('onLoadContent');
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
|
@ -41,7 +41,7 @@ class UIExtensionContext extends ExtensionContext {
|
||||
|
||||
terminateSelfWithResult(abilityResult, callback) {
|
||||
console.log('terminateSelfWithResult');
|
||||
return this.__context_impl__.terminateSelfWithResult(abilityResult, callback)
|
||||
return this.__context_impl__.terminateSelfWithResult(abilityResult, callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ private:
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[uriStr, flag, targetBundleName](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
Uri uri(uriStr);
|
||||
auto errCode = AAFwk::UriPermissionManagerClient::GetInstance()->GrantUriPermission(uri, flag,
|
||||
auto errCode = AAFwk::UriPermissionManagerClient::GetInstance().GrantUriPermission(uri, flag,
|
||||
targetBundleName, 0);
|
||||
if (errCode == ERR_OK) {
|
||||
task.ResolveWithNoError(engine, engine.CreateUndefined());
|
||||
@ -152,7 +152,7 @@ private:
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[uriStr, bundleName](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
Uri uri(uriStr);
|
||||
auto errCode = AAFwk::UriPermissionManagerClient::GetInstance()->RevokeUriPermissionManually(uri,
|
||||
auto errCode = AAFwk::UriPermissionManagerClient::GetInstance().RevokeUriPermissionManually(uri,
|
||||
bundleName);
|
||||
if (errCode == ERR_OK) {
|
||||
task.ResolveWithNoError(engine, engine.CreateUndefined());
|
||||
|
@ -502,7 +502,7 @@ ErrCode AbilityContextImpl::RequestDialogService(NativeEngine &engine,
|
||||
sptr<IRemoteObject> remoteObject = new DialogRequestCallbackImpl(std::move(resultTask));
|
||||
want.SetParam(RequestConstants::REQUEST_CALLBACK_KEY, remoteObject);
|
||||
|
||||
auto err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, token_, -1);
|
||||
auto err = AAFwk::AbilityManagerClient::GetInstance()->RequestDialogService(want, token_);
|
||||
HILOG_DEBUG("RequestDialogService ret=%{public}d", static_cast<int32_t>(err));
|
||||
return err;
|
||||
}
|
||||
|
@ -169,10 +169,7 @@ ohos_shared_library("abilitykit_utils") {
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
deps += [ "//third_party/icu/icu4c:shared_icuuc" ]
|
||||
external_deps += [
|
||||
"ability_base:session_info",
|
||||
"ace_engine:ace_uicontent",
|
||||
]
|
||||
external_deps += [ "ability_base:session_info" ]
|
||||
}
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
@ -308,7 +305,6 @@ ohos_shared_library("abilitykit_native") {
|
||||
|
||||
public_deps += [
|
||||
"${ability_base_path}:session_info",
|
||||
"${ace_engine_path}/interfaces/inner_api/ace:ace_uicontent",
|
||||
"${multimedia_path}/interfaces/innerkits:image_native",
|
||||
"${windowmanager_path}/dm:libdm",
|
||||
"${windowmanager_path}/interfaces/kits/napi/window_runtime:windowstage_kit",
|
||||
@ -386,10 +382,7 @@ ohos_shared_library("extensionkit_native") {
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
public_deps += [
|
||||
"${ability_base_path}:session_info",
|
||||
"${ace_engine_path}/interfaces/inner_api/ace:ace_uicontent",
|
||||
]
|
||||
public_deps += [ "${ability_base_path}:session_info" ]
|
||||
}
|
||||
|
||||
innerapi_tags = [ "platformsdk" ]
|
||||
@ -480,7 +473,6 @@ ohos_shared_library("form_extension_module") {
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_base:session_info",
|
||||
"ace_engine:ace_uicontent",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
@ -629,7 +621,6 @@ ohos_shared_library("service_extension_module") {
|
||||
external_deps = [
|
||||
"ability_base:configuration",
|
||||
"ability_base:session_info",
|
||||
"ace_engine:ace_uicontent",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
@ -771,7 +762,6 @@ ohos_shared_library("ui_extension_module") {
|
||||
"ability_base:session_info",
|
||||
"ability_base:want",
|
||||
"ability_runtime:runtime",
|
||||
"ace_engine:ace_uicontent",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"napi:ace_napi",
|
||||
|
@ -92,6 +92,7 @@ Ability* Ability::Create(const std::unique_ptr<AbilityRuntime::Runtime>& runtime
|
||||
void Ability::Init(const std::shared_ptr<AbilityInfo> &abilityInfo, const std::shared_ptr<OHOSApplication> application,
|
||||
std::shared_ptr<AbilityHandler> &handler, const sptr<IRemoteObject> &token)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("%{public}s begin.", __func__);
|
||||
application_ = application;
|
||||
abilityInfo_ = abilityInfo;
|
||||
|
@ -62,6 +62,7 @@ void AbilityImpl::Init(std::shared_ptr<OHOSApplication> &application, const std:
|
||||
|
||||
void AbilityImpl::Start(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
HILOG_ERROR("AbilityImpl::Start ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
@ -700,6 +701,7 @@ void AbilityImpl::WindowLifeCycleImpl::ForegroundFailed(int32_t type)
|
||||
|
||||
void AbilityImpl::Foreground(const Want &want)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
HILOG_ERROR("AbilityImpl::Foreground ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
|
@ -116,6 +116,7 @@ void JsAbility::Init(const std::shared_ptr<AbilityInfo> &abilityInfo,
|
||||
const std::shared_ptr<OHOSApplication> application, std::shared_ptr<AbilityHandler> &handler,
|
||||
const sptr<IRemoteObject> &token)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
Ability::Init(abilityInfo, application, handler, token);
|
||||
|
||||
if (!abilityInfo) {
|
||||
@ -497,6 +498,7 @@ void JsAbility::OnBackground()
|
||||
|
||||
std::unique_ptr<NativeReference> JsAbility::CreateAppWindowStage()
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
auto &engine = jsRuntime_.GetNativeEngine();
|
||||
NativeValue *jsWindowStage = Rosen::CreateJsWindowStage(engine, GetScene());
|
||||
@ -538,6 +540,7 @@ void JsAbility::RestorePageStack(const Want &want)
|
||||
|
||||
void JsAbility::AbilityContinuationOrRecover(const Want &want)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
// multi-instance ability continuation
|
||||
HILOG_DEBUG("launch reason = %{public}d", launchParam_.launchReason);
|
||||
if (IsRestoredInContinuation()) {
|
||||
@ -562,6 +565,7 @@ void JsAbility::AbilityContinuationOrRecover(const Want &want)
|
||||
|
||||
void JsAbility::DoOnForeground(const Want &want)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (scene_ == nullptr) {
|
||||
if ((abilityContext_ == nullptr) || (sceneListener_ == nullptr)) {
|
||||
HILOG_ERROR("Ability::OnForeground error. abilityContext_ or sceneListener_ is nullptr!");
|
||||
@ -897,6 +901,7 @@ sptr<IRemoteObject> JsAbility::CallRequest()
|
||||
|
||||
NativeValue *JsAbility::CallObjectMethod(const char *name, NativeValue *const *argv, size_t argc, bool withResult)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("JsAbility::CallObjectMethod(%{public}s", name);
|
||||
|
||||
if (!jsAbilityObj_) {
|
||||
|
@ -422,7 +422,9 @@ void AbilityThread::Attach(
|
||||
void AbilityThread::HandleAbilityTransaction(const Want &want, const LifeCycleStateInfo &lifeCycleStateInfo,
|
||||
sptr<SessionInfo> sessionInfo)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::string connector = "##";
|
||||
std::string traceName = __PRETTY_FUNCTION__ + connector + want.GetElement().GetAbilityName();
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, traceName);
|
||||
HILOG_DEBUG("Handle ability transaction begin, name is %{public}s.", want.GetElement().GetAbilityName().c_str());
|
||||
if (abilityImpl_ == nullptr) {
|
||||
HILOG_ERROR("Handle ability transaction error, abilityImpl_ == nullptr.");
|
||||
|
@ -157,9 +157,9 @@ sptr<AAFwk::SessionInfo> Extension::GetSessionInfo()
|
||||
return sessionInfo_;
|
||||
}
|
||||
|
||||
void Extension::SetSceneSessionStageListener(const std::shared_ptr<Rosen::ISessionStageStateListener> &listener)
|
||||
void Extension::SetExtensionWindowLifeCycleListener(const sptr<Rosen::IWindowLifeCycle> &listener)
|
||||
{
|
||||
sceneSessionStageListener_ = listener;
|
||||
extensionWindowLifeCycleListener_ = listener;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,8 +42,8 @@ void ExtensionImpl::Init(std::shared_ptr<AppExecFwk::OHOSApplication> &applicati
|
||||
extension_ = extension;
|
||||
if (record->GetAbilityInfo() != nullptr &&
|
||||
record->GetAbilityInfo()->extensionAbilityType == AppExecFwk::ExtensionAbilityType::UI) {
|
||||
extension_->SetSceneSessionStageListener(
|
||||
std::make_shared<ExtensionSessionStateLifeCycleImpl>(token_, shared_from_this()));
|
||||
extension_->SetExtensionWindowLifeCycleListener(
|
||||
sptr<ExtensionWindowLifeCycleImpl>(new ExtensionWindowLifeCycleImpl(token_, shared_from_this())));
|
||||
}
|
||||
extension_->Init(record, application, handler, token);
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_INITIAL;
|
||||
@ -343,24 +343,24 @@ void ExtensionImpl::Background()
|
||||
lifecycleState_ = AAFwk::ABILITY_STATE_BACKGROUND_NEW;
|
||||
}
|
||||
|
||||
void ExtensionImpl::ExtensionSessionStateLifeCycleImpl::AfterForeground()
|
||||
void ExtensionImpl::ExtensionWindowLifeCycleImpl::AfterForeground()
|
||||
{
|
||||
HILOG_DEBUG("ExtensionSessionStateLifeCycleImpl AfterForeground called.");
|
||||
HILOG_DEBUG("called.");
|
||||
}
|
||||
|
||||
void ExtensionImpl::ExtensionSessionStateLifeCycleImpl::AfterBackground()
|
||||
void ExtensionImpl::ExtensionWindowLifeCycleImpl::AfterBackground()
|
||||
{
|
||||
HILOG_DEBUG("ExtensionSessionStateLifeCycleImpl AfterBackground called.");
|
||||
HILOG_DEBUG("called.");
|
||||
}
|
||||
|
||||
void ExtensionImpl::ExtensionSessionStateLifeCycleImpl::AfterActive()
|
||||
void ExtensionImpl::ExtensionWindowLifeCycleImpl::AfterActive()
|
||||
{
|
||||
HILOG_DEBUG("ExtensionSessionStateLifeCycleImpl AfterActive called.");
|
||||
HILOG_DEBUG("called.");
|
||||
}
|
||||
|
||||
void ExtensionImpl::ExtensionSessionStateLifeCycleImpl::AfterInactive()
|
||||
void ExtensionImpl::ExtensionWindowLifeCycleImpl::AfterInactive()
|
||||
{
|
||||
HILOG_DEBUG("ExtensionSessionStateLifeCycleImpl AfterInactive called.");
|
||||
HILOG_DEBUG("called.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "new_ability_impl.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "scene_board_judgement.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -31,6 +32,7 @@ using AbilityManagerClient = OHOS::AAFwk::AbilityManagerClient;
|
||||
void NewAbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState,
|
||||
sptr<AAFwk::SessionInfo> sessionInfo)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("NewAbilityImpl::HandleAbilityTransaction begin sourceState:%{public}d; targetState: %{public}d; "
|
||||
"isNewWant: %{public}d, sceneFlag: %{public}d",
|
||||
lifecycleState_,
|
||||
@ -93,6 +95,7 @@ void NewAbilityImpl::AbilityTransactionCallback(const AbilityLifeCycleState &sta
|
||||
*/
|
||||
bool NewAbilityImpl::AbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("NewAbilityImpl::AbilityTransaction begin");
|
||||
bool ret = true;
|
||||
switch (targetState.state) {
|
||||
|
@ -173,8 +173,8 @@ void JsUIExtension::BindContext(NativeEngine& engine, NativeObject* obj)
|
||||
|
||||
void JsUIExtension::OnStart(const AAFwk::Want &want)
|
||||
{
|
||||
Extension::OnStart(want);
|
||||
HILOG_DEBUG("JsUIExtension OnStart begin.");
|
||||
Extension::OnStart(want);
|
||||
HandleScope handleScope(jsRuntime_);
|
||||
NativeEngine* nativeEngine = &jsRuntime_.GetNativeEngine();
|
||||
napi_value napiWant = OHOS::AppExecFwk::WrapWant(reinterpret_cast<napi_env>(nativeEngine), want);
|
||||
@ -187,15 +187,23 @@ void JsUIExtension::OnStart(const AAFwk::Want &want)
|
||||
void JsUIExtension::OnStart(const AAFwk::Want &want, sptr<AAFwk::SessionInfo> sessionInfo)
|
||||
{
|
||||
HILOG_DEBUG("JsUIExtension OnStart begin.");
|
||||
|
||||
Extension::OnStart(want, sessionInfo);
|
||||
if (sessionInfo) {
|
||||
uiWindow_ = Ace::NG::UIWindow::CreateWindowExtension(GetContext(), sessionInfo->sessionToken);
|
||||
sptr<Rosen::WindowOption> option = new Rosen::WindowOption();
|
||||
auto context = GetContext();
|
||||
if (context == nullptr || context->GetAbilityInfo() == nullptr) {
|
||||
HILOG_ERROR("Failed to get context");
|
||||
return;
|
||||
}
|
||||
option->SetWindowName(context->GetBundleName() + context->GetAbilityInfo()->name);
|
||||
option->SetWindowType(Rosen::WindowType::WINDOW_TYPE_UI_EXTENSION);
|
||||
option->SetWindowSessionType(Rosen::WindowSessionType::EXTENSION_SESSION);
|
||||
uiWindow_ = Rosen::Window::Create(option, GetContext(), sessionInfo->sessionToken);
|
||||
if (uiWindow_ == nullptr) {
|
||||
HILOG_ERROR("JsUIExtension OnStart create ui window error.");
|
||||
return;
|
||||
}
|
||||
uiWindow_->RegisterSessionStageStateListener(sceneSessionStageListener_);
|
||||
uiWindow_->RegisterLifeCycleListener(extensionWindowLifeCycleListener_);
|
||||
} else {
|
||||
HILOG_DEBUG("JsUIExtension OnStart sessionInfo is nullptr.");
|
||||
}
|
||||
@ -217,8 +225,7 @@ void JsUIExtension::OnStart(const AAFwk::Want &want, sptr<AAFwk::SessionInfo> se
|
||||
|
||||
if (uiWindow_ != nullptr && !contextPath_.empty()) {
|
||||
HILOG_DEBUG("JsUIExtension OnStart contextPath is %{private}s", contextPath_.c_str());
|
||||
uiWindow_->LoadContent(contextPath_, nativeEngine, nullptr);
|
||||
uiWindow_->Connect();
|
||||
uiWindow_->SetUIContent(contextPath_, nativeEngine, nullptr);
|
||||
} else {
|
||||
HILOG_ERROR("JsUIExtension OnStart uiWindow or contextPath is null.");
|
||||
}
|
||||
@ -233,7 +240,7 @@ void JsUIExtension::OnStop()
|
||||
CallObjectMethod("onDestroy");
|
||||
|
||||
if (uiWindow_ != nullptr) {
|
||||
uiWindow_->Disconnect();
|
||||
uiWindow_->Destroy();
|
||||
} else {
|
||||
HILOG_ERROR("JsUIExtension::OnStop uiWindow is null.");
|
||||
}
|
||||
@ -246,7 +253,7 @@ sptr<IRemoteObject> JsUIExtension::OnConnect(const AAFwk::Want &want)
|
||||
NativeValue *result = CallOnConnect(want);
|
||||
if (uiWindow_) {
|
||||
HILOG_DEBUG("JsUIExtension::OnForeground uiWindow Foreground.");
|
||||
uiWindow_->Foreground();
|
||||
uiWindow_->Show();
|
||||
} else {
|
||||
HILOG_ERROR("JsUIExtension::OnForeground uiWindow is null.");
|
||||
}
|
||||
@ -286,7 +293,7 @@ void JsUIExtension::OnCommand(const AAFwk::Want &want, bool restart, int startId
|
||||
CallObjectMethod("onRequest", argv, ARGC_TWO);
|
||||
if (uiWindow_) {
|
||||
HILOG_DEBUG("JsUIExtension::OnForeground uiWindow Foreground.");
|
||||
uiWindow_->Foreground();
|
||||
uiWindow_->Show();
|
||||
} else {
|
||||
HILOG_ERROR("JsUIExtension::OnForeground uiWindow is null.");
|
||||
}
|
||||
@ -307,7 +314,7 @@ void JsUIExtension::OnForeground(const Want &want)
|
||||
Extension::OnForeground(want);
|
||||
if (uiWindow_) {
|
||||
HILOG_DEBUG("JsUIExtension::OnForeground uiWindow Foreground.");
|
||||
uiWindow_->Foreground();
|
||||
uiWindow_->Show();
|
||||
} else {
|
||||
HILOG_ERROR("JsUIExtension::OnForeground uiWindow is null.");
|
||||
}
|
||||
@ -323,7 +330,7 @@ void JsUIExtension::OnBackground()
|
||||
Extension::OnBackground();
|
||||
if (uiWindow_) {
|
||||
HILOG_DEBUG("JsUIExtension::OnForeground uiWindow Foreground.");
|
||||
uiWindow_->Background();
|
||||
uiWindow_->Hide();
|
||||
} else {
|
||||
HILOG_ERROR("JsUIExtension::OnForeground uiWindow is null.");
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ ohos_shared_library("appkit_native") {
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"faultloggerd:libdfx_dumpcatcher",
|
||||
"faultloggerd:libbacktrace_local",
|
||||
"faultloggerd:libfaultloggerd",
|
||||
"hicollie_native:libhicollie",
|
||||
"hisysevent_native:libhisysevent",
|
||||
@ -259,10 +259,7 @@ ohos_shared_library("app_context_utils") {
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
deps = [
|
||||
"${ability_runtime_native_path}/appkit:app_context",
|
||||
"${ability_runtime_native_path}/appkit:application_context_manager",
|
||||
]
|
||||
deps = [ "${ability_runtime_native_path}/appkit:app_context" ]
|
||||
|
||||
external_deps = [
|
||||
"ability_runtime:ability_runtime_error_util",
|
||||
@ -350,24 +347,3 @@ ohos_shared_library("appkit_delegator") {
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
||||
config("application_context_manager_config") {
|
||||
include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context" ]
|
||||
}
|
||||
|
||||
ohos_shared_library("application_context_manager") {
|
||||
sources = [ "${ability_runtime_native_path}/appkit/ability_runtime/context/application_context_manager.cpp" ]
|
||||
|
||||
cflags = []
|
||||
if (target_cpu == "arm") {
|
||||
cflags += [ "-DBINDER_IPC_32BIT" ]
|
||||
}
|
||||
|
||||
external_deps = [ "napi:ace_napi" ]
|
||||
|
||||
public_configs = [ ":application_context_manager_config" ]
|
||||
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
@ -675,7 +675,7 @@ std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::FindPropertyByToken
|
||||
|
||||
std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::FindPropertyByName(const std::string &name)
|
||||
{
|
||||
HILOG_INFO("Enter");
|
||||
HILOG_INFO("Find property by %{public}s.", name.c_str());
|
||||
|
||||
if (name.empty()) {
|
||||
HILOG_WARN("Invalid input parameter");
|
||||
|
@ -27,9 +27,6 @@ const std::string AbilityDelegatorArgs::KEY_TEST_WAIT_TIMEOUT {"-w"};
|
||||
const std::string AbilityDelegatorArgs::KEY_TEST_DEBUG {"-D"};
|
||||
const std::string AbilityDelegatorArgs::VALUE_TEST_DEBUG {"true"};
|
||||
|
||||
AbilityDelegatorArgs::AbilityDelegatorArgs()
|
||||
{}
|
||||
|
||||
AbilityDelegatorArgs::AbilityDelegatorArgs(const AAFwk::Want &want)
|
||||
{
|
||||
bundleName_ = want.GetStringParam(AbilityDelegatorArgs::KEY_TEST_BUNDLE_NAME);
|
||||
@ -45,9 +42,6 @@ AbilityDelegatorArgs::AbilityDelegatorArgs(const AAFwk::Want &want)
|
||||
}
|
||||
}
|
||||
|
||||
AbilityDelegatorArgs::~AbilityDelegatorArgs()
|
||||
{}
|
||||
|
||||
std::string AbilityDelegatorArgs::GetTestBundleName() const
|
||||
{
|
||||
return bundleName_;
|
||||
|
@ -16,7 +16,7 @@
|
||||
function isSystemplugin(shortName, moduleType) {
|
||||
const plugin = moduleType === 'ohos' ? globalThis.ohosplugin : globalThis.systemplugin;
|
||||
if (typeof (plugin) !== 'undefined') {
|
||||
var target = plugin;
|
||||
let target = plugin;
|
||||
for (let key of shortName.split('.')) {
|
||||
target = target[key];
|
||||
if (!target) {
|
||||
@ -28,7 +28,7 @@ function isSystemplugin(shortName, moduleType) {
|
||||
}
|
||||
|
||||
|
||||
var global = globalThis;
|
||||
let global = globalThis;
|
||||
globalThis.exports = { default: {} };
|
||||
globalThis.$app_define$ = function (page, packageName, parseContent) {
|
||||
const module = { exports: {} };
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "ability_runtime/context/context.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "js_ability_stage.h"
|
||||
#include "runtime.h"
|
||||
|
||||
@ -25,6 +26,7 @@ namespace AbilityRuntime {
|
||||
std::shared_ptr<AbilityStage> AbilityStage::Create(
|
||||
const std::unique_ptr<Runtime>& runtime, const AppExecFwk::HapModuleInfo& hapModuleInfo)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (!runtime) {
|
||||
return std::make_shared<AbilityStage>();
|
||||
}
|
||||
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "application_context_manager.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
ApplicationContextManager::ApplicationContextManager()
|
||||
{}
|
||||
|
||||
ApplicationContextManager::~ApplicationContextManager()
|
||||
{
|
||||
if (applicationContextObj_ != nullptr) {
|
||||
applicationContextObj_.reset();
|
||||
}
|
||||
}
|
||||
|
||||
ApplicationContextManager& ApplicationContextManager::GetApplicationContextManager()
|
||||
{
|
||||
static ApplicationContextManager applicationContextManager;
|
||||
return applicationContextManager;
|
||||
}
|
||||
|
||||
void ApplicationContextManager::AddGlobalObject(std::shared_ptr<NativeReference> applicationContextObj)
|
||||
{
|
||||
applicationContextObj_ = applicationContextObj;
|
||||
}
|
||||
|
||||
std::shared_ptr<NativeReference> ApplicationContextManager::GetGlobalObject()
|
||||
{
|
||||
return applicationContextObj_;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include "ability_runtime_error_util.h"
|
||||
#include "application_context.h"
|
||||
#include "application_context_manager.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "js_context_utils.h"
|
||||
@ -959,9 +958,6 @@ NativeValue* JsApplicationContextUtils::CreateJsApplicationContext(NativeEngine
|
||||
|
||||
BindNativeApplicationContext(engine, object);
|
||||
|
||||
ApplicationContextManager::GetApplicationContextManager()
|
||||
.AddGlobalObject(std::shared_ptr<NativeReference>(engine.CreateReference(objValue, 1)));
|
||||
|
||||
return objValue;
|
||||
}
|
||||
|
||||
|
@ -932,8 +932,8 @@ bool MainThread::InitResourceManager(std::shared_ptr<Global::Resource::ResourceM
|
||||
matchingSkills.AddEvent(OVERLAY_STATE_CHANGED);
|
||||
EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
|
||||
wptr<MainThread> weak = this;
|
||||
auto callback = [weak, resourceManager, bundleName, moduleName = entryHapModuleInfo.moduleName, loadPath]
|
||||
(const EventFwk::CommonEventData &data) {
|
||||
auto callback = [weak, resourceManager, bundleName, moduleName = entryHapModuleInfo.moduleName,
|
||||
loadPath](const EventFwk::CommonEventData &data) {
|
||||
HILOG_INFO("On overlay changed.");
|
||||
auto appThread = weak.promote();
|
||||
if (appThread == nullptr) {
|
||||
@ -1369,11 +1369,9 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
if (!isFirstStartUpWeb) {
|
||||
appmgr->PreStartNWebSpawnProcess();
|
||||
}
|
||||
|
||||
OHOS::NWeb::NWebHelper::TryPreReadLib(isFirstStartUpWeb, app->GetAppContext()->GetBundleCodeDir());
|
||||
}).detach();
|
||||
#endif
|
||||
|
||||
HILOG_DEBUG("MainThread::handleLaunchApplication called end.");
|
||||
}
|
||||
|
||||
@ -1493,6 +1491,7 @@ void MainThread::HandleAbilityStage(const HapModuleInfo &abilityStage)
|
||||
void MainThread::LoadAllExtensions(NativeEngine &nativeEngine, const std::string &filePath,
|
||||
const BundleInfo &bundleInfo)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("LoadAllExtensions.filePath:%{public}s, extensionInfo size = %{public}d", filePath.c_str(),
|
||||
static_cast<int32_t>(bundleInfo.extensionInfos.size()));
|
||||
if (!extensionConfigMgr_) {
|
||||
@ -1613,11 +1612,18 @@ bool MainThread::PrepareAbilityDelegator(const std::shared_ptr<UserTestRecord> &
|
||||
*/
|
||||
void MainThread::HandleLaunchAbility(const std::shared_ptr<AbilityLocalRecord> &abilityRecord)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
CHECK_POINTER_LOG(abilityRecord, "MainThread::HandleLaunchAbility parameter(abilityRecord) is null");
|
||||
std::string connector = "##";
|
||||
std::string traceName = __PRETTY_FUNCTION__ + connector;
|
||||
if (abilityRecord->GetWant() != nullptr) {
|
||||
traceName += abilityRecord->GetWant()->GetElement().GetAbilityName();
|
||||
} else {
|
||||
HILOG_ERROR("Want is nullptr, cant not get abilityName.");
|
||||
}
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, traceName);
|
||||
HILOG_DEBUG("MainThread::handleLaunchAbility called start.");
|
||||
CHECK_POINTER_LOG(applicationImpl_, "MainThread::HandleLaunchAbility applicationImpl_ is null");
|
||||
CHECK_POINTER_LOG(abilityRecordMgr_, "MainThread::HandleLaunchAbility abilityRecordMgr_ is null");
|
||||
CHECK_POINTER_LOG(abilityRecord, "MainThread::HandleLaunchAbility parameter(abilityRecord) is null");
|
||||
|
||||
auto abilityToken = abilityRecord->GetToken();
|
||||
CHECK_POINTER_LOG(abilityToken, "MainThread::HandleLaunchAbility failed. abilityRecord->GetToken failed");
|
||||
|
@ -23,38 +23,26 @@
|
||||
#include <unistd.h>
|
||||
#include <sigchain.h>
|
||||
|
||||
#include "dfx_dump_catcher.h"
|
||||
#include "dfx_dump_res.h"
|
||||
#include "dfx_frame_format.h"
|
||||
#include "dfx_util.h"
|
||||
#include "faultloggerd_client.h"
|
||||
#include "file_ex.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_runtime.h"
|
||||
|
||||
using namespace OHOS::HiviewDFX;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
std::weak_ptr<EventHandler> MixStackDumper::signalHandler_;
|
||||
std::weak_ptr<OHOSApplication> MixStackDumper::application_;
|
||||
static std::mutex g_mutex;
|
||||
using OHOS::HiviewDFX::NativeFrame;
|
||||
namespace {
|
||||
static const char PID_STR_NAME[] = "Pid:";
|
||||
static const char PPID_STR_NAME[] = "PPid:";
|
||||
static const char NSPID_STR_NAME[] = "NSpid:";
|
||||
static const char PROC_SELF_STATUS_PATH[] = "/proc/self/status";
|
||||
static const std::string PROC_SELF_CMDLINE_PATH = "/proc/self/cmdline";
|
||||
static constexpr int STATUS_LINE_SIZE = 1024;
|
||||
static constexpr int FRAME_BUF_LEN = 1024;
|
||||
static constexpr int HEADER_BUF_LEN = 512;
|
||||
static constexpr int NAMESPACE_MATCH_NUM = 2;
|
||||
static bool hasInstalled = false;
|
||||
typedef struct ProcInfo {
|
||||
int tid;
|
||||
int pid;
|
||||
int ppid;
|
||||
bool ns;
|
||||
} ProcInfo;
|
||||
}
|
||||
|
||||
namespace {
|
||||
static const std::string PROC_SELF_CMDLINE_PATH = "/proc/self/cmdline";
|
||||
static constexpr int HEADER_BUF_LEN = 512;
|
||||
static bool hasInstalled = false;
|
||||
static pid_t g_targetDumpTid = -1;
|
||||
static struct ProcInfo g_procInfo = {0};
|
||||
|
||||
@ -63,40 +51,6 @@ static std::string PrintJsFrame(const JsFrames& jsFrame)
|
||||
return " at " + jsFrame.functionName + " (" + jsFrame.fileName + ":" + jsFrame.pos + ")\n";
|
||||
}
|
||||
|
||||
static std::string PrintNativeFrame(const NativeFrame& frame)
|
||||
{
|
||||
char buf[FRAME_BUF_LEN] = {0};
|
||||
std::string mapName = frame.binaryName;
|
||||
if (mapName.empty()) {
|
||||
mapName = "Unknown";
|
||||
}
|
||||
|
||||
#ifdef __LP64__
|
||||
char frameFormatWithMapName[] = "#%02zu pc %016" PRIx64 " %s\n";
|
||||
char frameFormatWithFuncName[] = "#%02zu pc %016" PRIx64 " %s(%s+%" PRIu64 ")\n";
|
||||
#else
|
||||
char frameFormatWithMapName[] = "#%02zu pc %08" PRIx64 " %s\n";
|
||||
char frameFormatWithFuncName[] = "#%02zu pc %08" PRIx64 " %s(%s+%" PRIu64 ")\n";
|
||||
#endif
|
||||
|
||||
if (frame.funcName.empty()) {
|
||||
int ret = snprintf_s(buf, sizeof(buf), sizeof(buf) - 1, frameFormatWithMapName, \
|
||||
frame.index, frame.relativePc, mapName.c_str());
|
||||
if (ret <= 0) {
|
||||
HILOG_ERROR("DfxMixStackDumper::PrintNativeFrame snprintf_s failed.");
|
||||
}
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
int ret = snprintf_s(buf, sizeof(buf), sizeof(buf) - 1, frameFormatWithFuncName, \
|
||||
frame.index, frame.relativePc, mapName.c_str(),\
|
||||
frame.funcName.c_str(), frame.funcOffset);
|
||||
if (ret <= 0) {
|
||||
HILOG_ERROR("DfxMixStackDumper::PrintNativeFrame snprintf_s failed.");
|
||||
}
|
||||
return std::string(buf);
|
||||
}
|
||||
|
||||
static pid_t GetPid()
|
||||
{
|
||||
return g_procInfo.pid;
|
||||
@ -107,118 +61,16 @@ static bool HasNameSpace()
|
||||
return g_procInfo.ns;
|
||||
}
|
||||
|
||||
static int GetProcStatus(struct ProcInfo* procInfo)
|
||||
static std::string LoadThreadWchan(pid_t tid)
|
||||
{
|
||||
if (procInfo->pid >= 1) {
|
||||
return 0;
|
||||
std::string wchanPath = "/proc/self/task/" + std::to_string(tid) + "/wchan";
|
||||
std::string wchan;
|
||||
if (LoadStringFromFile(wchanPath, wchan)) {
|
||||
return wchan;
|
||||
} else {
|
||||
return "null";
|
||||
}
|
||||
|
||||
procInfo->pid = getpid();
|
||||
procInfo->tid = gettid();
|
||||
procInfo->ppid = getppid();
|
||||
procInfo->ns = false;
|
||||
char buf[STATUS_LINE_SIZE];
|
||||
FILE *fp = fopen(PROC_SELF_STATUS_PATH, "r");
|
||||
if (fp == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
int p = 0, pp = 0, t = 0;
|
||||
while (!feof(fp)) {
|
||||
if (fgets(buf, STATUS_LINE_SIZE, fp) == nullptr) {
|
||||
fclose(fp);
|
||||
return -1;
|
||||
}
|
||||
if (strncmp(buf, PID_STR_NAME, strlen(PID_STR_NAME)) == 0) {
|
||||
// Pid: 1892
|
||||
if (sscanf_s(buf, "%*[^0-9]%d", &p) != 1) {
|
||||
perror("sscanf_s failed.");
|
||||
}
|
||||
procInfo->pid = p;
|
||||
if (procInfo->pid == getpid()) {
|
||||
procInfo->ns = false;
|
||||
break;
|
||||
}
|
||||
procInfo->ns = true;
|
||||
continue;
|
||||
}
|
||||
if (strncmp(buf, PPID_STR_NAME, strlen(PPID_STR_NAME)) == 0) {
|
||||
// PPid: 240
|
||||
if (sscanf_s(buf, "%*[^0-9]%d", &pp) != 1) {
|
||||
perror("sscanf_s failed.");
|
||||
}
|
||||
procInfo->ppid = pp;
|
||||
continue;
|
||||
}
|
||||
// NSpid: 1892 1
|
||||
if (strncmp(buf, NSPID_STR_NAME, strlen(NSPID_STR_NAME)) == 0) {
|
||||
if (sscanf_s(buf, "%*[^0-9]%d%*[^0-9]%d", &p, &t) != NAMESPACE_MATCH_NUM) {
|
||||
perror("sscanf_s failed.");
|
||||
}
|
||||
procInfo->tid = t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
(void)fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void TidToNstid(const int tid, int& nstid)
|
||||
{
|
||||
char path[NAME_LEN];
|
||||
(void)memset_s(path, sizeof(path), '\0', sizeof(path));
|
||||
if (snprintf_s(path, sizeof(path), sizeof(path) - 1, "/proc/%d/task/%d/status", GetPid(), tid) <= 0) {
|
||||
HILOG_WARN("snprintf_s error.");
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[STATUS_LINE_SIZE];
|
||||
FILE *fp = fopen(path, "r");
|
||||
if (fp == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
int p = 0, t = 0;
|
||||
while (!feof(fp)) {
|
||||
if (fgets(buf, STATUS_LINE_SIZE, fp) == nullptr) {
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
// NSpid: 1892 1
|
||||
if (strncmp(buf, NSPID_STR_NAME, strlen(NSPID_STR_NAME)) == 0) {
|
||||
if (sscanf_s(buf, "%*[^0-9]%d%*[^0-9]%d", &p, &t) != NAMESPACE_MATCH_NUM) {
|
||||
HILOG_ERROR("sscanf_s failed.");
|
||||
}
|
||||
nstid = t;
|
||||
break;
|
||||
}
|
||||
}
|
||||
(void)fclose(fp);
|
||||
}
|
||||
|
||||
static std::string GetCurrentTimeStr(uint64_t current = 0)
|
||||
{
|
||||
time_t now = time(nullptr);
|
||||
uint64_t millisecond = 0;
|
||||
const uint64_t ratio = 1000;
|
||||
if (current > static_cast<uint64_t>(now)) {
|
||||
millisecond = current % ratio;
|
||||
now = static_cast<time_t>(current / ratio);
|
||||
}
|
||||
|
||||
auto tm = std::localtime(&now);
|
||||
char seconds[128] = { 0 }; // 128 : time buffer size
|
||||
if (tm == nullptr || strftime(seconds, sizeof(seconds) - 1, "%Y-%m-%d %H:%M:%S", tm) == 0) {
|
||||
return "invalid timestamp\n";
|
||||
}
|
||||
|
||||
char formatTimeBuf[256] = { 0 }; // 256 : buffer size
|
||||
int ret = snprintf_s(formatTimeBuf, sizeof(formatTimeBuf), sizeof(formatTimeBuf) - 1,
|
||||
"%s.%03u\n", seconds, millisecond);
|
||||
if (ret <= 0) {
|
||||
return "invalid timestamp\n";
|
||||
}
|
||||
return std::string(formatTimeBuf, strlen(formatTimeBuf));
|
||||
}
|
||||
|
||||
bool MixStackDumper::Dump_SignalHandler(int sig, siginfo_t *si, void *context)
|
||||
@ -275,7 +127,7 @@ bool MixStackDumper::IsJsNativePcEqual(uintptr_t *jsNativePointer, uint64_t nati
|
||||
}
|
||||
|
||||
void MixStackDumper::BuildJsNativeMixStack(int fd, std::vector<JsFrames>& jsFrames,
|
||||
std::vector<NativeFrame>& nativeFrames)
|
||||
std::vector<DfxFrame>& nativeFrames)
|
||||
{
|
||||
uint32_t jsIdx = 0;
|
||||
uint32_t nativeIdx = 0;
|
||||
@ -295,13 +147,13 @@ void MixStackDumper::BuildJsNativeMixStack(int fd, std::vector<JsFrames>& jsFram
|
||||
if (IsJsNativePcEqual(jsFrames[jsIdx].nativePointer, nativeFrames[nativeIdx].pc,
|
||||
nativeFrames[nativeIdx].funcOffset)) {
|
||||
HILOG_DEBUG("DfxMixStackDumper::BuildJsNativeMixStack pc register values matched.");
|
||||
mixStackStr += PrintNativeFrame(nativeFrames[nativeIdx]);
|
||||
mixStackStr += HiviewDFX::DfxFrameFormat::GetFrameStr(nativeFrames[nativeIdx]);
|
||||
mixStackStr += PrintJsFrame(jsFrames[jsIdx]);
|
||||
nativeIdx++;
|
||||
jsIdx++;
|
||||
matchJsFrame = true;
|
||||
} else {
|
||||
mixStackStr += PrintNativeFrame(nativeFrames[nativeIdx]);
|
||||
mixStackStr += HiviewDFX::DfxFrameFormat::GetFrameStr(nativeFrames[nativeIdx]);
|
||||
nativeIdx++;
|
||||
}
|
||||
}
|
||||
@ -316,7 +168,7 @@ void MixStackDumper::BuildJsNativeMixStack(int fd, std::vector<JsFrames>& jsFram
|
||||
}
|
||||
|
||||
while (nativeIdx < nativeFrames.size()) {
|
||||
mixStackStr += PrintNativeFrame(nativeFrames[nativeIdx]);
|
||||
mixStackStr += HiviewDFX::DfxFrameFormat::GetFrameStr(nativeFrames[nativeIdx]);
|
||||
nativeIdx++;
|
||||
}
|
||||
|
||||
@ -339,15 +191,6 @@ std::string MixStackDumper::GetThreadStackTraceLabel(pid_t tid)
|
||||
return result.str();
|
||||
}
|
||||
|
||||
void MixStackDumper::PrintNativeFrames(int fd, std::vector<NativeFrame>& nativeFrames)
|
||||
{
|
||||
for (const auto& frame : nativeFrames) {
|
||||
std::string nativeFrameStr = PrintNativeFrame(frame);
|
||||
Write(fd, nativeFrameStr);
|
||||
}
|
||||
Write(fd, "\n");
|
||||
}
|
||||
|
||||
void MixStackDumper::PrintProcessHeader(int fd, pid_t pid, uid_t uid)
|
||||
{
|
||||
char headerBuf[HEADER_BUF_LEN] = { 0 };
|
||||
@ -376,7 +219,7 @@ bool MixStackDumper::DumpMixFrame(int fd, pid_t nstid, pid_t tid)
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<NativeFrame> nativeFrames;
|
||||
std::vector<DfxFrame> nativeFrames;
|
||||
bool hasNativeFrame = true;
|
||||
if (!catcher_->CatchFrame(nstid, nativeFrames)) {
|
||||
hasNativeFrame = false;
|
||||
@ -395,19 +238,20 @@ bool MixStackDumper::DumpMixFrame(int fd, pid_t nstid, pid_t tid)
|
||||
hasJsFrame = false;
|
||||
}
|
||||
|
||||
Write(fd, GetThreadStackTraceLabel(tid));
|
||||
if (!hasNativeFrame && !hasJsFrame) {
|
||||
std::string result = "Failed to frames for " + std::to_string(nstid) + ".\n";
|
||||
HILOG_ERROR("%{public}s", result.c_str());
|
||||
HILOG_ERROR("Failed to unwind frames for %{public}d.", nstid);
|
||||
std::string wchan = "Thread wchan:" + LoadThreadWchan(tid);
|
||||
Write(fd, wchan);
|
||||
Write(fd, "\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string threadComm = GetThreadStackTraceLabel(tid);
|
||||
Write(fd, threadComm);
|
||||
if (hasNativeFrame && !hasJsFrame) {
|
||||
PrintNativeFrames(fd, nativeFrames);
|
||||
Write(fd, HiviewDFX::DfxFrameFormat::GetFramesStr(nativeFrames));
|
||||
Write(fd, "\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
BuildJsNativeMixStack(fd, jsFrames, nativeFrames);
|
||||
return true;
|
||||
}
|
||||
@ -442,7 +286,7 @@ void MixStackDumper::GetThreadList(std::vector<pid_t>& threadList)
|
||||
|
||||
void MixStackDumper::Init(pid_t pid)
|
||||
{
|
||||
catcher_ = std::make_unique<OHOS::HiviewDFX::DfxDumpCatcher>(pid);
|
||||
catcher_ = std::make_unique<OHOS::HiviewDFX::DfxCatchFrameLocal>(pid);
|
||||
if (!catcher_->InitFrameCatcher()) {
|
||||
HILOG_ERROR("Init DumpCatcher Failed.");
|
||||
}
|
||||
@ -460,16 +304,16 @@ void MixStackDumper::HandleMixDumpRequest()
|
||||
{
|
||||
int fd = -1;
|
||||
int resFd = -1;
|
||||
int dumpRes = OHOS::HiviewDFX::ProcessDumpRes::DUMP_ESUCCESS;
|
||||
int dumpRes = OHOS::HiviewDFX::DumpErrorCode::DUMP_ESUCCESS;
|
||||
std::unique_lock<std::mutex> lock(g_mutex);
|
||||
HILOG_INFO("Current process is ready to dump stack trace.");
|
||||
(void)GetProcStatus(&g_procInfo);
|
||||
(void)GetProcStatus(g_procInfo);
|
||||
do {
|
||||
fd = RequestPipeFd(GetPid(), FaultLoggerPipeType::PIPE_FD_WRITE_BUF);
|
||||
resFd = RequestPipeFd(GetPid(), FaultLoggerPipeType::PIPE_FD_WRITE_RES);
|
||||
if (fd < 0 || resFd < 0) {
|
||||
HILOG_ERROR("request pid(%{public}d) pipe fd failed", GetPid());
|
||||
dumpRes = OHOS::HiviewDFX::ProcessDumpRes::DUMP_EGETFD;
|
||||
dumpRes = OHOS::HiviewDFX::DumpErrorCode::DUMP_EGETFD;
|
||||
break;
|
||||
}
|
||||
MixStackDumper mixDumper;
|
||||
@ -477,14 +321,8 @@ void MixStackDumper::HandleMixDumpRequest()
|
||||
g_targetDumpTid = -1;
|
||||
} while (false);
|
||||
|
||||
OHOS::HiviewDFX::DumpResMsg dumpResMsg;
|
||||
dumpResMsg.res = dumpRes;
|
||||
const char* strRes = OHOS::HiviewDFX::DfxDumpRes::GetInstance().GetResStr(dumpRes);
|
||||
if (strncpy_s(dumpResMsg.strRes, sizeof(dumpResMsg.strRes), strRes, sizeof(dumpResMsg.strRes) - 1) != 0) {
|
||||
HILOG_ERROR("DfxMixStackDumper::HandleProcessMixDumpRequest strncpy_s failed.");
|
||||
}
|
||||
if (resFd >= 0) {
|
||||
write(resFd, &dumpResMsg, sizeof(struct OHOS::HiviewDFX::DumpResMsg));
|
||||
write(resFd, &dumpRes, sizeof(dumpRes));
|
||||
close(resFd);
|
||||
}
|
||||
if (fd >= 0) {
|
||||
@ -514,7 +352,7 @@ std::string MixStackDumper::DumpMixStackLocked(int fd, pid_t requestTid)
|
||||
pid_t targetNsTid = requestTid;
|
||||
pid_t targetTid = requestTid;
|
||||
if (HasNameSpace()) {
|
||||
TidToNstid(targetTid, targetNsTid);
|
||||
TidToNstid(GetPid(), targetTid, targetNsTid);
|
||||
}
|
||||
DumpMixFrame(fd, targetNsTid, targetTid);
|
||||
} else {
|
||||
@ -523,7 +361,7 @@ std::string MixStackDumper::DumpMixStackLocked(int fd, pid_t requestTid)
|
||||
for (auto& tid : threads) {
|
||||
pid_t nstid = tid;
|
||||
if (HasNameSpace()) {
|
||||
TidToNstid(tid, nstid);
|
||||
TidToNstid(GetPid(), tid, nstid);
|
||||
}
|
||||
if (nstid == gettid()) {
|
||||
continue;
|
||||
@ -538,9 +376,9 @@ std::string MixStackDumper::DumpMixStackLocked(int fd, pid_t requestTid)
|
||||
std::string MixStackDumper::GetMixStack(bool onlyMainThread)
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(g_mutex);
|
||||
(void)GetProcStatus(&g_procInfo);
|
||||
(void)GetProcStatus(g_procInfo);
|
||||
MixStackDumper mixDumper;
|
||||
return mixDumper.DumpMixStackLocked(-1, onlyMainThread ? GetPid() : -1);
|
||||
}
|
||||
} // AppExecFwk
|
||||
} // OHOS
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "application_impl.h"
|
||||
#include "context_impl.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "runtime.h"
|
||||
#include "system_ability_definition.h"
|
||||
@ -513,6 +514,7 @@ void OHOSApplication::OnAbilitySaveState(const PacMap &outState)
|
||||
std::shared_ptr<AbilityRuntime::Context> OHOSApplication::AddAbilityStage(
|
||||
const std::shared_ptr<AbilityLocalRecord> &abilityRecord)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (abilityRecord == nullptr) {
|
||||
HILOG_ERROR("AddAbilityStage:abilityRecord is nullptr");
|
||||
return nullptr;
|
||||
|
@ -25,8 +25,8 @@ namespace AbilityRuntime {
|
||||
class JsRuntime;
|
||||
class JsQuickfixCallback final {
|
||||
public:
|
||||
explicit JsQuickfixCallback(const std::map<std::string, std::string> moduleAndHqfPath) :
|
||||
moduleAndHqfPath_(moduleAndHqfPath) {};
|
||||
explicit JsQuickfixCallback(
|
||||
const std::map<std::string, std::string> moduleAndHqfPath) : moduleAndHqfPath_(moduleAndHqfPath) {};
|
||||
~JsQuickfixCallback() = default;
|
||||
|
||||
bool operator()(std::string baseFileName,
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "file_path_utils.h"
|
||||
#include "hdc_register.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "hot_reloader.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "js_console_log.h"
|
||||
@ -212,6 +213,7 @@ JsRuntime::~JsRuntime()
|
||||
|
||||
std::unique_ptr<JsRuntime> JsRuntime::Create(const Options& options)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
std::unique_ptr<JsRuntime> instance;
|
||||
|
||||
if (!options.preload && options.isStageModel) {
|
||||
@ -446,6 +448,7 @@ void JsRuntime::FinishPreload()
|
||||
|
||||
bool JsRuntime::Initialize(const Options& options)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
if (!preloaded_) {
|
||||
if (!CreateJsEnv(options)) {
|
||||
HILOG_ERROR("Create js environment failed.");
|
||||
@ -677,6 +680,7 @@ void JsRuntime::Deinitialize()
|
||||
|
||||
NativeValue* JsRuntime::LoadJsBundle(const std::string& path, const std::string& hapPath, bool useCommonChunk)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
auto nativeEngine = GetNativeEnginePointer();
|
||||
CHECK_POINTER_AND_RETURN(nativeEngine, nullptr);
|
||||
NativeObject* globalObj = ConvertNativeValueTo<NativeObject>(nativeEngine->GetGlobal());
|
||||
@ -705,6 +709,7 @@ NativeValue* JsRuntime::LoadJsBundle(const std::string& path, const std::string&
|
||||
|
||||
NativeValue* JsRuntime::LoadJsModule(const std::string& path, const std::string& hapPath)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
if (!RunScript(path, hapPath, false)) {
|
||||
HILOG_ERROR("Failed to run script: %{private}s", path.c_str());
|
||||
return nullptr;
|
||||
@ -726,6 +731,7 @@ NativeValue* JsRuntime::LoadJsModule(const std::string& path, const std::string&
|
||||
std::unique_ptr<NativeReference> JsRuntime::LoadModule(const std::string& moduleName, const std::string& modulePath,
|
||||
const std::string& hapPath, bool esmodule, bool useCommonChunk)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("JsRuntime::LoadModule(%{public}s, %{private}s, %{private}s, %{public}s)",
|
||||
moduleName.c_str(), modulePath.c_str(), hapPath.c_str(), esmodule ? "true" : "false");
|
||||
auto nativeEngine = GetNativeEnginePointer();
|
||||
@ -797,6 +803,7 @@ std::unique_ptr<NativeReference> JsRuntime::LoadSystemModule(
|
||||
|
||||
bool JsRuntime::RunScript(const std::string& srcPath, const std::string& hapPath, bool useCommonChunk)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
auto nativeEngine = GetNativeEnginePointer();
|
||||
CHECK_POINTER_AND_RETURN(nativeEngine, false);
|
||||
auto vm = GetEcmaVm();
|
||||
@ -830,14 +837,26 @@ bool JsRuntime::RunScript(const std::string& srcPath, const std::string& hapPath
|
||||
}
|
||||
|
||||
auto func = [&](std::string modulePath, const std::string abcPath) {
|
||||
std::unique_ptr<uint8_t[]> dataPtr = nullptr;
|
||||
size_t len = 0;
|
||||
if (!extractor->ExtractToBufByName(modulePath, dataPtr, len, true)) {
|
||||
HILOG_ERROR("Get abc file failed.");
|
||||
return false;
|
||||
}
|
||||
if (!extractor->IsHapCompress(modulePath)) {
|
||||
std::unique_ptr<uint8_t[]> dataPtr = nullptr;
|
||||
size_t len = 0;
|
||||
if (!extractor->ExtractToBufByName(modulePath, dataPtr, len, true)) {
|
||||
HILOG_ERROR("Get abc file failed.");
|
||||
return false;
|
||||
}
|
||||
return LoadScript(abcPath, dataPtr.release(), len, isBundle_);
|
||||
} else {
|
||||
std::ostringstream outStream;
|
||||
if (!extractor->GetFileBuffer(modulePath, outStream)) {
|
||||
HILOG_ERROR("Get abc file failed");
|
||||
return false;
|
||||
}
|
||||
const auto& outStr = outStream.str();
|
||||
std::vector<uint8_t> buffer;
|
||||
buffer.assign(outStr.begin(), outStr.end());
|
||||
|
||||
return LoadScript(abcPath, dataPtr.release(), len, isBundle_);
|
||||
return LoadScript(abcPath, &buffer, isBundle_);
|
||||
}
|
||||
};
|
||||
|
||||
if (useCommonChunk) {
|
||||
|
@ -95,6 +95,10 @@ public:
|
||||
#endif
|
||||
NativeEngine& engine = jsRuntime_.GetNativeEngine();
|
||||
engine.CallFunction(engine.CreateUndefined(), jsFunction_->Get(), args_.data(), args_.size());
|
||||
if (engine.HasPendingException()) {
|
||||
HILOG_ERROR("Pending exception after CallFUnction in JsTimer. Handle uncaught exception here.");
|
||||
engine.HandleUncaughtException();
|
||||
}
|
||||
}
|
||||
|
||||
void PushArgs(const std::shared_ptr<NativeReference>& ref)
|
||||
@ -192,4 +196,4 @@ void InitTimer(NativeEngine& engine, NativeObject& globalObject)
|
||||
BindNativeFunction(engine, globalObject, "clearInterval", moduleName, StopTimeoutOrInterval);
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
} // namespace OHOS
|
||||
|
@ -83,7 +83,8 @@ void InitWorkerFunc(NativeEngine* nativeEngine)
|
||||
auto workerPostTask = [nativeEngine](std::function<void()>&& callback) {
|
||||
nativeEngine->CallDebuggerPostTaskFunc(std::move(callback));
|
||||
};
|
||||
panda::JSNApi::StartDebugger(ARK_DEBUGGER_LIB_PATH, vm, needBreakPoint, instanceId, workerPostTask);
|
||||
panda::JSNApi::DebugOption debugOption = {ARK_DEBUGGER_LIB_PATH, needBreakPoint};
|
||||
panda::JSNApi::StartDebugger(vm, debugOption, instanceId, workerPostTask);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ void RestoreContainerScope(int32_t id);
|
||||
|
||||
struct AssetHelper final {
|
||||
explicit AssetHelper(const std::string& codePath, bool isDebugVersion, bool isBundle)
|
||||
: codePath_(codePath), isDebugVersion_(isDebugVersion), isBundle_(isBundle)
|
||||
: codePath_(codePath), isDebugVersion_(isDebugVersion), isBundle_(isBundle)
|
||||
{
|
||||
if (!codePath_.empty() && codePath.back() != '/') {
|
||||
codePath_.append("/");
|
||||
|
@ -353,7 +353,8 @@ bool SimulatorImpl::OnInit()
|
||||
return false;
|
||||
}
|
||||
|
||||
panda::JSNApi::StartDebugger(ARK_DEBUGGER_LIB_PATH, vm_, true, 0,
|
||||
panda::JSNApi::DebugOption debugOption = {ARK_DEBUGGER_LIB_PATH, true}
|
||||
panda::JSNApi::StartDebugger(vm_, debugOption, 0,
|
||||
std::bind(&DebuggerTask::OnPostTask, &debuggerTask_, std::placeholders::_1));
|
||||
|
||||
auto nativeEngine = std::make_unique<ArkNativeEngine>(vm_, nullptr);
|
||||
|
@ -250,7 +250,7 @@ public:
|
||||
*/
|
||||
ErrCode TerminateUIExtensionAbility(const sptr<SessionInfo> &extensionSessionInfo,
|
||||
int resultCode = DEFAULT_INVAL_VALUE, const Want *resultWant = nullptr);
|
||||
|
||||
|
||||
/**
|
||||
* CloseUIAbilityBySCB, close the special ability by scb.
|
||||
*
|
||||
@ -986,6 +986,17 @@ public:
|
||||
ErrCode ShareDataDone(
|
||||
const sptr<IRemoteObject> &token, const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam);
|
||||
|
||||
/**
|
||||
* Request dialog service with want, send want to ability manager service.
|
||||
*
|
||||
* @param want target component.
|
||||
* @param callerToken caller ability token.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode RequestDialogService(
|
||||
const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken);
|
||||
|
||||
private:
|
||||
class AbilityMgrDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
|
@ -900,6 +900,18 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request dialog service with want, send want to ability manager service.
|
||||
*
|
||||
* @param want, the want of the dialog service to start.
|
||||
* @param callerToken, caller ability token.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t RequestDialogService(const Want &want, const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Acquire the shared data.
|
||||
* @param missionId The missionId of Target ability.
|
||||
@ -1206,6 +1218,9 @@ public:
|
||||
// ipc id for close ui ability by scb
|
||||
CLOSE_UI_ABILITY_BY_SCB,
|
||||
|
||||
// ipc id for request dialog service
|
||||
REQUEST_DIALOG_SERVICE,
|
||||
|
||||
// ipc id for continue ability(1101)
|
||||
START_CONTINUATION = 1101,
|
||||
|
||||
|
@ -95,6 +95,7 @@ ohos_shared_library("runtime") {
|
||||
"ets_utils:console",
|
||||
"ets_utils:timer",
|
||||
"eventhandler:libeventhandler",
|
||||
"hitrace_native:hitrace_meter",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"napi:ace_napi",
|
||||
|
@ -24,10 +24,9 @@
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
using ClearProxyCallback = std::function<void()>;
|
||||
class UriPermissionManagerClient : public std::enable_shared_from_this<UriPermissionManagerClient> {
|
||||
class UriPermissionManagerClient {
|
||||
public:
|
||||
static std::shared_ptr<UriPermissionManagerClient> GetInstance();
|
||||
UriPermissionManagerClient() = default;
|
||||
static UriPermissionManagerClient& GetInstance();
|
||||
~UriPermissionManagerClient() = default;
|
||||
|
||||
/**
|
||||
@ -59,6 +58,7 @@ public:
|
||||
void OnLoadSystemAbilitySuccess(const sptr<IRemoteObject> &remoteObject);
|
||||
void OnLoadSystemAbilityFail();
|
||||
private:
|
||||
UriPermissionManagerClient() = default;
|
||||
sptr<IUriPermissionManager> ConnectUriPermService();
|
||||
void ClearProxy();
|
||||
bool LoadUriPermService();
|
||||
@ -77,8 +77,6 @@ private:
|
||||
};
|
||||
|
||||
private:
|
||||
static std::recursive_mutex recursiveMutex_;
|
||||
static std::shared_ptr<UriPermissionManagerClient> instance_;
|
||||
std::mutex mutex_;
|
||||
std::mutex saLoadMutex_;
|
||||
std::condition_variable loadSaVariable_;
|
||||
|
@ -34,7 +34,7 @@ void UriPermissionLoadCallback::OnLoadSystemAbilitySuccess(
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Load system ability %{public}d succeed.", systemAbilityId);
|
||||
UriPermissionManagerClient::GetInstance()->OnLoadSystemAbilitySuccess(remoteObject);
|
||||
UriPermissionManagerClient::GetInstance().OnLoadSystemAbilitySuccess(remoteObject);
|
||||
}
|
||||
|
||||
void UriPermissionLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
|
||||
@ -45,7 +45,7 @@ void UriPermissionLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId)
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Load system ability %{public}d failed.", systemAbilityId);
|
||||
UriPermissionManagerClient::GetInstance()->OnLoadSystemAbilityFail();
|
||||
UriPermissionManagerClient::GetInstance().OnLoadSystemAbilityFail();
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
@ -27,17 +27,10 @@ namespace AAFwk {
|
||||
namespace {
|
||||
const int LOAD_SA_TIMEOUT_MS = 4 * 1000;
|
||||
} // namespace
|
||||
std::shared_ptr<UriPermissionManagerClient> UriPermissionManagerClient::instance_ = nullptr;
|
||||
std::recursive_mutex UriPermissionManagerClient::recursiveMutex_;
|
||||
std::shared_ptr<UriPermissionManagerClient> UriPermissionManagerClient::GetInstance()
|
||||
UriPermissionManagerClient& UriPermissionManagerClient::GetInstance()
|
||||
{
|
||||
if (instance_ == nullptr) {
|
||||
std::lock_guard<std::recursive_mutex> lock_l(recursiveMutex_);
|
||||
if (instance_ == nullptr) {
|
||||
instance_ = std::make_shared<UriPermissionManagerClient>();
|
||||
}
|
||||
}
|
||||
return instance_;
|
||||
static UriPermissionManagerClient instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
int UriPermissionManagerClient::GrantUriPermission(const Uri &uri, unsigned int flag,
|
||||
@ -84,11 +77,8 @@ sptr<IUriPermissionManager> UriPermissionManagerClient::ConnectUriPermService()
|
||||
HILOG_ERROR("Failed to get uri permission manager.");
|
||||
return nullptr;
|
||||
}
|
||||
auto self = shared_from_this();
|
||||
const auto& onClearProxyCallback = [self] {
|
||||
if (self) {
|
||||
self->ClearProxy();
|
||||
}
|
||||
const auto& onClearProxyCallback = [] {
|
||||
UriPermissionManagerClient::GetInstance().ClearProxy();
|
||||
};
|
||||
sptr<UpmsDeathRecipient> recipient(new UpmsDeathRecipient(onClearProxyCallback));
|
||||
uriPermMgr->AsObject()->AddDeathRecipient(recipient);
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "napi_remote_object.h"
|
||||
#include "iremote_object.h"
|
||||
#include "session_info.h"
|
||||
#include "ui_window.h"
|
||||
#include "foundation/window/window_manager/interfaces/innerkits/wm/window.h"
|
||||
#include "want.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -207,15 +207,15 @@ public:
|
||||
|
||||
sptr<AAFwk::SessionInfo> GetSessionInfo();
|
||||
|
||||
void SetSceneSessionStageListener(const std::shared_ptr<Rosen::ISessionStageStateListener> &listener);
|
||||
void SetExtensionWindowLifeCycleListener(const sptr<Rosen::IWindowLifeCycle> &listener);
|
||||
|
||||
std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo_ = nullptr;
|
||||
protected:
|
||||
std::shared_ptr<AppExecFwk::AbilityHandler> handler_ = nullptr;
|
||||
|
||||
// window scene
|
||||
std::shared_ptr<Ace::NG::UIWindow> uiWindow_;
|
||||
std::shared_ptr<Rosen::ISessionStageStateListener> sceneSessionStageListener_ = nullptr;
|
||||
sptr<Rosen::Window> uiWindow_;
|
||||
sptr<Rosen::IWindowLifeCycle> extensionWindowLifeCycleListener_ = nullptr;
|
||||
private:
|
||||
std::shared_ptr<AppExecFwk::OHOSApplication> application_ = nullptr;
|
||||
std::shared_ptr<AAFwk::Want> launchWant_ = nullptr;
|
||||
|
@ -171,11 +171,11 @@ private:
|
||||
sptr<IRemoteObject> token_;
|
||||
std::shared_ptr<Extension> extension_;
|
||||
|
||||
class ExtensionSessionStateLifeCycleImpl : public Rosen::ISessionStageStateListener {
|
||||
class ExtensionWindowLifeCycleImpl : public Rosen::IWindowLifeCycle {
|
||||
public:
|
||||
ExtensionSessionStateLifeCycleImpl(const sptr<IRemoteObject>& token, const std::shared_ptr<ExtensionImpl>& owner)
|
||||
ExtensionWindowLifeCycleImpl(const sptr<IRemoteObject>& token, const std::shared_ptr<ExtensionImpl>& owner)
|
||||
: token_(token), owner_(owner) {}
|
||||
virtual ~ExtensionSessionStateLifeCycleImpl() {}
|
||||
virtual ~ExtensionWindowLifeCycleImpl() {}
|
||||
void AfterForeground() override;
|
||||
void AfterBackground() override;
|
||||
void AfterActive() override;
|
||||
|
@ -62,7 +62,8 @@ public:
|
||||
/**
|
||||
* Default constructor used to create a AbilityDelegatorArgs instance.
|
||||
*/
|
||||
AbilityDelegatorArgs();
|
||||
AbilityDelegatorArgs() = default;
|
||||
virtual ~AbilityDelegatorArgs() = default;
|
||||
|
||||
/**
|
||||
* A constructor used to create a AbilityDelegatorArgs instance with the input parameter passed.
|
||||
@ -71,11 +72,6 @@ public:
|
||||
*/
|
||||
explicit AbilityDelegatorArgs(const AAFwk::Want &want);
|
||||
|
||||
/**
|
||||
* Default deconstructor used to deconstruct.
|
||||
*/
|
||||
~AbilityDelegatorArgs();
|
||||
|
||||
/**
|
||||
* Obtains the bundle name of the application being tested.
|
||||
*
|
||||
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ABILITY_RUNTIME_APPLICATION_CONTEXT_MANAGER_H
|
||||
#define OHOS_ABILITY_RUNTIME_APPLICATION_CONTEXT_MANAGER_H
|
||||
|
||||
#include "native_engine/native_engine.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
class ApplicationContextManager {
|
||||
public:
|
||||
ApplicationContextManager(const ApplicationContextManager&) = delete;
|
||||
|
||||
ApplicationContextManager& operator=(const ApplicationContextManager&) = delete;
|
||||
|
||||
static ApplicationContextManager& GetApplicationContextManager();
|
||||
|
||||
void AddGlobalObject(std::shared_ptr<NativeReference> applicationContextObj);
|
||||
|
||||
std::shared_ptr<NativeReference> GetGlobalObject();
|
||||
|
||||
private:
|
||||
ApplicationContextManager();
|
||||
|
||||
~ApplicationContextManager();
|
||||
|
||||
std::shared_ptr<NativeReference> applicationContextObj_;
|
||||
};
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_APPLICATION_CONTEXT_MANAGER_H
|
@ -20,7 +20,7 @@
|
||||
#include <unistd.h>
|
||||
#include <vector>
|
||||
|
||||
#include "dfx_dump_catcher.h"
|
||||
#include "catchframe_local.h"
|
||||
#include "event_handler.h"
|
||||
#include "ohos_application.h"
|
||||
#include "runtime.h"
|
||||
@ -44,9 +44,8 @@ private:
|
||||
void GetThreadList(std::vector<pid_t>& threadList);
|
||||
bool IsJsNativePcEqual(uintptr_t *jsNativePointer, uint64_t nativePc, uint64_t nativeOffset);
|
||||
void BuildJsNativeMixStack(int fd, std::vector<JsFrames>& jsFrames,
|
||||
std::vector<OHOS::HiviewDFX::NativeFrame>& nativeFrames);
|
||||
std::vector<OHOS::HiviewDFX::DfxFrame>& nativeFrames);
|
||||
std::string GetThreadStackTraceLabel(pid_t tid);
|
||||
void PrintNativeFrames(int fd, std::vector<OHOS::HiviewDFX::NativeFrame>& nativeFrames);
|
||||
void PrintProcessHeader(int fd, pid_t pid, uid_t uid);
|
||||
void Write(int fd, const std::string& outStr);
|
||||
std::string DumpMixStackLocked(int fd, pid_t tid);
|
||||
@ -56,7 +55,7 @@ private:
|
||||
private:
|
||||
static std::weak_ptr<EventHandler> signalHandler_;
|
||||
static std::weak_ptr<OHOSApplication> application_;
|
||||
std::unique_ptr<OHOS::HiviewDFX::DfxDumpCatcher> catcher_{nullptr};
|
||||
std::unique_ptr<OHOS::HiviewDFX::DfxCatchFrameLocal> catcher_{nullptr};
|
||||
std::string outputStr_;
|
||||
};
|
||||
} // AppExecFwk
|
||||
|
@ -140,7 +140,8 @@ bool JsEnvironment::StartDebugger(const char* libraryPath, bool needBreakPoint,
|
||||
const DebuggerPostTask& debuggerPostTask)
|
||||
{
|
||||
if (vm_ != nullptr) {
|
||||
return panda::JSNApi::StartDebugger(libraryPath, vm_, needBreakPoint, instanceId, debuggerPostTask);
|
||||
panda::JSNApi::DebugOption debugOption = {libraryPath, needBreakPoint};
|
||||
return panda::JSNApi::StartDebugger(vm_, debugOption, instanceId, debuggerPostTask);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -191,14 +191,12 @@ void SourceMap::SplitSourceMap(const std::string& sourceMapData)
|
||||
std::string value;
|
||||
while ((leftBracket = sourceMapData.find(": {", rightBracket)) != std::string::npos) {
|
||||
rightBracket = sourceMapData.find("},", leftBracket);
|
||||
uint32_t subLeftBracket = leftBracket;
|
||||
uint32_t subRightBracket = rightBracket;
|
||||
value = sourceMapData.substr(subLeftBracket + INDEX_ONE, subRightBracket - subLeftBracket + INDEX_TWO);
|
||||
std::size_t sources = value.find("\"sources\": [");
|
||||
value = sourceMapData.substr(leftBracket, rightBracket);
|
||||
std::size_t sources = value.find("\"sources\": [");
|
||||
if (sources == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
std::size_t names = value.find("],");
|
||||
std::size_t names = value.find("],", sources);
|
||||
if (names == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
@ -534,7 +532,6 @@ std::string SourceMap::GetOriginalNames(std::shared_ptr<SourceMapData> targetMap
|
||||
posDiff += static_cast<int32_t>(names[i + 1].length()) - static_cast<int32_t>(names[i].length());
|
||||
}
|
||||
// In case there are other variable names not replaced.
|
||||
// example:var e = process.a.b + _ohos_process_1.a.b;
|
||||
found = jsCode.find(names[i], found + names[i + 1].length());
|
||||
}
|
||||
}
|
||||
|
12
service_router_framework/services/srms/sa_profile/404.json
Normal file
12
service_router_framework/services/srms/sa_profile/404.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"process": "service_router",
|
||||
"systemability": [
|
||||
{
|
||||
"name": 404,
|
||||
"libpath": "libsrms.z.so",
|
||||
"run-on-create": false,
|
||||
"distributed": false,
|
||||
"dump_level": 1
|
||||
}
|
||||
]
|
||||
}
|
@ -22,7 +22,7 @@ group("srms") {
|
||||
}
|
||||
|
||||
ohos_sa_profile("srms_sa_profile") {
|
||||
sources = [ "404.xml" ]
|
||||
sources = [ "404.json" ]
|
||||
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
"services" : [
|
||||
{
|
||||
"name" : "service_router",
|
||||
"path" : ["/system/bin/sa_main", "/system/profile/service_router.xml"],
|
||||
"path" : ["/system/bin/sa_main", "/system/profile/service_router.json"],
|
||||
"ondemand" : true,
|
||||
"uid" : "servicerouter",
|
||||
"start-mode" : "condition",
|
||||
|
@ -760,6 +760,16 @@ public:
|
||||
* @return Returns ERR_OK if the current process has the permission, others on failure.
|
||||
*/
|
||||
virtual int VerifyPermission(const std::string &permission, int pid, int uid) override;
|
||||
|
||||
/**
|
||||
* Request dialog service with want, send want to ability manager service.
|
||||
*
|
||||
* @param want, the want of the dialog service to start.
|
||||
* @param callerToken, caller ability token.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
virtual int32_t RequestDialogService(const Want &want, const sptr<IRemoteObject> &callerToken) override;
|
||||
|
||||
virtual int32_t AcquireShareData(
|
||||
const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData) override;
|
||||
virtual int32_t ShareDataDone(const sptr<IRemoteObject> &token,
|
||||
|
@ -977,6 +977,8 @@ public:
|
||||
int32_t IsValidMissionIds(
|
||||
const std::vector<int32_t> &missionIds, std::vector<MissionVaildResult> &results) override;
|
||||
|
||||
virtual int32_t RequestDialogService(const Want &want, const sptr<IRemoteObject> &callerToken) override;
|
||||
|
||||
virtual int32_t AcquireShareData(
|
||||
const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData) override;
|
||||
virtual int32_t ShareDataDone(const sptr<IRemoteObject>& token,
|
||||
@ -1336,6 +1338,9 @@ private:
|
||||
|
||||
bool CheckProxyComponent(const Want &want, const int result);
|
||||
|
||||
int32_t RequestDialogServiceInner(const Want &want, const sptr<IRemoteObject> &callerToken,
|
||||
int requestCode, int32_t userId);
|
||||
|
||||
bool IsReleaseCallInterception(const sptr<IAbilityConnection> &connect, const AppExecFwk::ElementName &element,
|
||||
int &result);
|
||||
|
||||
|
@ -210,6 +210,8 @@ private:
|
||||
|
||||
int VerifyPermissionInner(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
int HandleRequestDialogService(MessageParcel &data, MessageParcel &reply);
|
||||
|
||||
int AcquireShareDataInner(MessageParcel &data, MessageParcel &reply);
|
||||
int ShareDataDoneInner(MessageParcel &data, MessageParcel &reply);
|
||||
int GetAbilityTokenByCalleeObjInner(MessageParcel &data, MessageParcel &reply);
|
||||
|
@ -706,7 +706,8 @@ std::shared_ptr<AbilityRecord> AbilityConnectManager::GetServiceRecordByElementN
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<AbilityRecord> AbilityConnectManager::GetExtensionByTokenFromServiceMap(const sptr<IRemoteObject> &token)
|
||||
std::shared_ptr<AbilityRecord> AbilityConnectManager::GetExtensionByTokenFromServiceMap(
|
||||
const sptr<IRemoteObject> &token)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(Lock_);
|
||||
auto IsMatch = [token](auto service) {
|
||||
@ -1227,7 +1228,8 @@ void AbilityConnectManager::OnTimeOut(uint32_t msgId, int64_t abilityRecordId)
|
||||
HILOG_ERROR("AbilityConnectManager on time out event: ability record is nullptr.");
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("Ability timeout ,msg:%{public}d,name:%{public}s", msgId, abilityRecord->GetAbilityInfo().name.c_str());
|
||||
HILOG_DEBUG("Ability timeout ,msg:%{public}d,name:%{public}s", msgId,
|
||||
abilityRecord->GetAbilityInfo().name.c_str());
|
||||
|
||||
switch (msgId) {
|
||||
case AbilityManagerService::INACTIVE_TIMEOUT_MSG:
|
||||
@ -1507,8 +1509,8 @@ void AbilityConnectManager::GetAbilityRunningInfos(std::vector<AbilityRunningInf
|
||||
std::for_each(serviceMap_.begin(), serviceMap_.end(), queryInfo);
|
||||
}
|
||||
|
||||
void AbilityConnectManager::GetExtensionRunningInfo(std::shared_ptr<AbilityRecord> &abilityRecord, const int32_t userId,
|
||||
std::vector<ExtensionRunningInfo> &info)
|
||||
void AbilityConnectManager::GetExtensionRunningInfo(std::shared_ptr<AbilityRecord> &abilityRecord,
|
||||
const int32_t userId, std::vector<ExtensionRunningInfo> &info)
|
||||
{
|
||||
ExtensionRunningInfo extensionInfo;
|
||||
AppExecFwk::RunningProcessInfo processInfo;
|
||||
|
@ -709,6 +709,17 @@ ErrCode AbilityManagerClient::GetProcessRunningInfos(std::vector<AppExecFwk::Run
|
||||
return abms->GetProcessRunningInfos(info);
|
||||
}
|
||||
|
||||
ErrCode AbilityManagerClient::RequestDialogService(
|
||||
const Want &want, const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto abms = GetAbilityManager();
|
||||
CHECK_POINTER_RETURN_NOT_CONNECTED(abms);
|
||||
HILOG_INFO("request is:%{public}s.", want.GetElement().GetURI().c_str());
|
||||
HandleDlpApp(const_cast<Want &>(want));
|
||||
return abms->RequestDialogService(want, callerToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start synchronizing remote device mission
|
||||
* @param devId, deviceId.
|
||||
|
@ -3774,6 +3774,45 @@ int AbilityManagerProxy::VerifyPermission(const std::string &permission, int pid
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AbilityManagerProxy::RequestDialogService(const Want &want, const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
HILOG_INFO("RequestDialogService Call");
|
||||
if (!callerToken) {
|
||||
HILOG_ERROR("callerToken is invalid.");
|
||||
return ERR_INVALID_CALLER;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
if (!data.WriteParcelable(&want)) {
|
||||
HILOG_ERROR("want write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
if (!data.WriteRemoteObject(callerToken)) {
|
||||
HILOG_ERROR("infos write failed.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("remote is nullptr.");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
auto error = remote->SendRequest(IAbilityManager::REQUEST_DIALOG_SERVICE, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("request dialog service Send request error: %{public}d", error);
|
||||
return error;
|
||||
}
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
int32_t AbilityManagerProxy::AcquireShareData(
|
||||
const int32_t &missionId, const sptr<IAcquireShareDataCallback> &shareData)
|
||||
{
|
||||
|
@ -340,7 +340,7 @@ bool AbilityManagerService::Init()
|
||||
HILOG_ERROR("RegisterBundleEventCallback failed!");
|
||||
}
|
||||
} else {
|
||||
HILOG_ERROR("Get BundleManager or abilieyBundleEventCallback failed!");
|
||||
HILOG_ERROR("Get BundleManager or abilityBundleEventCallback failed!");
|
||||
}
|
||||
};
|
||||
handler_->PostTask(registerBundleEventCallbackTask, "RegisterBundleEventCallback");
|
||||
@ -576,9 +576,26 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
|
||||
|
||||
auto type = abilityInfo.type;
|
||||
if (type == AppExecFwk::AbilityType::DATA) {
|
||||
HILOG_ERROR("Cannot start data ability, use 'AcquireDataAbility()' instead.");
|
||||
HILOG_ERROR("Cannot start data ability by start ability.");
|
||||
return ERR_WRONG_INTERFACE_CALL;
|
||||
} else if (type == AppExecFwk::AbilityType::SERVICE || type == AppExecFwk::AbilityType::EXTENSION) {
|
||||
} else if (type == AppExecFwk::AbilityType::EXTENSION) {
|
||||
auto isSACall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
|
||||
auto isGatewayCall = AAFwk::PermissionVerification::GetInstance()->IsGatewayCall();
|
||||
auto isSystemAppCall = AAFwk::PermissionVerification::GetInstance()->IsSystemAppCall();
|
||||
auto isShellCall = AAFwk::PermissionVerification::GetInstance()->IsShellCall();
|
||||
if (!isSACall && !isGatewayCall && !isSystemAppCall && !isShellCall) {
|
||||
HILOG_ERROR("Cannot start extension by start ability, use startServiceExtensionAbility.");
|
||||
return ERR_WRONG_INTERFACE_CALL;
|
||||
}
|
||||
|
||||
if (isSystemAppCall) {
|
||||
result = CheckCallServicePermission(abilityRequest);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Check permission failed");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} else if (type == AppExecFwk::AbilityType::SERVICE) {
|
||||
HILOG_DEBUG("Check call service or extension permission, name is %{public}s.", abilityInfo.name.c_str());
|
||||
result = CheckCallServicePermission(abilityRequest);
|
||||
if (result != ERR_OK) {
|
||||
@ -736,7 +753,7 @@ int AbilityManagerService::StartAbility(const Want &want, const AbilityStartSett
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
auto abilityInfo = abilityRequest.abilityInfo;
|
||||
validUserId = abilityInfo.applicationInfo.singleton ? U0_USER_ID : validUserId;
|
||||
HILOG_DEBUG("userId : %{public}d, singleton is : %{public}d",
|
||||
@ -934,7 +951,6 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!isStartAsCaller) {
|
||||
UpdateCallerInfo(abilityRequest.want, callerToken);
|
||||
@ -1012,6 +1028,128 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t AbilityManagerService::RequestDialogService(const Want &want, const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto flags = want.GetFlags();
|
||||
if ((flags & Want::FLAG_ABILITY_CONTINUATION) == Want::FLAG_ABILITY_CONTINUATION) {
|
||||
HILOG_ERROR("RequestDialogService with continuation flags is not allowed!");
|
||||
return ERR_INVALID_CONTINUATION_FLAG;
|
||||
}
|
||||
|
||||
HILOG_INFO("request dialog service, target is %{public}s",want.GetElement().GetURI().c_str());
|
||||
return RequestDialogServiceInner(want, callerToken, -1, -1);
|
||||
}
|
||||
|
||||
int32_t AbilityManagerService::RequestDialogServiceInner(const Want &want, const sptr<IRemoteObject> &callerToken,
|
||||
int requestCode, int32_t userId)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (callerToken == nullptr || !VerificationAllToken(callerToken)) {
|
||||
HILOG_WARN("caller is invalid.");
|
||||
return ERR_INVALID_CALLER;
|
||||
}
|
||||
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "CHECK_DLP");
|
||||
if (!DlpUtils::OtherAppsAccessDlpCheck(callerToken, want) ||
|
||||
!DlpUtils::DlpAccessOtherAppsCheck(callerToken, want)) {
|
||||
HILOG_ERROR("%{public}s: Permission verification failed.", __func__);
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
if (AbilityUtil::HandleDlpApp(const_cast<Want &>(want))) {
|
||||
HILOG_ERROR("Cannot handle dlp by RequestDialogService.");
|
||||
return ERR_WRONG_INTERFACE_CALL;
|
||||
}
|
||||
}
|
||||
|
||||
auto result = interceptorExecuter_ == nullptr ? ERR_INVALID_VALUE :
|
||||
interceptorExecuter_->DoProcess(want, requestCode, GetUserId(), true);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("interceptorExecuter_ is nullptr or DoProcess return error.");
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t oriValidUserId = GetValidUserId(userId);
|
||||
int32_t validUserId = oriValidUserId;
|
||||
if (!JudgeMultiUserConcurrency(validUserId)) {
|
||||
HILOG_ERROR("Multi-user non-concurrent mode is not satisfied.");
|
||||
return ERR_CROSS_USER;
|
||||
}
|
||||
|
||||
AbilityRequest abilityRequest;
|
||||
result = GenerateAbilityRequest(want, requestCode, abilityRequest, callerToken, validUserId);
|
||||
ComponentRequest componentRequest = initComponentRequest(callerToken, requestCode, result);
|
||||
if (CheckProxyComponent(want, result) && !IsComponentInterceptionStart(want, componentRequest, abilityRequest)) {
|
||||
return componentRequest.requestResult;
|
||||
}
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Generate ability request local error when RequestDialogService.");
|
||||
return result;
|
||||
}
|
||||
UpdateCallerInfo(abilityRequest.want, callerToken);
|
||||
|
||||
auto abilityInfo = abilityRequest.abilityInfo;
|
||||
validUserId = abilityInfo.applicationInfo.singleton ? U0_USER_ID : validUserId;
|
||||
HILOG_DEBUG("userId is : %{public}d, singleton is : %{public}d",
|
||||
validUserId, static_cast<int>(abilityInfo.applicationInfo.singleton));
|
||||
|
||||
result = CheckStaticCfgPermission(abilityInfo, false, -1);
|
||||
if (result != AppExecFwk::Constants::PERMISSION_GRANTED) {
|
||||
HILOG_ERROR("CheckStaticCfgPermission error, result is %{public}d.", result);
|
||||
return ERR_STATIC_CFG_PERMISSION;
|
||||
}
|
||||
|
||||
auto type = abilityInfo.type;
|
||||
if (type == AppExecFwk::AbilityType::PAGE) {
|
||||
result = CheckCallAbilityPermission(abilityRequest);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Check permission failed");
|
||||
return result;
|
||||
}
|
||||
} else if (type == AppExecFwk::AbilityType::EXTENSION &&
|
||||
abilityInfo.extensionAbilityType == AppExecFwk::ExtensionAbilityType::SERVICE) {
|
||||
HILOG_DEBUG("Check call ability permission, name is %{public}s.", abilityInfo.name.c_str());
|
||||
result = CheckCallServicePermission(abilityRequest);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Check permission failed");
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
HILOG_ERROR("RequestDialogService do not support other component.");
|
||||
return ERR_WRONG_INTERFACE_CALL;
|
||||
}
|
||||
|
||||
if (type == AppExecFwk::AbilityType::EXTENSION) {
|
||||
auto connectManager = GetConnectManagerByUserId(validUserId);
|
||||
if (!connectManager) {
|
||||
HILOG_ERROR("connectManager is nullptr. userId=%{public}d", validUserId);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
HILOG_DEBUG("request dialog service, start service extension,name is %{public}s.", abilityInfo.name.c_str());
|
||||
ReportEventToSuspendManager(abilityInfo);
|
||||
return connectManager->StartAbility(abilityRequest);
|
||||
}
|
||||
|
||||
if (!IsComponentInterceptionStart(want, componentRequest, abilityRequest)) {
|
||||
return componentRequest.requestResult;
|
||||
}
|
||||
if (!IsAbilityControllerStart(want, abilityInfo.bundleName)) {
|
||||
HILOG_ERROR("IsAbilityControllerStart failed : %{public}s.", abilityInfo.bundleName.c_str());
|
||||
return ERR_WOULD_BLOCK;
|
||||
}
|
||||
auto missionListManager = GetListManagerByUserId(oriValidUserId);
|
||||
if (missionListManager == nullptr) {
|
||||
HILOG_ERROR("missionListManager is nullptr. userId:%{public}d", validUserId);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
ReportAbilitStartInfoToRSS(abilityInfo);
|
||||
ReportEventToSuspendManager(abilityInfo);
|
||||
HILOG_DEBUG("RequestDialogService, start ability, name is %{public}s.", abilityInfo.name.c_str());
|
||||
return missionListManager->StartAbility(abilityRequest);
|
||||
}
|
||||
|
||||
int AbilityManagerService::StartUIAbilityBySCB(const Want &want, const StartOptions &startOptions,
|
||||
sptr<SessionInfo> sessionInfo)
|
||||
{
|
||||
@ -5614,7 +5752,7 @@ std::string AbilityManagerService::GetBundleNameFromToken(const sptr<IRemoteObje
|
||||
} else {
|
||||
callerBundleName = abilityRecord->GetAbilityInfo().bundleName;
|
||||
}
|
||||
return callerBundleName;
|
||||
return callerBundleName;
|
||||
}
|
||||
|
||||
bool AbilityManagerService::JudgeMultiUserConcurrency(const int32_t userId)
|
||||
|
@ -167,6 +167,7 @@ void AbilityManagerStub::ThirdStepInit()
|
||||
requestFuncMap_[TERMINATE_UI_EXTENSION_ABILITY] = &AbilityManagerStub::TerminateUIExtensionAbilityInner;
|
||||
requestFuncMap_[CONNECT_UI_EXTENSION_ABILITY] = &AbilityManagerStub::ConnectUIExtensionAbilityInner;
|
||||
#endif
|
||||
requestFuncMap_[REQUEST_DIALOG_SERVICE] = &AbilityManagerStub::HandleRequestDialogService;
|
||||
requestFuncMap_[SET_COMPONENT_INTERCEPTION] = &AbilityManagerStub::SetComponentInterceptionInner;
|
||||
requestFuncMap_[SEND_ABILITY_RESULT_BY_TOKEN] = &AbilityManagerStub::SendResultToAbilityByTokenInner;
|
||||
requestFuncMap_[QUERY_MISSION_VAILD] = &AbilityManagerStub::IsValidMissionIdsInner;
|
||||
@ -1768,6 +1769,28 @@ int AbilityManagerStub::EnableRecoverAbilityInner(MessageParcel &data, MessagePa
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int AbilityManagerStub::HandleRequestDialogService(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
std::unique_ptr<AAFwk::Want> want(data.ReadParcelable<AAFwk::Want>());
|
||||
if (want == nullptr) {
|
||||
HILOG_ERROR("want is nullptr");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> callerToken = data.ReadRemoteObject();
|
||||
if (!callerToken) {
|
||||
HILOG_ERROR("callerToken is invalid.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
int32_t result = RequestDialogService(*want, callerToken);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
HILOG_ERROR("reply write failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int AbilityManagerStub::AcquireShareDataInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
int32_t missionId = data.ReadInt32();
|
||||
|
@ -2352,7 +2352,6 @@ void AbilityRecord::GrantUriPermission(Want &want, int32_t userId, std::string t
|
||||
uriVec = want.GetStringArrayParam(AbilityConfig::PARAMS_STREAM);
|
||||
uriVec.emplace_back(uriStr);
|
||||
HILOG_DEBUG("GrantUriPermission uriVec size: %{public}zu", uriVec.size());
|
||||
auto upmClient = AAFwk::UriPermissionManagerClient::GetInstance();
|
||||
auto bundleFlag = AppExecFwk::BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO;
|
||||
auto fromTokenId = IPCSkeleton::GetCallingTokenID();
|
||||
for (auto&& str : uriVec) {
|
||||
@ -2377,8 +2376,9 @@ void AbilityRecord::GrantUriPermission(Want &want, int32_t userId, std::string t
|
||||
continue;
|
||||
}
|
||||
int autoremove = 1;
|
||||
auto ret = IN_PROCESS_CALL(upmClient->GrantUriPermission(uri, want.GetFlags(),
|
||||
targetBundleName, autoremove));
|
||||
auto ret = IN_PROCESS_CALL(
|
||||
AAFwk::UriPermissionManagerClient::GetInstance().GrantUriPermission(uri, want.GetFlags(),
|
||||
targetBundleName, autoremove));
|
||||
if (ret == 0) {
|
||||
isGrantedUriPermission_ = true;
|
||||
}
|
||||
@ -2407,7 +2407,6 @@ void AbilityRecord::GrantDmsUriPermission(Want &want, std::string targetBundleNa
|
||||
{
|
||||
std::vector<std::string> uriVec = want.GetStringArrayParam(PARAMS_URI);
|
||||
HILOG_DEBUG("GrantDmsUriPermission uriVec size: %{public}zu", uriVec.size());
|
||||
auto upmClient = AAFwk::UriPermissionManagerClient::GetInstance();
|
||||
for (auto&& str : uriVec) {
|
||||
Uri uri(str);
|
||||
auto&& scheme = uri.GetScheme();
|
||||
@ -2418,8 +2417,9 @@ void AbilityRecord::GrantDmsUriPermission(Want &want, std::string targetBundleNa
|
||||
continue;
|
||||
}
|
||||
int autoremove = 1;
|
||||
auto ret = IN_PROCESS_CALL(upmClient->GrantUriPermission(uri, want.GetFlags(),
|
||||
targetBundleName, autoremove));
|
||||
auto ret = IN_PROCESS_CALL(
|
||||
AAFwk::UriPermissionManagerClient::GetInstance().GrantUriPermission(uri, want.GetFlags(),
|
||||
targetBundleName, autoremove));
|
||||
if (ret) {
|
||||
isGrantedUriPermission_ = true;
|
||||
}
|
||||
@ -2432,8 +2432,7 @@ void AbilityRecord::RevokeUriPermission()
|
||||
{
|
||||
if (isGrantedUriPermission_) {
|
||||
HILOG_DEBUG("To remove uri permission.");
|
||||
auto upmClient = AAFwk::UriPermissionManagerClient::GetInstance();
|
||||
upmClient->RevokeUriPermission(applicationInfo_.accessTokenId);
|
||||
AAFwk::UriPermissionManagerClient::GetInstance().RevokeUriPermission(applicationInfo_.accessTokenId);
|
||||
isGrantedUriPermission_ = false;
|
||||
}
|
||||
}
|
||||
|
@ -86,7 +86,8 @@ int FreeInstallManager::StartFreeInstall(const Want &want, int32_t userId, int r
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("StartFreeInstall called");
|
||||
auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
|
||||
if (!isSaCall && !IsTopAbility(callerToken)) {
|
||||
auto isGatewayCall = AAFwk::PermissionVerification::GetInstance()->IsGatewayCall();
|
||||
if (!isSaCall && !isGatewayCall && !IsTopAbility(callerToken)) {
|
||||
return NOT_TOP_ABILITY;
|
||||
}
|
||||
FreeInstallInfo info = BuildFreeInstallInfo(want, userId, requestCode, callerToken, isAsync);
|
||||
|
@ -31,7 +31,8 @@ namespace AAFwk {
|
||||
using ErmsCallerInfo = OHOS::AppExecFwk::ErmsParams::CallerInfo;
|
||||
|
||||
const std::string BLACK_ACTION_SELECT_DATA = "ohos.want.action.select";
|
||||
const std::string STR_PC = "pc";
|
||||
const std::string STR_PHONE = "phone";
|
||||
const std::string STR_DEFAULT = "default";
|
||||
const std::string TYPE_ONLY_MATCH_WILDCARD = "reserved/wildcard";
|
||||
const std::string SHOW_DEFAULT_PICKER_FLAG = "ohos.ability.params.showDefaultPicker";
|
||||
|
||||
@ -96,12 +97,12 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_
|
||||
|
||||
AAFwk::Want want;
|
||||
auto abilityMgr = DelayedSingleton<AbilityManagerService>::GetInstance();
|
||||
if (dialogAppInfos.size() == 0 && deviceType != STR_PC) {
|
||||
if (dialogAppInfos.size() == 0 && (deviceType == STR_PHONE || deviceType == STR_DEFAULT)) {
|
||||
HILOG_ERROR("implicit query ability infos failed, show tips dialog.");
|
||||
want = sysDialogScheduler->GetTipsDialogWant(request.callerToken);
|
||||
abilityMgr->StartAbility(want);
|
||||
return ERR_IMPLICIT_START_ABILITY_FAIL;
|
||||
} else if (dialogAppInfos.size() == 0 && deviceType == STR_PC) {
|
||||
} else if (dialogAppInfos.size() == 0 && deviceType != STR_PHONE && deviceType != STR_DEFAULT) {
|
||||
std::vector<DialogAppInfo> dialogAllAppInfos;
|
||||
bool isMoreHapList = true;
|
||||
ret = GenerateAbilityRequestByAction(userId, request, dialogAllAppInfos, deviceType, isMoreHapList);
|
||||
@ -129,7 +130,7 @@ int ImplicitStartProcessor::ImplicitStartAbility(AbilityRequest &request, int32_
|
||||
return IN_PROCESS_CALL(startAbilityTask(info.bundleName, info.abilityName));
|
||||
}
|
||||
|
||||
if (deviceType != STR_PC) {
|
||||
if (deviceType == STR_PHONE || deviceType == STR_DEFAULT) {
|
||||
HILOG_INFO("ImplicitQueryInfos success, Multiple apps to choose.");
|
||||
want = sysDialogScheduler->GetSelectorDialogWant(dialogAppInfos, request.want, request.callerToken);
|
||||
ret = abilityMgr->StartAbility(want, request.callerToken);
|
||||
@ -181,7 +182,7 @@ int ImplicitStartProcessor::GenerateAbilityRequestByAction(int32_t userId,
|
||||
std::vector<AppExecFwk::AbilityInfo> implicitAbilityInfos;
|
||||
std::vector<AppExecFwk::ExtensionAbilityInfo> implicitExtensionInfos;
|
||||
std::vector<std::string> infoNames;
|
||||
if (deviceType == STR_PC) {
|
||||
if (deviceType != STR_PHONE && deviceType != STR_DEFAULT) {
|
||||
IN_PROCESS_CALL_WITHOUT_RET(bms->ImplicitQueryInfos(implicitwant, abilityInfoFlag, userId,
|
||||
withDefault, implicitAbilityInfos, implicitExtensionInfos));
|
||||
if (implicitAbilityInfos.size() != 0 && request.want.GetType() != TYPE_ONLY_MATCH_WILDCARD) {
|
||||
@ -195,7 +196,7 @@ int ImplicitStartProcessor::GenerateAbilityRequestByAction(int32_t userId,
|
||||
if (isExtension && info.type != AbilityType::EXTENSION) {
|
||||
continue;
|
||||
}
|
||||
if (deviceType == STR_PC) {
|
||||
if (deviceType != STR_PHONE && deviceType != STR_DEFAULT) {
|
||||
auto isDefaultFlag = false;
|
||||
if (withDefault) {
|
||||
auto defaultMgr = GetDefaultAppProxy();
|
||||
|
@ -117,6 +117,7 @@ int32_t MissionListManager::GetMissionCount() const
|
||||
|
||||
int MissionListManager::StartAbility(AbilityRequest &abilityRequest)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::lock_guard<std::recursive_mutex> guard(managerLock_);
|
||||
bool isReachToSingleLimit = CheckSingleLimit(abilityRequest);
|
||||
if (isReachToSingleLimit) {
|
||||
@ -304,7 +305,9 @@ void MissionListManager::StartWaitingAbility()
|
||||
int MissionListManager::StartAbilityLocked(const std::shared_ptr<AbilityRecord> ¤tTopAbility,
|
||||
const std::shared_ptr<AbilityRecord> &callerAbility, const AbilityRequest &abilityRequest)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
std::string connector = "##";
|
||||
std::string traceName = __PRETTY_FUNCTION__ + connector + abilityRequest.want.GetElement().GetAbilityName();
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, traceName);
|
||||
HILOG_DEBUG("Start ability locked.");
|
||||
// 1. choose target mission list
|
||||
auto targetList = GetTargetMissionList(callerAbility, abilityRequest);
|
||||
@ -499,6 +502,7 @@ bool MissionListManager::CreateOrReusedMissionInfo(const AbilityRequest &ability
|
||||
void MissionListManager::GetTargetMissionAndAbility(const AbilityRequest &abilityRequest,
|
||||
std::shared_ptr<Mission> &targetMission, std::shared_ptr<AbilityRecord> &targetRecord, bool &isReachToLimit)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
if (HandleReusedMissionAndAbility(abilityRequest, targetMission, targetRecord)) {
|
||||
return;
|
||||
}
|
||||
@ -517,7 +521,7 @@ void MissionListManager::GetTargetMissionAndAbility(const AbilityRequest &abilit
|
||||
if (CheckLimit()) {
|
||||
isReachToLimit = true;
|
||||
HILOG_ERROR("already reach to limit, not create new mission and ability.");
|
||||
return;
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("Make new mission data.");
|
||||
targetRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
|
@ -71,7 +71,7 @@ const int32_t UI_DEFAULT_WIDTH = 2560;
|
||||
const int32_t UI_DEFAULT_HEIGHT = 1600;
|
||||
|
||||
const std::string STR_PHONE = "phone";
|
||||
const std::string STR_PC = "pc";
|
||||
const std::string STR_DEFAULT = "default";
|
||||
const std::string DIALOG_NAME_ANR = "dialog_anr_service";
|
||||
const std::string DIALOG_NAME_TIPS = "dialog_tips_service";
|
||||
const std::string DIALOG_SELECTOR_NAME = "dialog_selector_service";
|
||||
@ -276,8 +276,9 @@ const std::string SystemDialogScheduler::GetDialogPositionParams(const DialogPos
|
||||
|
||||
void SystemDialogScheduler::InitDialogPosition(DialogType type, DialogPosition &position) const
|
||||
{
|
||||
position.wideScreen = (deviceType_ == STR_PC);
|
||||
position.align = (deviceType_ == STR_PHONE) ? DialogAlign::BOTTOM : DialogAlign::CENTER;
|
||||
position.wideScreen = (deviceType_ == STR_PHONE) ? false : (deviceType_ != STR_DEFAULT);
|
||||
position.align = ((deviceType_ == STR_PHONE) ? true : (deviceType_ == STR_DEFAULT)) ?
|
||||
DialogAlign::BOTTOM : DialogAlign::CENTER;
|
||||
auto display = Rosen::DisplayManager::GetInstance().GetDefaultDisplay();
|
||||
|
||||
switch (type) {
|
||||
|
@ -51,7 +51,10 @@ ohos_shared_library("libappms") {
|
||||
"src/window_focus_changed_listener.cpp",
|
||||
]
|
||||
|
||||
defines = [ "AMS_LOG_TAG = \"AppMgrService\"" ]
|
||||
defines = [
|
||||
"AMS_LOG_TAG = \"AppMgrService\"",
|
||||
"APP_MGR_SERVICE_APPMS",
|
||||
]
|
||||
|
||||
if (ability_command_for_test) {
|
||||
defines += [ "ABILITY_COMMAND_FOR_TEST" ]
|
||||
@ -87,6 +90,7 @@ ohos_shared_library("libappms") {
|
||||
"init:libbeget_proxy",
|
||||
"init:libbegetutil",
|
||||
"ipc:ipc_core",
|
||||
"netmanager_base:socket_permission",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
"window_manager:libwsutils",
|
||||
|
@ -53,6 +53,9 @@
|
||||
#include "permission_verification.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "uri_permission_manager_client.h"
|
||||
#ifdef APP_MGR_SERVICE_APPMS
|
||||
#include "socket_permission.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -299,6 +302,7 @@ bool AppMgrServiceInner::GetBundleAndHapInfo(const AbilityInfo &abilityInfo,
|
||||
const std::shared_ptr<ApplicationInfo> &appInfo, BundleInfo &bundleInfo, HapModuleInfo &hapModuleInfo,
|
||||
int32_t appIndex) const
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto bundleMgr_ = remoteClientManager_->GetBundleManager();
|
||||
if (bundleMgr_ == nullptr) {
|
||||
HILOG_ERROR("GetBundleManager fail");
|
||||
@ -367,11 +371,13 @@ void AppMgrServiceInner::AttachApplication(const pid_t pid, const sptr<IAppSched
|
||||
|
||||
void AppMgrServiceInner::LaunchApplication(const std::shared_ptr<AppRunningRecord> &appRecord)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
if (!appRecord) {
|
||||
HILOG_ERROR("appRecord is null");
|
||||
return;
|
||||
}
|
||||
std::string connector = "##";
|
||||
std::string traceName = __PRETTY_FUNCTION__ + connector + appRecord->GetApplicationInfo()->name;
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, traceName);
|
||||
|
||||
if (!configuration_) {
|
||||
HILOG_ERROR("configuration_ is null");
|
||||
@ -1660,6 +1666,13 @@ void AppMgrServiceInner::StartProcess(const std::string &appName, const std::str
|
||||
if (result != Security::AccessToken::PERMISSION_GRANTED) {
|
||||
setAllowInternet = 1;
|
||||
allowInternet = 0;
|
||||
#ifdef APP_MGR_SERVICE_APPMS
|
||||
auto ret = SetInternetPermission(bundleInfo.uid, 0);
|
||||
HILOG_DEBUG("SetInternetPermission, ret = %{public}d", ret);
|
||||
} else {
|
||||
auto ret = SetInternetPermission(bundleInfo.uid, 1);
|
||||
HILOG_DEBUG("SetInternetPermission, ret = %{public}d", ret);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (hasAccessBundleDirReq) {
|
||||
|
@ -72,6 +72,7 @@ std::shared_ptr<AppRunningRecord> AppRunningManager::CreateAppRunningRecord(
|
||||
std::shared_ptr<AppRunningRecord> AppRunningManager::CheckAppRunningRecordIsExist(const std::string &appName,
|
||||
const std::string &processName, const int uid, const BundleInfo &bundleInfo)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("appName: %{public}s, processName: %{public}s, uid : %{public}d",
|
||||
appName.c_str(), processName.c_str(), uid);
|
||||
|
||||
|
@ -83,6 +83,8 @@ struct VerificationInfo {
|
||||
|
||||
bool JudgeCallerIsAllowedToUseSystemAPI() const;
|
||||
|
||||
bool IsSystemAppCall() const;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_MOVE(PermissionVerification);
|
||||
|
||||
|
@ -379,5 +379,11 @@ bool PermissionVerification::JudgeCallerIsAllowedToUseSystemAPI() const
|
||||
auto callerToken = IPCSkeleton::GetCallingFullTokenID();
|
||||
return Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(callerToken);
|
||||
}
|
||||
|
||||
bool PermissionVerification::IsSystemAppCall() const
|
||||
{
|
||||
auto callerToken = IPCSkeleton::GetCallingFullTokenID();
|
||||
return Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(callerToken);
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -30,13 +30,13 @@ export default class JumpInterceptorServiceExtAbility extends extension {
|
||||
|
||||
async onRequest(want, startId) {
|
||||
globalThis.abilityWant = want;
|
||||
globalThis.params = JSON.parse(want['parameters']['params']);
|
||||
globalThis.position = JSON.parse(want['parameters']['position']);
|
||||
globalThis.interceptor_callerBundleName = want['parameters']['interceptor_callerBundleName'];
|
||||
globalThis.interceptor_callerModuleName = want['parameters']['interceptor_callerModuleName'];
|
||||
globalThis.interceptor_callerLabelId = want['parameters']['interceptor_callerLabelId'];
|
||||
globalThis.interceptor_targetModuleName = want['parameters']['interceptor_targetModuleName'];
|
||||
globalThis.interceptor_targetLabelId = want['parameters']['interceptor_targetLabelId'];
|
||||
globalThis.params = JSON.parse(want.parameters.params);
|
||||
globalThis.position = JSON.parse(want.parameters.position);
|
||||
globalThis.interceptor_callerBundleName = want.parameters.interceptor_callerBundleName;
|
||||
globalThis.interceptor_callerModuleName = want.parameters.interceptor_callerModuleName;
|
||||
globalThis.interceptor_callerLabelId = want.parameters.interceptor_callerLabelId;
|
||||
globalThis.interceptor_targetModuleName = want.parameters.interceptor_targetModuleName;
|
||||
globalThis.interceptor_targetLabelId = want.parameters.interceptor_targetLabelId;
|
||||
await this.getHapResource();
|
||||
display.getDefaultDisplay().then(dis => {
|
||||
let navigationBarRect = {
|
||||
|
@ -67,7 +67,7 @@ export default class SelectorServiceExtensionAbility extends extension {
|
||||
let appIcon = '';
|
||||
let type = '';
|
||||
let userId = Number('0');
|
||||
if (globalThis.params.deviceType === 'pc') {
|
||||
if (globalThis.params.deviceType !== 'phone' && globalThis.params.deviceType !== 'default') {
|
||||
type = hap.type;
|
||||
userId = Number(hap.userId);
|
||||
}
|
||||
@ -92,14 +92,14 @@ export default class SelectorServiceExtensionAbility extends extension {
|
||||
async onRequest(want, startId) {
|
||||
console.debug(TAG, 'onRequest, want: ' + JSON.stringify(want));
|
||||
globalThis.abilityWant = want;
|
||||
globalThis.params = JSON.parse(want['parameters']['params']);
|
||||
globalThis.position = JSON.parse(want['parameters']['position']);
|
||||
globalThis.params = JSON.parse(want.parameters.params);
|
||||
globalThis.position = JSON.parse(want.parameters.position);
|
||||
console.debug(TAG, 'onRequest, want: ' + JSON.stringify(want));
|
||||
console.debug(TAG, 'onRequest, params: ' + JSON.stringify(globalThis.params));
|
||||
globalThis.callerToken = want['parameters']['callerToken'];
|
||||
globalThis.callerToken = want.parameters.callerToken;
|
||||
console.debug(TAG, 'onRequest, params: ' + JSON.stringify(globalThis.params));
|
||||
console.debug(TAG, 'onRequest, position: ' + JSON.stringify(globalThis.position));
|
||||
if (globalThis.params.deviceType === 'pc') {
|
||||
if (globalThis.params.deviceType !== 'phone' && globalThis.params.deviceType !== 'default') {
|
||||
globalThis.modelFlag = Boolean(globalThis.params.modelFlag);
|
||||
globalThis.action = Boolean(globalThis.params.action);
|
||||
}
|
||||
@ -127,7 +127,7 @@ export default class SelectorServiceExtensionAbility extends extension {
|
||||
this.createWindow('SelectorDialog' + startId, window.WindowType.TYPE_DIALOG, navigationBarRect);
|
||||
}
|
||||
winNum++;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
|
@ -31,9 +31,9 @@ export default class TipsServiceExtensionAbility extends extension {
|
||||
onRequest(want, startId) {
|
||||
console.debug(TAG, 'onRequest, want: ' + JSON.stringify(want));
|
||||
globalThis.abilityWant = want;
|
||||
globalThis.params = JSON.parse(want['parameters']['params']);
|
||||
globalThis.position = JSON.parse(want['parameters']['position']);
|
||||
globalThis.callerToken = want['parameters']['callerToken'];
|
||||
globalThis.params = JSON.parse(want.parameters.params);
|
||||
globalThis.position = JSON.parse(want.parameters.position);
|
||||
globalThis.callerToken = want.parameters.callerToken;
|
||||
|
||||
display.getDefaultDisplay().then(dis => {
|
||||
let navigationBarRect = {
|
||||
@ -52,7 +52,7 @@ export default class TipsServiceExtensionAbility extends extension {
|
||||
this.createWindow('TipsDialog' + startId, window.WindowType.TYPE_DIALOG, navigationBarRect);
|
||||
}
|
||||
winNum++;
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
|
@ -156,7 +156,7 @@ struct SelectorPhoneDialog {
|
||||
if (item.split("#")[2] != "") {
|
||||
Text(item.split("#")[2])
|
||||
.fontSize(16)
|
||||
.width(58)
|
||||
.width(80)
|
||||
.height(23)
|
||||
.textAlign(TextAlign.Center)
|
||||
.alignSelf(ItemAlign.Center)
|
||||
@ -164,7 +164,7 @@ struct SelectorPhoneDialog {
|
||||
} else {
|
||||
Text(item.split("#")[0])
|
||||
.fontSize(16)
|
||||
.width(58)
|
||||
.width(80)
|
||||
.height(23)
|
||||
.textAlign(TextAlign.Center)
|
||||
.alignSelf(ItemAlign.Center)
|
||||
@ -176,15 +176,15 @@ struct SelectorPhoneDialog {
|
||||
this.onSelectApp(item)
|
||||
})
|
||||
}
|
||||
.margin({ top: 80 })
|
||||
.margin({ top: 85 })
|
||||
}, item => item)
|
||||
}
|
||||
.columnsTemplate(this.selector.swiper.gridColumns)
|
||||
.rowsTemplate(this.selector.swiper.gridRows)
|
||||
.columnsGap(12)
|
||||
.rowsGap(12)
|
||||
.margin({ top: 10 })
|
||||
.height(200)
|
||||
.margin({ top: 30 })
|
||||
.height(210)
|
||||
}, item => item)
|
||||
}
|
||||
.indicatorStyle({ color: "#bebdc0", selectedColor: "#ff326Ce9", size: 4 })
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"services" : [{
|
||||
"name" : "quick_fix",
|
||||
"path" : ["/system/bin/sa_main", "/system/profile/quick_fix.xml"],
|
||||
"path" : ["/system/bin/sa_main", "/system/profile/quick_fix.json"],
|
||||
"ondemand" : true,
|
||||
"uid" : "quickfixserver",
|
||||
"gid" : ["system"],
|
||||
|
@ -517,26 +517,46 @@ void QuickFixManagerApplyTask::RemoveTimeoutTask()
|
||||
bool QuickFixManagerApplyTask::SetQuickFixInfo(const std::shared_ptr<AppExecFwk::QuickFixResult> &result)
|
||||
{
|
||||
auto resultJson = nlohmann::json::parse(result->ToString());
|
||||
const auto &jsonObjectEnd = resultJson.end();
|
||||
if ((resultJson.find(QUICK_FIX_BUNDLE_NAME) == jsonObjectEnd)
|
||||
|| (resultJson.find(QUICK_FIX_BUNDLE_VERSION_CODE) == jsonObjectEnd)
|
||||
|| (resultJson.find(QUICK_FIX_PATCH_VERSION_CODE) == jsonObjectEnd)
|
||||
|| (resultJson.find(QUICK_FIX_IS_SO_CONTAINED) == jsonObjectEnd)
|
||||
|| (resultJson.find(QUICK_FIX_TYPE) == jsonObjectEnd)
|
||||
|| (resultJson.find(QUICK_FIX_MODULE_NAME) == jsonObjectEnd)) {
|
||||
HILOG_ERROR("Incomplete result.");
|
||||
if (!resultJson.contains(QUICK_FIX_BUNDLE_NAME) || !resultJson.at(QUICK_FIX_BUNDLE_NAME).is_string()) {
|
||||
HILOG_ERROR("Invalid bundleName.");
|
||||
return false;
|
||||
}
|
||||
|
||||
bundleName_ = resultJson.at(QUICK_FIX_BUNDLE_NAME).get<std::string>();
|
||||
bundleVersionCode_ = resultJson.at(QUICK_FIX_BUNDLE_VERSION_CODE).get<int>();
|
||||
patchVersionCode_ = resultJson.at(QUICK_FIX_PATCH_VERSION_CODE).get<int>();
|
||||
|
||||
if (!resultJson.contains(QUICK_FIX_BUNDLE_VERSION_CODE) ||
|
||||
!resultJson.at(QUICK_FIX_BUNDLE_VERSION_CODE).is_number()) {
|
||||
HILOG_ERROR("Invalid bundle version code.");
|
||||
return false;
|
||||
}
|
||||
bundleVersionCode_ = resultJson.at(QUICK_FIX_BUNDLE_VERSION_CODE).get<uint32_t>();
|
||||
|
||||
if (!resultJson.contains(QUICK_FIX_PATCH_VERSION_CODE) ||
|
||||
!resultJson.at(QUICK_FIX_PATCH_VERSION_CODE).is_number()) {
|
||||
HILOG_ERROR("Invalid patch version code.");
|
||||
return false;
|
||||
}
|
||||
patchVersionCode_ = resultJson.at(QUICK_FIX_PATCH_VERSION_CODE).get<uint32_t>();
|
||||
|
||||
if (!resultJson.contains(QUICK_FIX_IS_SO_CONTAINED) || !resultJson.at(QUICK_FIX_IS_SO_CONTAINED).is_boolean()) {
|
||||
HILOG_ERROR("Invalid so status.");
|
||||
return false;
|
||||
}
|
||||
isSoContained_ = resultJson.at(QUICK_FIX_IS_SO_CONTAINED).get<bool>();
|
||||
|
||||
if (!resultJson.contains(QUICK_FIX_TYPE) || !resultJson.at(QUICK_FIX_TYPE).is_number()) {
|
||||
HILOG_ERROR("Invalid quickfix type.");
|
||||
return false;
|
||||
}
|
||||
type_ = static_cast<AppExecFwk::QuickFixType>(resultJson.at(QUICK_FIX_TYPE).get<int32_t>());
|
||||
if (type_ != AppExecFwk::QuickFixType::PATCH && type_ != AppExecFwk::QuickFixType::HOT_RELOAD) {
|
||||
HILOG_ERROR("Quick fix type is invalid.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!resultJson.contains(QUICK_FIX_MODULE_NAME) || !resultJson.at(QUICK_FIX_MODULE_NAME).is_array()) {
|
||||
HILOG_ERROR("Invalid moduleName.");
|
||||
return false;
|
||||
}
|
||||
moduleNames_ = resultJson.at(QUICK_FIX_MODULE_NAME).get<std::vector<std::string>>();
|
||||
|
||||
HILOG_INFO("bundleName: %{public}s, bundleVersion: %{public}d, patchVersion: %{public}d, soContained: %{public}d, "
|
||||
@ -758,7 +778,6 @@ void QuickFixManagerApplyTask::PostRevokeQuickFixTask()
|
||||
applyTask->HandleRevokeQuickFixAppRunning();
|
||||
return;
|
||||
}
|
||||
|
||||
applyTask->HandleRevokeQuickFixAppStop();
|
||||
};
|
||||
|
||||
|
12
services/sa_profile/184.json
Normal file
12
services/sa_profile/184.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"process": "quick_fix",
|
||||
"systemability": [
|
||||
{
|
||||
"name": 184,
|
||||
"libpath": "libquickfixms.z.so",
|
||||
"run-on-create": false,
|
||||
"distributed": false,
|
||||
"dump_level": 1
|
||||
}
|
||||
]
|
||||
}
|
@ -18,7 +18,7 @@ ohos_sa_profile("ams_sa_profile") {
|
||||
"180.json",
|
||||
"182.json",
|
||||
"183.json",
|
||||
"184.xml",
|
||||
"184.json",
|
||||
"501.json",
|
||||
]
|
||||
|
||||
|
@ -25,6 +25,7 @@ config("upms_config") {
|
||||
}
|
||||
|
||||
libupms_sources = [
|
||||
"src/uri_bundle_event_callback.cpp",
|
||||
"src/uri_permission_manager_service.cpp",
|
||||
"src/uri_permission_manager_stub_impl.cpp",
|
||||
]
|
||||
@ -42,6 +43,7 @@ ohos_shared_library("libupms") {
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
|
||||
"${ability_runtime_services_path}/common:event_report",
|
||||
"${ability_runtime_services_path}/common:perm_verification",
|
||||
]
|
||||
|
||||
@ -53,6 +55,10 @@ ohos_shared_library("libupms") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_core",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"hisysevent_native:libhisysevent",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
@ -87,6 +93,8 @@ ohos_static_library("libupms_static") {
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_core",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
|
44
services/uripermmgr/include/uri_bundle_event_callback.h
Normal file
44
services/uripermmgr/include/uri_bundle_event_callback.h
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bundle_event_callback_host.h"
|
||||
#include "common_event_support.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "uri_permission_manager_stub_impl.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
/**
|
||||
* @brief This class is a callback class that will be registered to BundleManager.
|
||||
* This class will be called by BundleManager when install, uninstall, updates of haps happens,
|
||||
* and executes corresponding functionalities of Uri Permission manager.
|
||||
*/
|
||||
class UriBundleEventCallback : public AppExecFwk::BundleEventCallbackHost {
|
||||
public:
|
||||
UriBundleEventCallback() = default;
|
||||
explicit UriBundleEventCallback(sptr<UriPermissionManagerStubImpl> impl);
|
||||
~UriBundleEventCallback() = default;
|
||||
/**
|
||||
* @brief The main callback function that will be called by BundleManager
|
||||
* when install, uninstall, updates of haps happens to notify UriPermissionManger.
|
||||
* @param eventData the data passed from BundleManager that includes bundleName, change type of haps
|
||||
* etc. More can be found from BundleCommonEventMgr::NotifyBundleStatus()
|
||||
*/
|
||||
void OnReceiveEvent(const EventFwk::CommonEventData eventData) override;
|
||||
private:
|
||||
sptr<UriPermissionManagerStubImpl> upms_;
|
||||
};
|
||||
} // namespace OHOS
|
||||
} // namespace AAFwk
|
@ -46,11 +46,12 @@ public:
|
||||
const std::string targetBundleName, int autoremove) override;
|
||||
|
||||
void RevokeUriPermission(const Security::AccessToken::AccessTokenID tokenId) override;
|
||||
void RevokeAllUriPermissions(int tokenId);
|
||||
int RevokeUriPermissionManually(const Uri &uri, const std::string bundleName) override;
|
||||
sptr<AppExecFwk::IBundleMgr> ConnectBundleManager();
|
||||
|
||||
private:
|
||||
sptr<AppExecFwk::IAppMgr> ConnectAppMgr();
|
||||
sptr<AppExecFwk::IBundleMgr> ConnectBundleManager();
|
||||
sptr<StorageManager::IStorageManager> ConnectStorageManager();
|
||||
int GetCurrentAccountId();
|
||||
void ClearAppMgrProxy();
|
||||
|
46
services/uripermmgr/src/uri_bundle_event_callback.cpp
Normal file
46
services/uripermmgr/src/uri_bundle_event_callback.cpp
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "uri_bundle_event_callback.h"
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
const std::string KEY_TOKEN = "accessTokenId";
|
||||
UriBundleEventCallback::UriBundleEventCallback(sptr<UriPermissionManagerStubImpl> impl)
|
||||
{
|
||||
upms_ = impl;
|
||||
}
|
||||
void UriBundleEventCallback::OnReceiveEvent(const EventFwk::CommonEventData eventData)
|
||||
{
|
||||
const Want& want = eventData.GetWant();
|
||||
// action contains the change type of haps.
|
||||
std::string action = want.GetAction();
|
||||
std::string bundleName = want.GetElement().GetBundleName();
|
||||
int token = want.GetIntParam(KEY_TOKEN, 0);
|
||||
// verify data
|
||||
if (action.empty() || bundleName.empty()) {
|
||||
HILOG_ERROR("OnReceiveEvent failed, empty action/bundleName");
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("OnReceiveEvent, action:%{public}s.", action.c_str());
|
||||
if (action == EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED) {
|
||||
HILOG_DEBUG("revoke URI permission when uninstall.");
|
||||
if (!upms_) {
|
||||
HILOG_ERROR("Uri permission manager is nullptr");
|
||||
return;
|
||||
}
|
||||
upms_->RevokeAllUriPermissions(token);
|
||||
}
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
@ -20,6 +20,7 @@
|
||||
#include "ipc_skeleton.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "uri_bundle_event_callback.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
@ -75,6 +76,19 @@ bool UriPermissionManagerService::Init()
|
||||
if (impl_ == nullptr) {
|
||||
impl_ = new UriPermissionManagerStubImpl();
|
||||
}
|
||||
// Register UriBundleEventCallback to receive hap updates
|
||||
HILOG_INFO("Register UriBundleEventCallback to receive hap updates.");
|
||||
auto bms = impl_->ConnectBundleManager();
|
||||
sptr<UriBundleEventCallback> uriBundleEventCallback =
|
||||
new (std::nothrow) UriBundleEventCallback(impl_);
|
||||
if (bms && uriBundleEventCallback) {
|
||||
bool re = bms->RegisterBundleEventCallback(uriBundleEventCallback);
|
||||
if (!re) {
|
||||
HILOG_ERROR("RegisterBundleEventCallback failed!");
|
||||
}
|
||||
} else {
|
||||
HILOG_ERROR("Get BundleManager or uriBundleEventCallback failed!");
|
||||
}
|
||||
ready_ = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -174,6 +174,44 @@ void UriPermissionManagerStubImpl::RevokeUriPermission(const TokenId tokenId)
|
||||
}
|
||||
}
|
||||
|
||||
void UriPermissionManagerStubImpl::RevokeAllUriPermissions(int tokenId)
|
||||
{
|
||||
HILOG_DEBUG("Start to remove all uri permission for uninstalled app.");
|
||||
std::map<unsigned int, std::vector<std::string>> uriLists;
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(mutex_);
|
||||
for (auto iter = uriMap_.begin(); iter != uriMap_.end();) {
|
||||
auto& list = iter->second;
|
||||
for (auto it = list.begin(); it != list.end();) {
|
||||
if (it->targetTokenId == tokenId || it->fromTokenId == tokenId) {
|
||||
HILOG_INFO("Erase an info form list.");
|
||||
uriLists[it->targetTokenId].emplace_back(iter->first);
|
||||
list.erase(it++);
|
||||
} else {
|
||||
it++;
|
||||
}
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
uriMap_.erase(iter++);
|
||||
} else {
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto storageMgrProxy = ConnectStorageManager();
|
||||
if (storageMgrProxy == nullptr) {
|
||||
HILOG_ERROR("ConnectStorageManager failed");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!uriLists.empty()) {
|
||||
for (auto iter = uriLists.begin(); iter != uriLists.end(); iter++) {
|
||||
storageMgrProxy->DeleteShareFile(iter->first, iter->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int UriPermissionManagerStubImpl::RevokeUriPermissionManually(const Uri &uri, const std::string bundleName)
|
||||
{
|
||||
HILOG_DEBUG("Start to remove uri permission manually.");
|
||||
@ -362,8 +400,8 @@ void UriPermissionManagerStubImpl::ClearSMProxy()
|
||||
storageManager_ = nullptr;
|
||||
}
|
||||
|
||||
void UriPermissionManagerStubImpl::ProxyDeathRecipient::OnRemoteDied([[maybe_unused]]
|
||||
const wptr<IRemoteObject>& remote)
|
||||
void UriPermissionManagerStubImpl::ProxyDeathRecipient::OnRemoteDied(
|
||||
[[maybe_unused]] const wptr<IRemoteObject>& remote)
|
||||
{
|
||||
if (proxy_) {
|
||||
HILOG_DEBUG("%{public}s, bms stub died.", __func__);
|
||||
|
@ -38,11 +38,13 @@ group("fuzztest") {
|
||||
"abilitymanagerserviceninth_fuzzer:fuzztest",
|
||||
|
||||
# "abilitymanagerservicesecond_fuzzer:fuzztest",
|
||||
"abilitymanager_fuzzer:fuzztest",
|
||||
"abilitymanagerserviceseventh_fuzzer:fuzztest",
|
||||
"abilitymanagerservicesixth_fuzzer:fuzztest",
|
||||
"abilitymanagerservicetenth_fuzzer:fuzztest",
|
||||
"abilitymanagerservicethird_fuzzer:fuzztest",
|
||||
"abilitymgrrest_fuzzer:fuzztest",
|
||||
"abilityrunningrecord_fuzzer:fuzztest",
|
||||
"appstateobservermanager_fuzzer:fuzztest",
|
||||
"missiondatastoragea_fuzzer:fuzztest",
|
||||
"missiondatastorageb_fuzzer:fuzztest",
|
||||
@ -50,18 +52,15 @@ group("fuzztest") {
|
||||
"missioninfomgrb_fuzzer:fuzztest",
|
||||
"missioninfomgrc_fuzzer:fuzztest",
|
||||
|
||||
# "abilitymanager_fuzzer:fuzztest",
|
||||
"abilityrunningrecord_fuzzer:fuzztest",
|
||||
|
||||
# "abilityschedulerstub_fuzzer:fuzztest",
|
||||
"abilitytransitiondone_fuzzer:fuzztest",
|
||||
"acquiredataability_fuzzer:fuzztest",
|
||||
"addabilitystagedone_fuzzer:fuzztest",
|
||||
"amsmanager_fuzzer:fuzztest",
|
||||
"amsmgrscheduler_fuzzer:fuzztest",
|
||||
"applicationanrlistener_fuzzer:fuzztest",
|
||||
"applifecycledeal_fuzzer:fuzztest",
|
||||
|
||||
# "appmanager_fuzzer:fuzztest",
|
||||
"appmanager_fuzzer:fuzztest",
|
||||
"appmgrrest_fuzzer:fuzztest",
|
||||
|
||||
# "appmgrservicefirst_fuzzer:fuzztest",
|
||||
|
@ -39,7 +39,7 @@ uint32_t GetU32Data(const char* ptr)
|
||||
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
uint32_t code = GetU32Data(data);
|
||||
uint32_t code = GetU32Data(data) % (IAbilityManager::GET_ABILITY_TOKEN + 1);
|
||||
|
||||
MessageParcel parcel;
|
||||
parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN);
|
||||
|
73
test/fuzztest/amsmanager_fuzzer/BUILD.gn
Normal file
73
test/fuzztest/amsmanager_fuzzer/BUILD.gn
Normal file
@ -0,0 +1,73 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#####################hydra-fuzz###################
|
||||
import("//build/config/features.gni")
|
||||
import("//build/ohos.gni")
|
||||
import("//build/test.gni")
|
||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
module_output_path = "ability_runtime/app_manager"
|
||||
|
||||
##############################fuzztest##########################################
|
||||
ohos_fuzztest("AmsManagerFuzzTest") {
|
||||
module_out_path = module_output_path
|
||||
|
||||
fuzz_config_file = "${ability_runtime_test_path}/fuzztest/amsmanager_fuzzer"
|
||||
include_dirs =
|
||||
[ "${ability_runtime_innerkits_path}/app_manager/include/appmgr" ]
|
||||
cflags = [
|
||||
"-g",
|
||||
"-O0",
|
||||
"-Wno-unused-variable",
|
||||
"-fno-omit-frame-pointer",
|
||||
]
|
||||
sources = [ "amsmanager_fuzzer.cpp" ]
|
||||
|
||||
configs = [ "${ability_runtime_services_path}/appmgr:appmgr_config" ]
|
||||
|
||||
deps = [
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_services_path}/appmgr:libappms",
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"ability_base:want",
|
||||
"ability_base:zuri",
|
||||
"bundle_framework:appexecfwk_base",
|
||||
"bundle_framework:appexecfwk_core",
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"ipc:ipc_core",
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
external_deps += [
|
||||
"input:libmmi-client",
|
||||
"window_manager:libwm",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
###############################################################################
|
||||
group("fuzztest") {
|
||||
testonly = true
|
||||
deps = []
|
||||
deps += [
|
||||
# deps file
|
||||
":AmsManagerFuzzTest",
|
||||
]
|
||||
}
|
||||
###############################################################################
|
97
test/fuzztest/amsmanager_fuzzer/amsmanager_fuzzer.cpp
Normal file
97
test/fuzztest/amsmanager_fuzzer/amsmanager_fuzzer.cpp
Normal file
@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "amsmanager_fuzzer.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "ams_mgr_scheduler.h"
|
||||
#include "app_mgr_constants.h"
|
||||
#include "app_mgr_service_event_handler.h"
|
||||
#include "app_mgr_service_inner.h"
|
||||
#include "message_parcel.h"
|
||||
#include "securec.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
constexpr size_t FOO_MAX_LEN = 1024;
|
||||
constexpr size_t U32_AT_SIZE = 4;
|
||||
}
|
||||
const std::u16string AMSMGR_INTERFACE_TOKEN = u"ohos.aafwk.AmsManager";
|
||||
|
||||
uint32_t GetU32Data(const char* ptr)
|
||||
{
|
||||
// convert fuzz input data to an integer
|
||||
return (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3];
|
||||
}
|
||||
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
uint32_t code = GetU32Data(data) % (static_cast<uint32_t>(IAmsMgr::Message::SET_CURRENT_USER_ID) + 1);
|
||||
|
||||
MessageParcel parcel;
|
||||
parcel.WriteInterfaceToken(AMSMGR_INTERFACE_TOKEN);
|
||||
parcel.WriteBuffer(data, size);
|
||||
parcel.RewindRead(0);
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
std::shared_ptr<AppMgrServiceInner> appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
std::shared_ptr<EventRunner> runner = EventRunner::Create(Constants::APP_MGR_SERVICE_NAME);
|
||||
std::shared_ptr<AMSEventHandler> eventHandler = std::make_shared<AMSEventHandler>(runner, appMgrServiceInner);
|
||||
std::shared_ptr<AmsMgrScheduler> amsMgr = std::make_shared<AmsMgrScheduler>(appMgrServiceInner, eventHandler);
|
||||
amsMgr->OnRemoteRequest(code, parcel, reply, option);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Fuzzer entry point */
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
/* Run your code on data */
|
||||
if (data == nullptr) {
|
||||
std::cout << "invalid data" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Validate the length of size */
|
||||
if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* ch = (char*)malloc(size + 1);
|
||||
if (ch == nullptr) {
|
||||
std::cout << "malloc failed." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
(void)memset_s(ch, size + 1, 0x00, size + 1);
|
||||
if (memcpy_s(ch, size, data, size) != EOK) {
|
||||
std::cout << "copy failed." << std::endl;
|
||||
free(ch);
|
||||
ch = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
OHOS::DoSomethingInterestingWithMyAPI(ch, size);
|
||||
free(ch);
|
||||
ch = nullptr;
|
||||
return 0;
|
||||
}
|
||||
|
46
service_router_framework/services/srms/sa_profile/404.xml → test/fuzztest/amsmanager_fuzzer/amsmanager_fuzzer.h
Executable file → Normal file
46
service_router_framework/services/srms/sa_profile/404.xml → test/fuzztest/amsmanager_fuzzer/amsmanager_fuzzer.h
Executable file → Normal file
@ -1,25 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
-->
|
||||
<info>
|
||||
<process>service_router</process>
|
||||
<systemability>
|
||||
<name>404</name>
|
||||
<libpath>/system/lib64/libsrms.z.so</libpath>
|
||||
<run-on-create>false</run-on-create>
|
||||
<distributed>false</distributed>
|
||||
<dump-level>1</dump-level>
|
||||
</systemability>
|
||||
</info>
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_AMSMANAGER_FUZZER_H
|
||||
#define FUZZTEST_OHOS_ABILITY_RUNTIME_AMSMANAGER_FUZZER_H
|
||||
|
||||
#define FUZZ_PROJECT_NAME "amsmanager_fuzzer"
|
||||
|
||||
#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_AMSMANAGER_FUZZER_H
|
@ -1,25 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
-->
|
||||
<info>
|
||||
<process>quick_fix</process>
|
||||
<systemability>
|
||||
<name>184</name>
|
||||
<libpath>libquickfixms.z.so</libpath>
|
||||
<run-on-create>false</run-on-create>
|
||||
<distributed>false</distributed>
|
||||
<dump-level>1</dump-level>
|
||||
</systemability>
|
||||
</info>
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
FUZZ
|
25
test/fuzztest/amsmanager_fuzzer/project.xml
Normal file
25
test/fuzztest/amsmanager_fuzzer/project.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<fuzz_config>
|
||||
<fuzztest>
|
||||
<!-- maximum length of a test input -->
|
||||
<max_len>1000</max_len>
|
||||
<!-- maximum total time in seconds to run the fuzzer -->
|
||||
<max_total_time>300</max_total_time>
|
||||
<!-- memory usage limit in Mb -->
|
||||
<rss_limit_mb>4096</rss_limit_mb>
|
||||
</fuzztest>
|
||||
</fuzz_config>
|
@ -41,7 +41,7 @@ uint32_t GetU32Data(const char* ptr)
|
||||
|
||||
bool DoSomethingInterestingWithMyAPI(const char* data, size_t size)
|
||||
{
|
||||
uint32_t code = GetU32Data(data);
|
||||
uint32_t code = GetU32Data(data) % (static_cast<uint32_t>(IAppMgr::Message::JUDGE_SANDBOX_BY_PID) + 1);
|
||||
|
||||
MessageParcel parcel;
|
||||
parcel.WriteInterfaceToken(APPMGR_INTERFACE_TOKEN);
|
||||
|
@ -13,6 +13,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MOCK_WINDOW_H
|
||||
#define MOCK_WINDOW_H
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <iremote_object.h>
|
||||
#include <parcel.h>
|
||||
@ -183,3 +186,4 @@ public:
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // MOCK_WINDOW_H
|
@ -223,6 +223,7 @@ int MockAbilityDelegatorStub::BlockAppService()
|
||||
}
|
||||
|
||||
bool MockAbilityDelegatorStub2::finishFlag_ = false;
|
||||
TESTCASE_BRANCH MockAbilityDelegatorStub2::testcaseBranch_ = TESTCASE_BRANCH::BRANCH_1;
|
||||
|
||||
MockAbilityDelegatorStub2::MockAbilityDelegatorStub2()
|
||||
{}
|
||||
@ -366,6 +367,23 @@ int MockAbilityDelegatorStub2::GetTopAbility(sptr<IRemoteObject>& token)
|
||||
return OHOS::ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
AppExecFwk::ElementName MockAbilityDelegatorStub2::GetTopAbility()
|
||||
{
|
||||
HILOG_INFO("GetTopAbility.");
|
||||
AppExecFwk::ElementName elementName = {};
|
||||
|
||||
if (testcaseBranch_ == TESTCASE_BRANCH::BRANCH_2) {
|
||||
elementName = AppExecFwk::ElementName("deviceId", "com.ohos.bundleName", "EntryAbility", "entry");
|
||||
} else if (testcaseBranch_ == TESTCASE_BRANCH::BRANCH_3) {
|
||||
elementName = AppExecFwk::ElementName("deviceId", "com.example.myapplication",
|
||||
"com.example.myapplication.MainAbility", "entry");
|
||||
} else {
|
||||
HILOG_INFO("Empty top ability.");
|
||||
}
|
||||
|
||||
return elementName;
|
||||
}
|
||||
|
||||
int MockAbilityDelegatorStub2::DelegatorDoAbilityForeground(const sptr<IRemoteObject>& token)
|
||||
{
|
||||
HILOG_INFO("MockAbilityDelegatorStub2::DelegatorDoAbilityForeground is called");
|
||||
|
@ -175,6 +175,12 @@ public:
|
||||
static bool finishFlag_;
|
||||
};
|
||||
|
||||
enum TESTCASE_BRANCH {
|
||||
BRANCH_1 = 1,
|
||||
BRANCH_2 = 2,
|
||||
BRANCH_3 = 3,
|
||||
};
|
||||
|
||||
class MockAbilityDelegatorStub2 : public AbilityManagerStub {
|
||||
public:
|
||||
MockAbilityDelegatorStub2();
|
||||
@ -299,6 +305,7 @@ public:
|
||||
int FinishUserTest(
|
||||
const std::string& msg, const int64_t& resultCode, const std::string& bundleName) override;
|
||||
int GetTopAbility(sptr<IRemoteObject>& token) override;
|
||||
AppExecFwk::ElementName GetTopAbility() override;
|
||||
int DelegatorDoAbilityForeground(const sptr<IRemoteObject>& token) override;
|
||||
int DelegatorDoAbilityBackground(const sptr<IRemoteObject>& token) override;
|
||||
int DoAbilityForeground(const sptr<IRemoteObject>& token, uint32_t flag);
|
||||
@ -322,6 +329,7 @@ public:
|
||||
public:
|
||||
std::string powerState_;
|
||||
static bool finishFlag_;
|
||||
static TESTCASE_BRANCH testcaseBranch_;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
import("//build/test.gni")
|
||||
import("//foundation/ability/ability_runtime/ability_runtime.gni")
|
||||
module_output_path = "ability_delegator/"
|
||||
module_output_path = "ability_runtime/ability_delegator"
|
||||
|
||||
ability_delegator_mock_sources = [
|
||||
"${ability_runtime_path}/tools/aa/src/shell_command_executor.cpp",
|
||||
|
@ -14,6 +14,8 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <gtest/hwext/gtest-multithread.h>
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
@ -30,11 +32,15 @@
|
||||
#include "hilog_wrapper.h"
|
||||
#include "mock_ability_delegator_stub.h"
|
||||
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
using namespace testing::mt;
|
||||
using namespace OHOS;
|
||||
using namespace OHOS::AppExecFwk;
|
||||
using namespace OHOS::AAFwk;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
namespace {
|
||||
const std::string ABILITY_NAME = "com.example.myapplication.MainAbilitymodule";
|
||||
const std::string PROPERTY_ABILITY_NAME = "com.example.myapplication.MainAbilitymodule";
|
||||
@ -126,4 +132,89 @@ HWTEST_F(IabilityMonitorModuleTest, Iability_Monitor_Test_0200, Function | Mediu
|
||||
property->moduleName_ = PROPERTY_ABILITY_STAGE_MODULE_NAME;
|
||||
property->srcEntrance_ = PROPERTY_ABILITY_STAGE_SOURCE_ENTRANCE2;
|
||||
EXPECT_FALSE(stageMonitor.Match(property3));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MatchTest_0100
|
||||
* @tc.desc: Match test when ability stage is invalid.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI76SHL
|
||||
*/
|
||||
HWTEST_F(IabilityMonitorModuleTest, MatchTest_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("test start.");
|
||||
IAbilityStageMonitor stageMonitor(ABILITY_STAGE_MODULE_NAME, ABILITY_STAGE_SOURCE_ENTRANCE);
|
||||
EXPECT_FALSE(stageMonitor.Match(nullptr));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: MatchTest_0200
|
||||
* @tc.desc: Test notify when matched.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI76SHL
|
||||
*/
|
||||
HWTEST_F(IabilityMonitorModuleTest, MatchTest_0200, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("test start.");
|
||||
IAbilityStageMonitor stageMonitor(ABILITY_STAGE_MODULE_NAME, ABILITY_STAGE_SOURCE_ENTRANCE);
|
||||
std::shared_ptr<DelegatorAbilityStageProperty> property = std::make_shared<DelegatorAbilityStageProperty>();
|
||||
property->moduleName_ = PROPERTY_ABILITY_STAGE_MODULE_NAME;
|
||||
property->srcEntrance_ = PROPERTY_ABILITY_STAGE_SOURCE_ENTRANCE;
|
||||
EXPECT_TRUE(stageMonitor.Match(property, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WaitForAbility_0100
|
||||
* @tc.desc: Wait for ability timeout.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI76SHL
|
||||
*/
|
||||
HWTEST_F(IabilityMonitorModuleTest, WaitForAbilityTest_0100, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("test start.");
|
||||
IAbilityStageMonitor stageMonitor(ABILITY_STAGE_MODULE_NAME, ABILITY_STAGE_SOURCE_ENTRANCE);
|
||||
|
||||
// wait for 100ms until timeout
|
||||
EXPECT_EQ(stageMonitor.WaitForAbilityStage(100), nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: WaitForAbilityTest_0200
|
||||
* @tc.desc: Wait for ability in multi-thread test.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI76SHL
|
||||
*/
|
||||
std::shared_ptr<IAbilityStageMonitor> gt_iAbilityStageMonitor = nullptr;
|
||||
|
||||
void IAbilityStageMonitorWaitTask()
|
||||
{
|
||||
ASSERT_NE(gt_iAbilityStageMonitor, nullptr);
|
||||
HILOG_INFO("Running in thread %{public}d", gettid());
|
||||
auto property = gt_iAbilityStageMonitor->WaitForAbilityStage();
|
||||
if (property == nullptr) {
|
||||
HILOG_WARN("Wait for ability stage failed.");
|
||||
}
|
||||
}
|
||||
|
||||
void IAbilityStageMonitorMatchTask()
|
||||
{
|
||||
ASSERT_NE(gt_iAbilityStageMonitor, nullptr);
|
||||
HILOG_INFO("Running in thread %{public}d", gettid());
|
||||
std::shared_ptr<DelegatorAbilityStageProperty> property = std::make_shared<DelegatorAbilityStageProperty>();
|
||||
property->moduleName_ = PROPERTY_ABILITY_STAGE_MODULE_NAME;
|
||||
property->srcEntrance_ = PROPERTY_ABILITY_STAGE_SOURCE_ENTRANCE;
|
||||
EXPECT_TRUE(gt_iAbilityStageMonitor->Match(property, true));
|
||||
}
|
||||
|
||||
HWTEST_F(IabilityMonitorModuleTest, WaitForAbilityTest_0200, TestSize.Level1)
|
||||
{
|
||||
HILOG_INFO("test start.");
|
||||
gt_iAbilityStageMonitor = std::make_shared<IAbilityStageMonitor>(ABILITY_STAGE_MODULE_NAME,
|
||||
ABILITY_STAGE_SOURCE_ENTRANCE);
|
||||
SET_THREAD_NUM(1);
|
||||
GTEST_RUN_TASK(IAbilityStageMonitorWaitTask);
|
||||
GTEST_RUN_TASK(IAbilityStageMonitorMatchTask);
|
||||
gt_iAbilityStageMonitor.reset();
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user