mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-24 12:43:16 -04:00
!173 Modify test code
Merge pull request !173 from blackleon/master_1108
This commit is contained in:
@@ -262,12 +262,9 @@ ohos_unittest("ability_context_test") {
|
||||
|
||||
deps = [
|
||||
"${INNERKITS_PATH}/want:want",
|
||||
"//base/global/resmgr_standard/frameworks/resmgr:global_resmgr",
|
||||
"//foundation/aafwk/standard/frameworks/kits/ability/native:abilitykit_native",
|
||||
"//foundation/aafwk/standard/frameworks/kits/ability/native:dummy_classes",
|
||||
"//foundation/aafwk/standard/interfaces/innerkits/ability_manager:ability_manager",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/appexecfwk_base:appexecfwk_base",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler:libeventhandler",
|
||||
"//foundation/appexecfwk/standard/kits:appkit_native",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy",
|
||||
"//third_party/googletest:gmock_main",
|
||||
@@ -278,7 +275,6 @@ ohos_unittest("ability_context_test") {
|
||||
external_deps = [
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"multimodalinput_base:libmmi-client",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,9 @@ using OHOS::AAFwk::Want;
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
struct FormInfo;
|
||||
struct ShortcutInfo;
|
||||
|
||||
enum class DumpFlag {
|
||||
DUMP_BUNDLE_LIST = 1,
|
||||
DUMP_ALL_BUNDLE_INFO,
|
||||
@@ -169,6 +172,7 @@ public:
|
||||
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;
|
||||
@@ -205,11 +209,16 @@ public:
|
||||
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 GetModuleUsageRecords(
|
||||
const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords) = 0;
|
||||
virtual bool NotifyActivityLifeStatus(
|
||||
const std::string &bundleName, const std::string &abilityName, const int64_t launchTime) = 0;
|
||||
|
||||
enum class Message {
|
||||
GET_APPLICATION_INFO,
|
||||
GET_APPLICATION_INFOS,
|
||||
@@ -225,6 +234,8 @@ public:
|
||||
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,
|
||||
@@ -255,9 +266,15 @@ public:
|
||||
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_ACTIVITY_LIFE_STATUS,
|
||||
};
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_BUNDLEMGR_INCLUDE_MOCK_BUNDLE_MGR_INTERFACE_H
|
||||
#endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_BUNDLEMGR_INCLUDE_MOCK_BUNDLE_MGR_INTERFACE_H
|
||||
|
||||
@@ -21,7 +21,67 @@
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
|
||||
bool BundleMgrProxy::QueryAbilityInfo(const AAFwk::Want &want, AbilityInfo &abilityInfo)
|
||||
bool BundleMgrProxy::GetApplicationInfo(
|
||||
const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo)
|
||||
{
|
||||
if (appName.empty()) {
|
||||
return false;
|
||||
}
|
||||
appInfo.name = "Helloworld";
|
||||
appInfo.bundleName = "com.ohos.hiworld";
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetApplicationInfos(
|
||||
const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos)
|
||||
{
|
||||
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;
|
||||
}
|
||||
std::string BundleMgrProxy::GetAppIdByBundleName(const std::string &bundleName, const int userId)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
bool BundleMgrProxy::GetBundleNameForUid(const int uid, std::string &bundleName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetNameForUid(const int uid, std::string &name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetBundleGids(const std::string &bundleName, std::vector<int> &gids)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
std::string BundleMgrProxy::GetAppType(const std::string &bundleName)
|
||||
{
|
||||
GTEST_LOG_(INFO) << " BundleMgrProxy::GetAppTyp";
|
||||
return "system";
|
||||
}
|
||||
bool BundleMgrProxy::CheckIsSystemAppByUid(const int uid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo)
|
||||
{
|
||||
ElementName eleName = want.GetElement();
|
||||
if (eleName.GetBundleName().empty()) {
|
||||
@@ -33,35 +93,240 @@ bool BundleMgrProxy::QueryAbilityInfo(const AAFwk::Want &want, AbilityInfo &abil
|
||||
abilityInfo.applicationName = "Helloworld";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BundleMgrProxy::QueryAbilityInfoByUri(const std::string &uri, AbilityInfo &abilityInfo)
|
||||
bool BundleMgrProxy::QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::QueryAbilityInfosForClone(const Want &want, std::vector<AbilityInfo> &abilityInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
bool BundleMgrProxy::QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
std::string BundleMgrProxy::GetAbilityLabel(const std::string &bundleName, const std::string &className)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
bool BundleMgrProxy::GetBundleArchiveInfo(
|
||||
const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo)
|
||||
{
|
||||
GTEST_LOG_(INFO) << " BundleMgrProxy::GetHapModuleInfo";
|
||||
hapModuleInfo.name = abilityInfo.package;
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetLaunchWantForBundle(const std::string &bundleName, Want &want)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int BundleMgrProxy::CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int BundleMgrProxy::CheckPermission(const std::string &bundleName, const std::string &permission)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
bool BundleMgrProxy::GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetAllPermissionGroupDefs(std::vector<PermissionDef> &permissionDefs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetAppsGrantedPermissions(
|
||||
const std::vector<std::string> &permissions, std::vector<std::string> &appNames)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::HasSystemCapability(const std::string &capName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetSystemAvailableCapabilities(std::vector<std::string> &systemCaps)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::IsSafeMode()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::CleanBundleCacheFiles(
|
||||
const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::CleanBundleDataFiles(const std::string &bundleName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::UnregisterBundleStatusCallback()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::DumpInfos(const DumpFlag flag, const std::string &bundleName, std::string &result)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::IsApplicationEnabled(const std::string &bundleName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::SetApplicationEnabled(const std::string &bundleName, bool isEnable)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::IsAbilityEnabled(const AbilityInfo &abilityInfo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
std::string BundleMgrProxy::GetAbilityIcon(const std::string &bundleName, const std::string &className)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
bool BundleMgrProxy::CanRequestPermission(
|
||||
const std::string &bundleName, const std::string &permissionName, const int userId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::RequestPermissionFromUser(
|
||||
const std::string &bundleName, const std::string &permission, const int userId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::RegisterAllPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::RegisterPermissionsChanged(
|
||||
const std::vector<int> &uids, const sptr<OnPermissionChangedCallback> &callback)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::UnregisterPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetAllFormsInfo(std::vector<FormInfo> &formInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetFormsInfoByModule(
|
||||
const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrProxy::GetModuleUsageRecords(const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
sptr<IBundleInstaller> BundleMgrProxy::GetBundleInstaller()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
bool BundleMgrProxy::NotifyActivityLifeStatus(
|
||||
const std::string &bundleName, const std::string &abilityName, const int64_t launchTime)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BundleMgrProxy::GetApplicationInfo(
|
||||
int BundleMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
GTEST_LOG_(INFO) << " BundleMgrStub::OnRemoteRequest";
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool BundleMgrService::GetApplicationInfo(
|
||||
const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo)
|
||||
{
|
||||
if (appName.empty()) {
|
||||
return false;
|
||||
}
|
||||
appInfo.name = "Helloworld";
|
||||
appInfo.bundleName = "com.ohos.hiworld";
|
||||
appInfo.bundleName = "com.foobar.hiworld";
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string BundleMgrProxy::GetAppType(const std::string &bundleName)
|
||||
bool BundleMgrService::GetApplicationInfos(
|
||||
const ApplicationFlag flag, const int userId, std::vector<ApplicationInfo> &appInfos)
|
||||
{
|
||||
GTEST_LOG_(INFO) << " BundleMgrProxy::GetAppTyp";
|
||||
return "system";
|
||||
return true;
|
||||
}
|
||||
|
||||
int BundleMgrStub::OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
|
||||
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;
|
||||
}
|
||||
|
||||
bool BundleMgrService::QueryAbilityInfo(const AAFwk::Want &want, AbilityInfo &abilityInfo)
|
||||
std::string BundleMgrService::GetAppIdByBundleName(const std::string &bundleName, const int userId)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
bool BundleMgrService::GetBundleNameForUid(const int uid, std::string &bundleName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetNameForUid(const int uid, std::string &name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetBundleGids(const std::string &bundleName, std::vector<int> &gids)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
std::string BundleMgrService::GetAppType(const std::string &bundleName)
|
||||
{
|
||||
GTEST_LOG_(INFO) << " BundleMgrService::GetAppType";
|
||||
return "system";
|
||||
}
|
||||
bool BundleMgrService::CheckIsSystemAppByUid(const int uid)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo)
|
||||
{
|
||||
ElementName elementName = want.GetElement();
|
||||
if (elementName.GetBundleName().empty()) {
|
||||
@@ -81,33 +346,170 @@ bool BundleMgrService::QueryAbilityInfo(const AAFwk::Want &want, AbilityInfo &ab
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BundleMgrService::QueryAbilityInfoByUri(const std::string &uri, AbilityInfo &abilityInfo)
|
||||
bool BundleMgrService::QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::QueryAbilityInfosForClone(const Want &want, std::vector<AbilityInfo> &abilityInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BundleMgrService::GetApplicationInfo(
|
||||
const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo)
|
||||
bool BundleMgrService::QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos)
|
||||
{
|
||||
if (appName.empty()) {
|
||||
return false;
|
||||
}
|
||||
appInfo.name = "Helloworld";
|
||||
appInfo.bundleName = "com.foobar.hiworld";
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string BundleMgrService::GetAppType(const std::string &bundleName)
|
||||
std::string BundleMgrService::GetAbilityLabel(const std::string &bundleName, const std::string &className)
|
||||
{
|
||||
GTEST_LOG_(INFO) << " BundleMgrService::GetAppType";
|
||||
return "system";
|
||||
return "";
|
||||
}
|
||||
bool BundleMgrService::GetBundleArchiveInfo(
|
||||
const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BundleMgrService::GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo)
|
||||
{
|
||||
GTEST_LOG_(INFO) << " BundleMgrService::GetHapModuleInfo";
|
||||
hapModuleInfo.name = "Captain";
|
||||
hapModuleInfo.name = abilityInfo.package;
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetLaunchWantForBundle(const std::string &bundleName, Want &want)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int BundleMgrService::CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int BundleMgrService::CheckPermission(const std::string &bundleName, const std::string &permission)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
bool BundleMgrService::GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetAllPermissionGroupDefs(std::vector<PermissionDef> &permissionDefs)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetAppsGrantedPermissions(
|
||||
const std::vector<std::string> &permissions, std::vector<std::string> &appNames)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::HasSystemCapability(const std::string &capName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetSystemAvailableCapabilities(std::vector<std::string> &systemCaps)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::IsSafeMode()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::CleanBundleCacheFiles(
|
||||
const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::CleanBundleDataFiles(const std::string &bundleName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::UnregisterBundleStatusCallback()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::DumpInfos(const DumpFlag flag, const std::string &bundleName, std::string &result)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::IsApplicationEnabled(const std::string &bundleName)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::SetApplicationEnabled(const std::string &bundleName, bool isEnable)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::IsAbilityEnabled(const AbilityInfo &abilityInfo)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
std::string BundleMgrService::GetAbilityIcon(const std::string &bundleName, const std::string &className)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
bool BundleMgrService::CanRequestPermission(
|
||||
const std::string &bundleName, const std::string &permissionName, const int userId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::RequestPermissionFromUser(
|
||||
const std::string &bundleName, const std::string &permission, const int userId)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::RegisterAllPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::RegisterPermissionsChanged(
|
||||
const std::vector<int> &uids, const sptr<OnPermissionChangedCallback> &callback)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::UnregisterPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetAllFormsInfo(std::vector<FormInfo> &formInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetFormsInfoByModule(
|
||||
const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
bool BundleMgrService::GetModuleUsageRecords(const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
sptr<IBundleInstaller> BundleMgrService::GetBundleInstaller()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
bool BundleMgrService::NotifyActivityLifeStatus(
|
||||
const std::string &bundleName, const std::string &abilityName, const int64_t launchTime)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#define OHOS_AAFWK_ABILITY_MOCK_BUNDLE_MANAGER_H
|
||||
|
||||
#include <vector>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "ability_info.h"
|
||||
#include "application_info.h"
|
||||
@@ -33,202 +34,70 @@ public:
|
||||
{}
|
||||
~BundleMgrProxy() = default;
|
||||
|
||||
virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) override;
|
||||
virtual bool QueryAbilityInfoByUri(const std::string &uri, AbilityInfo &abilityInfo) override;
|
||||
|
||||
virtual std::string GetAppType(const std::string &bundleName) override;
|
||||
|
||||
virtual bool GetApplicationInfo(
|
||||
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
|
||||
{
|
||||
return true;
|
||||
};
|
||||
bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
bool CheckIsSystemAppByUid(const int uid) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetBundleInfos(const BundleFlag flag, std::vector<BundleInfo> &bundleInfos) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual int GetUidByBundleName(const std::string &bundleName, const int userId) override
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &className) override
|
||||
{
|
||||
return "";
|
||||
};
|
||||
// obtains information about an application bundle contained in a OHOS Ability Package (HAP).
|
||||
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 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;
|
||||
virtual bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) override;
|
||||
virtual bool GetNameForUid(const int uid, std::string &name) override;
|
||||
virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) override;
|
||||
virtual std::string GetAppType(const std::string &bundleName) override;
|
||||
virtual bool CheckIsSystemAppByUid(const int uid) override;
|
||||
virtual bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) override;
|
||||
virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) override;
|
||||
virtual bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos) override;
|
||||
virtual bool QueryAbilityInfosForClone(const Want &want, std::vector<AbilityInfo> &abilityInfos) override;
|
||||
virtual bool QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) override;
|
||||
virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) override;
|
||||
virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &className) override;
|
||||
virtual bool GetBundleArchiveInfo(
|
||||
const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) override;
|
||||
virtual bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) override;
|
||||
// obtains the Want for starting the main ability of an application based on the given bundle name.
|
||||
virtual bool GetLaunchWantForBundle(const std::string &bundleName, Want &want) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
// checks whether the publickeys of two bundles are the same.
|
||||
virtual int CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName) override
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
// checks whether a specified bundle has been granted a specific permission.
|
||||
virtual int CheckPermission(const std::string &bundleName, const std::string &permission) override
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
virtual bool GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetAllPermissionGroupDefs(std::vector<PermissionDef> &permissionDefs) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetLaunchWantForBundle(const std::string &bundleName, Want &want) override;
|
||||
virtual int CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName) override;
|
||||
virtual int CheckPermission(const std::string &bundleName, const std::string &permission) override;
|
||||
virtual bool GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) override;
|
||||
virtual bool GetAllPermissionGroupDefs(std::vector<PermissionDef> &permissionDefs) override;
|
||||
virtual bool GetAppsGrantedPermissions(
|
||||
const std::vector<std::string> &permissions, std::vector<std::string> &appNames) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool HasSystemCapability(const std::string &capName) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetSystemAvailableCapabilities(std::vector<std::string> &systemCaps) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool IsSafeMode() override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
// clears cache data of a specified application.
|
||||
const std::vector<std::string> &permissions, std::vector<std::string> &appNames) override;
|
||||
virtual bool HasSystemCapability(const std::string &capName) override;
|
||||
virtual bool GetSystemAvailableCapabilities(std::vector<std::string> &systemCaps) override;
|
||||
virtual bool IsSafeMode() override;
|
||||
virtual bool CleanBundleCacheFiles(
|
||||
const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool CleanBundleDataFiles(const std::string &bundleName) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
// unregister callback of all application
|
||||
virtual bool UnregisterBundleStatusCallback() override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool DumpInfos(const DumpFlag flag, const std::string &bundleName, std::string &result) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual sptr<IBundleInstaller> GetBundleInstaller() override
|
||||
{
|
||||
return nullptr;
|
||||
};
|
||||
const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback) override;
|
||||
virtual bool CleanBundleDataFiles(const std::string &bundleName) override;
|
||||
virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override;
|
||||
virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override;
|
||||
virtual bool UnregisterBundleStatusCallback() override;
|
||||
virtual bool DumpInfos(const DumpFlag flag, const std::string &bundleName, std::string &result) override;
|
||||
virtual bool IsApplicationEnabled(const std::string &bundleName) override;
|
||||
virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) override;
|
||||
virtual bool IsAbilityEnabled(const AbilityInfo &abilityInfo) override;
|
||||
virtual bool SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled) override;
|
||||
virtual std::string GetAbilityIcon(const std::string &bundleName, const std::string &className) override;
|
||||
virtual bool CanRequestPermission(
|
||||
const std::string &bundleName, const std::string &permissionName, const int userId) override
|
||||
{
|
||||
printf("===================22222222===========\n");
|
||||
return false;
|
||||
}
|
||||
const std::string &bundleName, const std::string &permissionName, const int userId) override;
|
||||
virtual bool RequestPermissionFromUser(
|
||||
const std::string &bundleName, const std::string &permission, const int userId) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual std::string GetAppIdByBundleName(const std::string &bundleName, const int userId) override
|
||||
{
|
||||
return "";
|
||||
}
|
||||
virtual bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool GetNameForUid(const int uid, std::string &name) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool IsAbilityEnabled(const AbilityInfo &abilityInfo) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual std::string GetAbilityIcon(const std::string &bundleName, const std::string &className) override
|
||||
{
|
||||
return "";
|
||||
}
|
||||
virtual bool RegisterAllPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
const std::string &bundleName, const std::string &permission, const int userId) override;
|
||||
virtual bool RegisterAllPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) override;
|
||||
virtual bool RegisterPermissionsChanged(
|
||||
const std::vector<int> &uids, const sptr<OnPermissionChangedCallback> &callback) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool UnregisterPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool IsApplicationEnabled(const std::string &bundleName) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
const std::vector<int> &uids, const sptr<OnPermissionChangedCallback> &callback) override;
|
||||
virtual bool UnregisterPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) override;
|
||||
virtual bool GetAllFormsInfo(std::vector<FormInfo> &formInfos) override;
|
||||
virtual bool GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos) override;
|
||||
virtual bool GetFormsInfoByModule(
|
||||
const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos) override;
|
||||
virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) override;
|
||||
virtual bool GetModuleUsageRecords(
|
||||
const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords) override;
|
||||
virtual sptr<IBundleInstaller> GetBundleInstaller() override;
|
||||
virtual bool NotifyActivityLifeStatus(
|
||||
const std::string &bundleName, const std::string &abilityName, const int64_t launchTime) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
const std::string &bundleName, const std::string &abilityName, const int64_t launchTime) override;
|
||||
};
|
||||
|
||||
class BundleMgrStub : public IRemoteStub<IBundleMgr> {
|
||||
@@ -240,202 +109,70 @@ public:
|
||||
|
||||
class BundleMgrService : public BundleMgrStub {
|
||||
public:
|
||||
virtual bool QueryAbilityInfo(const AAFwk::Want &want, AbilityInfo &abilityInfo) override;
|
||||
virtual bool QueryAbilityInfoByUri(const std::string &uri, AbilityInfo &abilityInfo) override;
|
||||
|
||||
virtual std::string GetAppType(const std::string &bundleName) override;
|
||||
|
||||
virtual bool GetApplicationInfo(
|
||||
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
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool CheckIsSystemAppByUid(const int uid) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetBundleInfos(const BundleFlag flag, std::vector<BundleInfo> &bundleInfos) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual int GetUidByBundleName(const std::string &bundleName, const int userId) override
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
virtual bool GetBundleNameForUid(const int uid, std::string &bundleName) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &className) override
|
||||
{
|
||||
return "";
|
||||
};
|
||||
// obtains information about an application bundle contained in a OHOS Ability Package (HAP).
|
||||
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 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;
|
||||
virtual bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) override;
|
||||
virtual bool GetNameForUid(const int uid, std::string &name) override;
|
||||
virtual bool GetBundleGids(const std::string &bundleName, std::vector<int> &gids) override;
|
||||
virtual std::string GetAppType(const std::string &bundleName) override;
|
||||
virtual bool CheckIsSystemAppByUid(const int uid) override;
|
||||
virtual bool GetBundleInfosByMetaData(const std::string &metaData, std::vector<BundleInfo> &bundleInfos) override;
|
||||
virtual bool QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo) override;
|
||||
virtual bool QueryAbilityInfos(const Want &want, std::vector<AbilityInfo> &abilityInfos) override;
|
||||
virtual bool QueryAbilityInfosForClone(const Want &want, std::vector<AbilityInfo> &abilityInfos) override;
|
||||
virtual bool QueryAbilityInfoByUri(const std::string &abilityUri, AbilityInfo &abilityInfo) override;
|
||||
virtual bool QueryKeepAliveBundleInfos(std::vector<BundleInfo> &bundleInfos) override;
|
||||
virtual std::string GetAbilityLabel(const std::string &bundleName, const std::string &className) override;
|
||||
virtual bool GetBundleArchiveInfo(
|
||||
const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
const std::string &hapFilePath, const BundleFlag flag, BundleInfo &bundleInfo) override;
|
||||
virtual bool GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo) override;
|
||||
// obtains the Want for starting the main ability of an application based on the given bundle name.
|
||||
virtual bool GetLaunchWantForBundle(const std::string &bundleName, Want &want) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
// checks whether the publickeys of two bundles are the same.
|
||||
virtual int CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName) override
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
// checks whether a specified bundle has been granted a specific permission.
|
||||
virtual int CheckPermission(const std::string &bundleName, const std::string &permission) override
|
||||
{
|
||||
return 0;
|
||||
};
|
||||
virtual bool GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetAllPermissionGroupDefs(std::vector<PermissionDef> &permissionDefs) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetLaunchWantForBundle(const std::string &bundleName, Want &want) override;
|
||||
virtual int CheckPublicKeys(const std::string &firstBundleName, const std::string &secondBundleName) override;
|
||||
virtual int CheckPermission(const std::string &bundleName, const std::string &permission) override;
|
||||
virtual bool GetPermissionDef(const std::string &permissionName, PermissionDef &permissionDef) override;
|
||||
virtual bool GetAllPermissionGroupDefs(std::vector<PermissionDef> &permissionDefs) override;
|
||||
virtual bool GetAppsGrantedPermissions(
|
||||
const std::vector<std::string> &permissions, std::vector<std::string> &appNames) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool HasSystemCapability(const std::string &capName) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool GetSystemAvailableCapabilities(std::vector<std::string> &systemCaps) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool IsSafeMode() override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
// clears cache data of a specified application.
|
||||
const std::vector<std::string> &permissions, std::vector<std::string> &appNames) override;
|
||||
virtual bool HasSystemCapability(const std::string &capName) override;
|
||||
virtual bool GetSystemAvailableCapabilities(std::vector<std::string> &systemCaps) override;
|
||||
virtual bool IsSafeMode() override;
|
||||
virtual bool CleanBundleCacheFiles(
|
||||
const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool CleanBundleDataFiles(const std::string &bundleName) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
// unregister callback of all application
|
||||
virtual bool UnregisterBundleStatusCallback() override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual bool DumpInfos(const DumpFlag flag, const std::string &bundleName, std::string &result) override
|
||||
{
|
||||
return true;
|
||||
};
|
||||
virtual sptr<IBundleInstaller> GetBundleInstaller() override
|
||||
{
|
||||
return nullptr;
|
||||
};
|
||||
const std::string &bundleName, const sptr<ICleanCacheCallback> &cleanCacheCallback) override;
|
||||
virtual bool CleanBundleDataFiles(const std::string &bundleName) override;
|
||||
virtual bool RegisterBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override;
|
||||
virtual bool ClearBundleStatusCallback(const sptr<IBundleStatusCallback> &bundleStatusCallback) override;
|
||||
virtual bool UnregisterBundleStatusCallback() override;
|
||||
virtual bool DumpInfos(const DumpFlag flag, const std::string &bundleName, std::string &result) override;
|
||||
virtual bool IsApplicationEnabled(const std::string &bundleName) override;
|
||||
virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) override;
|
||||
virtual bool IsAbilityEnabled(const AbilityInfo &abilityInfo) override;
|
||||
virtual bool SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled) override;
|
||||
virtual std::string GetAbilityIcon(const std::string &bundleName, const std::string &className) override;
|
||||
virtual bool CanRequestPermission(
|
||||
const std::string &bundleName, const std::string &permissionName, const int userId) override
|
||||
{
|
||||
printf("===================333333333333333333===========\n");
|
||||
return false;
|
||||
}
|
||||
const std::string &bundleName, const std::string &permissionName, const int userId) override;
|
||||
virtual bool RequestPermissionFromUser(
|
||||
const std::string &bundleName, const std::string &permission, const int userId) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual std::string GetAppIdByBundleName(const std::string &bundleName, const int userId) override
|
||||
{
|
||||
return "";
|
||||
}
|
||||
virtual bool GetBundlesForUid(const int uid, std::vector<std::string> &bundleNames) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool GetNameForUid(const int uid, std::string &name) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool IsAbilityEnabled(const AbilityInfo &abilityInfo) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool SetAbilityEnabled(const AbilityInfo &abilityInfo, bool isEnabled) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual std::string GetAbilityIcon(const std::string &bundleName, const std::string &className) override
|
||||
{
|
||||
return "";
|
||||
}
|
||||
virtual bool RegisterAllPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
const std::string &bundleName, const std::string &permission, const int userId) override;
|
||||
virtual bool RegisterAllPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) override;
|
||||
virtual bool RegisterPermissionsChanged(
|
||||
const std::vector<int> &uids, const sptr<OnPermissionChangedCallback> &callback) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool UnregisterPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool IsApplicationEnabled(const std::string &bundleName) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual bool SetApplicationEnabled(const std::string &bundleName, bool isEnable) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
const std::vector<int> &uids, const sptr<OnPermissionChangedCallback> &callback) override;
|
||||
virtual bool UnregisterPermissionsChanged(const sptr<OnPermissionChangedCallback> &callback) override;
|
||||
virtual bool GetAllFormsInfo(std::vector<FormInfo> &formInfos) override;
|
||||
virtual bool GetFormsInfoByApp(const std::string &bundleName, std::vector<FormInfo> &formInfos) override;
|
||||
virtual bool GetFormsInfoByModule(
|
||||
const std::string &bundleName, const std::string &moduleName, std::vector<FormInfo> &formInfos) override;
|
||||
virtual bool GetShortcutInfos(const std::string &bundleName, std::vector<ShortcutInfo> &shortcutInfos) override;
|
||||
virtual bool GetModuleUsageRecords(
|
||||
const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
const int32_t number, std::vector<ModuleUsageRecord> &moduleUsageRecords) override;
|
||||
virtual sptr<IBundleInstaller> GetBundleInstaller() override;
|
||||
virtual bool NotifyActivityLifeStatus(
|
||||
const std::string &bundleName, const std::string &abilityName, const int64_t launchTime) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
const std::string &bundleName, const std::string &abilityName, const int64_t launchTime) override;
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "sys_mgr_client.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
@@ -30,6 +30,8 @@ SysMrgClient::~SysMrgClient()
|
||||
|
||||
sptr<IRemoteObject> SysMrgClient::GetSystemAbility(const int32_t systemAbilityId)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AaFwk_Ability_GetHapModuleInfo_0100 SysMrgClient::GetSystemAbility( "
|
||||
<< systemAbilityId << " )";
|
||||
if (servicesMap_[systemAbilityId] == nullptr) {
|
||||
OHOS::sptr<ISystemAbilityManager> abilityManager =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
@@ -40,11 +42,16 @@ sptr<IRemoteObject> SysMrgClient::GetSystemAbility(const int32_t systemAbilityId
|
||||
OHOS::sptr<OHOS::IRemoteObject> object = abilityManager->GetSystemAbility(systemAbilityId);
|
||||
servicesMap_[systemAbilityId] = object;
|
||||
}
|
||||
return servicesMap_[systemAbilityId];
|
||||
auto ret = servicesMap_[systemAbilityId];
|
||||
GTEST_LOG_(INFO) << "AaFwk_Ability_GetHapModuleInfo_0100 SysMrgClient::GetSystemAbility( "
|
||||
<< ret.GetRefPtr() << " )";
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SysMrgClient::RegisterSystemAbility(const int32_t systemAbilityId, sptr<IRemoteObject> broker)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "AaFwk_Ability_GetHapModuleInfo_0100 SysMrgClient::RegisterSystemAbility( "
|
||||
<< broker.GetRefPtr() << " )";
|
||||
servicesMap_[systemAbilityId] = broker;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -52,6 +52,8 @@ void AbilityContextTest::SetUpTestCase(void)
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_AbilityContext_SetUpTestCase start";
|
||||
OHOS::sptr<OHOS::IRemoteObject> bundleObject = new (std::nothrow) BundleMgrService();
|
||||
OHOS::sptr<OHOS::IRemoteObject> abilityObject = new (std::nothrow) OHOS::AAFwk::MockAbilityManagerService();
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_AbilityContext_SetUpTestCase bundleObject->" << bundleObject.GetRefPtr();
|
||||
GTEST_LOG_(INFO) << "AppExecFwk_AbilityContext_SetUpTestCase abilityObject->" << abilityObject.GetRefPtr();
|
||||
|
||||
auto sysMgr = OHOS::DelayedSingleton<SysMrgClient>::GetInstance();
|
||||
if (sysMgr == NULL) {
|
||||
@@ -77,7 +79,6 @@ void AbilityContextTest::SetUp(void)
|
||||
void AbilityContextTest::TearDown(void)
|
||||
{}
|
||||
|
||||
|
||||
/**
|
||||
* @tc.number: AaFwk_AbilityContext_StartAbility_0100
|
||||
* @tc.name: StartAbility
|
||||
@@ -565,13 +566,14 @@ HWTEST_F(AbilityContextTest, AaFwk_Ability_GetHapModuleInfo_0100, TestSize.Level
|
||||
|
||||
std::shared_ptr<ContextDeal> contextDeal = std::make_shared<ContextDeal>();
|
||||
std::shared_ptr<AbilityInfo> abilityInfo = std::make_shared<AbilityInfo>();
|
||||
std::string name = "Captain";
|
||||
abilityInfo->name = name;
|
||||
std::string name = "com.ohos.callui";
|
||||
std::string package = "com.ohos.callui";
|
||||
abilityInfo->bundleName = name;
|
||||
abilityInfo->package = package;
|
||||
contextDeal->SetAbilityInfo(abilityInfo);
|
||||
context_->AttachBaseContext(contextDeal);
|
||||
Want want;
|
||||
std::shared_ptr<HapModuleInfo> info = context_->GetHapModuleInfo();
|
||||
EXPECT_STREQ(info->name.c_str(), name.c_str());
|
||||
EXPECT_STREQ(info->name.c_str(), package.c_str());
|
||||
GTEST_LOG_(INFO) << "AaFwk_Ability_GetHapModuleInfo_0100 end";
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
||||
@@ -894,6 +894,51 @@ napi_value UnRegisterAsync(
|
||||
return result;
|
||||
}
|
||||
|
||||
static void FindRegisterObsByCallBack(napi_env env, DAHelperOnOffCB *data)
|
||||
{
|
||||
HILOG_INFO("NAPI_UnRegister, UnRegisterExecuteCB callback is not null.");
|
||||
if (data == nullptr || data->dataAbilityHelper == nullptr) {
|
||||
HILOG_ERROR("NAPI_UnRegister, param is null.");
|
||||
return;
|
||||
}
|
||||
// if match callback ,or match both callback and uri
|
||||
napi_value callbackA = 0;
|
||||
napi_get_reference_value(data->cbBase.cbInfo.env, data->cbBase.cbInfo.callback, &callbackA);
|
||||
std::string strUri = data->uri;
|
||||
do {
|
||||
auto helper = std::find_if(
|
||||
registerInstances_.begin(),
|
||||
registerInstances_.end(),
|
||||
[callbackA, strUri](const DAHelperOnOffCB *helper) {
|
||||
bool result = false;
|
||||
if (helper == nullptr || helper->cbBase.cbInfo.callback == nullptr) {
|
||||
HILOG_ERROR("UnRegisterExecuteCB %{public}s is nullptr",
|
||||
((helper == nullptr) ? "helper" : "helper->cbBase.cbInfo.callback"));
|
||||
return result;
|
||||
}
|
||||
if (helper->uri != strUri) {
|
||||
HILOG_ERROR("UnRegisterExecuteCB find uri inconsistent, h=[%{public}s] u=[%{public}s]",
|
||||
helper->uri.c_str(), strUri.c_str());
|
||||
return result;
|
||||
}
|
||||
napi_value callbackB = 0;
|
||||
napi_get_reference_value(helper->cbBase.cbInfo.env, helper->cbBase.cbInfo.callback, &callbackB);
|
||||
auto ret = napi_strict_equals(helper->cbBase.cbInfo.env, callbackA, callbackB, &result);
|
||||
HILOG_INFO("NAPI_UnRegister cb equals status=%{public}d result=%{public}d.", ret, result);
|
||||
return result;
|
||||
});
|
||||
if (helper != registerInstances_.end()) {
|
||||
data->NotifyList.emplace_back(*helper);
|
||||
registerInstances_.erase(helper);
|
||||
HILOG_INFO("NAPI_UnRegister Instances erase size = %{public}zu", registerInstances_.size());
|
||||
} else {
|
||||
HILOG_INFO("NAPI_UnRegister not match any callback. %{public}zu", registerInstances_.size());
|
||||
break; // not match any callback
|
||||
}
|
||||
} while (true);
|
||||
HILOG_INFO("NAPI_UnRegister, UnRegisterExecuteCB FindRegisterObsByCallBack Called End.");
|
||||
}
|
||||
|
||||
void FindRegisterObs(napi_env env, DAHelperOnOffCB *data)
|
||||
{
|
||||
HILOG_INFO("NAPI_UnRegister, FindRegisterObs main event thread execute.");
|
||||
@@ -903,42 +948,7 @@ void FindRegisterObs(napi_env env, DAHelperOnOffCB *data)
|
||||
}
|
||||
if (data->cbBase.cbInfo.callback != nullptr) {
|
||||
HILOG_INFO("NAPI_UnRegister, UnRegisterExecuteCB callback is not null.");
|
||||
// if match callback ,or match both callback and uri
|
||||
napi_value callbackA = 0;
|
||||
napi_get_reference_value(data->cbBase.cbInfo.env, data->cbBase.cbInfo.callback, &callbackA);
|
||||
do {
|
||||
auto helper = std::find_if(
|
||||
registerInstances_.begin(), registerInstances_.end(), [callbackA](const DAHelperOnOffCB *helper) {
|
||||
bool result = false;
|
||||
if (helper == nullptr || helper->cbBase.cbInfo.callback == nullptr) {
|
||||
HILOG_ERROR("UnRegisterExecuteCB %{public}s is nullptr",
|
||||
((helper == nullptr) ? "helper" : "helper->cbBase.cbInfo.callback"));
|
||||
return result;
|
||||
}
|
||||
napi_value callbackB = 0;
|
||||
napi_get_reference_value(helper->cbBase.cbInfo.env, helper->cbBase.cbInfo.callback, &callbackB);
|
||||
auto ret = napi_strict_equals(helper->cbBase.cbInfo.env, callbackA, callbackB, &result);
|
||||
HILOG_INFO("NAPI_UnRegister cb equals status=%{public}d result=%{public}d.", ret, result);
|
||||
return result;
|
||||
});
|
||||
if (helper != registerInstances_.end()) {
|
||||
OHOS::Uri uri((*helper)->uri);
|
||||
// if uri is not empty, uri and callback has to be equal at the same time.
|
||||
if (data->uri == uri.ToString()) {
|
||||
// match callback, or match both callback and uri
|
||||
data->NotifyList.emplace_back(*helper);
|
||||
registerInstances_.erase(helper);
|
||||
HILOG_INFO("NAPI_UnRegister Instances erase size = %{public}zu", registerInstances_.size());
|
||||
} else {
|
||||
HILOG_INFO("NAPI_UnRegister uri=%{public}s,helper.Uri=%{public}s",
|
||||
data->uri.c_str(),
|
||||
uri.ToString().c_str());
|
||||
}
|
||||
} else {
|
||||
HILOG_INFO("NAPI_UnRegister not match any callback. %{public}zu", registerInstances_.size());
|
||||
break; // not match any callback
|
||||
}
|
||||
} while (true);
|
||||
FindRegisterObsByCallBack(env, data);
|
||||
} else {
|
||||
HILOG_INFO("NAPI_UnRegister, uri=%{public}s.", data->uri.c_str());
|
||||
if (data->uri != "") {
|
||||
@@ -1117,6 +1127,53 @@ void NAPIDataAbilityObserver::SetCallbackRef(const napi_ref &ref)
|
||||
HILOG_INFO("NAPIDataAbilityObserver::%{public}s, called. end", __func__);
|
||||
}
|
||||
|
||||
static void OnChangeJSThreadWorker(uv_work_t *work, int status)
|
||||
{
|
||||
HILOG_INFO("OnChange, uv_queue_work");
|
||||
if (work == nullptr) {
|
||||
HILOG_ERROR("OnChange, uv_queue_work input work is nullptr");
|
||||
return;
|
||||
}
|
||||
DAHelperOnOffCB *onCB = (DAHelperOnOffCB *)work->data;
|
||||
NAPIDataAbilityObserver* obs = onCB->observer;
|
||||
onCB->observer = nullptr;
|
||||
if (obs != nullptr) {
|
||||
obs->ChangeWorkRun();
|
||||
}
|
||||
napi_value result[ARGS_TWO] = {0};
|
||||
result[PARAM0] = GetCallbackErrorValue(onCB->cbBase.cbInfo.env, NO_ERROR);
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(onCB->cbBase.cbInfo.env, &undefined);
|
||||
napi_value callResult = 0;
|
||||
napi_get_reference_value(onCB->cbBase.cbInfo.env, onCB->cbBase.cbInfo.callback, &callback);
|
||||
napi_call_function(onCB->cbBase.cbInfo.env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult);
|
||||
if (obs != nullptr) {
|
||||
if (obs->GetWorkInt() == 1) {
|
||||
obs->ReleaseJSCallback();
|
||||
DAHelperOnOffCB* assicuated = obs->GetAssociatedObject();
|
||||
if (assicuated != nullptr) {
|
||||
HILOG_INFO("OnChange, uv_queue_work ReleaseJSCallback Called");
|
||||
obs->SetAssociatedObject(nullptr);
|
||||
delete assicuated;
|
||||
assicuated = nullptr;
|
||||
}
|
||||
} else {
|
||||
obs->ChangeWorkRunDone();
|
||||
obs->ChangeWorkPreDone();
|
||||
}
|
||||
}
|
||||
if (onCB != nullptr) {
|
||||
delete onCB;
|
||||
onCB = nullptr;
|
||||
}
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
HILOG_INFO("OnChange, uv_queue_work. end");
|
||||
}
|
||||
|
||||
void NAPIDataAbilityObserver::OnChange()
|
||||
{
|
||||
HILOG_INFO("%{public}s, called.", __func__);
|
||||
@@ -1156,51 +1213,7 @@ void NAPIDataAbilityObserver::OnChange()
|
||||
loop,
|
||||
work,
|
||||
[](uv_work_t *work) {},
|
||||
[](uv_work_t *work, int status) {
|
||||
HILOG_INFO("OnChange, uv_queue_work");
|
||||
// JS Thread
|
||||
DAHelperOnOffCB *onCB = (DAHelperOnOffCB *)work->data;
|
||||
NAPIDataAbilityObserver* obs = onCB->observer;
|
||||
onCB->observer = nullptr;
|
||||
if (obs != nullptr) {
|
||||
obs->ChangeWorkRun();
|
||||
}
|
||||
napi_value result[ARGS_TWO] = {0};
|
||||
result[PARAM0] = GetCallbackErrorValue(onCB->cbBase.cbInfo.env, NO_ERROR);
|
||||
napi_value callback = 0;
|
||||
napi_value undefined = 0;
|
||||
napi_get_undefined(onCB->cbBase.cbInfo.env, &undefined);
|
||||
napi_value callResult = 0;
|
||||
napi_get_reference_value(onCB->cbBase.cbInfo.env, onCB->cbBase.cbInfo.callback, &callback);
|
||||
napi_call_function(onCB->cbBase.cbInfo.env, undefined, callback, ARGS_TWO, &result[PARAM0], &callResult);
|
||||
|
||||
if (obs != nullptr) {
|
||||
if (obs->GetWorkInt() == 1) {
|
||||
obs->ReleaseJSCallback();
|
||||
DAHelperOnOffCB* assicuated = obs->GetAssociatedObject();
|
||||
if (assicuated != nullptr) {
|
||||
HILOG_INFO("OnChange, uv_queue_work ReleaseJSCallback Called");
|
||||
obs->SetAssociatedObject(nullptr);
|
||||
delete assicuated;
|
||||
assicuated = nullptr;
|
||||
}
|
||||
}
|
||||
else {
|
||||
obs->ChangeWorkRunDone();
|
||||
obs->ChangeWorkPreDone();
|
||||
}
|
||||
}
|
||||
|
||||
if (onCB != nullptr) {
|
||||
delete onCB;
|
||||
onCB = nullptr;
|
||||
}
|
||||
if (work != nullptr) {
|
||||
delete work;
|
||||
work = nullptr;
|
||||
}
|
||||
HILOG_INFO("OnChange, uv_queue_work. end");
|
||||
});
|
||||
OnChangeJSThreadWorker);
|
||||
if (rev != 0) {
|
||||
if (onCB != nullptr) {
|
||||
delete onCB;
|
||||
|
||||
@@ -80,9 +80,9 @@ public:
|
||||
std::shared_ptr<AbilityRecord> GetTopAbility();
|
||||
void ClearStack();
|
||||
|
||||
inline static std::shared_ptr<MockAppMgrClient> mockAppMgrClient_{nullptr};
|
||||
inline static std::shared_ptr<AbilityManagerService> abilityMgrServ_{nullptr};
|
||||
sptr<MockAbilityScheduler> scheduler_{nullptr};
|
||||
inline static std::shared_ptr<MockAppMgrClient> mockAppMgrClient_ {nullptr};
|
||||
inline static std::shared_ptr<AbilityManagerService> abilityMgrServ_ {nullptr};
|
||||
sptr<MockAbilityScheduler> scheduler_ {nullptr};
|
||||
inline static bool doOnce_ = false; // In order for mock to execute once
|
||||
|
||||
static constexpr int TEST_WAIT_TIME = 100000;
|
||||
|
||||
Reference in New Issue
Block a user