mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2025-01-08 01:51:23 +00:00
Merge branch 'master' of gitee.com:openharmony/ability_ability_runtime into master
This commit is contained in:
commit
1067b4d373
@ -32,11 +32,9 @@ namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
namespace {
|
||||
constexpr int32_t INDEX_ZERO = 0;
|
||||
constexpr int32_t INDEX_ONE = 1;
|
||||
constexpr int32_t ERROR_CODE_ONE = 1;
|
||||
constexpr size_t ARGC_ONE = 1;
|
||||
constexpr size_t ARGC_TWO = 2;
|
||||
constexpr size_t ARGC_THREE = 3;
|
||||
const int UPDATE_FORM_PARAMS_SIZE = 2;
|
||||
class JsFormExtensionContext final {
|
||||
public:
|
||||
@ -126,8 +124,8 @@ private:
|
||||
NativeValue* OnStartAbility(NativeEngine& engine, NativeCallbackInfo& info)
|
||||
{
|
||||
HILOG_INFO("OnStartAbility is called");
|
||||
// only support one or two or three params
|
||||
if (info.argc != ARGC_ONE && info.argc != ARGC_TWO && info.argc != ARGC_THREE) {
|
||||
// only support one or two params
|
||||
if (info.argc != ARGC_ONE && info.argc != ARGC_TWO) {
|
||||
HILOG_ERROR("Not enough params");
|
||||
return engine.CreateUndefined();
|
||||
}
|
||||
@ -142,16 +140,8 @@ private:
|
||||
want.GetElement().GetAbilityName().c_str());
|
||||
unwrapArgc++;
|
||||
|
||||
AAFwk::StartOptions startOptions;
|
||||
if (info.argc > ARGC_ONE && info.argv[INDEX_ONE]->TypeOf() == NATIVE_OBJECT) {
|
||||
HILOG_INFO("OnStartAbility start options is used.");
|
||||
AppExecFwk::UnwrapStartOptions(reinterpret_cast<napi_env>(&engine),
|
||||
reinterpret_cast<napi_value>(info.argv[INDEX_ONE]), startOptions);
|
||||
unwrapArgc++;
|
||||
}
|
||||
|
||||
AsyncTask::CompleteCallback complete =
|
||||
[weak = context_, want, startOptions, unwrapArgc](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
[weak = context_, want, unwrapArgc](NativeEngine& engine, AsyncTask& task, int32_t status) {
|
||||
HILOG_INFO("startAbility begin");
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
@ -161,8 +151,8 @@ private:
|
||||
}
|
||||
|
||||
ErrCode errcode = ERR_OK;
|
||||
(unwrapArgc == 1) ? errcode = context->StartAbility(want) :
|
||||
errcode = context->StartAbility(want, startOptions);
|
||||
// entry to the core functionality.
|
||||
errcode = context->StartAbility(want);
|
||||
if (errcode == 0) {
|
||||
task.Resolve(engine, engine.CreateUndefined());
|
||||
} else {
|
||||
|
@ -53,18 +53,8 @@ int FormExtensionContext::UpdateForm(const int64_t formId, const AppExecFwk::For
|
||||
ErrCode FormExtensionContext::StartAbility(const AAFwk::Want &want) const
|
||||
{
|
||||
HILOG_DEBUG("%{public}s begin.", __func__);
|
||||
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, token_, -1);
|
||||
HILOG_DEBUG("%{public}s. End calling StartAbility. ret=%{public}d", __func__, err);
|
||||
if (err != ERR_OK) {
|
||||
HILOG_ERROR("FormExtensionContext::StartAbility is failed %{public}d", err);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
ErrCode FormExtensionContext::StartAbility(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions) const
|
||||
{
|
||||
HILOG_DEBUG("%{public}s begin.", __func__);
|
||||
ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, startOptions, token_, -1);
|
||||
// route to FMS
|
||||
ErrCode err = AppExecFwk::FormMgr::GetInstance().StartAbility(want, token_);
|
||||
HILOG_DEBUG("%{public}s. End calling StartAbility. ret=%{public}d", __func__, err);
|
||||
if (err != ERR_OK) {
|
||||
HILOG_ERROR("FormExtensionContext::StartAbility is failed %{public}d", err);
|
||||
|
@ -825,9 +825,11 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
std::string contactsDataAbility("com.ohos.contactsdataability");
|
||||
std::string mediaDataAbility("com.ohos.medialibrary.medialibrarydata");
|
||||
std::string telephonyDataAbility("com.ohos.telephonydataability");
|
||||
std::string fusionSearchAbility("com.ohos.FusionSearch");
|
||||
auto appInfo = appLaunchData.GetApplicationInfo();
|
||||
auto bundleName = appInfo.bundleName;
|
||||
if (bundleName == contactsDataAbility || bundleName == mediaDataAbility || bundleName == telephonyDataAbility) {
|
||||
if (bundleName == contactsDataAbility || bundleName == mediaDataAbility || bundleName == telephonyDataAbility
|
||||
|| bundleName == fusionSearchAbility) {
|
||||
std::vector<std::string> localPaths;
|
||||
ChangeToLocalPath(bundleName, appInfo.moduleSourceDirs, localPaths);
|
||||
LoadAbilityLibrary(localPaths);
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include <cerrno>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <sys/epoll.h>
|
||||
|
||||
#include "native_engine/impl/ark/ark_native_engine.h"
|
||||
@ -28,6 +27,7 @@
|
||||
#include "js_module_searcher.h"
|
||||
#include "js_runtime_utils.h"
|
||||
#include "js_timer.h"
|
||||
#include "js_worker.h"
|
||||
#include "parameters.h"
|
||||
#include "systemcapability.h"
|
||||
|
||||
@ -40,7 +40,6 @@ namespace AbilityRuntime {
|
||||
namespace {
|
||||
constexpr uint8_t SYSCAP_MAX_SIZE = 64;
|
||||
constexpr int64_t DEFAULT_GC_POOL_SIZE = 0x10000000; // 256MB
|
||||
constexpr int64_t ASSET_FILE_MAX_SIZE = 20 * 1024 * 1024;
|
||||
#if defined(_ARM64_)
|
||||
constexpr char ARK_DEBUGGER_LIB_PATH[] = "/system/lib64/libark_debugger.z.so";
|
||||
#else
|
||||
@ -203,84 +202,6 @@ bool MakeFilePath(const std::string& codePath, const std::string& modulePath, st
|
||||
return true;
|
||||
}
|
||||
|
||||
void RegisterInitWorkerFunc(NativeEngine& engine)
|
||||
{
|
||||
auto&& initWorkerFunc = [](NativeEngine* nativeEngine) {
|
||||
HILOG_INFO("RegisterInitWorkerFunc called");
|
||||
if (nativeEngine == nullptr) {
|
||||
HILOG_ERROR("Input nativeEngine is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
NativeObject* globalObj = ConvertNativeValueTo<NativeObject>(nativeEngine->GetGlobal());
|
||||
if (globalObj == nullptr) {
|
||||
HILOG_ERROR("Failed to get global object");
|
||||
return;
|
||||
}
|
||||
|
||||
InitConsoleLogModule(*nativeEngine, *globalObj);
|
||||
};
|
||||
engine.SetInitWorkerFunc(initWorkerFunc);
|
||||
}
|
||||
|
||||
bool GetResourceData(const std::string& filePath, std::vector<uint8_t>& content)
|
||||
{
|
||||
std::ifstream stream(filePath);
|
||||
if (!stream.is_open()) {
|
||||
HILOG_ERROR("GetResourceData failed with file can't open, check uri.");
|
||||
return false;
|
||||
}
|
||||
|
||||
stream.seekg(0, std::ios::end);
|
||||
auto fileLen = stream.tellg();
|
||||
if (fileLen > ASSET_FILE_MAX_SIZE) {
|
||||
HILOG_ERROR("GetResourceData failed with file too large.");
|
||||
stream.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
content.resize(fileLen);
|
||||
stream.seekg(0, std::ios::beg);
|
||||
stream.read(reinterpret_cast<char*>(content.data()), content.size());
|
||||
stream.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RegisterAssetFunc(NativeEngine& engine, const std::string& codePath)
|
||||
{
|
||||
auto&& assetFunc = [codePath](const std::string& uri, std::vector<uint8_t>& content, std::string &ami) {
|
||||
if (uri.empty()) {
|
||||
HILOG_ERROR("Uri is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("RegisterAssetFunc called, uri: %{private}s", uri.c_str());
|
||||
size_t index = uri.find_last_of(".");
|
||||
if (index == std::string::npos) {
|
||||
HILOG_ERROR("Invalid uri");
|
||||
return;
|
||||
}
|
||||
|
||||
std::string fileUri = uri.substr(0, index) + ".abc";
|
||||
std::string targetFile = codePath;
|
||||
targetFile += (codePath.back() == '/') ? fileUri : "/" + fileUri;
|
||||
ami = targetFile;
|
||||
HILOG_INFO("Get asset, ami: %{private}s", ami.c_str());
|
||||
if (!GetResourceData(ami, content)) {
|
||||
HILOG_ERROR("Get asset content failed.");
|
||||
return;
|
||||
}
|
||||
};
|
||||
engine.SetGetAssetFunc(assetFunc);
|
||||
}
|
||||
|
||||
void RegisterWorker(NativeEngine& engine, const std::string& codePath)
|
||||
{
|
||||
RegisterInitWorkerFunc(engine);
|
||||
RegisterAssetFunc(engine, codePath);
|
||||
}
|
||||
|
||||
class UvLoopHandler : public AppExecFwk::FileDescriptorListener, public std::enable_shared_from_this<UvLoopHandler> {
|
||||
public:
|
||||
explicit UvLoopHandler(uv_loop_t* uvLoop) : uvLoop_(uvLoop) {}
|
||||
@ -412,7 +333,7 @@ bool JsRuntime::Initialize(const Options& options)
|
||||
moduleManager->SetAppLibPath(packagePath.c_str());
|
||||
}
|
||||
|
||||
RegisterWorker(*nativeEngine_, options.codePath);
|
||||
InitWorkerModule(*nativeEngine_, options.codePath);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
117
frameworks/native/runtime/js_worker.cpp
Normal file
117
frameworks/native/runtime/js_worker.cpp
Normal file
@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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 "js_worker.h"
|
||||
|
||||
#include <cerrno>
|
||||
#include <climits>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
|
||||
#include "hilog_wrapper.h"
|
||||
#include "js_console_log.h"
|
||||
#include "js_runtime_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
namespace {
|
||||
constexpr int64_t ASSET_FILE_MAX_SIZE = 20 * 1024 * 1024;
|
||||
|
||||
void InitWorkerFunc(NativeEngine* nativeEngine)
|
||||
{
|
||||
HILOG_INFO("RegisterInitWorkerFunc called");
|
||||
if (nativeEngine == nullptr) {
|
||||
HILOG_ERROR("Input nativeEngine is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
NativeObject* globalObj = ConvertNativeValueTo<NativeObject>(nativeEngine->GetGlobal());
|
||||
if (globalObj == nullptr) {
|
||||
HILOG_ERROR("Failed to get global object");
|
||||
return;
|
||||
}
|
||||
|
||||
InitConsoleLogModule(*nativeEngine, *globalObj);
|
||||
}
|
||||
|
||||
bool ReadAssetData(const std::string& filePath, std::vector<uint8_t>& content)
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
if (realpath(filePath.c_str(), path) == nullptr) {
|
||||
HILOG_ERROR("ReadAssetData realpath(%{private}s) failed, errno = %{public}d", filePath.c_str(), errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ifstream stream(path, std::ios::binary | std::ios::ate);
|
||||
if (!stream.is_open()) {
|
||||
HILOG_ERROR("ReadAssetData failed to open file %{private}s", filePath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
auto fileLen = stream.tellg();
|
||||
if (fileLen > ASSET_FILE_MAX_SIZE) {
|
||||
HILOG_ERROR("ReadAssetData failed, file is too large");
|
||||
return false;
|
||||
}
|
||||
|
||||
content.resize(fileLen);
|
||||
|
||||
stream.seekg(0);
|
||||
stream.read(reinterpret_cast<char*>(content.data()), content.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
struct AssetHelper final {
|
||||
explicit AssetHelper(const std::string& codePath) : codePath_(codePath)
|
||||
{
|
||||
if (!codePath_.empty() && codePath.back() != '/') {
|
||||
codePath_.append("/");
|
||||
}
|
||||
}
|
||||
|
||||
void operator()(const std::string& uri, std::vector<uint8_t>& content, std::string &ami) const
|
||||
{
|
||||
if (uri.empty()) {
|
||||
HILOG_ERROR("Uri is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
HILOG_INFO("RegisterAssetFunc called, uri: %{private}s", uri.c_str());
|
||||
size_t index = uri.find_last_of(".");
|
||||
if (index == std::string::npos) {
|
||||
HILOG_ERROR("Invalid uri");
|
||||
return;
|
||||
}
|
||||
|
||||
ami = codePath_ + uri.substr(0, index) + ".abc";
|
||||
HILOG_INFO("Get asset, ami: %{private}s", ami.c_str());
|
||||
if (!ReadAssetData(ami, content)) {
|
||||
HILOG_ERROR("Get asset content failed.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string codePath_;
|
||||
};
|
||||
}
|
||||
|
||||
void InitWorkerModule(NativeEngine& engine, const std::string& codePath)
|
||||
{
|
||||
engine.SetInitWorkerFunc(InitWorkerFunc);
|
||||
engine.SetGetAssetFunc(AssetHelper(codePath));
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
29
frameworks/native/runtime/js_worker.h
Normal file
29
frameworks/native/runtime/js_worker.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* 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 FOUNDATION_OHOS_ABILITYRUNTIME_JS_WORKER_H
|
||||
#define FOUNDATION_OHOS_ABILITYRUNTIME_JS_WORKER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "native_engine/native_engine.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
void InitWorkerModule(NativeEngine& engine, const std::string& codePath);
|
||||
} // namespace AbilityRuntime
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // FOUNDATION_OHOS_ABILITYRUNTIME_JS_WORKER_H
|
@ -37,6 +37,10 @@ JS_ERROR:
|
||||
FG: {type: INT32, desc: whether current app is in foreground}
|
||||
HAPPEN_TIME: {type: INT64, desc: fault trigger time}
|
||||
LIFETIME: {type: INT64, desc: elapse time since process start}
|
||||
PANME: {type: STRING, desc: process name}
|
||||
FIRST_FRAME: {type: STRING, desc: first stack info}
|
||||
SECOND_FRAME: {type: STRING, desc: second stack info}
|
||||
LAST_FRAME: {type: STRING, desc: last stack info}
|
||||
|
||||
THREAD_BLOCK_3S:
|
||||
__BASE: {type: FAULT, level: CRITICAL, tag: STABILITY, desc: application freeze}
|
||||
|
@ -31,7 +31,7 @@ namespace {
|
||||
struct AbilityTransitionInfo : public Parcelable {
|
||||
std::string bundleName_;
|
||||
std::string abilityName_;
|
||||
uint32_t mode_ = 1;
|
||||
uint32_t mode_ = 0;
|
||||
std::vector<AppExecFwk::SupportWindowMode> windowModes_;
|
||||
sptr<IRemoteObject> abilityToken_ = nullptr;
|
||||
uint64_t displayId_ = 0;
|
||||
|
@ -42,6 +42,7 @@ ohos_shared_library("runtime") {
|
||||
"${ability_runtime_native_path}/runtime/js_runtime.cpp",
|
||||
"${ability_runtime_native_path}/runtime/js_runtime_utils.cpp",
|
||||
"${ability_runtime_native_path}/runtime/js_timer.cpp",
|
||||
"${ability_runtime_native_path}/runtime/js_worker.cpp",
|
||||
"${ability_runtime_native_path}/runtime/runtime.cpp",
|
||||
]
|
||||
|
||||
|
@ -55,7 +55,6 @@ public:
|
||||
* @return errCode ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode StartAbility(const AAFwk::Want &want) const;
|
||||
ErrCode StartAbility(const AAFwk::Want &want, const AAFwk::StartOptions &startOptions) const;
|
||||
|
||||
/**
|
||||
* @brief Obtains information about the current ability.
|
||||
|
@ -746,8 +746,8 @@ public:
|
||||
void SetRestarting(const bool isRestart);
|
||||
void SetRestarting(const bool isRestart, int32_t canReStartCount);
|
||||
int32_t GetRestartCount() const;
|
||||
void SetDlp(bool isDlp);
|
||||
bool IsDlp() const;
|
||||
void SetAppIndex(const int32_t appIndex);
|
||||
int32_t GetAppIndex() const;
|
||||
bool IsRestarting() const;
|
||||
void SetAppState(const AppState &state);
|
||||
AppState GetAppState() const;
|
||||
@ -916,7 +916,7 @@ private:
|
||||
std::shared_ptr<CallContainer> callContainer_ = nullptr;
|
||||
bool isStartedByCall_ = false;
|
||||
bool isStartToBackground_ = false;
|
||||
bool isDlp_ = false;
|
||||
int32_t appIndex_ = 0;
|
||||
bool minimizeReason_ = false;
|
||||
|
||||
bool clearMissionFlag_ = false;
|
||||
|
@ -330,8 +330,6 @@ int AbilityManagerService::StartAbility(const Want &want, const sptr<IRemoteObje
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
HILOG_INFO("%{public}s", __func__);
|
||||
|
||||
HILOG_INFO("Start ability come, ability is %{public}s, userId is %{public}d",
|
||||
want.GetElement().GetAbilityName().c_str(), userId);
|
||||
|
||||
@ -359,6 +357,11 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr<IRemot
|
||||
}
|
||||
|
||||
if (callerToken != nullptr && !VerificationAllToken(callerToken)) {
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(callerToken);
|
||||
if (abilityRecord && abilityRecord->GetAppIndex() != 0 &&
|
||||
abilityRecord->GetApplicationInfo().bundleName == want.GetElement().GetBundleName()) {
|
||||
(const_cast<Want &>(want)).SetParam(DLP_INDEX, abilityRecord->GetAppIndex());
|
||||
}
|
||||
auto isSpecificSA = AAFwk::PermissionVerification::GetInstance()->
|
||||
CheckSpecificSystemAbilityAccessPermission();
|
||||
if (!isSpecificSA) {
|
||||
@ -822,7 +825,6 @@ int AbilityManagerService::CheckOptExtensionAbility(const Want &want, AbilityReq
|
||||
int AbilityManagerService::StartExtensionAbility(const Want &want, const sptr<IRemoteObject> &callerToken,
|
||||
int32_t userId, AppExecFwk::ExtensionAbilityType extensionType)
|
||||
{
|
||||
AbilityUtil::HandleDlpApp(const_cast<Want &>(want));
|
||||
HILOG_INFO("Start extension ability come, bundlename: %{public}s, ability is %{public}s, userId is %{public}d",
|
||||
want.GetElement().GetBundleName().c_str(), want.GetElement().GetAbilityName().c_str(), userId);
|
||||
AAFWK::EventInfo eventInfo;
|
||||
|
@ -48,6 +48,7 @@ const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId";
|
||||
const std::string ABILITY_OWNER_USERID = "AbilityMS_Owner_UserId";
|
||||
const std::u16string SYSTEM_ABILITY_TOKEN_CALLBACK = u"ohos.aafwk.ISystemAbilityTokenCallback";
|
||||
const std::string SHOW_ON_LOCK_SCREEN = "ShowOnLockScreen";
|
||||
const std::string DLP_INDEX = "ohos.dlp.params.index";
|
||||
int64_t AbilityRecord::abilityRecordId = 0;
|
||||
int64_t AbilityRecord::g_abilityRecordEventId_ = 0;
|
||||
const int32_t DEFAULT_USER_ID = 0;
|
||||
@ -136,6 +137,7 @@ std::shared_ptr<AbilityRecord> AbilityRecord::CreateAbilityRecord(const AbilityR
|
||||
abilityRequest.want, abilityRequest.abilityInfo, abilityRequest.appInfo, abilityRequest.requestCode);
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, nullptr);
|
||||
abilityRecord->SetUid(abilityRequest.uid);
|
||||
abilityRecord->SetAppIndex(abilityRequest.want.GetIntParam(DLP_INDEX, 0));
|
||||
if (!abilityRecord->Init()) {
|
||||
HILOG_ERROR("failed to init new ability record");
|
||||
return nullptr;
|
||||
@ -499,6 +501,7 @@ void AbilityRecord::SetWindowModeAndDisplayId(sptr<AbilityTransitionInfo> &info,
|
||||
auto mode = want->GetIntParam(Want::PARAM_RESV_WINDOW_MODE, -1);
|
||||
auto displayId = want->GetIntParam(Want::PARAM_RESV_DISPLAY_ID, -1);
|
||||
if (mode != -1) {
|
||||
HILOG_INFO("%{public}s: origin window mode is %{public}d.", __func__, mode);
|
||||
info->mode_ = static_cast<uint32_t>(mode);
|
||||
}
|
||||
if (displayId != -1) {
|
||||
@ -512,6 +515,7 @@ sptr<AbilityTransitionInfo> AbilityRecord::CreateAbilityTransitionInfo(const spt
|
||||
sptr<AbilityTransitionInfo> info = new AbilityTransitionInfo();
|
||||
if (startOptions != nullptr) {
|
||||
info->mode_ = static_cast<uint32_t>(startOptions->GetWindowMode());
|
||||
HILOG_INFO("%{public}s: window mode is %{public}d.", __func__, info->mode_);
|
||||
info->displayId_ = static_cast<uint64_t>(startOptions->GetDisplayID());
|
||||
} else {
|
||||
SetWindowModeAndDisplayId(info, want);
|
||||
@ -526,13 +530,15 @@ sptr<AbilityTransitionInfo> AbilityRecord::CreateAbilityTransitionInfo(const Abi
|
||||
sptr<AbilityTransitionInfo> info = new AbilityTransitionInfo();
|
||||
auto abilityStartSetting = abilityRequest.startSetting;
|
||||
if (abilityStartSetting) {
|
||||
int base = 10; // Numerical base (radix) that determines the valid characters and their interpretation.
|
||||
auto mode =
|
||||
strtol(abilityStartSetting->GetProperty(AbilityStartSetting::WINDOW_MODE_KEY).c_str(), nullptr, base);
|
||||
info->mode_ = static_cast<uint32_t>(mode);
|
||||
auto displayId =
|
||||
strtol(abilityStartSetting->GetProperty(AbilityStartSetting::WINDOW_DISPLAY_ID_KEY).c_str(), nullptr, base);
|
||||
info->displayId_ = static_cast<uint64_t>(displayId);
|
||||
auto windowMode = abilityStartSetting->GetProperty(AbilityStartSetting::WINDOW_MODE_KEY);
|
||||
auto displayId = abilityStartSetting->GetProperty(AbilityStartSetting::WINDOW_DISPLAY_ID_KEY);
|
||||
try {
|
||||
info->mode_ = static_cast<uint32_t>(std::stoi(windowMode));
|
||||
info->displayId_ = static_cast<uint64_t>(std::stoi(displayId));
|
||||
} catch (...) {
|
||||
HILOG_WARN("windowMode: stoi(%{public}s) failed", windowMode.c_str());
|
||||
HILOG_WARN("displayId: stoi(%{public}s) failed", displayId.c_str());
|
||||
}
|
||||
} else {
|
||||
SetWindowModeAndDisplayId(info, std::make_shared<Want>(abilityRequest.want));
|
||||
}
|
||||
@ -1650,14 +1656,14 @@ void AbilityRecord::SetMinimizeReason(bool fromUser)
|
||||
minimizeReason_ = fromUser;
|
||||
}
|
||||
|
||||
void AbilityRecord::SetDlp(bool isDlp)
|
||||
void AbilityRecord::SetAppIndex(const int32_t appIndex)
|
||||
{
|
||||
isDlp_ = isDlp;
|
||||
appIndex_ = appIndex;
|
||||
}
|
||||
|
||||
bool AbilityRecord::IsDlp() const
|
||||
int32_t AbilityRecord::GetAppIndex() const
|
||||
{
|
||||
return isDlp_;
|
||||
return appIndex_;
|
||||
}
|
||||
|
||||
bool AbilityRecord::IsMinimizeFromUser() const
|
||||
|
@ -1231,7 +1231,7 @@ void MissionListManager::CompleteTerminateAndUpdateMission(const std::shared_ptr
|
||||
terminateAbilityList_.remove(it);
|
||||
// update inner mission info time
|
||||
bool excludeFromMissions = abilityRecord->GetAbilityInfo().excludeFromMissions;
|
||||
if (abilityRecord->IsDlp() || abilityRecord->GetAbilityInfo().removeMissionAfterTerminate ||
|
||||
if ((abilityRecord->GetAppIndex() != 0) || abilityRecord->GetAbilityInfo().removeMissionAfterTerminate ||
|
||||
excludeFromMissions) {
|
||||
RemoveMissionLocked(abilityRecord->GetMissionId(), excludeFromMissions);
|
||||
return;
|
||||
@ -1488,7 +1488,7 @@ void MissionListManager::UpdateMissionSnapshot(const std::shared_ptr<AbilityReco
|
||||
}
|
||||
int32_t missionId = abilityRecord->GetMissionId();
|
||||
MissionSnapshot snapshot;
|
||||
snapshot.isPrivate = abilityRecord->IsDlp();
|
||||
snapshot.isPrivate = (abilityRecord->GetAppIndex() != 0);
|
||||
DelayedSingleton<MissionInfoMgr>::GetInstance()->UpdateMissionSnapshot(missionId, abilityRecord->GetToken(),
|
||||
snapshot);
|
||||
if (listenerController_) {
|
||||
@ -1960,7 +1960,7 @@ void MissionListManager::HandleAbilityDiedByDefault(std::shared_ptr<AbilityRecor
|
||||
|
||||
// update running state.
|
||||
if (!ability->IsUninstallAbility()) {
|
||||
if (ability->IsDlp() || ability->GetAbilityInfo().removeMissionAfterTerminate ||
|
||||
if ((ability->GetAppIndex() != 0) || ability->GetAbilityInfo().removeMissionAfterTerminate ||
|
||||
ability->GetAbilityInfo().excludeFromMissions) {
|
||||
RemoveMissionLocked(mission->GetMissionId(), ability->GetAbilityInfo().excludeFromMissions);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user