mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 22:21:36 -04:00
Signed-off-by: zhongjianfei <zhongjianfei@huawei.com> Change-Id: I3fe09204b8295486a4f2b6ca7d8303d451e1801d
This commit is contained in:
@@ -900,7 +900,9 @@ void Ability::OnConfigurationUpdatedNotify(const Configuration &changeConfigurat
|
||||
APP_LOGE("%{public}s scene_ -> UpdateConfiguration success.", __func__);
|
||||
}
|
||||
|
||||
abilityContext_->SetConfiguration(application_->GetConfiguration());
|
||||
if (abilityContext_ != nullptr && application_ != nullptr) {
|
||||
abilityContext_->SetConfiguration(application_->GetConfiguration());
|
||||
}
|
||||
// Notify Ability Subclass
|
||||
OnConfigurationUpdated(changeConfiguration);
|
||||
APP_LOGI("%{public}s Notify Ability Subclass.", __func__);
|
||||
|
||||
@@ -66,7 +66,7 @@ void AbilityImpl::Init(std::shared_ptr<OHOSApplication> &application, const std:
|
||||
void AbilityImpl::Start(const Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Start ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
@@ -107,7 +107,7 @@ void AbilityImpl::Start(const Want &want)
|
||||
void AbilityImpl::Stop()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Stop ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ void AbilityImpl::Stop()
|
||||
void AbilityImpl::Active()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Active ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ void AbilityImpl::Active()
|
||||
void AbilityImpl::Inactive()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Inactive ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
@@ -194,7 +194,8 @@ int AbilityImpl::GetCompatibleVersion()
|
||||
void AbilityImpl::AfterUnFocused()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
if (!ability_ || !contextDeal_ || !handler_) {
|
||||
if (!ability_ || !ability_->GetAbilityInfo() || !contextDeal_ || !handler_) {
|
||||
APP_LOGE("AbilityImpl::AfterUnFocused failed");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -268,7 +269,7 @@ void AbilityImpl::WindowLifeCycleImpl::AfterUnFocused()
|
||||
void AbilityImpl::Foreground(const Want &want)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Foreground ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
@@ -293,7 +294,7 @@ void AbilityImpl::Foreground(const Want &want)
|
||||
void AbilityImpl::Background()
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::Background ability_ or abilityLifecycleCallbacks_ is nullptr");
|
||||
return;
|
||||
}
|
||||
@@ -838,8 +839,6 @@ Uri AbilityImpl::DenormalizeUri(const Uri &uri)
|
||||
void AbilityImpl::ScheduleUpdateConfiguration(const Configuration &config)
|
||||
{
|
||||
APP_LOGI("%{public}s begin.", __func__);
|
||||
|
||||
|
||||
if (ability_ == nullptr) {
|
||||
APP_LOGE("AbilityImpl::ScheduleUpdateConfiguration ability_ is nullptr");
|
||||
return;
|
||||
|
||||
@@ -527,12 +527,13 @@ void AbilityThread::HandleCommandAbility(const Want &want, bool restart, int sta
|
||||
{
|
||||
BYTRACE_NAME(BYTRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
APP_LOGI("AbilityThread::HandleCommandAbility begin");
|
||||
APP_LOGI("AbilityThread::HandleCommandAbility before abilityImpl_->CommandAbility");
|
||||
if (abilityImpl_ == nullptr) {
|
||||
APP_LOGE("AbilityThread::HandleCommandAbility failed. abilityImpl_ == nullptr");
|
||||
return;
|
||||
}
|
||||
abilityImpl_->CommandAbility(want, restart, startId);
|
||||
APP_LOGI("AbilityThread::HandleCommandAbility after abilityImpl_->CommandAbility");
|
||||
APP_LOGI("AbilityThread::HandleCommandAbility before ScheduleCommandAbilityDone");
|
||||
ErrCode err = AbilityManagerClient::GetInstance()->ScheduleCommandAbilityDone(token_);
|
||||
APP_LOGI("AbilityThread::HandleCommandAbility after ScheduleCommandAbilityDone");
|
||||
if (err != ERR_OK) {
|
||||
APP_LOGE("AbilityThread:: HandleCommandAbility faile err = %{public}d", err);
|
||||
}
|
||||
@@ -759,7 +760,7 @@ void AbilityThread::ScheduleAbilityTransaction(const Want &want, const LifeCycle
|
||||
*/
|
||||
void AbilityThread::ScheduleConnectAbility(const Want &want)
|
||||
{
|
||||
APP_LOGI("AbilityThread::ScheduleConnectAbility begin, isExtension_:%{public}d", isExtension_);
|
||||
APP_LOGI("AbilityThread::ScheduleConnectAbility begin, isExtension_:%{public}d", isExtension_);
|
||||
wptr<AbilityThread> weak = this;
|
||||
auto task = [weak, want]() {
|
||||
auto abilityThread = weak.promote();
|
||||
@@ -792,7 +793,7 @@ void AbilityThread::ScheduleConnectAbility(const Want &want)
|
||||
*/
|
||||
void AbilityThread::ScheduleDisconnectAbility(const Want &want)
|
||||
{
|
||||
APP_LOGI("AbilityThread::ScheduleDisconnectAbility begin, isExtension_:%{public}d", isExtension_);
|
||||
APP_LOGI("AbilityThread::ScheduleDisconnectAbility begin, isExtension_:%{public}d", isExtension_);
|
||||
wptr<AbilityThread> weak = this;
|
||||
auto task = [weak, want]() {
|
||||
auto abilityThread = weak.promote();
|
||||
@@ -1144,7 +1145,7 @@ int AbilityThread::BatchInsert(const Uri &uri, const std::vector<NativeRdb::Valu
|
||||
APP_LOGI("AbilityThread::BatchInsert begin");
|
||||
int ret = -1;
|
||||
if (abilityImpl_ == nullptr) {
|
||||
APP_LOGE("AbilityThread::BatchInsert abilityImpl_ is nullptr");
|
||||
APP_LOGE("AbilityThread::BatchInsert abilityImpl_ is nullptr");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,294 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_BUNDLEMGR_INCLUDE_MOCK_BUNDLE_MGR_INTERFACE_H
|
||||
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_BUNDLEMGR_INCLUDE_MOCK_BUNDLE_MGR_INTERFACE_H
|
||||
|
||||
#include "ability_info.h"
|
||||
#include "application_info.h"
|
||||
#include "iremote_broker.h"
|
||||
#include "iremote_object.h"
|
||||
|
||||
#include "bundle_info.h"
|
||||
#include "common_event_info.h"
|
||||
#include "hap_module_info.h"
|
||||
#include "ohos/aafwk/content/want.h"
|
||||
#include "permission_def.h"
|
||||
#include "module_usage_record.h"
|
||||
#include "distributed_bundle_info.h"
|
||||
|
||||
using OHOS::AAFwk::Want;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
struct FormInfo;
|
||||
struct ShortcutInfo;
|
||||
|
||||
enum class DumpFlag {
|
||||
DUMP_BUNDLE_LIST = 1,
|
||||
DUMP_ALL_BUNDLE_INFO,
|
||||
DUMP_BUNDLE_INFO,
|
||||
};
|
||||
|
||||
enum class InstallFlag {
|
||||
NORMAL = 0,
|
||||
// Allow to replace the existing bundle when the new version isn't lower than the old one.
|
||||
// If the bundle does not exist, just like normal flag.
|
||||
REPLACE_EXISTING = 1,
|
||||
};
|
||||
|
||||
enum class InstallLocation {
|
||||
INTERNAL_ONLY = 1,
|
||||
PREFER_EXTERNAL = 2,
|
||||
};
|
||||
|
||||
struct InstallParam : public Parcelable {
|
||||
InstallFlag installFlag = InstallFlag::NORMAL;
|
||||
InstallLocation installLocation = InstallLocation::INTERNAL_ONLY;
|
||||
int userId = -1;
|
||||
// Is keep user data while uninstall.
|
||||
bool isKeepData = false;
|
||||
bool noCheckSignature = false;
|
||||
|
||||
// the parcel object function is not const.
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
static InstallParam *Unmarshalling(Parcel &parcel);
|
||||
};
|
||||
class IBundleStatusCallback : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.BundleStatusCallback");
|
||||
|
||||
virtual void OnBundleStateChanged(const uint8_t installType, const int32_t resultCode, const std::string &resultMsg,
|
||||
const std::string &bundleName) = 0;
|
||||
|
||||
enum class Message {
|
||||
ON_BUNDLE_STATE_CHANGED,
|
||||
};
|
||||
};
|
||||
|
||||
class ICleanCacheCallback : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.CleanCacheCallback");
|
||||
|
||||
virtual void OnCleanCacheFinished(bool succeeded) = 0;
|
||||
|
||||
enum class Message {
|
||||
ON_CLEAN_CACHE_CALLBACK,
|
||||
};
|
||||
};
|
||||
|
||||
class OnPermissionChangedCallback : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.OnPermissionChangedCallback");
|
||||
/**
|
||||
* @brief Called when an application's permission changed.
|
||||
* @param uid Indicates the uid of the application which permission changed.
|
||||
*/
|
||||
virtual void OnChanged(const int32_t uid) = 0;
|
||||
|
||||
enum class Message {
|
||||
ON_CHANGED,
|
||||
};
|
||||
};
|
||||
|
||||
class IStatusReceiver : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.StatusReceiver");
|
||||
|
||||
virtual void OnStatusNotify(const int progress) = 0;
|
||||
virtual void OnFinished(const int32_t resultCode, const std::string &resultMsg) = 0;
|
||||
|
||||
enum class Message {
|
||||
ON_STATUS_NOTIFY,
|
||||
ON_FINISHED,
|
||||
};
|
||||
|
||||
enum {
|
||||
SUCCESS = 0,
|
||||
ERR_INSTALL_INTERNAL_ERROR,
|
||||
ERR_INSTALL_PARSE_FAILED,
|
||||
ERR_INSTALL_VERSION_DOWNGRADE,
|
||||
ERR_INSTALL_VERIFICATION_FAILED,
|
||||
ERR_INSTALL_NO_SIGNATURE_INFO,
|
||||
ERR_INSTALL_UPDATE_INCOMPATIBLE,
|
||||
ERR_INSTALL_INVALID_BUNDLE_FILE,
|
||||
ERR_INSTALL_MISSING_INSTALLED_BUNDLE,
|
||||
ERR_INSTALL_ALREADY_EXIST,
|
||||
ERR_INSTALL_PARSE_UNEXPECTED,
|
||||
ERR_INSTALL_PARSE_MISSING_BUNDLE,
|
||||
ERR_INSTALL_PARSE_MISSING_ABILITY,
|
||||
ERR_INSTALL_PARSE_NO_PROFILE,
|
||||
ERR_INSTALL_PARSE_BAD_PROFILE,
|
||||
ERR_INSTALL_PARSE_PROFILE_PROP_TYPE_ERROR,
|
||||
ERR_INSTALL_PARSE_PROFILE_MISSING_PROP,
|
||||
ERR_UNINSTALL_INVALID_NAME,
|
||||
ERR_UNKNOW,
|
||||
};
|
||||
};
|
||||
|
||||
class IBundleInstaller : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.BundleInstaller");
|
||||
|
||||
virtual bool Install(const std::string &bundleFilePath, const InstallParam &installParam,
|
||||
const sptr<IStatusReceiver> &statusReceiver) = 0;
|
||||
virtual bool Uninstall(const std::string &bundleName, const InstallParam &installParam,
|
||||
const sptr<IStatusReceiver> &statusReceiver) = 0;
|
||||
|
||||
enum class Message {
|
||||
INSTALL,
|
||||
UNINSTALL,
|
||||
};
|
||||
};
|
||||
|
||||
class IBundleMgr : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.aafwk.BundleMgr");
|
||||
virtual bool GetApplicationInfo(
|
||||
const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) = 0;
|
||||
virtual bool GetApplicationInfos(
|
||||
const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos) = 0;
|
||||
virtual bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo) = 0;
|
||||
virtual bool GetBundleInfos(const BundleFlag flag, std::vector<BundleInfo> &bundleInfos) = 0;
|
||||
virtual int GetUidByBundleName(const std::string &bundleName, const int userId) = 0;
|
||||
virtual std::string GetAppIdByBundleName(const std::string &bundleName, const int userId) = 0;
|
||||
virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) = 0;
|
||||
virtual bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) = 0;
|
||||
virtual bool GetNameForUid(const int uid, std::string &name) = 0;
|
||||
virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) = 0;
|
||||
virtual std::string GetAppType(const std::string &bundleName) = 0;
|
||||
virtual bool CheckIsSystemAppByUid(const int uid) = 0;
|
||||
virtual bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) = 0;
|
||||
virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) = 0;
|
||||
virtual bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos) = 0;
|
||||
virtual bool QueryAbilityInfosForClone(const Want &want, std::vector<AbilityInfo> &abilityInfos) = 0;
|
||||
virtual bool QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) = 0;
|
||||
virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) = 0;
|
||||
virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &className) = 0;
|
||||
virtual bool GetBundleArchiveInfo(
|
||||
const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) = 0;
|
||||
virtual bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) = 0;
|
||||
virtual bool GetLaunchWantForBundle(const std::string &bundleName, Want &want) = 0;
|
||||
virtual int CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName) = 0;
|
||||
virtual int CheckPermission(const std::string &bundleName, const std::string &permission) = 0;
|
||||
virtual bool GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) = 0;
|
||||
virtual bool GetAllPermissionGroupDefs(std::vector<PermissionDef> &permissionDefs) = 0;
|
||||
virtual bool GetAppsGrantedPermissions(
|
||||
const std::vector<std::string> &permissions, std::vector<std::string> &appNames) = 0;
|
||||
virtual bool HasSystemCapability(const std::string &capName) = 0;
|
||||
virtual bool GetSystemAvailableCapabilities(std::vector<std::string> &systemCaps) = 0;
|
||||
virtual bool IsSafeMode() = 0;
|
||||
virtual bool CleanBundleCacheFiles(
|
||||
const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback) = 0;
|
||||
virtual bool CleanBundleDataFiles(const std::string &bundleName, const int userId = 0) = 0;
|
||||
virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) = 0;
|
||||
virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) = 0;
|
||||
virtual bool UnregisterBundleStatusCallback() = 0;
|
||||
virtual bool DumpInfos(
|
||||
const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result) = 0;
|
||||
virtual bool IsApplicationEnabled(const std::string &bundleName) = 0;
|
||||
virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) = 0;
|
||||
virtual bool IsAbilityEnabled(const AbilityInfo &abilityInfo) = 0;
|
||||
virtual bool SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled) = 0;
|
||||
virtual std::string GetAbilityIcon(const std::string &bundleName, const std::string &className) = 0;
|
||||
virtual bool CanRequestPermission(
|
||||
const std::string &bundleName, const std::string &permissionName, const int userId) = 0;
|
||||
virtual bool RequestPermissionFromUser(
|
||||
const std::string &bundleName, const std::string &permission, const int userId) = 0;
|
||||
virtual bool RegisterAllPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) = 0;
|
||||
virtual bool RegisterPermissionsChanged(
|
||||
const std::vector<int> &uids, const sptr<OnPermissionChangedCallback> &callback) = 0;
|
||||
virtual bool UnregisterPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) = 0;
|
||||
virtual bool GetAllFormsInfo(std::vector<FormInfo> &formInfos) = 0;
|
||||
virtual bool GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos) = 0;
|
||||
virtual bool GetFormsInfoByModule(
|
||||
const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos) = 0;
|
||||
virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) = 0;
|
||||
virtual bool GetModuleUsageRecords(const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords) = 0;
|
||||
virtual sptr<IBundleInstaller> GetBundleInstaller() = 0;
|
||||
virtual bool NotifyAbilityLifeStatus(
|
||||
const std::string &bundleName, const std::string &abilityName, const int64_t launchTime, const int uid = 0) = 0;
|
||||
virtual bool GetBundleGidsByUid(const std::string &bundleName, const int &uid, std::vector<int> &gids) = 0;
|
||||
virtual bool QueryAbilityInfosByUri(const std::string &abilityUri, std::vector<AbilityInfo> &abilityInfos) = 0;
|
||||
virtual int CheckPermissionByUid(
|
||||
const std::string &bundleName, const std::string &permission, const int userId) = 0;
|
||||
virtual bool GetAllCommonEventInfo(const std::string &eventKey, std::vector<CommonEventInfo> &commonEventInfos) = 0;
|
||||
virtual bool RemoveClonedBundle(const std::string &bundleName, const int32_t uid) = 0;
|
||||
virtual bool BundleClone(const std::string &bundleName) = 0;
|
||||
virtual bool CheckBundleNameInAllowList(const std::string &bundleName) = 0;
|
||||
virtual bool GetDistributedBundleInfo(
|
||||
const std::string &networkId, int32_t userId, const std::string &bundleName,
|
||||
DistributedBundleInfo &distributedBundleInfo) = 0;
|
||||
|
||||
enum class Message {
|
||||
GET_APPLICATION_INFO,
|
||||
GET_APPLICATION_INFOS,
|
||||
GET_BUNDLE_INFO,
|
||||
GET_BUNDLE_INFOS,
|
||||
GET_UID_BY_BUNDLE_NAME,
|
||||
GET_APPID_BY_BUNDLE_NAME,
|
||||
GET_BUNDLE_NAME_FOR_UID,
|
||||
GET_BUNDLES_FOR_UID,
|
||||
GET_NAME_FOR_UID,
|
||||
GET_BUNDLE_GIDS,
|
||||
GET_APP_TYPE,
|
||||
CHECK_IS_SYSTEM_APP_BY_UID,
|
||||
GET_BUNDLE_INFOS_BY_METADATA,
|
||||
QUERY_ABILITY_INFO,
|
||||
QUERY_ABILITY_INFOS,
|
||||
QUERY_ABILITY_INFOS_FOR_CLONE,
|
||||
QUERY_ABILITY_INFO_BY_URI,
|
||||
QUERY_KEEPALIVE_BUNDLE_INFOS,
|
||||
GET_ABILITY_LABEL,
|
||||
GET_BUNDLE_ARCHIVE_INFO,
|
||||
GET_HAP_MODULE_INFO,
|
||||
GET_LAUNCH_WANT_FOR_BUNDLE,
|
||||
CHECK_PUBLICKEYS,
|
||||
CHECK_PERMISSION,
|
||||
GET_PERMISSION_DEF,
|
||||
GET_ALL_PERMISSION_GROUP_DEFS,
|
||||
GET_APPS_GRANTED_PERMISSIONS,
|
||||
HAS_SYSTEM_CAPABILITY,
|
||||
GET_SYSTEM_AVAILABLE_CAPABILITIES,
|
||||
IS_SAFE_MODE,
|
||||
CLEAN_BUNDLE_CACHE_FILES,
|
||||
CLEAN_BUNDLE_DATA_FILES,
|
||||
REGISTER_BUNDLE_STATUS_CALLBACK,
|
||||
CLEAR_BUNDLE_STATUS_CALLBACK,
|
||||
UNREGISTER_BUNDLE_STATUS_CALLBACK,
|
||||
DUMP_INFOS,
|
||||
IS_APPLICATION_ENABLED,
|
||||
SET_APPLICATION_ENABLED,
|
||||
IS_ABILITY_ENABLED,
|
||||
SET_ABILITY_ENABLED,
|
||||
GET_ABILITY_ICON,
|
||||
CAN_REQUEST_PERMISSION,
|
||||
REQUEST_PERMISSION_FROM_USER,
|
||||
REGISTER_ALL_PERMISSIONS_CHANGED,
|
||||
REGISTER_PERMISSIONS_CHANGED,
|
||||
UNREGISTER_PERMISSIONS_CHANGED,
|
||||
GET_ALL_FORMS_INFO,
|
||||
GET_FORMS_INFO_BY_APP,
|
||||
GET_FORMS_INFO_BY_MODULE,
|
||||
GET_MODULE_USAGE_RECORD,
|
||||
GET_SHORTCUT_INFO,
|
||||
GET_BUNDLE_INSTALLER,
|
||||
NOTIFY_ABILITY_LIFE_STATUS,
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_BUNDLEMGR_INCLUDE_MOCK_BUNDLE_MGR_INTERFACE_H
|
||||
@@ -36,14 +36,6 @@ bool BundleMgrProxy::GetApplicationInfos(
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetBundleInfos(const BundleFlag flag, std::vector<BundleInfo> &bundleInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int BundleMgrProxy::GetUidByBundleName(const std::string &bundleName, const int userId)
|
||||
{
|
||||
return 0;
|
||||
@@ -282,14 +274,6 @@ bool BundleMgrService::GetApplicationInfos(
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetBundleInfos(const BundleFlag flag, std::vector<BundleInfo> &bundleInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int BundleMgrService::GetUidByBundleName(const std::string &bundleName, const int userId)
|
||||
{
|
||||
return 0;
|
||||
|
||||
@@ -38,8 +38,19 @@ public:
|
||||
const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) override;
|
||||
virtual bool GetApplicationInfos(
|
||||
const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos) override;
|
||||
virtual bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo) override;
|
||||
virtual bool GetBundleInfos(const BundleFlag flag, std::vector<BundleInfo> &bundleInfos) override;
|
||||
virtual bool GetBundleInfo(const std::string &bundleName,
|
||||
const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool GetBundleInfos(const BundleFlag flag, std::vector<BundleInfo> &bundleInfos, int32_t userId) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual sptr<IBundleUserMgr> GetBundleUserMgr() override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
virtual int GetUidByBundleName(const std::string &bundleName, const int userId) override;
|
||||
virtual std::string GetAppIdByBundleName(const std::string &bundleName, const int userId) override;
|
||||
virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) override;
|
||||
@@ -104,7 +115,6 @@ public:
|
||||
|
||||
class BundleMgrStub : public IRemoteStub<IBundleMgr> {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"IBundleMgr");
|
||||
virtual int OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
};
|
||||
@@ -115,8 +125,19 @@ public:
|
||||
const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) override;
|
||||
virtual bool GetApplicationInfos(
|
||||
const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos) override;
|
||||
virtual bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo) override;
|
||||
virtual bool GetBundleInfos(const BundleFlag flag, std::vector<BundleInfo> &bundleInfos) override;
|
||||
virtual bool GetBundleInfo(const std::string &bundleName,
|
||||
const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool GetBundleInfos(const BundleFlag flag, std::vector<BundleInfo> &bundleInfos, int32_t userId) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual sptr<IBundleUserMgr> GetBundleUserMgr() override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
virtual int GetUidByBundleName(const std::string &bundleName, const int userId) override;
|
||||
virtual std::string GetAppIdByBundleName(const std::string &bundleName, const int userId) override;
|
||||
virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) override;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "ability_info.h"
|
||||
#include "application_info.h"
|
||||
#include "foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr/bundle_mgr_interface.h"
|
||||
#include "bundle_mgr_interface.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "iremote_proxy.h"
|
||||
#include "iremote_stub.h"
|
||||
@@ -232,7 +232,6 @@ public:
|
||||
|
||||
class BundleMgrStub : public IRemoteStub<IBundleMgr> {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"IBundleMgr");
|
||||
~BundleMgrStub() = default;
|
||||
virtual int OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
|
||||
@@ -169,6 +169,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ScheduleUpdateConfiguration_002, Tes
|
||||
auto language = OHOS::Global::I18n::LocaleConfig::GetSystemLanguage();
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_ScheduleUpdateConfiguration_002 : " << language;
|
||||
config.AddItem(GlobalConfigurationKey::SYSTEM_LANGUAGE, language);
|
||||
Want want; // Trigger Ability LifeCycle to Active
|
||||
mockAbilityimpl->CommandAbility(want, 0, 0);
|
||||
mockAbilityimpl->ScheduleUpdateConfiguration(config);
|
||||
auto testNotify3 = pMocKPageAbility->OnConfigurationUpdated_;
|
||||
EXPECT_EQ(testNotify3, 1);
|
||||
@@ -192,6 +194,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ScheduleUpdateConfiguration_003, Tes
|
||||
std::shared_ptr<MockAbilityimpl> mockAbilityimpl = std::make_shared<MockAbilityimpl>();
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
std::shared_ptr<ApplicationInfo> applicationInfo = std::make_shared<ApplicationInfo>();
|
||||
abilityInfo->name = "pageAbility";
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
EXPECT_NE(token, nullptr);
|
||||
@@ -207,6 +210,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ScheduleUpdateConfiguration_003, Tes
|
||||
std::shared_ptr<Ability> ability = pMocKPageAbility;
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
contextDeal->SetApplicationInfo(applicationInfo);
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
std::shared_ptr<Global::Resource::ResourceManager> resourceManager(
|
||||
Global::Resource::CreateResourceManager());
|
||||
if (resourceManager == nullptr) {
|
||||
@@ -227,12 +232,14 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ScheduleUpdateConfiguration_003, Tes
|
||||
auto language = OHOS::Global::I18n::LocaleConfig::GetSystemLanguage();
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_ScheduleUpdateConfiguration_003 : " << language;
|
||||
config.AddItem(GlobalConfigurationKey::SYSTEM_LANGUAGE, language);
|
||||
Want want; // Trigger Ability LifeCycle to Active
|
||||
mockAbilityimpl->CommandAbility(want, 0, 0);
|
||||
mockAbilityimpl->ScheduleUpdateConfiguration(config);
|
||||
auto testNotify3 = pMocKPageAbility->OnConfigurationUpdated_;
|
||||
EXPECT_EQ(testNotify3, 1);
|
||||
mockAbilityimpl->ScheduleUpdateConfiguration(config);
|
||||
auto testNotify4 = pMocKPageAbility->OnConfigurationUpdated_;
|
||||
EXPECT_EQ(testNotify4, 1);
|
||||
EXPECT_EQ(testNotify4, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -469,11 +476,13 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Active_001, TestSize.Level1)
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
std::shared_ptr<ApplicationInfo> applicationInfo = std::make_shared<ApplicationInfo>();
|
||||
contextDeal->SetApplicationInfo(applicationInfo);
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
pMocKPageAbility->AttachBaseContext(contextDeal);
|
||||
application->AttachBaseContext(contextDeal);
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
AbilityLifecycleExecutor AbilityLifecycleExecutor_;
|
||||
mockAbilityimpl->ImplActive();
|
||||
|
||||
EXPECT_EQ(MockPageAbility::Event::ON_ACTIVE, pMocKPageAbility->state_);
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_ACTIVE, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
@@ -509,11 +518,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Active_002, TestSize.Level1)
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
AbilityLifecycleExecutor AbilityLifecycleExecutor_;
|
||||
mockAbilityimpl->ImplActive();
|
||||
mockAbilityimpl->SetlifecycleState(AAFwk::ABILITY_STATE_SUSPENDED);
|
||||
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_SUSPENDED, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
}
|
||||
@@ -550,11 +556,13 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Inactive_001, TestSize.Level1)
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
std::shared_ptr<ApplicationInfo> applicationInfo = std::make_shared<ApplicationInfo>();
|
||||
contextDeal->SetApplicationInfo(applicationInfo);
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
pMocKPageAbility->AttachBaseContext(contextDeal);
|
||||
application->AttachBaseContext(contextDeal);
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
AbilityLifecycleExecutor AbilityLifecycleExecutor_;
|
||||
mockAbilityimpl->ImplInactive();
|
||||
|
||||
EXPECT_EQ(MockPageAbility::Event::ON_INACTIVE, pMocKPageAbility->state_);
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_INACTIVE, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
@@ -590,11 +598,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Inactive_002, TestSize.Level1)
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
AbilityLifecycleExecutor AbilityLifecycleExecutor_;
|
||||
mockAbilityimpl->ImplInactive();
|
||||
mockAbilityimpl->SetlifecycleState(AAFwk::ABILITY_STATE_SUSPENDED);
|
||||
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_SUSPENDED, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
}
|
||||
@@ -627,16 +632,15 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Foreground_001, TestSize.Level1)
|
||||
std::shared_ptr<AbilityHandler> handler = std::make_shared<AbilityHandler>(eventRunner, abilityThread);
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
MockPageAbility *pMocKPageAbility = new (std::nothrow) MockPageAbility();
|
||||
Want want;
|
||||
pMocKPageAbility->OnForeground(want);
|
||||
EXPECT_NE(pMocKPageAbility, nullptr);
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
Want want;
|
||||
AbilityLifecycleExecutor AbilityLifecycleExecutor_;
|
||||
EXPECT_EQ(MockPageAbility::Event::ON_FOREGROUND, pMocKPageAbility->state_);
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_INACTIVE, mockAbilityimpl->GetCurrentState());
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_INITIAL, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -670,12 +674,9 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Foreground_002, TestSize.Level1)
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
Want want;
|
||||
AbilityLifecycleExecutor AbilityLifecycleExecutor_;
|
||||
mockAbilityimpl->ImplForeground(want);
|
||||
mockAbilityimpl->SetlifecycleState(AAFwk::ABILITY_STATE_SUSPENDED);
|
||||
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_SUSPENDED, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
}
|
||||
@@ -712,11 +713,13 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_Background_001, TestSize.Level1)
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
std::shared_ptr<ApplicationInfo> applicationInfo = std::make_shared<ApplicationInfo>();
|
||||
contextDeal->SetApplicationInfo(applicationInfo);
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
pMocKPageAbility->AttachBaseContext(contextDeal);
|
||||
application->AttachBaseContext(contextDeal);
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
AbilityLifecycleExecutor AbilityLifecycleExecutor_;
|
||||
mockAbilityimpl->ImplBackground();
|
||||
|
||||
EXPECT_EQ(MockPageAbility::Event::ON_BACKGROUND, pMocKPageAbility->state_);
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_BACKGROUND, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
@@ -777,6 +780,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_001, TestSize.Level1)
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "pageAbility";
|
||||
abilityInfo->isStageBasedModel = true;
|
||||
abilityInfo->type = AppExecFwk::AbilityType::PAGE;
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
EXPECT_NE(token, nullptr);
|
||||
if (token != nullptr) {
|
||||
@@ -792,6 +797,11 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_001, TestSize.Level1)
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
std::shared_ptr<ApplicationInfo> applicationInfo = std::make_shared<ApplicationInfo>();
|
||||
contextDeal->SetApplicationInfo(applicationInfo);
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
pMocKPageAbility->AttachBaseContext(contextDeal);
|
||||
application->AttachBaseContext(contextDeal);
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
Want want;
|
||||
mockAbilityimpl->ImplForeground(want);
|
||||
@@ -818,6 +828,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_002, TestSize.Level1)
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "pageAbility";
|
||||
abilityInfo->isStageBasedModel = true;
|
||||
abilityInfo->type = AppExecFwk::AbilityType::PAGE;
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
EXPECT_NE(token, nullptr);
|
||||
if (token != nullptr) {
|
||||
@@ -833,6 +845,11 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_002, TestSize.Level1)
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
std::shared_ptr<ApplicationInfo> applicationInfo = std::make_shared<ApplicationInfo>();
|
||||
contextDeal->SetApplicationInfo(applicationInfo);
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
pMocKPageAbility->AttachBaseContext(contextDeal);
|
||||
application->AttachBaseContext(contextDeal);
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
Want want;
|
||||
mockAbilityimpl->ImplForeground(want);
|
||||
@@ -856,7 +873,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_002, TestSize.Level1)
|
||||
*/
|
||||
HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Background_001, TestSize.Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_New_Foreground_001 start";
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityImpl_New_Background_001 start";
|
||||
std::shared_ptr<MockAbilityimpl> mockAbilityimpl = std::make_shared<MockAbilityimpl>();
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
@@ -876,10 +893,13 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Background_001, TestSize.Level1)
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
std::shared_ptr<ApplicationInfo> applicationInfo = std::make_shared<ApplicationInfo>();
|
||||
contextDeal->SetApplicationInfo(applicationInfo);
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
pMocKPageAbility->AttachBaseContext(contextDeal);
|
||||
application->AttachBaseContext(contextDeal);
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
mockAbilityimpl->ImplBackground();
|
||||
|
||||
EXPECT_EQ(MockPageAbility::Event::ON_BACKGROUND, pMocKPageAbility->state_);
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_BACKGROUND, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
@@ -903,6 +923,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Background_002, TestSize.Level1)
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "pageAbility";
|
||||
abilityInfo->isStageBasedModel = true;
|
||||
abilityInfo->type = AppExecFwk::AbilityType::PAGE;
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
EXPECT_NE(token, nullptr);
|
||||
if (token != nullptr) {
|
||||
@@ -918,12 +940,15 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Background_002, TestSize.Level1)
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
std::shared_ptr<ApplicationInfo> applicationInfo = std::make_shared<ApplicationInfo>();
|
||||
contextDeal->SetApplicationInfo(applicationInfo);
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
pMocKPageAbility->AttachBaseContext(contextDeal);
|
||||
application->AttachBaseContext(contextDeal);
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
mockAbilityimpl->ImplBackground();
|
||||
mockAbilityimpl->ImplBackground();
|
||||
mockAbilityimpl->ImplBackground();
|
||||
|
||||
EXPECT_EQ(MockPageAbility::Event::ON_BACKGROUND, pMocKPageAbility->state_);
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_BACKGROUND_NEW, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
@@ -947,6 +972,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_Background_001, TestS
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "pageAbility";
|
||||
abilityInfo->isStageBasedModel = true;
|
||||
abilityInfo->type = AppExecFwk::AbilityType::PAGE;
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
EXPECT_NE(token, nullptr);
|
||||
if (token != nullptr) {
|
||||
@@ -962,12 +989,15 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_Background_001, TestS
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
std::shared_ptr<ApplicationInfo> applicationInfo = std::make_shared<ApplicationInfo>();
|
||||
contextDeal->SetApplicationInfo(applicationInfo);
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
pMocKPageAbility->AttachBaseContext(contextDeal);
|
||||
application->AttachBaseContext(contextDeal);
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
Want want;
|
||||
mockAbilityimpl->ImplForeground(want);
|
||||
mockAbilityimpl->ImplBackground();
|
||||
|
||||
EXPECT_EQ(MockPageAbility::Event::ON_BACKGROUND, pMocKPageAbility->state_);
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_BACKGROUND_NEW, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
@@ -991,6 +1021,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_Background_002, TestS
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "pageAbility";
|
||||
abilityInfo->isStageBasedModel = true;
|
||||
abilityInfo->type = AppExecFwk::AbilityType::PAGE;
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
EXPECT_NE(token, nullptr);
|
||||
if (token != nullptr) {
|
||||
@@ -1006,13 +1038,16 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_Background_002, TestS
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
std::shared_ptr<ApplicationInfo> applicationInfo = std::make_shared<ApplicationInfo>();
|
||||
contextDeal->SetApplicationInfo(applicationInfo);
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
pMocKPageAbility->AttachBaseContext(contextDeal);
|
||||
application->AttachBaseContext(contextDeal);
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
Want want;
|
||||
mockAbilityimpl->ImplForeground(want);
|
||||
mockAbilityimpl->ImplBackground();
|
||||
mockAbilityimpl->ImplForeground(want);
|
||||
|
||||
EXPECT_EQ(MockPageAbility::Event::ON_FOREGROUND, pMocKPageAbility->state_);
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_FOREGROUND_NEW, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
@@ -1036,6 +1071,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_Background_003, TestS
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "pageAbility";
|
||||
abilityInfo->isStageBasedModel = true;
|
||||
abilityInfo->type = AppExecFwk::AbilityType::PAGE;
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
EXPECT_NE(token, nullptr);
|
||||
if (token != nullptr) {
|
||||
@@ -1051,12 +1088,15 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_Background_003, TestS
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
std::shared_ptr<ApplicationInfo> applicationInfo = std::make_shared<ApplicationInfo>();
|
||||
contextDeal->SetApplicationInfo(applicationInfo);
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
pMocKPageAbility->AttachBaseContext(contextDeal);
|
||||
application->AttachBaseContext(contextDeal);
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
Want want;
|
||||
mockAbilityimpl->ImplBackground();
|
||||
mockAbilityimpl->ImplForeground(want);
|
||||
|
||||
EXPECT_EQ(MockPageAbility::Event::ON_FOREGROUND, pMocKPageAbility->state_);
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_FOREGROUND_NEW, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
@@ -1080,6 +1120,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_Background_004, TestS
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "pageAbility";
|
||||
abilityInfo->isStageBasedModel = true;
|
||||
abilityInfo->type = AppExecFwk::AbilityType::PAGE;
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
EXPECT_NE(token, nullptr);
|
||||
if (token != nullptr) {
|
||||
@@ -1095,13 +1137,16 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_New_Foreground_Background_004, TestS
|
||||
if (pMocKPageAbility != nullptr) {
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
std::shared_ptr<ApplicationInfo> applicationInfo = std::make_shared<ApplicationInfo>();
|
||||
contextDeal->SetApplicationInfo(applicationInfo);
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
pMocKPageAbility->AttachBaseContext(contextDeal);
|
||||
application->AttachBaseContext(contextDeal);
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
Want want;
|
||||
mockAbilityimpl->ImplBackground();
|
||||
mockAbilityimpl->ImplForeground(want);
|
||||
mockAbilityimpl->ImplBackground();
|
||||
|
||||
EXPECT_EQ(MockPageAbility::Event::ON_BACKGROUND, pMocKPageAbility->state_);
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_BACKGROUND_NEW, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
@@ -1137,7 +1182,6 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_DispatchSaveAbilityState_001, TestSi
|
||||
std::shared_ptr<Ability> ability = std::make_shared<Ability>();
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
AbilityLifecycleExecutor AbilityLifecycleExecutor_;
|
||||
mockAbilityimpl->DispatchSaveAbilityState();
|
||||
}
|
||||
}
|
||||
@@ -1279,12 +1323,8 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ConnectAbility_001, TestSize.Level1)
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
Want want;
|
||||
|
||||
AbilityLifecycleExecutor AbilityLifecycleExecutor_;
|
||||
mockAbilityimpl->ConnectAbility(want);
|
||||
|
||||
EXPECT_EQ(MockPageAbility::Event::ON_ACTIVE, pMocKPageAbility->state_);
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_ACTIVE, mockAbilityimpl->GetCurrentState());
|
||||
EXPECT_EQ(nullptr, mockAbilityimpl->ConnectAbility(want));
|
||||
@@ -1321,10 +1361,7 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_ConnectAbility_002, TestSize.Level1)
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
Want want;
|
||||
|
||||
AbilityLifecycleExecutor AbilityLifecycleExecutor_;
|
||||
mockAbilityimpl->ConnectAbility(want);
|
||||
mockAbilityimpl->SetlifecycleState(AAFwk::ABILITY_STATE_SUSPENDED);
|
||||
|
||||
@@ -1366,13 +1403,10 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_CommandAbility_001, TestSize.Level1)
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
Want want;
|
||||
bool restart = true;
|
||||
int startId = 1;
|
||||
AbilityLifecycleExecutor AbilityLifecycleExecutor_;
|
||||
mockAbilityimpl->CommandAbility(want, restart, startId);
|
||||
|
||||
EXPECT_EQ(MockPageAbility::Event::ON_ACTIVE, pMocKPageAbility->state_);
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_ACTIVE, mockAbilityimpl->GetCurrentState());
|
||||
}
|
||||
@@ -1409,16 +1443,11 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_CommandAbility_002, TestSize.Level1)
|
||||
std::shared_ptr<Ability> ability = nullptr;
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
AbilityImpl_->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
Want want;
|
||||
|
||||
bool restart = true;
|
||||
int startId = 1;
|
||||
|
||||
AbilityLifecycleExecutor AbilityLifecycleExecutor_;
|
||||
AbilityImpl_->CommandAbility(want, restart, startId);
|
||||
mockAbilityimpl->SetlifecycleState(AAFwk::ABILITY_STATE_SUSPENDED);
|
||||
|
||||
EXPECT_EQ(AAFwk::ABILITY_STATE_SUSPENDED, mockAbilityimpl->MockGetCurrentState());
|
||||
}
|
||||
}
|
||||
@@ -1921,7 +1950,6 @@ HWTEST_F(AbilityImplTest, AaFwk_AbilityImpl_CheckAndRestore_001, TestSize.Level1
|
||||
ability.reset(pMocKPageAbility);
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
mockAbilityimpl->Init(application, record, ability, handler, token, contextDeal);
|
||||
|
||||
EXPECT_FALSE(mockAbilityimpl->CheckAndRestore());
|
||||
PacMap inState;
|
||||
mockAbilityimpl->DispatchRestoreAbilityState(inState);
|
||||
|
||||
@@ -741,14 +741,18 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_OnBackground_0100, Function | MediumTest
|
||||
HWTEST_F(AbilityBaseTest, AaFwk_Ability_OnBackground_0200, Function | MediumTest | Level3)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AaFwk_Ability_OnBackground_0200 start";
|
||||
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
std::shared_ptr<OHOSApplication> application = nullptr;
|
||||
std::shared_ptr<AbilityHandler> handler = nullptr;
|
||||
sptr<IRemoteObject> token = nullptr;
|
||||
ability_->Init(abilityInfo, application, handler, token);
|
||||
ability_->OnBackground();
|
||||
|
||||
AbilityLifecycleExecutor::LifecycleState state = ability_->GetState();
|
||||
std::shared_ptr<LifeCycle> lifeCycle = ability_->GetLifecycle();
|
||||
|
||||
EXPECT_EQ(AbilityLifecycleExecutor::LifecycleState::UNINITIALIZED, state);
|
||||
EXPECT_EQ(nullptr, lifeCycle);
|
||||
EXPECT_EQ(AbilityLifecycleExecutor::LifecycleState::BACKGROUND, state);
|
||||
EXPECT_TRUE(lifeCycle);
|
||||
|
||||
GTEST_LOG_(INFO) << "AaFwk_Ability_OnBackground_0200 end";
|
||||
}
|
||||
@@ -776,8 +780,9 @@ HWTEST_F(AbilityBaseTest, AaFwk_Ability_OnBackground_0300, Function | MediumTest
|
||||
std::shared_ptr<LifeCycle> lifeCycle = ability_->GetLifecycle();
|
||||
LifeCycle::Event lifeCycleState = lifeCycle->GetLifecycleState();
|
||||
|
||||
EXPECT_EQ(AbilityLifecycleExecutor::LifecycleState::BACKGROUND_NEW, state);
|
||||
EXPECT_EQ(LifeCycle::Event::ON_BACKGROUND, lifeCycleState);
|
||||
// Sence is nullptr, so lifecycle schedule failed.
|
||||
EXPECT_EQ(AbilityLifecycleExecutor::LifecycleState::INITIAL, state);
|
||||
EXPECT_EQ(LifeCycle::Event::UNDEFINED, lifeCycleState);
|
||||
|
||||
GTEST_LOG_(INFO) << "AaFwk_Ability_OBackground_0300 end";
|
||||
}
|
||||
|
||||
@@ -398,6 +398,16 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleConnectAbility_0200, Fun
|
||||
AbilityThread *abilitythread = new (std::nothrow) AbilityThread();
|
||||
EXPECT_NE(abilitythread, nullptr);
|
||||
if (abilitythread != nullptr) {
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "MockPageAbility";
|
||||
abilityInfo->type = AbilityType::PAGE;
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityLocalRecord> abilityRecord =
|
||||
std::make_shared<AbilityLocalRecord>(abilityInfo, token);
|
||||
std::shared_ptr<EventRunner> mainRunner = EventRunner::Create(abilityInfo->name);
|
||||
abilitythread->Attach(application, abilityRecord, mainRunner, nullptr);
|
||||
|
||||
Want want;
|
||||
abilitythread->ScheduleConnectAbility(want);
|
||||
}
|
||||
@@ -449,7 +459,15 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleDisconnectAbility_0200,
|
||||
AbilityThread *abilitythread = new (std::nothrow) AbilityThread();
|
||||
EXPECT_NE(abilitythread, nullptr);
|
||||
if (abilitythread != nullptr) {
|
||||
std::shared_ptr<AbilityImpl> abilityimpl = std::make_shared<AbilityImpl>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "MockPageAbility";
|
||||
abilityInfo->type = AbilityType::PAGE;
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityLocalRecord> abilityRecord =
|
||||
std::make_shared<AbilityLocalRecord>(abilityInfo, token);
|
||||
std::shared_ptr<EventRunner> mainRunner = EventRunner::Create(abilityInfo->name);
|
||||
abilitythread->Attach(application, abilityRecord, mainRunner, nullptr);
|
||||
|
||||
Want want;
|
||||
abilitythread->ScheduleDisconnectAbility(want);
|
||||
@@ -506,10 +524,19 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_ScheduleCommandAbility_0200, Fun
|
||||
AbilityThread *abilitythread = new (std::nothrow) AbilityThread();
|
||||
EXPECT_NE(abilitythread, nullptr);
|
||||
if (abilitythread != nullptr) {
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "MockPageAbility";
|
||||
abilityInfo->type = AbilityType::PAGE;
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityLocalRecord> abilityRecord =
|
||||
std::make_shared<AbilityLocalRecord>(abilityInfo, token);
|
||||
std::shared_ptr<EventRunner> mainRunner = EventRunner::Create(abilityInfo->name);
|
||||
abilitythread->Attach(application, abilityRecord, mainRunner, nullptr);
|
||||
|
||||
Want want;
|
||||
bool restart = true;
|
||||
int startId = 0;
|
||||
|
||||
abilitythread->ScheduleCommandAbility(want, restart, startId);
|
||||
}
|
||||
GTEST_LOG_(INFO) << "AaFwk_AbilityThread_ScheduleCommandAbility_0200 end";
|
||||
@@ -563,7 +590,15 @@ HWTEST_F(AbilityThreadTest, AaFwk_AbilityThread_SendResult_0200, Function | Medi
|
||||
AbilityThread *abilitythread = new (std::nothrow) AbilityThread();
|
||||
EXPECT_NE(abilitythread, nullptr);
|
||||
if (abilitythread != nullptr) {
|
||||
std::shared_ptr<AbilityImpl> abilityimpl = std::make_shared<AbilityImpl>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
abilityInfo->name = "MockPageAbility";
|
||||
abilityInfo->type = AbilityType::PAGE;
|
||||
sptr<IRemoteObject> token = sptr<IRemoteObject>(new (std::nothrow) MockAbilityToken());
|
||||
std::shared_ptr<OHOSApplication> application = std::make_shared<OHOSApplication>();
|
||||
std::shared_ptr<AbilityLocalRecord> abilityRecord =
|
||||
std::make_shared<AbilityLocalRecord>(abilityInfo, token);
|
||||
std::shared_ptr<EventRunner> mainRunner = EventRunner::Create(abilityInfo->name);
|
||||
abilitythread->Attach(application, abilityRecord, mainRunner, nullptr);
|
||||
|
||||
int requestCode = 0;
|
||||
int resultCode = 0;
|
||||
|
||||
@@ -279,7 +279,6 @@ sptr<AppExecFwk::IBundleMgr> ContextImpl::GetBundleManager() const
|
||||
}
|
||||
HILOG_DEBUG("ContextImpl::GetBundleManager before iface_cast<bundleObj>");
|
||||
sptr<AppExecFwk::IBundleMgr> bms = iface_cast<AppExecFwk::IBundleMgr>(bundleObj);
|
||||
HILOG_DEBUG("ContextImpl::GetBundleManager after iface_cast<bundleObj>");
|
||||
HILOG_DEBUG("ContextImpl::GetBundleManager end");
|
||||
return bms;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "context.h"
|
||||
#include "context_impl.h"
|
||||
#include "iremote_object.h"
|
||||
#include "mock_ability_token.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@@ -41,7 +42,7 @@ public:
|
||||
void TearDown();
|
||||
};
|
||||
|
||||
class MockToken : public OHOS::IRemoteObject {
|
||||
class MockToken : public OHOS::AppExecFwk::MockAbilityToken {
|
||||
public:
|
||||
int32_t GetObjectRefCount() override
|
||||
{
|
||||
@@ -138,8 +139,10 @@ HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_AddAbility_001, Function | Me
|
||||
HWTEST_F(AbilityStageTest, AppExecFwk_AbilityStage_AddAbility_002, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_AddAbility_002 start";
|
||||
sptr<IRemoteObject> token = new MockToken();
|
||||
sptr<IRemoteObject> token = new (std::nothrow) MockToken();
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_AddAbility_002 111";
|
||||
abilityStage_->AddAbility(token, std::make_shared<AppExecFwk::AbilityLocalRecord>(nullptr, nullptr));
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_AddAbility_002 222";
|
||||
EXPECT_TRUE(abilityStage_->ContainsAbility());
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_AbilityStage_AddAbility_002 end";
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ HWTEST_F(ContextImplTest, AppExecFwk_ContextImpl_SetApplicationInfo_001, Functio
|
||||
HWTEST_F(ContextImplTest, AppExecFwk_ContextImpl_GetApplicationInfo_001, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_ContextImpl_GetApplicationInfo_001 start";
|
||||
EXPECT_NE(contextImpl_->GetApplicationInfo(), nullptr);
|
||||
EXPECT_TRUE(contextImpl_->GetApplicationInfo() == nullptr);
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_ContextImpl_GetApplicationInfo_001 end";
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@ HWTEST_F(ContextImplTest, AppExecFwk_ContextImpl_GetApplicationInfo_001, Functio
|
||||
HWTEST_F(ContextImplTest, AppExecFwk_ContextImpl_GetApplicationContext_001, Function | MediumTest | Level1)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_ContextImpl_GetApplicationContext_001 start";
|
||||
EXPECT_EQ(contextImpl_->GetApplicationContext(), nullptr);
|
||||
EXPECT_TRUE(contextImpl_->GetApplicationContext() == nullptr);
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_ContextImpl_GetApplicationContext_001 end";
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ HWTEST_F(ContextImplTest, AppExecFwk_ContextImpl_SetParentContext_001, Function
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_ContextImpl_SetParentContext_001 start";
|
||||
std::shared_ptr<AbilityRuntime::ContextImpl> contextImpl_ = std::make_shared<AbilityRuntime::ContextImpl>();
|
||||
contextImpl_->SetParentContext(contextImpl_);
|
||||
EXPECT_NE(contextImpl_->GetApplicationContext(), nullptr);
|
||||
EXPECT_TRUE(contextImpl_->GetApplicationContext() == nullptr);
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_ContextImpl_SetParentContext_001 end";
|
||||
}
|
||||
|
||||
|
||||
@@ -195,8 +195,11 @@ bool MakeFilePath(const std::string& codePath, const std::string& modulePath, st
|
||||
{
|
||||
std::string path(codePath);
|
||||
path.append("/").append(modulePath);
|
||||
|
||||
char resolvedPath[PATH_MAX];
|
||||
if (path.length() > PATH_MAX) {
|
||||
HILOG_ERROR("Path length(%{public}d) longer than MAX(%{public}d)", (int32_t)path.length(), PATH_MAX);
|
||||
return false;
|
||||
}
|
||||
char resolvedPath[PATH_MAX + 1] = { 0 };
|
||||
if (realpath(path.c_str(), resolvedPath) != nullptr) {
|
||||
fileName = resolvedPath;
|
||||
return true;
|
||||
|
||||
@@ -1014,7 +1014,7 @@ int AbilityManagerService::StartContinuation(const Want &want, const sptr<IRemot
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
DistributedClient dmsClient;
|
||||
auto result = dmsClient.StartContinuation(want, missionId, appUid, status);
|
||||
auto result = dmsClient.StartContinuation(want, missionId, appUid, status);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("StartContinuation failed, result = %{public}d, notify caller", result);
|
||||
NotifyContinuationResult(missionId, result);
|
||||
@@ -2628,7 +2628,6 @@ sptr<AppExecFwk::IBundleMgr> AbilityManagerService::GetBundleManager()
|
||||
}
|
||||
iBundleManager_ = iface_cast<AppExecFwk::IBundleMgr>(bundleObj);
|
||||
}
|
||||
|
||||
return iBundleManager_;
|
||||
}
|
||||
|
||||
@@ -3310,13 +3309,16 @@ int AbilityManagerService::GetMissionSaveTime() const
|
||||
int32_t AbilityManagerService::GetMissionIdByAbilityToken(const sptr<IRemoteObject> &token)
|
||||
{
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(token);
|
||||
if (!abilityRecord) {
|
||||
HILOG_ERROR("abilityRecord is Null.");
|
||||
return -1;
|
||||
}
|
||||
auto userId = abilityRecord->GetApplicationInfo().uid / BASE_USER_RANGE;
|
||||
auto missionListManager = GetListManagerByUserId(userId);
|
||||
if (!missionListManager) {
|
||||
HILOG_ERROR("missionListManager is Null. userId=%{public}d", userId);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return missionListManager->GetMissionIdByAbilityToken(token);
|
||||
}
|
||||
|
||||
@@ -3941,15 +3943,18 @@ int32_t AbilityManagerService::GetAbilityInfoFromExtension(const Want &want, App
|
||||
ElementName elementName = want.GetElement();
|
||||
std::string bundleName = elementName.GetBundleName();
|
||||
std::string abilityName = elementName.GetAbilityName();
|
||||
AppExecFwk::BundleMgrClient bundleClient;
|
||||
AppExecFwk::BundleInfo bundleInfo;
|
||||
if (!bundleClient.GetBundleInfo(bundleName, AppExecFwk::BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO, bundleInfo,
|
||||
GetUserId())) {
|
||||
HILOG_ERROR("Failed to get bundle info when generate ability request.");
|
||||
return RESOLVE_APP_ERR;
|
||||
AppExecFwk::BundleMgrClient bundleClient;
|
||||
auto bundleFlag = AppExecFwk::BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO;
|
||||
if (!bundleClient.GetBundleInfo(bundleName, bundleFlag, bundleInfo, GetUserId())) {
|
||||
auto bms = GetBundleManager();
|
||||
CHECK_POINTER_AND_RETURN(bms, RESOLVE_APP_ERR);
|
||||
if (!bms->GetBundleInfo(bundleName, bundleFlag, bundleInfo, GetUserId())) {
|
||||
HILOG_ERROR("Failed to get bundle info when generate ability request.");
|
||||
return RESOLVE_APP_ERR;
|
||||
}
|
||||
}
|
||||
bool found = false;
|
||||
|
||||
for (auto &extensionInfo: bundleInfo.extensionInfos) {
|
||||
if (extensionInfo.name != abilityName) {
|
||||
continue;
|
||||
@@ -3961,7 +3966,6 @@ int32_t AbilityManagerService::GetAbilityInfoFromExtension(const Want &want, App
|
||||
InitAbilityInfoFromExtension(extensionInfo, abilityInfo);
|
||||
break;
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,10 @@ int SharedMemory::PushSharedMemory(const void *data, const int size)
|
||||
|
||||
void* SharedMemory::PopSharedMemory(int shmKey, int size)
|
||||
{
|
||||
if (size <= 0) {
|
||||
HILOG_ERROR("size is invalid: %{public}d.", size);
|
||||
return nullptr;
|
||||
}
|
||||
void *data = reinterpret_cast<void *>(malloc(size));
|
||||
int shmId = shmget(shmKey, 0, 0 | SHM_READ_WRITE_PERMISSIONS);
|
||||
if (shmId == -1) {
|
||||
|
||||
@@ -29,6 +29,7 @@ config("appexecfwk_core_mock_config") {
|
||||
"//base/notification/ces_standard/interfaces/innerkits/native/include/",
|
||||
"//foundation/aafwk/standard/services/abilitymgr/test/mock/libs/aakit/include/",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base/include",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_core/include/bundlemgr/",
|
||||
]
|
||||
}
|
||||
|
||||
-507
@@ -1,507 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_INTERFACE_H
|
||||
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_INTERFACE_H
|
||||
|
||||
#include "ability_info.h"
|
||||
#include "form_info.h"
|
||||
#include "shortcut_info.h"
|
||||
#include "module_usage_record.h"
|
||||
#include "application_info.h"
|
||||
#include "bundle_info.h"
|
||||
#include "bundle_user_mgr_interface.h"
|
||||
#include "hap_module_info.h"
|
||||
#include "permission_def.h"
|
||||
#include "bundle_installer_interface.h"
|
||||
#include "bundle_status_callback_interface.h"
|
||||
#include "clean_cache_callback_interface.h"
|
||||
#include "common_event_info.h"
|
||||
#include "on_permission_changed_callback_interface.h"
|
||||
#include "ohos/aafwk/content/want.h"
|
||||
#include "distributed_bundle_info.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
enum class DumpFlag {
|
||||
DUMP_BUNDLE_LIST = 1, // corresponse to option "-bundle-list"
|
||||
DUMP_ALL_BUNDLE_INFO, // corresponse to option "-bundle"
|
||||
DUMP_BUNDLE_INFO, // corresponse to option "-bundle [name]"
|
||||
};
|
||||
|
||||
class IBundleMgr : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.BundleMgr");
|
||||
|
||||
using Want = OHOS::AAFwk::Want;
|
||||
/**
|
||||
* @brief Obtains the ApplicationInfo based on a given bundle name.
|
||||
* @param appName Indicates the application bundle name to be queried.
|
||||
* @param flag Indicates the flag used to specify information contained
|
||||
* in the ApplicationInfo object that will be returned.
|
||||
* @param userId Indicates the user ID.
|
||||
* @param appInfo Indicates the obtained ApplicationInfo object.
|
||||
* @return Returns true if the application is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetApplicationInfo(
|
||||
const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) = 0;
|
||||
/**
|
||||
* @brief Obtains information about all installed applications of a specified user.
|
||||
* @param flag Indicates the flag used to specify information contained
|
||||
* in the ApplicationInfo objects that will be returned.
|
||||
* @param userId Indicates the user ID.
|
||||
* @param appInfos Indicates all of the obtained ApplicationInfo objects.
|
||||
* @return Returns true if the application is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetApplicationInfos(
|
||||
const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos) = 0;
|
||||
/**
|
||||
* @brief Obtains the BundleInfo based on a given bundle name.
|
||||
* @param bundleName Indicates the application bundle name to be queried.
|
||||
* @param flag Indicates the information contained in the BundleInfo object to be returned.
|
||||
* @param bundleInfo Indicates the obtained BundleInfo object.
|
||||
* @param userId Indicates the user ID.
|
||||
* @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetBundleInfo(
|
||||
const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId = 0) = 0;
|
||||
/**
|
||||
* @brief Obtains BundleInfo of all bundles available in the system.
|
||||
* @param flag Indicates the flag used to specify information contained in the BundleInfo that will be returned.
|
||||
* @param bundleInfos Indicates all of the obtained BundleInfo objects.
|
||||
* @param userId Indicates the user ID.
|
||||
* @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetBundleInfos(
|
||||
const BundleFlag flag, std::vector<BundleInfo> &bundleInfos, int32_t userId = 0) = 0;
|
||||
/**
|
||||
* @brief Obtains the application UID based on the given bundle name and user ID.
|
||||
* @param bundleName Indicates the bundle name of the application.
|
||||
* @param userId Indicates the user ID.
|
||||
* @return Returns the uid if successfully obtained; returns -1 otherwise.
|
||||
*/
|
||||
virtual int GetUidByBundleName(const std::string &bundleName, const int userId) = 0;
|
||||
/**
|
||||
* @brief Obtains the application ID based on the given bundle name and user ID.
|
||||
* @param bundleName Indicates the bundle name of the application.
|
||||
* @param userId Indicates the user ID.
|
||||
* @return Returns the application ID if successfully obtained; returns empty string otherwise.
|
||||
*/
|
||||
virtual std::string GetAppIdByBundleName(const std::string &bundleName, const int userId) = 0;
|
||||
/**
|
||||
* @brief Obtains the bundle name of a specified application based on the given UID.
|
||||
* @param uid Indicates the uid.
|
||||
* @param bundleName Indicates the obtained bundle name.
|
||||
* @return Returns true if the bundle name is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) = 0;
|
||||
/**
|
||||
* @brief Obtains all bundle names of a specified application based on the given application UID.
|
||||
* @param uid Indicates the uid.
|
||||
* @param bundleNames Indicates the obtained bundle names.
|
||||
* @return Returns true if the bundle names is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) = 0;
|
||||
/**
|
||||
* @brief Obtains the formal name associated with the given UID.
|
||||
* @param uid Indicates the uid.
|
||||
* @param name Indicates the obtained formal name.
|
||||
* @return Returns true if the formal name is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetNameForUid(const int uid, std::string &name) = 0;
|
||||
/**
|
||||
* @brief Obtains an array of all group IDs associated with a specified bundle.
|
||||
* @param bundleName Indicates the bundle name.
|
||||
* @param gids Indicates the group IDs associated with the specified bundle.
|
||||
* @return Returns true if the gids is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) = 0;
|
||||
/**
|
||||
* @brief Obtains the type of a specified application based on the given bundle name.
|
||||
* @param bundleName Indicates the bundle name.
|
||||
* @return Returns "system" if the bundle is a system application; returns "third-party" otherwise.
|
||||
*/
|
||||
virtual std::string GetAppType(const std::string &bundleName) = 0;
|
||||
/**
|
||||
* @brief Check whether the app is system app by it's UID.
|
||||
* @param uid Indicates the uid.
|
||||
* @return Returns true if the bundle is a system application; returns false otherwise.
|
||||
*/
|
||||
virtual bool CheckIsSystemAppByUid(const int uid) = 0;
|
||||
/**
|
||||
* @brief Obtains the BundleInfo of application bundles based on the specified metaData.
|
||||
* @param metaData Indicates the metadata to get in the bundle.
|
||||
* @param bundleInfos Indicates all of the obtained BundleInfo objects.
|
||||
* @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) = 0;
|
||||
/**
|
||||
* @brief Query the AbilityInfo by the given Want.
|
||||
* @param want Indicates the information of the ability.
|
||||
* @param abilityInfo Indicates the obtained AbilityInfo object.
|
||||
* @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) = 0;
|
||||
/**
|
||||
* @brief Query the AbilityInfo of list by the given Want.
|
||||
* @param want Indicates the information of the ability.
|
||||
* @param abilityInfos Indicates the obtained AbilityInfos object.
|
||||
* @return Returns true if the AbilityInfos is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos) = 0;
|
||||
/**
|
||||
* @brief Query the AbilityInfo by ability.uri in config.json.
|
||||
* @param abilityUri Indicates the uri of the ability.
|
||||
* @param abilityInfo Indicates the obtained AbilityInfo object.
|
||||
* @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool QueryAbilityInfosForClone(const Want &want, std::vector<AbilityInfo> &abilityInfos) = 0;
|
||||
virtual bool QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) = 0;
|
||||
/**
|
||||
* @brief Obtains the BundleInfo of all keep-alive applications in the system.
|
||||
* @param bundleInfos Indicates all of the obtained BundleInfo objects.
|
||||
* @return Returns true if the BundleInfos is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) = 0;
|
||||
/**
|
||||
* @brief Obtains the label of a specified ability.
|
||||
* @param bundleName Indicates the bundle name.
|
||||
* @param className Indicates the ability class name.
|
||||
* @return Returns the label of the ability if exist; returns empty string otherwise.
|
||||
*/
|
||||
virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &className) = 0;
|
||||
/**
|
||||
* @brief Obtains information about an application bundle contained in an ohos Ability Package (HAP).
|
||||
* @param hapFilePath Indicates the absolute file path of the HAP.
|
||||
* @param flag Indicates the information contained in the BundleInfo object to be returned.
|
||||
* @param bundleInfo Indicates the obtained BundleInfo object.
|
||||
* @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetBundleArchiveInfo(
|
||||
const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) = 0;
|
||||
/**
|
||||
* @brief Obtain the HAP module info of a specific ability.
|
||||
* @param abilityInfo Indicates the ability.
|
||||
* @param hapModuleInfo Indicates the obtained HapModuleInfo object.
|
||||
* @return Returns true if the HapModuleInfo is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) = 0;
|
||||
/**
|
||||
* @brief Obtains the Want for starting the main ability of an application based on the given bundle name.
|
||||
* @param bundleName Indicates the bundle name.
|
||||
* @param want Indicates the obtained launch Want object.
|
||||
* @return Returns true if the launch Want object is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetLaunchWantForBundle(const std::string &bundleName, Want &want) = 0;
|
||||
/**
|
||||
* @brief Checks whether the publickeys of two bundles are the same.
|
||||
* @param firstBundleName Indicates the first bundle name.
|
||||
* @param secondBundleName Indicates the second bundle name.
|
||||
* @return Returns SIGNATURE_UNKNOWN_BUNDLE if at least one of the given bundles is not found;
|
||||
* returns SIGNATURE_NOT_MATCHED if their publickeys are different;
|
||||
* returns SIGNATURE_MATCHED if their publickeys are the same.
|
||||
*/
|
||||
virtual int CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName) = 0;
|
||||
/**
|
||||
* @brief Checks whether a specified bundle has been granted a specific permission.
|
||||
* @param bundleName Indicates the name of the bundle to check.
|
||||
* @param permission Indicates the permission to check.
|
||||
* @return Returns 0 if the bundle has the permission; returns -1 otherwise.
|
||||
*/
|
||||
virtual int CheckPermission(const std::string &bundleName, const std::string &permission) = 0;
|
||||
/**
|
||||
* @brief Obtains detailed information about a specified permission.
|
||||
* @param permissionName Indicates the name of the ohos permission.
|
||||
* @param permissionDef Indicates the object containing detailed information about the given ohos permission.
|
||||
* @return Returns true if the PermissionDef object is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) = 0;
|
||||
/**
|
||||
* @brief Obtains all known permission groups in the system.
|
||||
* @param permissionDefs Indicates the list of objects containing the permission group information.
|
||||
* @return Returns true if the PermissionDef objects is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetAllPermissionGroupDefs(std::vector<PermissionDef> &permissionDefs) = 0;
|
||||
/**
|
||||
* @brief Obtains all known permission groups in the system.
|
||||
* @param permissions Indicates the permission array.
|
||||
* @param appNames Indicates the list of application names that have the specified permissions.
|
||||
* @return Returns true if the application names is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetAppsGrantedPermissions(
|
||||
const std::vector<std::string> &permissions, std::vector<std::string> &appNames) = 0;
|
||||
/**
|
||||
* @brief Checks whether the system has a specified capability.
|
||||
* @param capName Indicates the name of the system feature to check.
|
||||
* @return Returns true if the given feature specified by name is available in the system; returns false otherwise.
|
||||
*/
|
||||
virtual bool HasSystemCapability(const std::string &capName) = 0;
|
||||
/**
|
||||
* @brief Obtains the capabilities that are available in the system.
|
||||
* @param systemCaps Indicates the list of capabilities available in the system.
|
||||
* @return Returns true if capabilities in the system are successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetSystemAvailableCapabilities(std::vector<std::string> &systemCaps) = 0;
|
||||
/**
|
||||
* @brief Checks whether the current device has been started in safe mode.
|
||||
* @return Returns true if the device is in safe mode; returns false otherwise.
|
||||
*/
|
||||
virtual bool IsSafeMode() = 0;
|
||||
/**
|
||||
* @brief Clears cache data of a specified application.
|
||||
* @param bundleName Indicates the bundle name of the application whose cache data is to be cleared.
|
||||
* @param cleanCacheCallback Indicates the callback to be invoked for returning the operation result.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool CleanBundleCacheFiles(
|
||||
const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback) = 0;
|
||||
/**
|
||||
* @brief Clears application running data of a specified application.
|
||||
* @param bundleName Indicates the bundle name of the application whose data is to be cleared.
|
||||
* @return Returns true if the data cleared successfully; returns false otherwise.
|
||||
*/
|
||||
virtual bool CleanBundleDataFiles(const std::string &bundleName, const int userId = 0) = 0;
|
||||
/**
|
||||
* @brief Register the specific bundle status callback.
|
||||
* @param bundleStatusCallback Indicates the callback to be invoked for returning the bundle status changed result.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) = 0;
|
||||
/**
|
||||
* @brief Clear the specific bundle status callback.
|
||||
* @param bundleStatusCallback Indicates the callback to be cleared.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) = 0;
|
||||
/**
|
||||
* @brief Unregister all the callbacks of status changed.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool UnregisterBundleStatusCallback() = 0;
|
||||
/**
|
||||
* @brief Dump the bundle informations with specific flags.
|
||||
* @param flag Indicates the information contained in the dump result.
|
||||
* @param bundleName Indicates the bundle name if needed.
|
||||
* @param userId Indicates the user ID.
|
||||
* @param result Indicates the dump information result.
|
||||
* @return Returns true if the dump result is successfully obtained; returns false otherwise.
|
||||
*/
|
||||
virtual bool DumpInfos(
|
||||
const DumpFlag flag, const std::string &bundleName, int32_t userId, std::string &result) = 0;
|
||||
/**
|
||||
* @brief Checks whether a specified application is enabled.
|
||||
* @param bundleName Indicates the bundle name of the application.
|
||||
* @return Returns true if the application is enabled; returns false otherwise.
|
||||
*/
|
||||
virtual bool IsApplicationEnabled(const std::string &bundleName) = 0;
|
||||
/**
|
||||
* @brief Sets whether to enable a specified application.
|
||||
* @param bundleName Indicates the bundle name of the application.
|
||||
* @param isEnable Specifies whether to enable the application.
|
||||
* The value true means to enable it, and the value false means to disable it.
|
||||
* @return Returns true if the application is enabled; returns false otherwise.
|
||||
*/
|
||||
virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) = 0;
|
||||
/**
|
||||
* @brief Sets whether to enable a specified ability.
|
||||
* @param abilityInfo Indicates information about the ability to check.
|
||||
* @return Returns true if the ability is enabled; returns false otherwise.
|
||||
*/
|
||||
virtual bool IsAbilityEnabled(const AbilityInfo &abilityInfo) = 0;
|
||||
/**
|
||||
* @brief Sets whether to enable a specified ability.
|
||||
* @param abilityInfo Indicates information about the ability.
|
||||
* @param isEnabled Specifies whether to enable the ability.
|
||||
* The value true means to enable it, and the value false means to disable it.
|
||||
* @return Returns true if the ability is enabled; returns false otherwise.
|
||||
*/
|
||||
virtual bool SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled) = 0;
|
||||
/**
|
||||
* @brief Obtains the icon of a specified ability.
|
||||
* @param bundleName Indicates the bundle name.
|
||||
* @param className Indicates the ability class name.
|
||||
* @return Returns the icon resource string of the ability if exist; returns empty string otherwise.
|
||||
*/
|
||||
virtual std::string GetAbilityIcon(const std::string &bundleName, const std::string &className) = 0;
|
||||
/**
|
||||
* @brief Confirms with the permission management module to check whether a request prompt is required for granting
|
||||
* a certain permission.
|
||||
* @param bundleName Indicates the name of the bundle to check.
|
||||
* @param permission Indicates the permission to check.
|
||||
* @param userId Indicates the user id.
|
||||
* @return Returns true if the current application does not have the permission and the user does not turn off
|
||||
* further requests; returns false if the current application already has the permission, the permission is rejected
|
||||
* by the system, or the permission is denied by the user and the user has turned off further requests.
|
||||
*/
|
||||
virtual bool CanRequestPermission(
|
||||
const std::string &bundleName, const std::string &permissionName, const int userId) = 0;
|
||||
/**
|
||||
* @brief Requests a certain permission from user.
|
||||
* @param bundleName Indicates the name of the bundle to request permission.
|
||||
* @param permission Indicates the permission to request permission.
|
||||
* @param userId Indicates the user id.
|
||||
* @return Returns true if the permission request successfully; returns false otherwise.
|
||||
*/
|
||||
virtual bool RequestPermissionFromUser(
|
||||
const std::string &bundleName, const std::string &permission, const int userId) = 0;
|
||||
/**
|
||||
* @brief Registers a callback for listening for permission changes of all UIDs.
|
||||
* @param callback Indicates the callback method to register.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool RegisterAllPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) = 0;
|
||||
/**
|
||||
* @brief Registers a callback for listening for permission changes of specified UIDs.
|
||||
* @param uids Indicates the list of UIDs whose permission changes will be monitored.
|
||||
* @param callback Indicates the callback method to register.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool RegisterPermissionsChanged(
|
||||
const std::vector<int> &uids, const sptr<OnPermissionChangedCallback> &callback) = 0;
|
||||
/**
|
||||
* @brief Unregisters a specified callback for listening for permission changes.
|
||||
* @param callback Indicates the callback method to register.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool UnregisterPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) = 0;
|
||||
/**
|
||||
* @brief Obtains the FormInfo objects provided by all applications on the device.
|
||||
* @param formInfo list of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the
|
||||
* device.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetAllFormsInfo(std::vector<FormInfo> &formInfos) = 0;
|
||||
/**
|
||||
* @brief Obtains the FormInfo objects provided by a specified application on the device.
|
||||
* @param bundleName Indicates the bundle name of the application.
|
||||
* @param formInfo list of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the
|
||||
* device.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos) = 0;
|
||||
/**
|
||||
* @brief Obtains the FormInfo objects provided by a specified.
|
||||
* @param formInfo list of FormInfo objects if obtained; returns an empty List if no FormInfo is available on the
|
||||
* device.
|
||||
* @param moduleName Indicates the module name of the application.
|
||||
* @param bundleName Indicates the bundle name of the application.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetFormsInfoByModule(
|
||||
const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos) = 0;
|
||||
/**
|
||||
* @brief Obtains the ShortcutInfo objects provided by a specified application on the device.
|
||||
* @param bundleName Indicates the bundle name of the application.
|
||||
* @param shortcutInfos List of ShortcutInfo objects if obtained.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) = 0;
|
||||
/**
|
||||
* @brief Get module usage record list in descending order of lastLaunchTime.
|
||||
* @param maxNum the return size of the records, must be in range of 1 to 1000.
|
||||
* @param moduleUsageRecords List of ModuleUsageRecord objects if obtained.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool GetModuleUsageRecords(const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords) = 0;
|
||||
/**
|
||||
* @brief Obtains the interface used to install and uninstall bundles.
|
||||
* @return Returns a pointer to IBundleInstaller class if exist; returns nullptr otherwise.
|
||||
*/
|
||||
virtual sptr<IBundleInstaller> GetBundleInstaller() = 0;
|
||||
/**
|
||||
* @brief Obtains the interface used to create or delete user.
|
||||
* @return Returns a pointer to IBundleUserMgr class if exist; returns nullptr otherwise.
|
||||
*/
|
||||
virtual sptr<IBundleUserMgr> GetBundleUserMgr() = 0;
|
||||
/**
|
||||
* @brief Notify a specified ability for ability.
|
||||
* @param bundleName Indicates the bundle name of the ability to ability.
|
||||
* @param abilityName Indicates the name of the ability to ability.
|
||||
* @param launchTime Indicates the ability launchTime.
|
||||
* @return Returns true if this function is successfully called; returns false otherwise.
|
||||
*/
|
||||
virtual bool NotifyAbilityLifeStatus(
|
||||
const std::string &bundleName, const std::string &abilityName, const int64_t launchTime, const int uid = 0) = 0;
|
||||
virtual bool GetBundleGidsByUid(const std::string &bundleName, const int &uid, std::vector<int> &gids) = 0;
|
||||
virtual bool QueryAbilityInfosByUri(const std::string &abilityUri, std::vector<AbilityInfo> &abilityInfos) = 0;
|
||||
virtual int CheckPermissionByUid(
|
||||
const std::string &bundleName, const std::string &permission, const int userId) = 0;
|
||||
virtual bool GetAllCommonEventInfo(const std::string &eventKey, std::vector<CommonEventInfo> &commonEventInfos) = 0;
|
||||
virtual bool RemoveClonedBundle(const std::string &bundleName, const int32_t uid) = 0;
|
||||
virtual bool BundleClone(const std::string &bundleName) = 0;
|
||||
virtual bool CheckBundleNameInAllowList(const std::string &bundleName) = 0;
|
||||
virtual bool GetDistributedBundleInfo(
|
||||
const std::string &networkId, int32_t userId, const std::string &bundleName,
|
||||
DistributedBundleInfo &distributedBundleInfo) = 0;
|
||||
|
||||
enum class Message {
|
||||
GET_APPLICATION_INFO,
|
||||
GET_APPLICATION_INFOS,
|
||||
GET_BUNDLE_INFO,
|
||||
GET_BUNDLE_INFOS,
|
||||
GET_UID_BY_BUNDLE_NAME,
|
||||
GET_APPID_BY_BUNDLE_NAME,
|
||||
GET_BUNDLE_NAME_FOR_UID,
|
||||
GET_BUNDLES_FOR_UID,
|
||||
GET_NAME_FOR_UID,
|
||||
GET_BUNDLE_GIDS,
|
||||
GET_APP_TYPE,
|
||||
CHECK_IS_SYSTEM_APP_BY_UID,
|
||||
GET_BUNDLE_INFOS_BY_METADATA,
|
||||
QUERY_ABILITY_INFO,
|
||||
QUERY_ABILITY_INFOS,
|
||||
QUERY_ABILITY_INFO_BY_URI,
|
||||
QUERY_KEEPALIVE_BUNDLE_INFOS,
|
||||
GET_ABILITY_LABEL,
|
||||
GET_BUNDLE_ARCHIVE_INFO,
|
||||
GET_HAP_MODULE_INFO,
|
||||
GET_LAUNCH_WANT_FOR_BUNDLE,
|
||||
CHECK_PUBLICKEYS,
|
||||
CHECK_PERMISSION,
|
||||
GET_PERMISSION_DEF,
|
||||
GET_ALL_PERMISSION_GROUP_DEFS,
|
||||
GET_APPS_GRANTED_PERMISSIONS,
|
||||
HAS_SYSTEM_CAPABILITY,
|
||||
GET_SYSTEM_AVAILABLE_CAPABILITIES,
|
||||
IS_SAFE_MODE,
|
||||
CLEAN_BUNDLE_CACHE_FILES,
|
||||
CLEAN_BUNDLE_DATA_FILES,
|
||||
REGISTER_BUNDLE_STATUS_CALLBACK,
|
||||
CLEAR_BUNDLE_STATUS_CALLBACK,
|
||||
UNREGISTER_BUNDLE_STATUS_CALLBACK,
|
||||
DUMP_INFOS,
|
||||
IS_APPLICATION_ENABLED,
|
||||
SET_APPLICATION_ENABLED,
|
||||
IS_ABILITY_ENABLED,
|
||||
SET_ABILITY_ENABLED,
|
||||
GET_ABILITY_ICON,
|
||||
CAN_REQUEST_PERMISSION,
|
||||
REQUEST_PERMISSION_FROM_USER,
|
||||
REGISTER_ALL_PERMISSIONS_CHANGED,
|
||||
REGISTER_PERMISSIONS_CHANGED,
|
||||
UNREGISTER_PERMISSIONS_CHANGED,
|
||||
GET_ALL_FORMS_INFO,
|
||||
GET_FORMS_INFO_BY_APP,
|
||||
GET_FORMS_INFO_BY_MODULE,
|
||||
GET_MODULE_USAGE_RECORD,
|
||||
GET_SHORTCUT_INFO,
|
||||
GET_ALL_COMMON_EVENT_INFO,
|
||||
GET_BUNDLE_INSTALLER,
|
||||
NOTIFY_ABILITY_LIFE_STATUS,
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLEMGR_BUNDLE_MGR_INTERFACE_H
|
||||
-40
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_CLEAN_CACHE_CALLBACK_INTERFACE_H
|
||||
#define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_CLEAN_CACHE_CALLBACK_INTERFACE_H
|
||||
|
||||
#include "iremote_broker.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
class ICleanCacheCallback : public IRemoteBroker {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.CleanCacheCallback");
|
||||
|
||||
/**
|
||||
* @brief Called when clean cache files progress finished.
|
||||
* @param succeeded Indicates the result of the clean cache files progress.
|
||||
*/
|
||||
virtual void OnCleanCacheFinished(bool succeeded) = 0;
|
||||
|
||||
enum class Message {
|
||||
ON_CLEAN_CACHE_CALLBACK,
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_CLEAN_CACHE_CALLBACK_INTERFACE_H
|
||||
+1
-1
@@ -217,7 +217,6 @@ public:
|
||||
|
||||
class BundleMgrStub : public IRemoteStub<IBundleMgr> {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"IBundleMgr");
|
||||
virtual int OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
};
|
||||
@@ -228,6 +227,7 @@ public:
|
||||
~BundleMgrService();
|
||||
|
||||
bool QueryAbilityInfo(const AAFwk::Want &want, AbilityInfo &abilityInfo) override;
|
||||
bool QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo) override;
|
||||
bool QueryAbilityInfoByUri(const std::string &uri, AbilityInfo &abilityInfo) override;
|
||||
bool GetApplicationInfo(
|
||||
const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo) override;
|
||||
|
||||
+8
-3
@@ -23,7 +23,6 @@
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
using namespace OHOS::AAFwk;
|
||||
|
||||
int BundleMgrProxy::QueryWantAbility(
|
||||
const AAFwk::Want &__attribute__((unused)) want, std::vector<AbilityInfo> &__attribute__((unused)) abilityInfos)
|
||||
{
|
||||
@@ -144,6 +143,11 @@ bool BundleMgrService::QueryAbilityInfo(const AAFwk::Want &want, AbilityInfo &ab
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BundleMgrService::QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo)
|
||||
{
|
||||
return QueryAbilityInfo(want, abilityInfo);
|
||||
}
|
||||
|
||||
bool BundleMgrService::QueryAbilityInfoByUri(const std::string &uri, AbilityInfo &abilityInfo)
|
||||
{
|
||||
return false;
|
||||
@@ -155,13 +159,15 @@ bool BundleMgrService::GetApplicationInfo(
|
||||
if (appName.empty()) {
|
||||
return false;
|
||||
}
|
||||
appInfo.name = "Helloworld";
|
||||
appInfo.bundleName = "com.ix.hiworld";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BundleMgrService::CheckIsSystemAppByUid(const int uid)
|
||||
{
|
||||
int maxSysUid {MAX_SYS_UID};
|
||||
int baseSysUid{ROOT_UID};
|
||||
int baseSysUid {ROOT_UID};
|
||||
if (uid >= baseSysUid && uid <= maxSysUid) {
|
||||
return true;
|
||||
}
|
||||
@@ -208,6 +214,5 @@ bool BundleMgrService::NotifyAbilityLifeStatus(
|
||||
GTEST_LOG_(INFO) << "BundleMgrService::NotifyAbilityLifeStatus()";
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -34,6 +34,16 @@ SaMgrClient::~SaMgrClient()
|
||||
sptr<IRemoteObject> SaMgrClient::GetSystemAbility(const int32_t systemAbilityId)
|
||||
{
|
||||
HILOG_INFO("Test GetSystemAbility id : %{public}d", systemAbilityId);
|
||||
if (servicesMap_[systemAbilityId] == nullptr) {
|
||||
OHOS::sptr<ISystemAbilityManager> systemAbilityManager =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemAbilityManager == nullptr) {
|
||||
HILOG_ERROR("%s:fail to get Registry", __func__);
|
||||
return nullptr;
|
||||
}
|
||||
OHOS::sptr<OHOS::IRemoteObject> object = systemAbilityManager->GetSystemAbility(systemAbilityId);
|
||||
servicesMap_[systemAbilityId] = object;
|
||||
}
|
||||
return servicesMap_[systemAbilityId];
|
||||
}
|
||||
|
||||
|
||||
+12
-9
@@ -97,8 +97,8 @@ public:
|
||||
static constexpr int TEST_WAIT_TIME = 100000;
|
||||
|
||||
public:
|
||||
AbilityRequest abilityRequest_;
|
||||
std::shared_ptr<AbilityManagerService> abilityMs_ {nullptr};
|
||||
AbilityRequest abilityRequest_ {};
|
||||
std::shared_ptr<AbilityRecord> abilityRecord_ {nullptr};
|
||||
};
|
||||
|
||||
@@ -128,12 +128,12 @@ void AbilityManagerServiceTest::OnStartAms()
|
||||
|
||||
abilityMs_->handler_ = std::make_shared<AbilityEventHandler>(abilityMs_->eventLoop_, abilityMs_);
|
||||
abilityMs_->connectManager_ = std::make_shared<AbilityConnectManager>();
|
||||
abilityMs_->connectManagers_.emplace(0, abilityMs_->connectManager_);
|
||||
EXPECT_TRUE(abilityMs_->handler_);
|
||||
EXPECT_TRUE(abilityMs_->connectManager_);
|
||||
|
||||
abilityMs_->connectManager_->SetEventHandler(abilityMs_->handler_);
|
||||
|
||||
abilityMs_->dataAbilityManager_ = std::make_shared<DataAbilityManager>();
|
||||
abilityMs_->dataAbilityManagers_.emplace(0, abilityMs_->dataAbilityManager_);
|
||||
EXPECT_TRUE(abilityMs_->dataAbilityManager_);
|
||||
|
||||
abilityMs_->amsConfigResolver_ = std::make_shared<AmsConfigurationParameter>();
|
||||
@@ -143,13 +143,16 @@ void AbilityManagerServiceTest::OnStartAms()
|
||||
abilityMs_->pendingWantManager_ = std::make_shared<PendingWantManager>();
|
||||
EXPECT_TRUE(abilityMs_->pendingWantManager_);
|
||||
|
||||
abilityMs_->kernalAbilityManager_ = std::make_shared<KernalAbilityManager>(0);
|
||||
abilityMs_->currentMissionListManager_ = std::make_shared<MissionListManager>(0);
|
||||
abilityMs_->currentMissionListManager_->Init();
|
||||
int userId = abilityMs_->GetUserId();
|
||||
abilityMs_->SetStackManager(userId, true);
|
||||
EXPECT_TRUE(abilityMs_->GetStackManager());
|
||||
abilityMs_->stackManagers_.emplace(0, abilityMs_->GetStackManager());
|
||||
abilityMs_->systemAppManager_ = std::make_shared<KernalSystemAppManager>(userId);
|
||||
EXPECT_TRUE(abilityMs_->systemAppManager_);
|
||||
|
||||
abilityMs_->eventLoop_->Run();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1589,9 +1592,8 @@ HWTEST_F(AbilityManagerServiceTest, startAbility_004, TestSize.Level1)
|
||||
HWTEST_F(AbilityManagerServiceTest, startContinuation_001, TestSize.Level1)
|
||||
{
|
||||
Want want;
|
||||
ElementName element("device", "com.ix.musicService", "MusicService");
|
||||
ElementName element("", "com.ix.musicService", "MusicService");
|
||||
want.SetElement(element);
|
||||
|
||||
sptr<IRemoteObject> abilityToken = new (std::nothrow) MockAbilityToken();
|
||||
auto result = abilityMs_->StartContinuation(want, abilityToken, 0);
|
||||
EXPECT_EQ(OHOS::ERR_INVALID_VALUE, result);
|
||||
@@ -1611,7 +1613,6 @@ HWTEST_F(AbilityManagerServiceTest, startContinuation_002, TestSize.Level1)
|
||||
EXPECT_EQ(true, getLocalDeviceId);
|
||||
ElementName element(localDeviceId, "com.ix.hiMusic", "MusicAbility");
|
||||
want.SetElement(element);
|
||||
|
||||
sptr<IRemoteObject> abilityToken = new (std::nothrow) MockAbilityToken();
|
||||
auto result = abilityMs_->StartContinuation(want, abilityToken, 0);
|
||||
EXPECT_NE(OHOS::ERR_OK, result);
|
||||
@@ -1675,7 +1676,7 @@ HWTEST_F(AbilityManagerServiceTest, NotifyContinuationResult_001, TestSize.Level
|
||||
int32_t missionId = 0;
|
||||
int32_t isSuccess = 0;
|
||||
auto result = abilityMs_->NotifyContinuationResult(missionId, isSuccess);
|
||||
EXPECT_EQ(OHOS::ERR_INVALID_VALUE, result);
|
||||
EXPECT_EQ(OHOS::ERR_OK, result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1963,10 +1964,12 @@ HWTEST_F(AbilityManagerServiceTest, systemDialog_002, TestSize.Level1)
|
||||
Want want;
|
||||
ElementName elementdialog("device", AbilityConfig::SYSTEM_UI_BUNDLE_NAME, AbilityConfig::SYSTEM_DIALOG_NAME);
|
||||
want.SetElement(elementdialog);
|
||||
EXPECT_TRUE(abilityMs_->GetStackManager());
|
||||
auto result = StartAbility(want);
|
||||
EXPECT_EQ(OHOS::ERR_OK, result);
|
||||
auto stackManager = abilityMs_->GetStackManager();
|
||||
auto dialogAbility = stackManager->GetCurrentTopAbility();
|
||||
EXPECT_TRUE(dialogAbility);
|
||||
auto dialogtoken = dialogAbility->GetToken();
|
||||
EXPECT_TRUE(dialogAbility->GetAbilityInfo().bundleName == AbilityConfig::SYSTEM_UI_BUNDLE_NAME);
|
||||
|
||||
|
||||
+6
@@ -95,12 +95,14 @@ void AbilityWithApplicationsTest::OnStartabilityAms()
|
||||
|
||||
abilityMs_->handler_ = std::make_shared<AbilityEventHandler>(abilityMs_->eventLoop_, abilityMs_);
|
||||
abilityMs_->connectManager_ = std::make_shared<AbilityConnectManager>();
|
||||
abilityMs_->connectManagers_.emplace(0, abilityMs_->connectManager_);
|
||||
EXPECT_TRUE(abilityMs_->handler_);
|
||||
EXPECT_TRUE(abilityMs_->connectManager_);
|
||||
|
||||
abilityMs_->connectManager_->SetEventHandler(abilityMs_->handler_);
|
||||
|
||||
abilityMs_->dataAbilityManager_ = std::make_shared<DataAbilityManager>();
|
||||
abilityMs_->dataAbilityManagers_.emplace(0, abilityMs_->dataAbilityManager_);
|
||||
EXPECT_TRUE(abilityMs_->dataAbilityManager_);
|
||||
|
||||
abilityMs_->amsConfigResolver_ = std::make_shared<AmsConfigurationParameter>();
|
||||
@@ -110,6 +112,10 @@ void AbilityWithApplicationsTest::OnStartabilityAms()
|
||||
abilityMs_->pendingWantManager_ = std::make_shared<PendingWantManager>();
|
||||
EXPECT_TRUE(abilityMs_->pendingWantManager_);
|
||||
|
||||
abilityMs_->kernalAbilityManager_ = std::make_shared<KernalAbilityManager>(0);
|
||||
abilityMs_->currentMissionListManager_ = std::make_shared<MissionListManager>(0);
|
||||
abilityMs_->currentMissionListManager_->Init();
|
||||
|
||||
int userId = abilityMs_->GetUserId();
|
||||
abilityMs_->SetStackManager(userId, true);
|
||||
abilityMs_->systemAppManager_ = std::make_shared<KernalSystemAppManager>(userId);
|
||||
|
||||
+12
-8
@@ -82,7 +82,7 @@ public:
|
||||
void OnStartabilityAms();
|
||||
std::shared_ptr<AbilityRecord> GetAbilityRecord() const;
|
||||
void ResetAbilityRecord();
|
||||
void startAbility();
|
||||
void StartAbility();
|
||||
|
||||
public:
|
||||
std::shared_ptr<AbilityRecord> abilityRecord_ {nullptr};
|
||||
@@ -104,6 +104,8 @@ void AbilityMsAppmsTest::OnStartabilityAms()
|
||||
|
||||
abilityMs_->handler_ = std::make_shared<AbilityEventHandler>(abilityMs_->eventLoop_, abilityMs_);
|
||||
abilityMs_->connectManager_ = std::make_shared<AbilityConnectManager>();
|
||||
abilityMs_->dataAbilityManager_ = std::make_shared<DataAbilityManager>();
|
||||
abilityMs_->dataAbilityManagers_.emplace(0, abilityMs_->dataAbilityManager_);
|
||||
EXPECT_TRUE(abilityMs_->handler_);
|
||||
EXPECT_TRUE(abilityMs_->connectManager_);
|
||||
|
||||
@@ -139,22 +141,20 @@ void AbilityMsAppmsTest::TearDownTestCase(void)
|
||||
|
||||
void AbilityMsAppmsTest::SetUp(void)
|
||||
{
|
||||
sptr<OHOS::IRemoteObject> bundleObject = new BundleMgrService();
|
||||
DelayedSingleton<SaMgrClient>::GetInstance()->RegisterSystemAbility(
|
||||
OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID, bundleObject);
|
||||
OHOS::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID, new BundleMgrService());
|
||||
DelayedSingleton<AppScheduler>::GetInstance();
|
||||
|
||||
callback_ = std::make_shared<AppStateCallbackS>();
|
||||
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->Init(callback_);
|
||||
abilityMs_ = DelayedSingleton<AbilityManagerService>::GetInstance();
|
||||
OnStartabilityAms();
|
||||
startAbility();
|
||||
StartAbility();
|
||||
GTEST_LOG_(INFO) << "SetUp";
|
||||
}
|
||||
|
||||
void AbilityMsAppmsTest::TearDown(void)
|
||||
{
|
||||
OHOS::DelayedSingleton<SaMgrClient>::DestroyInstance();
|
||||
DelayedSingleton<AbilityManagerService>::DestroyInstance();
|
||||
GTEST_LOG_(INFO) << "TearDown";
|
||||
}
|
||||
@@ -180,7 +180,7 @@ void AbilityMsAppmsTest::ResetAbilityRecord()
|
||||
abilityRecord_->Init();
|
||||
}
|
||||
|
||||
void AbilityMsAppmsTest::startAbility()
|
||||
void AbilityMsAppmsTest::StartAbility()
|
||||
{
|
||||
Want want;
|
||||
AbilityInfo abilityInfo;
|
||||
@@ -276,11 +276,13 @@ HWTEST_F(AbilityMsAppmsTest, AaFwk_AbilityMS_AppMS_004, TestSize.Level1)
|
||||
sptr<AbilityScheduler> scheduler = new AbilityScheduler();
|
||||
std::shared_ptr<AbilityRecord> abilityRecord = nullptr;
|
||||
sptr<Token> token = nullptr;
|
||||
|
||||
auto checkStateFun = [&scheduler, &token, &abilityRecord]() {
|
||||
auto stackManager = DelayedSingleton<AbilityManagerService>::GetInstance()->GetStackManager();
|
||||
EXPECT_TRUE(stackManager);
|
||||
abilityRecord = stackManager->GetCurrentTopAbility();
|
||||
EXPECT_TRUE(abilityRecord);
|
||||
token = abilityRecord->GetToken();
|
||||
EXPECT_TRUE(token);
|
||||
DelayedSingleton<AbilityManagerService>::GetInstance()->AttachAbilityThread(scheduler, token);
|
||||
};
|
||||
|
||||
@@ -315,7 +317,9 @@ HWTEST_F(AbilityMsAppmsTest, AaFwk_AbilityMS_AppMS_005, TestSize.Level1)
|
||||
auto checkSourceActivtingState = [&stackManager, &sourceAbilityRecord, &scheduler, &sourcetoken]() {
|
||||
stackManager = DelayedSingleton<AbilityManagerService>::GetInstance()->GetStackManager();
|
||||
sourceAbilityRecord = stackManager->GetCurrentTopAbility();
|
||||
EXPECT_TRUE(sourceAbilityRecord);
|
||||
sourcetoken = sourceAbilityRecord->GetToken();
|
||||
EXPECT_TRUE(sourcetoken);
|
||||
DelayedSingleton<AbilityManagerService>::GetInstance()->AttachAbilityThread(scheduler, sourcetoken);
|
||||
auto sourceAbilityInfo = sourceAbilityRecord->GetAbilityInfo();
|
||||
EXPECT_EQ(sourceAbilityInfo.bundleName, "com.ix.hiworld");
|
||||
|
||||
+4
-3
@@ -46,9 +46,10 @@ using OHOS::AppExecFwk::ElementName;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace {
|
||||
#define SLEEP(milli) std::this_thread::sleep_for(std::chrono::seconds(milli))
|
||||
|
||||
namespace {} // namespace
|
||||
const int INVALID_CALLER_UID_ERR = 29360128;
|
||||
} // namespace
|
||||
class PendingWantRecordTest : public testing::Test {
|
||||
public:
|
||||
static void SetUpTestCase();
|
||||
@@ -330,7 +331,7 @@ HWTEST_F(PendingWantRecordTest, PendingWantRecordTest_0800, TestSize.Level1)
|
||||
std::make_shared<PendingWantRecord>(pendingManager_, 1, nullptr, key);
|
||||
EXPECT_NE(pendingWantRecord, nullptr);
|
||||
SenderInfo info;
|
||||
EXPECT_EQ(pendingWantRecord->SenderInner(info), NO_ERROR);
|
||||
EXPECT_EQ(pendingWantRecord->SenderInner(info), INVALID_CALLER_UID_ERR);
|
||||
EXPECT_TRUE(info.resolvedType == key->GetRequestResolvedType());
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -138,12 +138,14 @@ void TerminateAbilityTest::OnStartAms()
|
||||
|
||||
g_aams->handler_ = std::make_shared<AbilityEventHandler>(g_aams->eventLoop_, g_aams);
|
||||
g_aams->connectManager_ = std::make_shared<AbilityConnectManager>();
|
||||
g_aams->connectManagers_.emplace(0, g_aams->connectManager_);
|
||||
EXPECT_TRUE(g_aams->handler_);
|
||||
EXPECT_TRUE(g_aams->connectManager_);
|
||||
|
||||
g_aams->connectManager_->SetEventHandler(g_aams->handler_);
|
||||
|
||||
g_aams->dataAbilityManager_ = std::make_shared<DataAbilityManager>();
|
||||
g_aams->dataAbilityManagers_.emplace(0, g_aams->dataAbilityManager_);
|
||||
EXPECT_TRUE(g_aams->dataAbilityManager_);
|
||||
|
||||
g_aams->amsConfigResolver_ = std::make_shared<AmsConfigurationParameter>();
|
||||
@@ -153,6 +155,10 @@ void TerminateAbilityTest::OnStartAms()
|
||||
g_aams->pendingWantManager_ = std::make_shared<PendingWantManager>();
|
||||
EXPECT_TRUE(g_aams->pendingWantManager_);
|
||||
|
||||
g_aams->kernalAbilityManager_ = std::make_shared<KernalAbilityManager>(0);
|
||||
g_aams->currentMissionListManager_ = std::make_shared<MissionListManager>(0);
|
||||
g_aams->currentMissionListManager_->Init();
|
||||
|
||||
int userId = g_aams->GetUserId();
|
||||
g_aams->SetStackManager(userId, true);
|
||||
g_aams->systemAppManager_ = std::make_shared<KernalSystemAppManager>(userId);
|
||||
|
||||
@@ -237,7 +237,6 @@ public:
|
||||
|
||||
class BundleMgrStub : public IRemoteStub<IBundleMgr> {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"IBundleMgr");
|
||||
virtual int OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
};
|
||||
|
||||
@@ -255,7 +255,6 @@ public:
|
||||
|
||||
class BundleMgrStub : public IRemoteStub<IBundleMgr> {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"IBundleMgr");
|
||||
virtual int OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
};
|
||||
|
||||
@@ -264,7 +264,6 @@ public:
|
||||
|
||||
class BundleMgrStub : public IRemoteStub<IBundleMgr> {
|
||||
public:
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"IBundleMgr");
|
||||
virtual int OnRemoteRequest(
|
||||
uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user