mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 15:20:34 +00:00
merge conflict
Signed-off-by: donglin <donglin9@huawei.com> Change-Id: I4eb6be542f56c1b5229a8ee31b8156a3e041c967
This commit is contained in:
commit
4d61961e1e
@ -25,7 +25,7 @@ class Ability {
|
||||
onWindowStageDestroy() { }
|
||||
onForeground(want) { }
|
||||
onBackground() { }
|
||||
onPrepareTerminate() {
|
||||
onPrepareToTerminate() {
|
||||
return false;
|
||||
}
|
||||
onMemoryLevel(level) { }
|
||||
|
@ -502,7 +502,7 @@ bool JsAbility::OnPrepareTerminate()
|
||||
HILOG_DEBUG("call, ability: %{public}s.", GetAbilityName().c_str());
|
||||
Ability::OnPrepareTerminate();
|
||||
|
||||
NativeValue *jsValue = CallObjectMethod("onPrepareTerminate", nullptr, 0, true);
|
||||
NativeValue *jsValue = CallObjectMethod("onPrepareToTerminate", nullptr, 0, true);
|
||||
auto numberValue = ConvertNativeValueTo<NativeBoolean>(jsValue);
|
||||
if (numberValue == nullptr) {
|
||||
HILOG_ERROR("numberValue is nullptr.");
|
||||
|
@ -63,6 +63,7 @@ constexpr static char WALLPAPER_EXTENSION[] = "WallpaperExtension";
|
||||
constexpr static char FILEACCESS_EXT_ABILITY[] = "FileAccessExtension";
|
||||
constexpr static char ENTERPRISE_ADMIN_EXTENSION[] = "EnterpriseAdminExtension";
|
||||
constexpr static char INPUTMETHOD_EXTENSION[] = "InputMethodExtensionAbility";
|
||||
constexpr static char APP_ACCOUNT_AUTHORIZATION_EXTENSION[] = "AppAccountAuthorizationExtension";
|
||||
|
||||
AbilityThread::AbilityThread()
|
||||
: abilityImpl_(nullptr), token_(nullptr), currentAbility_(nullptr), abilityHandler_(nullptr), runner_(nullptr)
|
||||
@ -167,6 +168,9 @@ std::string AbilityThread::CreateAbilityName(const std::shared_ptr<AbilityLocalR
|
||||
if (abilityInfo->extensionAbilityType == ExtensionAbilityType::UI) {
|
||||
abilityName = UI_EXTENSION;
|
||||
}
|
||||
if (abilityInfo->extensionAbilityType == ExtensionAbilityType::APP_ACCOUNT_AUTHORIZATION) {
|
||||
abilityName = APP_ACCOUNT_AUTHORIZATION_EXTENSION;
|
||||
}
|
||||
HILOG_DEBUG("CreateAbilityName extension type, abilityName:%{public}s", abilityName.c_str());
|
||||
} else {
|
||||
abilityName = abilityInfo->name;
|
||||
|
@ -112,6 +112,51 @@ constexpr uint32_t CHECK_MAIN_THREAD_IS_ALIVE = 1;
|
||||
|
||||
const std::string OVERLAY_STATE_CHANGED = "usual.event.OVERLAY_STATE_CHANGED";
|
||||
|
||||
std::string GetLibPath(const std::string &hapPath, bool isPreInstallApp)
|
||||
{
|
||||
std::string libPath = LOCAL_CODE_PATH;
|
||||
if (isPreInstallApp) {
|
||||
auto pos = hapPath.rfind("/");
|
||||
libPath = hapPath.substr(0, pos);
|
||||
}
|
||||
return libPath;
|
||||
}
|
||||
|
||||
bool GetHapSoPath(const HapModuleInfo &hapInfo, AppLibPathMap &appLibPaths, bool isPreInstallApp)
|
||||
{
|
||||
if (hapInfo.compressNativeLibs) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hapInfo.nativeLibraryPath.empty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string libPath = GetLibPath(hapInfo.hapPath, isPreInstallApp);
|
||||
libPath += (libPath.back() == '/') ? hapInfo.nativeLibraryPath : "/" + hapInfo.nativeLibraryPath;
|
||||
HILOG_INFO("module lib path = %{public}s", libPath.c_str());
|
||||
appLibPaths["default"].emplace_back(libPath);
|
||||
return true;
|
||||
}
|
||||
|
||||
void GetHspNativeLibPath(const BaseSharedBundleInfo &hspInfo, AppLibPathMap &appLibPaths, bool isPreInstallApp)
|
||||
{
|
||||
if (hspInfo.nativeLibraryPath.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::string appLibPathKey = hspInfo.bundleName + "/" + hspInfo.moduleName;
|
||||
std::string libPath = LOCAL_CODE_PATH;
|
||||
if (!hspInfo.compressNativeLibs) {
|
||||
libPath = GetLibPath(hspInfo.hapPath, isPreInstallApp);
|
||||
appLibPathKey = "default";
|
||||
}
|
||||
libPath = libPath.back() == '/' ? libPath : libPath + "/";
|
||||
libPath += hspInfo.bundleName + "/" + hspInfo.nativeLibraryPath;
|
||||
HILOG_DEBUG("appLibPathKey: %{private}s, libPath: %{private}s", appLibPathKey.c_str(), libPath.c_str());
|
||||
appLibPaths[appLibPathKey].emplace_back(libPath);
|
||||
}
|
||||
|
||||
void GetNativeLibPath(const BundleInfo &bundleInfo, const HspList &hspList, AppLibPathMap &appLibPaths)
|
||||
{
|
||||
std::string patchNativeLibraryPath = bundleInfo.applicationInfo.appQuickFix.deployedAppqfInfo.nativeLibraryPath;
|
||||
@ -150,13 +195,13 @@ void GetNativeLibPath(const BundleInfo &bundleInfo, const HspList &hspList, AppL
|
||||
HILOG_INFO("name: %{public}s, patch lib path = %{private}s", hapInfo.name.c_str(), patchLibPath.c_str());
|
||||
appLibPaths[appLibPathKey].emplace_back(patchLibPath);
|
||||
}
|
||||
|
||||
std::string libPath = LOCAL_CODE_PATH;
|
||||
if (hapInfo.isLibIsolated) {
|
||||
libPath += (libPath.back() == '/') ? hapInfo.nativeLibraryPath : "/" + hapInfo.nativeLibraryPath;
|
||||
} else {
|
||||
libPath += (libPath.back() == '/') ? nativeLibraryPath : "/" + nativeLibraryPath;
|
||||
if (GetHapSoPath(hapInfo, appLibPaths, bundleInfo.isPreInstallApp)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string libPath = LOCAL_CODE_PATH;
|
||||
const auto &tmpNativePath = hapInfo.isLibIsolated ? hapInfo.nativeLibraryPath : nativeLibraryPath;
|
||||
libPath += (libPath.back() == '/') ? tmpNativePath : "/" + tmpNativePath;
|
||||
HILOG_DEBUG("appLibPathKey: %{private}s, libPath: %{private}s", appLibPathKey.c_str(), libPath.c_str());
|
||||
appLibPaths[appLibPathKey].emplace_back(libPath);
|
||||
}
|
||||
@ -164,16 +209,7 @@ void GetNativeLibPath(const BundleInfo &bundleInfo, const HspList &hspList, AppL
|
||||
for (auto &hspInfo : hspList) {
|
||||
HILOG_DEBUG("bundle:%s, module:%s, nativeLibraryPath:%s", hspInfo.bundleName.c_str(),
|
||||
hspInfo.moduleName.c_str(), hspInfo.nativeLibraryPath.c_str());
|
||||
if (hspInfo.nativeLibraryPath.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string appLibPathKey = hspInfo.bundleName + "/" + hspInfo.moduleName;
|
||||
std::string libPath = LOCAL_CODE_PATH;
|
||||
libPath = libPath.back() == '/' ? libPath : libPath + "/";
|
||||
libPath += hspInfo.bundleName + "/" + hspInfo.nativeLibraryPath;
|
||||
HILOG_DEBUG("appLibPathKey: %{private}s, libPath: %{private}s", appLibPathKey.c_str(), libPath.c_str());
|
||||
appLibPaths[appLibPathKey].emplace_back(libPath);
|
||||
GetHspNativeLibPath(hspInfo, appLibPaths, bundleInfo.isPreInstallApp);
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
@ -815,9 +851,13 @@ bool MainThread::InitCreate(
|
||||
std::shared_ptr<ContextDeal> &contextDeal, ApplicationInfo &appInfo, ProcessInfo &processInfo)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
// get application shared point
|
||||
application_ = std::shared_ptr<OHOSApplication>(ApplicationLoader::GetInstance().GetApplicationByName());
|
||||
if (application_ == nullptr) {
|
||||
HILOG_ERROR("InitCreate application create failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
applicationInfo_ = std::make_shared<ApplicationInfo>(appInfo);
|
||||
if (applicationInfo_ == nullptr) {
|
||||
HILOG_ERROR("MainThread::InitCreate create applicationInfo_ failed");
|
||||
@ -1054,6 +1094,46 @@ void MainThread::HandleOnOverlayChanged(const EventFwk::CommonEventData &data,
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool IsNeedLoadLibrary(const std::string &bundleName)
|
||||
{
|
||||
std::vector<std::string> needLoadLibraryBundleNames{
|
||||
"com.ohos.contactsdataability",
|
||||
"com.ohos.medialibrary.medialibrarydata",
|
||||
"com.ohos.telephonydataability",
|
||||
"com.ohos.FusionSearch",
|
||||
"com.ohos.formrenderservice"
|
||||
};
|
||||
|
||||
for (const auto &item : needLoadLibraryBundleNames) {
|
||||
if (item == bundleName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GetBundleForLaunchApplication(sptr<IBundleMgr> bundleMgr, const std::string &bundleName,
|
||||
int32_t appIndex, BundleInfo &bundleInfo)
|
||||
{
|
||||
bool queryResult;
|
||||
if (appIndex != 0) {
|
||||
HILOG_INFO("GetSandboxBundleInfo, bundleName = %{public}s", bundleName.c_str());
|
||||
queryResult = (bundleMgr->GetSandboxBundleInfo(bundleName,
|
||||
appIndex, UNSPECIFIED_USERID, bundleInfo) == 0);
|
||||
} else {
|
||||
HILOG_INFO("GetBundleInfo, bundleName = %{public}s", bundleName.c_str());
|
||||
queryResult = (bundleMgr->GetBundleInfoForSelf(
|
||||
(static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_DISABLE) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ABILITY) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA)), bundleInfo) == ERR_OK);
|
||||
}
|
||||
return queryResult;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Launch the application.
|
||||
@ -1070,19 +1150,32 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
return;
|
||||
}
|
||||
|
||||
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");
|
||||
std::string formRenderExtensionAbility("com.ohos.formrenderservice");
|
||||
auto appInfo = appLaunchData.GetApplicationInfo();
|
||||
ProcessInfo processInfo = appLaunchData.GetProcessInfo();
|
||||
HILOG_DEBUG("MainThread handle launch application, InitCreate Start.");
|
||||
std::shared_ptr<ContextDeal> contextDeal;
|
||||
if (!InitCreate(contextDeal, appInfo, processInfo)) {
|
||||
HILOG_ERROR("MainThread::handleLaunchApplication InitCreate failed");
|
||||
return;
|
||||
}
|
||||
sptr<IBundleMgr> bundleMgr = contextDeal->GetBundleManager();
|
||||
if (bundleMgr == nullptr) {
|
||||
HILOG_ERROR("MainThread::handleLaunchApplication GetBundleManager is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
auto bundleName = appInfo.bundleName;
|
||||
if (bundleName == contactsDataAbility || bundleName == mediaDataAbility || bundleName == telephonyDataAbility
|
||||
|| bundleName == fusionSearchAbility || bundleName == formRenderExtensionAbility) {
|
||||
BundleInfo bundleInfo;
|
||||
if (!GetBundleForLaunchApplication(bundleMgr, bundleName, appLaunchData.GetAppIndex(), bundleInfo)) {
|
||||
HILOG_ERROR("HandleLaunchApplication GetBundleInfo failed!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsNeedLoadLibrary(bundleName)) {
|
||||
std::vector<std::string> localPaths;
|
||||
ChangeToLocalPath(bundleName, appInfo.moduleSourceDirs, localPaths);
|
||||
LoadAbilityLibrary(localPaths);
|
||||
LoadNativeLiabrary(appInfo.nativeLibraryPath);
|
||||
LoadNativeLiabrary(bundleInfo, appInfo.nativeLibraryPath);
|
||||
}
|
||||
if (appInfo.needAppDetail) {
|
||||
HILOG_DEBUG("MainThread::handleLaunchApplication %{public}s need add app detail ability library path",
|
||||
@ -1090,56 +1183,13 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
LoadAppDetailAbilityLibrary(appInfo.appDetailAbilityLibraryPath);
|
||||
}
|
||||
LoadAppLibrary();
|
||||
// get application shared point
|
||||
application_ = std::shared_ptr<OHOSApplication>(ApplicationLoader::GetInstance().GetApplicationByName());
|
||||
if (application_ == nullptr) {
|
||||
HILOG_ERROR("HandleLaunchApplication::application launch failed");
|
||||
return;
|
||||
}
|
||||
ProcessInfo processInfo = appLaunchData.GetProcessInfo();
|
||||
|
||||
HILOG_DEBUG("MainThread handle launch application, InitCreate Start.");
|
||||
std::shared_ptr<ContextDeal> contextDeal = nullptr;
|
||||
if (!InitCreate(contextDeal, appInfo, processInfo)) {
|
||||
HILOG_ERROR("MainThread::handleLaunchApplication InitCreate failed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
applicationForDump_ = application_;
|
||||
mixStackDumper_ = std::make_shared<MixStackDumper>();
|
||||
if (!mixStackDumper_->IsInstalled()) {
|
||||
mixStackDumper_->InstallDumpHandler(application_, signalHandler_);
|
||||
}
|
||||
|
||||
sptr<IBundleMgr> bundleMgr = contextDeal->GetBundleManager();
|
||||
if (bundleMgr == nullptr) {
|
||||
HILOG_ERROR("MainThread::handleLaunchApplication GetBundleManager is nullptr");
|
||||
return;
|
||||
}
|
||||
|
||||
BundleInfo bundleInfo;
|
||||
bool queryResult;
|
||||
if (appLaunchData.GetAppIndex() != 0) {
|
||||
HILOG_INFO("GetSandboxBundleInfo, bundleName = %{public}s", appInfo.bundleName.c_str());
|
||||
queryResult = (bundleMgr->GetSandboxBundleInfo(appInfo.bundleName,
|
||||
appLaunchData.GetAppIndex(), UNSPECIFIED_USERID, bundleInfo) == 0);
|
||||
} else {
|
||||
HILOG_INFO("GetBundleInfo, bundleName = %{public}s", appInfo.bundleName.c_str());
|
||||
queryResult = (bundleMgr->GetBundleInfoForSelf(
|
||||
(static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_DISABLE) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_ABILITY) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA)), bundleInfo) == ERR_OK);
|
||||
}
|
||||
|
||||
if (!queryResult) {
|
||||
HILOG_ERROR("HandleLaunchApplication GetBundleInfo failed!");
|
||||
return;
|
||||
}
|
||||
|
||||
bool moduelJson = false;
|
||||
bool isStageBased = false;
|
||||
bool findEntryHapModuleInfo = false;
|
||||
@ -1362,25 +1412,61 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
HILOG_DEBUG("MainThread::handleLaunchApplication called end.");
|
||||
}
|
||||
|
||||
void MainThread::LoadNativeLiabrary(std::string &nativeLibraryPath)
|
||||
{
|
||||
#ifdef ABILITY_LIBRARY_LOADER
|
||||
if (nativeLibraryPath.empty()) {
|
||||
HILOG_WARN("Native library path is empty.");
|
||||
return;
|
||||
void MainThread::CalcNativeLiabraryEntries(const BundleInfo &bundleInfo, std::string &nativeLibraryPath)
|
||||
{
|
||||
bool loadSoFromDir = bundleInfo.hapModuleInfos.empty();
|
||||
std::vector<std::string> nativeFileEntries;
|
||||
for (const auto &item: bundleInfo.hapModuleInfos) {
|
||||
if (!item.compressNativeLibs) {
|
||||
HILOG_DEBUG("handle entries for: %{public}s, with path: %{public}s", item.moduleName.c_str(),
|
||||
item.nativeLibraryPath.c_str());
|
||||
if (item.nativeLibraryPath.empty()) {
|
||||
HILOG_DEBUG("nativeLibraryPath empty: %{public}s", item.moduleName.c_str());
|
||||
continue;
|
||||
}
|
||||
std::string libPath = GetLibPath(item.hapPath, bundleInfo.isPreInstallApp);
|
||||
libPath += (libPath.back() == '/') ? item.nativeLibraryPath : "/" + item.nativeLibraryPath;
|
||||
HILOG_INFO("module lib path: %{public}s", libPath.c_str());
|
||||
if (libPath.back() != '/') {
|
||||
libPath.push_back('/');
|
||||
}
|
||||
for (const auto &entryName : item.nativeLibraryFileNames) {
|
||||
HILOG_DEBUG("add entry: %{public}s.", entryName.c_str());
|
||||
nativeFileEntries.emplace_back(libPath + entryName);
|
||||
}
|
||||
} else {
|
||||
HILOG_DEBUG("compressNativeLibs flag true for: %{public}s.", item.moduleName.c_str());
|
||||
loadSoFromDir = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (loadSoFromDir) {
|
||||
if (nativeLibraryPath.empty()) {
|
||||
HILOG_WARN("Native library path is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nativeLibraryPath.back() == '/') {
|
||||
nativeLibraryPath.pop_back();
|
||||
}
|
||||
std::string libPath = LOCAL_CODE_PATH;
|
||||
libPath += (libPath.back() == '/') ? nativeLibraryPath : "/" + nativeLibraryPath;
|
||||
HILOG_DEBUG("native library path = %{public}s", libPath.c_str());
|
||||
|
||||
if (!ScanDir(libPath, nativeFileEntries_)) {
|
||||
HILOG_WARN("%{public}s scanDir %{public}s not exits", __func__, libPath.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (nativeLibraryPath.back() == '/') {
|
||||
nativeLibraryPath.pop_back();
|
||||
}
|
||||
std::string libPath = LOCAL_CODE_PATH;
|
||||
libPath += (libPath.back() == '/') ? nativeLibraryPath : "/" + nativeLibraryPath;
|
||||
HILOG_DEBUG("native library path = %{public}s", libPath.c_str());
|
||||
|
||||
if (!ScanDir(libPath, nativeFileEntries_)) {
|
||||
HILOG_WARN("%{public}s scanDir %{public}s not exits", __func__, libPath.c_str());
|
||||
if (!nativeFileEntries.empty()) {
|
||||
nativeFileEntries_.insert(nativeFileEntries_.end(), nativeFileEntries.begin(), nativeFileEntries.end());
|
||||
}
|
||||
}
|
||||
|
||||
void MainThread::LoadNativeLiabrary(const BundleInfo &bundleInfo, std::string &nativeLibraryPath)
|
||||
{
|
||||
CalcNativeLiabraryEntries(bundleInfo, nativeLibraryPath);
|
||||
if (nativeFileEntries_.empty()) {
|
||||
HILOG_WARN("No native library");
|
||||
return;
|
||||
@ -1411,8 +1497,8 @@ void MainThread::LoadNativeLiabrary(std::string &nativeLibraryPath)
|
||||
HILOG_DEBUG("%{public}s Success to dlopen %{public}s", __func__, fileEntry.c_str());
|
||||
handleAbilityLib_.emplace_back(handleAbilityLib);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void MainThread::ChangeToLocalPath(const std::string &bundleName,
|
||||
const std::vector<std::string> &sourceDirs, std::vector<std::string> &localPath)
|
||||
|
@ -1005,6 +1005,13 @@ public:
|
||||
const Want &want,
|
||||
const sptr<IRemoteObject> &callerToken);
|
||||
|
||||
/**
|
||||
* Set rootSceneSession by SCB.
|
||||
*
|
||||
* @param rootSceneSession Indicates root scene session of SCB.
|
||||
*/
|
||||
void SetRootSceneSession(const sptr<Rosen::RootSceneSession> &rootSceneSession);
|
||||
|
||||
private:
|
||||
class AbilityMgrDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
|
@ -48,10 +48,13 @@
|
||||
#include "uri.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "window_manager_service_handler.h"
|
||||
#include "iprepare_terminate_callback_interface.h"
|
||||
#endif
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class RootSceneSession;
|
||||
} // namespace Rosen
|
||||
|
||||
namespace AAFwk {
|
||||
constexpr const char* ABILITY_MANAGER_SERVICE_NAME = "AbilityManagerService";
|
||||
const int DEFAULT_INVAL_VALUE = -1;
|
||||
@ -951,6 +954,13 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set rootSceneSession by SCB.
|
||||
*
|
||||
* @param rootSceneSession Indicates root scene session of SCB.
|
||||
*/
|
||||
virtual void SetRootSceneSession(const sptr<Rosen::RootSceneSession> &rootSceneSession) {}
|
||||
|
||||
enum {
|
||||
// ipc id 1-1000 for kit
|
||||
// ipc id for terminating ability (1)
|
||||
@ -1131,7 +1141,10 @@ public:
|
||||
|
||||
SEND_ABILITY_RESULT_BY_TOKEN,
|
||||
|
||||
// prepare terminate ability (64)
|
||||
// ipc id for set rootSceneSession (64)
|
||||
SET_ROOTSSCENESESSION,
|
||||
|
||||
// prepare terminate ability (65)
|
||||
PREPARE_TERMINATE_ABILITY,
|
||||
|
||||
// ipc id 1001-2000 for DMS
|
||||
|
@ -26,8 +26,8 @@ public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.prepareTerminateCallback");
|
||||
virtual void DoPrepareTerminate() {};
|
||||
enum {
|
||||
// ipc id for DoPrepareTerminate
|
||||
ON_DO_PREPARE_TERMINATE,
|
||||
// ipc id for DoPrepareTerminate (1)
|
||||
ON_DO_PREPARE_TERMINATE = 1,
|
||||
CODE_MAX
|
||||
};
|
||||
};
|
||||
|
@ -881,8 +881,7 @@ public:
|
||||
/**
|
||||
* @brief Called when ability prepare terminate.
|
||||
*
|
||||
*
|
||||
* @return Return true if ability need stop terminating; return false if ability need be terminated.
|
||||
* @return Return true if ability need to stop terminating; return false if ability need to terminate.
|
||||
*/
|
||||
virtual bool OnPrepareTerminate();
|
||||
|
||||
|
@ -558,7 +558,8 @@ private:
|
||||
*/
|
||||
void LoadAbilityLibrary(const std::vector<std::string> &libraryPaths);
|
||||
|
||||
void LoadNativeLiabrary(std::string &nativeLibraryPath);
|
||||
void CalcNativeLiabraryEntries(const BundleInfo &bundleInfo, std::string &nativeLibraryPath);
|
||||
void LoadNativeLiabrary(const BundleInfo &bundleInfo, std::string &nativeLibraryPath);
|
||||
|
||||
void LoadAppDetailAbilityLibrary(std::string &nativeLibraryPath);
|
||||
|
||||
|
@ -48,5 +48,6 @@ ohos_shared_library("js_environment") {
|
||||
]
|
||||
|
||||
subsystem_name = "ability"
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
@ -151,6 +151,7 @@ ohos_shared_library("abilityms") {
|
||||
"safwk:system_ability_fwk",
|
||||
"samgr:samgr_proxy",
|
||||
"window_manager:libwsutils",
|
||||
"window_manager:scene_session",
|
||||
]
|
||||
|
||||
if (background_task_mgr_continuous_task_enable) {
|
||||
@ -189,6 +190,7 @@ ohos_shared_library("abilityms") {
|
||||
|
||||
version_script = "libabilityms.map"
|
||||
subsystem_name = "ability"
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
||||
|
@ -778,6 +778,13 @@ public:
|
||||
virtual int32_t ShareDataDone(const sptr<IRemoteObject> &token,
|
||||
const int32_t &resultCode, const int32_t &uniqueId, WantParams &wantParam) override;
|
||||
|
||||
/**
|
||||
* Set rootSceneSession by SCB.
|
||||
*
|
||||
* @param rootSceneSession Indicates root scene session of SCB.
|
||||
*/
|
||||
virtual void SetRootSceneSession(const sptr<Rosen::RootSceneSession> &rootSceneSession) override;
|
||||
|
||||
private:
|
||||
template <typename T>
|
||||
int GetParcelableInfos(MessageParcel &reply, std::vector<T> &parcelableInfos);
|
||||
|
@ -1010,6 +1010,13 @@ public:
|
||||
|
||||
int32_t GetConfiguration(AppExecFwk::Configuration& config);
|
||||
|
||||
/**
|
||||
* Set rootSceneSession by SCB.
|
||||
*
|
||||
* @param rootSceneSession Indicates root scene session of SCB.
|
||||
*/
|
||||
virtual void SetRootSceneSession(const sptr<Rosen::RootSceneSession> &rootSceneSession) override;
|
||||
|
||||
// MSG 0 - 20 represents timeout message
|
||||
static constexpr uint32_t LOAD_TIMEOUT_MSG = 0;
|
||||
static constexpr uint32_t ACTIVE_TIMEOUT_MSG = 1;
|
||||
|
@ -216,6 +216,7 @@ private:
|
||||
int AcquireShareDataInner(MessageParcel &data, MessageParcel &reply);
|
||||
int ShareDataDoneInner(MessageParcel &data, MessageParcel &reply);
|
||||
int GetAbilityTokenByCalleeObjInner(MessageParcel &data, MessageParcel &reply);
|
||||
int SetRootSceneSessionInner(MessageParcel &data, MessageParcel &reply);
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <queue>
|
||||
|
||||
#include "ability_record.h"
|
||||
#include "session/host/include/root_scene_session.h"
|
||||
#include "session_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -95,6 +96,17 @@ public:
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int CloseUIAbility(const std::shared_ptr<AbilityRecord> &abilityRecord);
|
||||
|
||||
/**
|
||||
* Set rootSceneSession by SCB.
|
||||
*
|
||||
* @param rootSceneSession Indicates root scene session of SCB.
|
||||
*/
|
||||
inline void SetRootSceneSession(const sptr<Rosen::RootSceneSession> &rootSceneSession)
|
||||
{
|
||||
rootSceneSession_ = rootSceneSession;
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<AbilityRecord> GetAbilityRecordByToken(const sptr<IRemoteObject> &token) const;
|
||||
void UpdateAbilityRecordLaunchReason(const AbilityRequest &abilityRequest,
|
||||
@ -116,6 +128,7 @@ private:
|
||||
mutable std::recursive_mutex sessionLock_;
|
||||
std::map<uint64_t, std::shared_ptr<AbilityRecord>> sessionAbilityMap_;
|
||||
std::list<std::shared_ptr<AbilityRecord>> terminateAbilityList_;
|
||||
sptr<Rosen::RootSceneSession> rootSceneSession_;
|
||||
};
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "session/host/include/root_scene_session.h"
|
||||
#include "session_info.h"
|
||||
#include "string_ex.h"
|
||||
#include "system_ability_definition.h"
|
||||
@ -1050,5 +1051,12 @@ ErrCode AbilityManagerClient::ShareDataDone(
|
||||
return abms->ShareDataDone(token, resultCode, uniqueId, wantParam);
|
||||
}
|
||||
|
||||
void AbilityManagerClient::SetRootSceneSession(const sptr<Rosen::RootSceneSession> &rootSceneSession)
|
||||
{
|
||||
HILOG_INFO("call");
|
||||
auto abms = GetAbilityManager();
|
||||
CHECK_POINTER_RETURN(abms);
|
||||
return abms->SetRootSceneSession(rootSceneSession);
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "ability_scheduler_proxy.h"
|
||||
#include "ability_scheduler_stub.h"
|
||||
#include "ability_util.h"
|
||||
#include "session/host/include/root_scene_session.h"
|
||||
#include "session_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -3943,5 +3944,31 @@ int32_t AbilityManagerProxy::ShareDataDone(
|
||||
HILOG_INFO("AbilityManagerProxy::ShareDataDone end.");
|
||||
return reply.ReadInt32();
|
||||
}
|
||||
|
||||
void AbilityManagerProxy::SetRootSceneSession(const sptr<Rosen::RootSceneSession> &rootSceneSession)
|
||||
{
|
||||
MessageParcel data;
|
||||
if (!WriteInterfaceToken(data)) {
|
||||
HILOG_ERROR("WriteInterfaceToken failed.");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteRemoteObject(rootSceneSession->AsObject())) {
|
||||
HILOG_ERROR("WriteRemoteObject failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
HILOG_ERROR("remote is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
MessageParcel reply;
|
||||
MessageOption option(MessageOption::TF_ASYNC);
|
||||
auto error = remote->SendRequest(IAbilityManager::SET_ROOTSSCENESESSION, data, reply, option);
|
||||
if (error != NO_ERROR) {
|
||||
HILOG_ERROR("Send request error: %{public}d", error);
|
||||
}
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -6255,9 +6255,16 @@ int AbilityManagerService::PrepareTerminateAbility(const sptr<IRemoteObject> &to
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
auto type = abilityRecord->GetAbilityInfo().type;
|
||||
if (type != AppExecFwk::AbilityType::PAGE) {
|
||||
HILOG_ERROR("Only support PAGE.");
|
||||
callback->DoPrepareTerminate();
|
||||
return RESOLVE_CALL_ABILITY_TYPE_ERR;
|
||||
}
|
||||
|
||||
auto timeoutTask = [&callback]() {
|
||||
callback->DoPrepareTerminate();
|
||||
}
|
||||
};
|
||||
int prepareTerminateTimeout =
|
||||
AmsConfigurationParameter::GetInstance().GetAppStartTimeoutTime() * PREPARE_TERMINATE_TIMEOUT_MULTIPLE;
|
||||
if (handler_) {
|
||||
@ -6957,5 +6964,14 @@ int32_t AbilityManagerService::ShareDataDone(
|
||||
handler_->RemoveEvent(SHAREDATA_TIMEOUT_MSG, uniqueId);
|
||||
return GetShareDataPairAndReturnData(abilityRecord, resultCode, uniqueId, wantParam);
|
||||
}
|
||||
|
||||
void AbilityManagerService::SetRootSceneSession(const sptr<Rosen::RootSceneSession> &rootSceneSession)
|
||||
{
|
||||
if (!CheckCallingTokenId(BUNDLE_NAME_SCENEBOARD, U0_USER_ID)) {
|
||||
HILOG_ERROR("Not sceneboard called, not allowed.");
|
||||
return;
|
||||
}
|
||||
uiAbilityLifecycleManager_->SetRootSceneSession(rootSceneSession);
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "ability_manager_errors.h"
|
||||
#include "ability_scheduler_proxy.h"
|
||||
#include "ability_scheduler_stub.h"
|
||||
#include "session/host/include/root_scene_session.h"
|
||||
#include "session_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -2026,5 +2027,17 @@ int AbilityManagerStub::VerifyPermissionInner(MessageParcel &data, MessageParcel
|
||||
}
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int AbilityManagerStub::SetRootSceneSessionInner(MessageParcel &data, MessageParcel &reply)
|
||||
{
|
||||
HILOG_DEBUG("Call.");
|
||||
auto rootSceneSession = iface_cast<Rosen::RootSceneSession>(data.ReadRemoteObject());
|
||||
if (rootSceneSession == nullptr) {
|
||||
HILOG_ERROR("Read rootSceneSession failed.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
SetRootSceneSession(rootSceneSession);
|
||||
return NO_ERROR;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -189,7 +189,7 @@ bool AbilitySchedulerProxy::SchedulePrepareTerminateAbility()
|
||||
HILOG_ERROR("Remote() is NULL");
|
||||
return false;
|
||||
}
|
||||
int32_t err = Remote()->SendRequest(IAbilityScheduler::SCHEDULE_ABILITY_PREPARE_TERMINATE, data, reply, option);
|
||||
int32_t err = remote->SendRequest(IAbilityScheduler::SCHEDULE_ABILITY_PREPARE_TERMINATE, data, reply, option);
|
||||
if (err != NO_ERROR) {
|
||||
HILOG_ERROR("end failed. err: %{public}d", err);
|
||||
return false;
|
||||
|
@ -488,7 +488,7 @@ bool MissionListManager::CreateOrReusedMissionInfo(const AbilityRequest &ability
|
||||
|
||||
std::string missionName = GetMissionName(abilityRequest);
|
||||
auto mgr = DelayedSingleton<MissionInfoMgr>::GetInstance();
|
||||
if (needFind && !abilityRequest.abilityInfo.applicationInfo.isLauncherApp && mgr &&
|
||||
if (needFind && mgr &&
|
||||
mgr->FindReusedMissionInfo(missionName, abilityRequest.specifiedFlag, isFindRecentStandard, info)
|
||||
&& info.missionInfo.id > 0) {
|
||||
reUsedMissionInfo = true;
|
||||
@ -549,7 +549,7 @@ void MissionListManager::GetTargetMissionAndAbility(const AbilityRequest &abilit
|
||||
info.missionInfo.label = targetRecord->GetLabel();
|
||||
}
|
||||
|
||||
if (abilityRequest.abilityInfo.applicationInfo.isLauncherApp || abilityRequest.abilityInfo.excludeFromMissions) {
|
||||
if (abilityRequest.abilityInfo.excludeFromMissions) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ void PrepareTerminateCallbackProxy::DoPrepareTerminate()
|
||||
HILOG_ERROR("Remote() is NULL");
|
||||
return;
|
||||
}
|
||||
int error = Remote()->SendRequest(ON_DO_PREPARE_TERMINATE, data, reply, option);
|
||||
int error = remote->SendRequest(ON_DO_PREPARE_TERMINATE, data, reply, option);
|
||||
if (error != ERR_OK) {
|
||||
HILOG_ERROR("SendRequest fail, error: %{public}d", error);
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ ohos_shared_library("perm_verification") {
|
||||
]
|
||||
|
||||
subsystem_name = "ability"
|
||||
innerapi_tags = [ "platformsdk_indirect" ]
|
||||
part_name = "ability_runtime"
|
||||
}
|
||||
|
||||
|
@ -1519,10 +1519,11 @@ HWTEST_F(MainThreadTest, LoadNativeLiabrary_0100, TestSize.Level1)
|
||||
HILOG_INFO("%{public}s start.", __func__);
|
||||
std::string nativeLibraryPath = "";
|
||||
ASSERT_NE(mainThread_, nullptr);
|
||||
mainThread_->LoadNativeLiabrary(nativeLibraryPath);
|
||||
BundleInfo bundleInfo;
|
||||
mainThread_->LoadNativeLiabrary(bundleInfo, nativeLibraryPath);
|
||||
|
||||
nativeLibraryPath = "test/";
|
||||
mainThread_->LoadNativeLiabrary(nativeLibraryPath);
|
||||
mainThread_->LoadNativeLiabrary(bundleInfo, nativeLibraryPath);
|
||||
HILOG_INFO("%{public}s end.", __func__);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user