mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-11-23 15:20:34 +00:00
modify code
Signed-off-by: xinking129 <xinxin13@huawei.com>
This commit is contained in:
parent
9b4884e163
commit
1b16840a34
@ -12,10 +12,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "bundle_mgr_helper.h"
|
||||
|
||||
#include "app_log_wrapper.h"
|
||||
#include "bundle_mgr_proxy.h"
|
||||
#include "bundle_mgr_service_death_recipient.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "iservice_registry.h"
|
||||
@ -23,36 +22,33 @@
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
BundleMgrHelper::BundleMgrHelper()
|
||||
{
|
||||
HILOG_INFO("create BundleMgrHelper");
|
||||
}
|
||||
BundleMgrHelper::BundleMgrHelper() {}
|
||||
|
||||
BundleMgrHelper::~BundleMgrHelper()
|
||||
{
|
||||
HILOG_ERROR("destroy BundleMgrHelper");
|
||||
if (bundleMgr_ != nullptr && deathRecipient_ != nullptr) {
|
||||
bundleMgr_->AsObject()->RemoveDeathRecipient(deathRecipient_);
|
||||
}
|
||||
}
|
||||
|
||||
ErrCode BundleMgrHelper::GetNameForUid(const int uid, std::string &name)
|
||||
ErrCode BundleMgrHelper::GetNameForUid(const int32_t uid, std::string &name)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
if (Connect() != ERR_OK) {
|
||||
HILOG_ERROR("failed to connect");
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
return bundleMgr_->GetNameForUid(uid, name);
|
||||
}
|
||||
|
||||
bool BundleMgrHelper::GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo,
|
||||
int32_t userId)
|
||||
{
|
||||
HILOG_ERROR("GetBundleInfo begin");
|
||||
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("failed to connect");
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -62,14 +58,14 @@ bool BundleMgrHelper::GetBundleInfo(const std::string &bundleName, const BundleF
|
||||
ErrCode BundleMgrHelper::InstallSandboxApp(const std::string &bundleName, int32_t dlpType, int32_t userId,
|
||||
int32_t &appIndex)
|
||||
{
|
||||
HILOG_ERROR("InstallSandboxApp begin");
|
||||
HILOG_DEBUG("Called.");
|
||||
if (bundleName.empty()) {
|
||||
HILOG_ERROR("InstallSandboxApp bundleName is empty");
|
||||
HILOG_ERROR("The bundleName is empty.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
ErrCode result = ConnectBundleInstaller();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("failed to connect");
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
@ -78,14 +74,14 @@ ErrCode BundleMgrHelper::InstallSandboxApp(const std::string &bundleName, int32_
|
||||
|
||||
ErrCode BundleMgrHelper::UninstallSandboxApp(const std::string &bundleName, int32_t appIndex, int32_t userId)
|
||||
{
|
||||
HILOG_ERROR("UninstallSandboxApp begin");
|
||||
HILOG_DEBUG("Called.");
|
||||
if (bundleName.empty() || appIndex <= Constants::INITIAL_APP_INDEX) {
|
||||
HILOG_ERROR("UninstallSandboxApp params are invalid");
|
||||
HILOG_ERROR("The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("failed to connect");
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
@ -94,11 +90,11 @@ ErrCode BundleMgrHelper::UninstallSandboxApp(const std::string &bundleName, int3
|
||||
|
||||
ErrCode BundleMgrHelper::GetUninstalledBundleInfo(const std::string bundleName, BundleInfo &bundleInfo)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
return false;
|
||||
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
return bundleMgr_->GetUninstalledBundleInfo(bundleName, bundleInfo);
|
||||
@ -107,31 +103,31 @@ ErrCode BundleMgrHelper::GetUninstalledBundleInfo(const std::string bundleName,
|
||||
ErrCode BundleMgrHelper::GetSandboxBundleInfo(
|
||||
const std::string &bundleName, int32_t appIndex, int32_t userId, BundleInfo &info)
|
||||
{
|
||||
HILOG_ERROR("GetSandboxBundleInfo begin");
|
||||
HILOG_DEBUG("Called.");
|
||||
if (bundleName.empty() || appIndex <= Constants::INITIAL_APP_INDEX) {
|
||||
HILOG_ERROR("UninstallSandboxApp params are invalid");
|
||||
HILOG_ERROR("The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
|
||||
ErrCode result = ConnectBundleInstaller();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("failed to connect");
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
return bundleMgr_->GetSandboxBundleInfo(bundleName, appIndex, userId, info);
|
||||
}
|
||||
|
||||
ErrCode BundleMgrHelper::GetSandboxAbilityInfo(const Want &want, int32_t appIndex, int32_t flags, int32_t userId,
|
||||
AbilityInfo &abilityInfo)
|
||||
{
|
||||
HILOG_ERROR("GetSandboxAbilityInfo begin");
|
||||
HILOG_DEBUG("Called.");
|
||||
if (appIndex <= Constants::INITIAL_APP_INDEX || appIndex > Constants::MAX_APP_INDEX) {
|
||||
HILOG_ERROR("GetSandboxAbilityInfo params are invalid");
|
||||
HILOG_ERROR("The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("failed to connect");
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
@ -141,14 +137,14 @@ ErrCode BundleMgrHelper::GetSandboxAbilityInfo(const Want &want, int32_t appInde
|
||||
ErrCode BundleMgrHelper::GetSandboxExtAbilityInfos(const Want &want, int32_t appIndex, int32_t flags,
|
||||
int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos)
|
||||
{
|
||||
HILOG_ERROR("GetSandboxExtensionAbilityInfos begin");
|
||||
HILOG_DEBUG("Called.");
|
||||
if (appIndex <= Constants::INITIAL_APP_INDEX || appIndex > Constants::MAX_APP_INDEX) {
|
||||
HILOG_ERROR("GetSandboxExtensionAbilityInfos params are invalid");
|
||||
HILOG_ERROR("The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("failed to connect");
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
@ -158,14 +154,14 @@ ErrCode BundleMgrHelper::GetSandboxExtAbilityInfos(const Want &want, int32_t app
|
||||
ErrCode BundleMgrHelper::GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo, int32_t appIndex, int32_t userId,
|
||||
HapModuleInfo &hapModuleInfo)
|
||||
{
|
||||
HILOG_ERROR("GetSandboxHapModuleInfo begin");
|
||||
HILOG_DEBUG("Called.");
|
||||
if (appIndex <= Constants::INITIAL_APP_INDEX || appIndex > Constants::MAX_APP_INDEX) {
|
||||
HILOG_ERROR("GetSandboxHapModuleInfo params are invalid");
|
||||
HILOG_ERROR("The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("failed to connect");
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
@ -174,38 +170,44 @@ ErrCode BundleMgrHelper::GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo,
|
||||
|
||||
ErrCode BundleMgrHelper::Connect()
|
||||
{
|
||||
HILOG_ERROR("connect begin");
|
||||
HILOG_DEBUG("Called.");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (bundleMgr_ == nullptr) {
|
||||
sptr<ISystemAbilityManager> systemAbilityManager =
|
||||
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
|
||||
if (systemAbilityManager == nullptr) {
|
||||
HILOG_ERROR("failed to get system ability manager");
|
||||
HILOG_ERROR("Failed to get system ability manager.");
|
||||
return ERR_APPEXECFWK_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
|
||||
sptr<IRemoteObject> remoteObject_ = systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
if (remoteObject_ == nullptr || (bundleMgr_ = iface_cast<IBundleMgr>(remoteObject_)) == nullptr) {
|
||||
HILOG_ERROR("failed to get bundle mgr service remote object");
|
||||
HILOG_ERROR("Failed to get bundle mgr service remote object.");
|
||||
return ERR_APPEXECFWK_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
std::weak_ptr<BundleMgrHelper> weakPtr = shared_from_this();
|
||||
auto deathCallback = [weakPtr](const wptr<IRemoteObject>& object) {
|
||||
auto sharedPtr = weakPtr.lock();
|
||||
if (sharedPtr != nullptr) {
|
||||
sharedPtr->OnDeath();
|
||||
if (sharedPtr == nullptr) {
|
||||
HILOG_ERROR("Bundle helper instance is nullptr.");
|
||||
return;
|
||||
}
|
||||
sharedPtr->OnDeath();
|
||||
};
|
||||
deathRecipient_ = new (std::nothrow) BundleMgrServiceDeathRecipient(deathCallback);
|
||||
if (deathRecipient_ == nullptr) {
|
||||
HILOG_ERROR("Failed to create death recipient ptr deathRecipient_!");
|
||||
return ERR_APPEXECFWK_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
bundleMgr_->AsObject()->AddDeathRecipient(deathRecipient_);
|
||||
}
|
||||
|
||||
HILOG_ERROR("connect end");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
ErrCode BundleMgrHelper::ConnectBundleInstaller()
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -216,7 +218,6 @@ ErrCode BundleMgrHelper::ConnectBundleInstaller()
|
||||
if (bundleInstaller_ == nullptr) {
|
||||
bundleInstaller_ = bundleMgr_->GetBundleInstaller();
|
||||
if ((bundleInstaller_ == nullptr) || (bundleInstaller_->AsObject() == nullptr)) {
|
||||
HILOG_ERROR("failed to get bundle installer proxy");
|
||||
HILOG_ERROR("Failed to get bundle installer proxy.");
|
||||
return ERR_APPEXECFWK_SERVICE_NOT_CONNECTED;
|
||||
}
|
||||
@ -227,8 +228,13 @@ ErrCode BundleMgrHelper::ConnectBundleInstaller()
|
||||
|
||||
void BundleMgrHelper::OnDeath()
|
||||
{
|
||||
HILOG_ERROR("BundleManagerService dead.");
|
||||
HILOG_DEBUG("Called.");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (bundleMgr_ == nullptr) {
|
||||
HILOG_ERROR("bundleMgr_ is nullptr.");
|
||||
return;
|
||||
}
|
||||
bundleMgr_->AsObject()->RemoveDeathRecipient(deathRecipient_);
|
||||
bundleMgr_ = nullptr;
|
||||
bundleInstaller_ = nullptr;
|
||||
}
|
||||
@ -236,7 +242,7 @@ void BundleMgrHelper::OnDeath()
|
||||
bool BundleMgrHelper::GetBundleInfo(const std::string &bundleName, int32_t flags,
|
||||
BundleInfo &bundleInfo, int32_t userId)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -248,6 +254,7 @@ bool BundleMgrHelper::GetBundleInfo(const std::string &bundleName, int32_t flags
|
||||
|
||||
bool BundleMgrHelper::GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModuleInfo &hapModuleInfo)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -259,7 +266,7 @@ bool BundleMgrHelper::GetHapModuleInfo(const AbilityInfo &abilityInfo, HapModule
|
||||
|
||||
std::string BundleMgrHelper::GetAbilityLabel(const std::string &bundleName, const std::string &abilityName)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -271,7 +278,7 @@ std::string BundleMgrHelper::GetAbilityLabel(const std::string &bundleName, cons
|
||||
|
||||
std::string BundleMgrHelper::GetAppType(const std::string &bundleName)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -284,7 +291,7 @@ std::string BundleMgrHelper::GetAppType(const std::string &bundleName)
|
||||
ErrCode BundleMgrHelper::GetBaseSharedBundleInfos(
|
||||
const std::string &bundleName, std::vector<BaseSharedBundleInfo> &baseSharedBundleInfos)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -296,7 +303,7 @@ ErrCode BundleMgrHelper::GetBaseSharedBundleInfos(
|
||||
|
||||
ErrCode BundleMgrHelper::GetBundleInfoForSelf(int32_t flags, BundleInfo &bundleInfo)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -308,7 +315,7 @@ ErrCode BundleMgrHelper::GetBundleInfoForSelf(int32_t flags, BundleInfo &bundleI
|
||||
|
||||
ErrCode BundleMgrHelper::GetDependentBundleInfo(const std::string &sharedBundleName, BundleInfo &sharedBundleInfo)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -320,7 +327,7 @@ ErrCode BundleMgrHelper::GetDependentBundleInfo(const std::string &sharedBundleN
|
||||
|
||||
bool BundleMgrHelper::GetGroupDir(const std::string &dataGroupId, std::string &dir)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -332,7 +339,7 @@ bool BundleMgrHelper::GetGroupDir(const std::string &dataGroupId, std::string &d
|
||||
|
||||
sptr<IOverlayManager> BundleMgrHelper::GetOverlayManagerProxy()
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -344,7 +351,7 @@ sptr<IOverlayManager> BundleMgrHelper::GetOverlayManagerProxy()
|
||||
|
||||
bool BundleMgrHelper::QueryAbilityInfo(const Want &want, AbilityInfo &abilityInfo)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -356,23 +363,19 @@ bool BundleMgrHelper::QueryAbilityInfo(const Want &want, AbilityInfo &abilityInf
|
||||
|
||||
bool BundleMgrHelper::QueryAbilityInfo(const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
return false;
|
||||
}
|
||||
if (bundleMgr_ == nullptr) {
|
||||
HILOG_ERROR("bundleMgr_ is nullptr.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return bundleMgr_->QueryAbilityInfo(want, flags, userId, abilityInfo);
|
||||
}
|
||||
|
||||
bool BundleMgrHelper::GetBundleInfos(int32_t flags, std::vector<BundleInfo> &bundleInfos, int32_t userId)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -384,7 +387,7 @@ bool BundleMgrHelper::GetBundleInfos(int32_t flags, std::vector<BundleInfo> &bun
|
||||
|
||||
bool BundleMgrHelper::GetBundleInfos(const BundleFlag flag, std::vector<BundleInfo> &bundleInfos, int32_t userId)
|
||||
{
|
||||
APP_LOGI("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -396,7 +399,7 @@ bool BundleMgrHelper::GetBundleInfos(const BundleFlag flag, std::vector<BundleIn
|
||||
|
||||
sptr<IQuickFixManager> BundleMgrHelper::GetQuickFixManagerProxy()
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -408,7 +411,7 @@ sptr<IQuickFixManager> BundleMgrHelper::GetQuickFixManagerProxy()
|
||||
|
||||
bool BundleMgrHelper::ProcessPreload(const Want &want)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -420,7 +423,7 @@ bool BundleMgrHelper::ProcessPreload(const Want &want)
|
||||
|
||||
sptr<IAppControlMgr> BundleMgrHelper::GetAppControlProxy()
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -433,8 +436,7 @@ sptr<IAppControlMgr> BundleMgrHelper::GetAppControlProxy()
|
||||
bool BundleMgrHelper::QueryExtensionAbilityInfos(const Want &want, const int32_t &flag, const int32_t &userId,
|
||||
std::vector<ExtensionAbilityInfo> &extensionInfos)
|
||||
{
|
||||
APP_LOGI("Called.");
|
||||
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -445,9 +447,9 @@ bool BundleMgrHelper::QueryExtensionAbilityInfos(const Want &want, const int32_t
|
||||
}
|
||||
|
||||
bool BundleMgrHelper::GetApplicationInfo(
|
||||
const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo)
|
||||
const std::string &appName, const ApplicationFlag flag, const int32_t userId, ApplicationInfo &appInfo)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -460,7 +462,7 @@ bool BundleMgrHelper::GetApplicationInfo(
|
||||
bool BundleMgrHelper::GetApplicationInfo(
|
||||
const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -472,7 +474,7 @@ bool BundleMgrHelper::GetApplicationInfo(
|
||||
|
||||
bool BundleMgrHelper::UnregisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -485,7 +487,7 @@ bool BundleMgrHelper::UnregisterBundleEventCallback(const sptr<IBundleEventCallb
|
||||
bool BundleMgrHelper::QueryExtensionAbilityInfoByUri(
|
||||
const std::string &uri, int32_t userId, ExtensionAbilityInfo &extensionAbilityInfo)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -498,7 +500,7 @@ bool BundleMgrHelper::QueryExtensionAbilityInfoByUri(
|
||||
bool BundleMgrHelper::ImplicitQueryInfoByPriority(
|
||||
const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo, ExtensionAbilityInfo &extensionInfo)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -510,7 +512,7 @@ bool BundleMgrHelper::ImplicitQueryInfoByPriority(
|
||||
|
||||
bool BundleMgrHelper::QueryAbilityInfoByUri(const std::string &abilityUri, int32_t userId, AbilityInfo &abilityInfo)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -523,7 +525,7 @@ bool BundleMgrHelper::QueryAbilityInfoByUri(const std::string &abilityUri, int32
|
||||
bool BundleMgrHelper::QueryAbilityInfo(
|
||||
const Want &want, int32_t flags, int32_t userId, AbilityInfo &abilityInfo, const sptr<IRemoteObject> &callBack)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -535,7 +537,7 @@ bool BundleMgrHelper::QueryAbilityInfo(
|
||||
|
||||
void BundleMgrHelper::UpgradeAtomicService(const Want &want, int32_t userId)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -548,7 +550,7 @@ void BundleMgrHelper::UpgradeAtomicService(const Want &want, int32_t userId)
|
||||
bool BundleMgrHelper::ImplicitQueryInfos(const Want &want, int32_t flags, int32_t userId, bool withDefault,
|
||||
std::vector<AbilityInfo> &abilityInfos, std::vector<ExtensionAbilityInfo> &extensionInfos)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -558,9 +560,9 @@ bool BundleMgrHelper::ImplicitQueryInfos(const Want &want, int32_t flags, int32_
|
||||
return bundleMgr_->ImplicitQueryInfos(want, flags, userId, withDefault, abilityInfos, extensionInfos);
|
||||
}
|
||||
|
||||
bool BundleMgrHelper::CleanBundleDataFiles(const std::string &bundleName, const int userId)
|
||||
bool BundleMgrHelper::CleanBundleDataFiles(const std::string &bundleName, const int32_t userId)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -573,7 +575,7 @@ bool BundleMgrHelper::CleanBundleDataFiles(const std::string &bundleName, const
|
||||
bool BundleMgrHelper::QueryDataGroupInfos(
|
||||
const std::string &bundleName, int32_t userId, std::vector<DataGroupInfo> &infos)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -583,9 +585,9 @@ bool BundleMgrHelper::QueryDataGroupInfos(
|
||||
return bundleMgr_->QueryDataGroupInfos(bundleName, userId, infos);
|
||||
}
|
||||
|
||||
bool BundleMgrHelper::GetBundleGidsByUid(const std::string &bundleName, const int &uid, std::vector<int> &gids)
|
||||
bool BundleMgrHelper::GetBundleGidsByUid(const std::string &bundleName, const int32_t &uid, std::vector<int32_t> &gids)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -597,7 +599,7 @@ bool BundleMgrHelper::GetBundleGidsByUid(const std::string &bundleName, const in
|
||||
|
||||
bool BundleMgrHelper::RegisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -609,7 +611,7 @@ bool BundleMgrHelper::RegisterBundleEventCallback(const sptr<IBundleEventCallbac
|
||||
|
||||
bool BundleMgrHelper::GetHapModuleInfo(const AbilityInfo &abilityInfo, int32_t userId, HapModuleInfo &hapModuleInfo)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -619,21 +621,32 @@ bool BundleMgrHelper::GetHapModuleInfo(const AbilityInfo &abilityInfo, int32_t u
|
||||
return bundleMgr_->GetHapModuleInfo(abilityInfo, userId, hapModuleInfo);
|
||||
}
|
||||
|
||||
int BundleMgrHelper::GetUidByBundleName(const std::string &bundleName, const int userId)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
bool BundleMgrHelper::QueryAppGalleryBundleName(std::string &bundleName) {
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return bundleMgr_->QueryAppGalleryBundleName(bundleName);
|
||||
}
|
||||
|
||||
ErrCode BundleMgrHelper::GetUidByBundleName(const std::string &bundleName, const int32_t userId)
|
||||
{
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
return bundleMgr_->GetUidByBundleName(bundleName, userId);
|
||||
}
|
||||
|
||||
sptr<IDefaultApp> BundleMgrHelper::GetDefaultAppProxy()
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
@ -646,14 +659,14 @@ sptr<IDefaultApp> BundleMgrHelper::GetDefaultAppProxy()
|
||||
ErrCode BundleMgrHelper::GetJsonProfile(ProfileType profileType, const std::string &bundleName,
|
||||
const std::string &moduleName, std::string &profile, int32_t userId)
|
||||
{
|
||||
HILOG_ERROR("Called.");
|
||||
HILOG_DEBUG("Called.");
|
||||
ErrCode result = Connect();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Failed to connect.");
|
||||
return false;
|
||||
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
return bundleMgr_->GetUidByBundleName(bundleName, userId);
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
} // namespace OHOS
|
||||
|
@ -32,12 +32,12 @@ std::unique_ptr<TestRunner> TestRunner::Create(const std::unique_ptr<AbilityRunt
|
||||
|
||||
auto bundleMgrHelper = DelayedSingleton<BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("Failed to get bundle manager service");
|
||||
HILOG_ERROR("Failed to get bundle manager service.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!args) {
|
||||
HILOG_ERROR("Invalid ability delegator args");
|
||||
HILOG_ERROR("Invalid ability delegator args.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ std::unique_ptr<TestRunner> TestRunner::Create(const std::unique_ptr<AbilityRunt
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA)), bundleInfo) != ERR_OK) {
|
||||
HILOG_ERROR("Failed to GetBundleInfo");
|
||||
HILOG_ERROR("Failed to GetBundleInfo.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -739,11 +739,11 @@ ErrCode ContextImpl::GetBundleManager()
|
||||
|
||||
bundleMgr_ = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgr_ == nullptr) {
|
||||
HILOG_ERROR("failed to get bundle manager service.");
|
||||
HILOG_ERROR("Failed to get bundle manager service.");
|
||||
return ERR_NULL_OBJECT;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("Success");
|
||||
HILOG_DEBUG("Success.");
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ std::shared_ptr<BundleMgrHelper> ContextContainer::GetBundleManager() const
|
||||
if (baseContext_ != nullptr) {
|
||||
return baseContext_->GetBundleManager();
|
||||
} else {
|
||||
HILOG_ERROR("ContextContainer::GetBundleManager baseContext_ is nullptr");
|
||||
HILOG_ERROR("BaseContext_ is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -240,7 +240,7 @@ std::string ContextContainer::GetProcessName()
|
||||
std::shared_ptr<Context> ContextContainer::CreateBundleContext(std::string bundleName, int flag, int accountId)
|
||||
{
|
||||
if (bundleName.empty()) {
|
||||
HILOG_ERROR("ContextContainer::CreateBundleContext bundleName is empty");
|
||||
HILOG_ERROR("BundleName is empty.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -250,12 +250,12 @@ std::shared_ptr<Context> ContextContainer::CreateBundleContext(std::string bundl
|
||||
|
||||
std::shared_ptr<BundleMgrHelper> bundleMgr = GetBundleManager();
|
||||
if (bundleMgr == nullptr) {
|
||||
HILOG_ERROR("ContextContainer::CreateBundleContext GetBundleManager is nullptr");
|
||||
HILOG_ERROR("GetBundleManager is nullptr.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
BundleInfo bundleInfo;
|
||||
HILOG_INFO("CreateBundleContext length: %{public}zu, bundleName: %{public}s, accountId is %{public}d",
|
||||
HILOG_INFO("Length: %{public}zu, bundleName: %{public}s, accountId is %{public}d.",
|
||||
bundleName.length(),
|
||||
bundleName.c_str(),
|
||||
accountId);
|
||||
@ -266,7 +266,7 @@ std::shared_ptr<Context> ContextContainer::CreateBundleContext(std::string bundl
|
||||
bundleMgr->GetBundleInfo(bundleName, BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, realAccountId);
|
||||
|
||||
if (bundleInfo.name.empty() || bundleInfo.applicationInfo.name.empty()) {
|
||||
HILOG_ERROR("ContextContainer::CreateBundleContext GetBundleInfo is error");
|
||||
HILOG_ERROR("GetBundleInfo is error.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -127,9 +127,9 @@ void ContextDeal::SetContext(const std::shared_ptr<Context> &context)
|
||||
|
||||
std::shared_ptr<BundleMgrHelper> ContextDeal::GetBundleManager() const
|
||||
{
|
||||
std::shared_ptr<BundleMgrHelper> bundleMgrHelper = DelayedSingleton<BundleMgrHelper>::GetInstance();
|
||||
auto bundleMgrHelper = DelayedSingleton<BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("failed to get bundle manager service");
|
||||
HILOG_ERROR("Failed to get bundle manager service.");
|
||||
return nullptr;
|
||||
}
|
||||
return bundleMgrHelper;
|
||||
@ -210,7 +210,7 @@ sptr<AAFwk::IAbilityManager> ContextDeal::GetAbilityManager()
|
||||
{
|
||||
auto remoteObject = OHOS::DelayedSingleton<SysMrgClient>::GetInstance()->GetSystemAbility(ABILITY_MGR_SERVICE_ID);
|
||||
if (remoteObject == nullptr) {
|
||||
HILOG_ERROR("failed to get ability manager service");
|
||||
HILOG_ERROR("Failed to get ability manager service.");
|
||||
return nullptr;
|
||||
}
|
||||
sptr<AAFwk::IAbilityManager> ams = iface_cast<AAFwk::IAbilityManager>(remoteObject);
|
||||
@ -455,18 +455,18 @@ bool ContextDeal::HapModuleInfoRequestInit()
|
||||
{
|
||||
auto ptr = GetBundleManager();
|
||||
if (ptr == nullptr) {
|
||||
HILOG_ERROR("GetHapModuleInfo failed to get bundle manager service");
|
||||
HILOG_ERROR("Failed to get bundle manager service.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (abilityInfo_ == nullptr) {
|
||||
HILOG_ERROR("GetHapModuleInfo failed for abilityInfo_ is nullptr");
|
||||
HILOG_ERROR("Failed for abilityInfo_ is nullptr.");
|
||||
return false;
|
||||
}
|
||||
|
||||
hapModuleInfoLocal_ = std::make_shared<HapModuleInfo>();
|
||||
if (!ptr->GetHapModuleInfo(*abilityInfo_.get(), *hapModuleInfoLocal_)) {
|
||||
HILOG_ERROR("IBundleMgr::GetHapModuleInfo failed, will retval false value");
|
||||
HILOG_ERROR("Failed, will retval false value.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -1129,11 +1129,11 @@ bool GetBundleForLaunchApplication(std::shared_ptr<BundleMgrHelper> bundleMgrHel
|
||||
{
|
||||
bool queryResult;
|
||||
if (appIndex != 0) {
|
||||
HILOG_INFO("bundleName = %{public}s", bundleName.c_str());
|
||||
HILOG_INFO("BundleName = %{public}s.", bundleName.c_str());
|
||||
queryResult = (bundleMgrHelper->GetSandboxBundleInfo(bundleName,
|
||||
appIndex, UNSPECIFIED_USERID, bundleInfo) == 0);
|
||||
} else {
|
||||
HILOG_INFO("bundleName = %{public}s", bundleName.c_str());
|
||||
HILOG_INFO("BundleName = %{public}s.", bundleName.c_str());
|
||||
queryResult = (bundleMgrHelper->GetBundleInfoForSelf(
|
||||
(static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_EXTENSION_ABILITY) +
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_HAP_MODULE) +
|
||||
@ -1159,9 +1159,9 @@ bool GetBundleForLaunchApplication(std::shared_ptr<BundleMgrHelper> bundleMgrHel
|
||||
void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, const Configuration &config)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
HILOG_INFO("LoadLifecycle: handle launch application start.");
|
||||
HILOG_INFO("Handle launch application start.");
|
||||
if (!CheckForHandleLaunchApplication(appLaunchData)) {
|
||||
HILOG_ERROR("MainThread::handleLaunchApplication CheckForHandleLaunchApplication failed");
|
||||
HILOG_ERROR("CheckForHandleLaunchApplication failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1173,22 +1173,22 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
|
||||
auto appInfo = appLaunchData.GetApplicationInfo();
|
||||
ProcessInfo processInfo = appLaunchData.GetProcessInfo();
|
||||
HILOG_DEBUG("MainThread handle launch application, InitCreate Start.");
|
||||
HILOG_DEBUG("InitCreate Start.");
|
||||
std::shared_ptr<ContextDeal> contextDeal;
|
||||
if (!InitCreate(contextDeal, appInfo, processInfo)) {
|
||||
HILOG_ERROR("MainThread::handleLaunchApplication InitCreate failed");
|
||||
HILOG_ERROR("InitCreate failed.");
|
||||
return;
|
||||
}
|
||||
auto bundleMgrHelper = contextDeal->GetBundleManager();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("MainThread::handleLaunchApplication GetBundleManager is nullptr");
|
||||
HILOG_ERROR("GetBundleManager is nullptr.");
|
||||
return;
|
||||
}
|
||||
|
||||
auto bundleName = appInfo.bundleName;
|
||||
BundleInfo bundleInfo;
|
||||
if (!GetBundleForLaunchApplication(bundleMgrHelper, bundleName, appLaunchData.GetAppIndex(), bundleInfo)) {
|
||||
HILOG_ERROR("HandleLaunchApplication GetBundleInfo failed!");
|
||||
HILOG_ERROR("GetBundleInfo failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1237,7 +1237,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
#endif
|
||||
}
|
||||
if (appInfo.needAppDetail) {
|
||||
HILOG_DEBUG("MainThread::handleLaunchApplication %{public}s need add app detail ability library path",
|
||||
HILOG_DEBUG("MainThread::handleLaunchApplication %{public}s need add app detail ability library path.",
|
||||
bundleName.c_str());
|
||||
LoadAppDetailAbilityLibrary(appInfo.appDetailAbilityLibraryPath);
|
||||
}
|
||||
@ -1252,7 +1252,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
if (isStageBased) {
|
||||
AppRecovery::GetInstance().InitApplicationInfo(GetMainHandler(), GetApplicationInfo());
|
||||
}
|
||||
HILOG_DEBUG("stageBased:%{public}d moduleJson:%{public}d size:%{public}zu",
|
||||
HILOG_DEBUG("StageBased:%{public}d moduleJson:%{public}d size:%{public}zu",
|
||||
isStageBased, moduelJson, bundleInfo.hapModuleInfos.size());
|
||||
|
||||
// create contextImpl
|
||||
@ -1266,12 +1266,12 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
HspList hspList;
|
||||
ErrCode ret = bundleMgrHelper->GetBaseSharedBundleInfos(appInfo.bundleName, hspList);
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_ERROR("GetBaseSharedBundleInfos failed: %{public}d", ret);
|
||||
HILOG_ERROR("GetBaseSharedBundleInfos failed: %{public}d.", ret);
|
||||
}
|
||||
AppLibPathMap appLibPaths {};
|
||||
GetNativeLibPath(bundleInfo, hspList, appLibPaths);
|
||||
bool isSystemApp = bundleInfo.applicationInfo.isSystemApp;
|
||||
HILOG_DEBUG("the application isSystemApp: %{public}d", isSystemApp);
|
||||
HILOG_DEBUG("The application isSystemApp: %{public}d.", isSystemApp);
|
||||
AbilityRuntime::JsRuntime::SetAppLibPath(appLibPaths, isSystemApp);
|
||||
|
||||
if (isStageBased) {
|
||||
@ -1292,7 +1292,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
options.apiTargetVersion = appInfo.apiTargetVersion;
|
||||
auto runtime = AbilityRuntime::Runtime::Create(options);
|
||||
if (!runtime) {
|
||||
HILOG_ERROR("Failed to create runtime");
|
||||
HILOG_ERROR("Failed to create runtime.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1301,7 +1301,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
auto cb = [weak]() {
|
||||
auto appThread = weak.promote();
|
||||
if (appThread == nullptr) {
|
||||
HILOG_ERROR("appThread is nullptr");
|
||||
HILOG_ERROR("AppThread is nullptr.");
|
||||
return false;
|
||||
}
|
||||
return appThread->NotifyDeviceDisConnect();
|
||||
@ -1313,11 +1313,11 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
std::string processName = "";
|
||||
if (processInfo_ != nullptr) {
|
||||
processName = processInfo_->GetProcessName();
|
||||
HILOG_DEBUG("MainThread::HandleLaunchApplication processName is %{public}s", processName.c_str());
|
||||
HILOG_DEBUG("MainThread::HandleLaunchApplication processName is %{public}s.", processName.c_str());
|
||||
}
|
||||
if (perfCmd.find(PERFCMD_PROFILE) != std::string::npos ||
|
||||
perfCmd.find(PERFCMD_DUMPHEAP) != std::string::npos) {
|
||||
HILOG_DEBUG("perfCmd is %{public}s", perfCmd.c_str());
|
||||
HILOG_DEBUG("PerfCmd is %{public}s.", perfCmd.c_str());
|
||||
runtime->StartProfiler(perfCmd, appLaunchData.GetDebugApp(), appInfo.debug, processName);
|
||||
} else {
|
||||
runtime->StartDebugMode(appLaunchData.GetDebugApp(), appInfo.debug, processName);
|
||||
@ -1327,7 +1327,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
std::map<std::string, std::string> modulePaths;
|
||||
if (!hqfInfos.empty()) {
|
||||
for (auto it = hqfInfos.begin(); it != hqfInfos.end(); it++) {
|
||||
HILOG_INFO("moudelName: %{private}s, hqfFilePath: %{private}s.",
|
||||
HILOG_INFO("MoudelName: %{private}s, hqfFilePath: %{private}s.",
|
||||
it->moduleName.c_str(), it->hqfFilePath.c_str());
|
||||
modulePaths.insert(std::make_pair(it->moduleName, it->hqfFilePath));
|
||||
}
|
||||
@ -1344,7 +1344,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
(std::string summary, const JsEnv::ErrorObject errorObj) {
|
||||
auto appThread = weak.promote();
|
||||
if (appThread == nullptr) {
|
||||
HILOG_ERROR("appThread is nullptr.");
|
||||
HILOG_ERROR("AppThread is nullptr.");
|
||||
return;
|
||||
}
|
||||
time_t timet;
|
||||
@ -2724,14 +2724,14 @@ int MainThread::GetOverlayModuleInfos(const std::string &bundleName, const std::
|
||||
|
||||
auto ret = overlayMgrProxy->GetTargetOverlayModuleInfo(moduleName, overlayModuleInfos);
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_ERROR("GetOverlayModuleInfo form bms failed.");
|
||||
HILOG_ERROR("GetOverlayModuleInfo form bundleMgrHelper failed.");
|
||||
return ret;
|
||||
}
|
||||
std::sort(overlayModuleInfos.begin(), overlayModuleInfos.end(),
|
||||
[](const OverlayModuleInfo& lhs, const OverlayModuleInfo& rhs) -> bool {
|
||||
return lhs.priority > rhs.priority;
|
||||
});
|
||||
HILOG_DEBUG("GetOverlayPath end, the size of overlay is: %{public}zu", overlayModuleInfos.size());
|
||||
HILOG_DEBUG("GetOverlayPath end, the size of overlay is: %{public}zu.", overlayModuleInfos.size());
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
@ -130,12 +130,12 @@ std::string JsModuleReader::GetPresetAppHapPath(const std::string& inputPath, co
|
||||
std::string presetAppHapPath = inputPath;
|
||||
std::string moduleName = inputPath.substr(inputPath.find_last_of("/") + 1);
|
||||
if (moduleName.empty()) {
|
||||
HILOG_ERROR("failed to obtain moduleName.");
|
||||
HILOG_ERROR("Failed to obtain moduleName.");
|
||||
return presetAppHapPath;
|
||||
}
|
||||
auto bundleMgrHelper = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("fail to get bundle manager helper.");
|
||||
HILOG_ERROR("Fail to get bundle manager helper.");
|
||||
return presetAppHapPath;
|
||||
}
|
||||
if (inputPath.find_first_of("/") == inputPath.find_last_of("/")) {
|
||||
|
@ -276,7 +276,7 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, std::vector<uint
|
||||
return false;
|
||||
}
|
||||
if (bundleInfo.hapModuleInfos.size() == 0) {
|
||||
HILOG_ERROR("get hapModuleInfo of bundleInfo failed.");
|
||||
HILOG_ERROR("Get hapModuleInfo of bundleInfo failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -292,12 +292,12 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, std::vector<uint
|
||||
}
|
||||
}
|
||||
}
|
||||
HILOG_INFO("HapPath: %{private}s", newHapPath.c_str());
|
||||
HILOG_INFO("HapPath: %{private}s.", newHapPath.c_str());
|
||||
bool newCreate = false;
|
||||
std::string loadPath = ExtractorUtil::GetLoadFilePath(newHapPath);
|
||||
std::shared_ptr<Extractor> extractor = ExtractorUtil::GetExtractor(loadPath, newCreate);
|
||||
if (extractor == nullptr) {
|
||||
HILOG_ERROR("loadPath %{private}s GetExtractor failed", loadPath.c_str());
|
||||
HILOG_ERROR("LoadPath %{private}s GetExtractor failed.", loadPath.c_str());
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<uint8_t[]> dataPtr = nullptr;
|
||||
@ -307,27 +307,27 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, std::vector<uint
|
||||
bool flag = false;
|
||||
for (const auto& basePath : workerInfo_->assetBasePathStr) {
|
||||
realfilePath = basePath + filePath;
|
||||
HILOG_DEBUG("realfilePath: %{private}s", realfilePath.c_str());
|
||||
HILOG_DEBUG("RealfilePath: %{private}s.", realfilePath.c_str());
|
||||
if (extractor->ExtractToBufByName(realfilePath, dataPtr, fileLen)) {
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag) {
|
||||
HILOG_ERROR("ExtractToBufByName error");
|
||||
HILOG_ERROR("ExtractToBufByName error.");
|
||||
return flag;
|
||||
}
|
||||
} else {
|
||||
realfilePath = filePath.substr(pos + 1);
|
||||
HILOG_DEBUG("realfilePath: %{private}s", realfilePath.c_str());
|
||||
HILOG_DEBUG("RealfilePath: %{private}s.", realfilePath.c_str());
|
||||
if (!extractor->ExtractToBufByName(realfilePath, dataPtr, fileLen)) {
|
||||
HILOG_ERROR("get mergeAbc fileBuffer failed");
|
||||
HILOG_ERROR("Get mergeAbc fileBuffer failed.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!workerInfo_->isDebugVersion && fileLen > ASSET_FILE_MAX_SIZE) {
|
||||
HILOG_ERROR("ReadFilePathData failed, file is too large");
|
||||
HILOG_ERROR("ReadFilePathData failed, file is too large.");
|
||||
return false;
|
||||
}
|
||||
content.assign(dataPtr.get(), dataPtr.get() + fileLen);
|
||||
|
@ -55,7 +55,6 @@ ohos_shared_library("quickfix_manager") {
|
||||
]
|
||||
sources += filter_include(output_values, [ "*.cpp" ])
|
||||
defines = [ "AMS_LOG_TAG = \"QuickFixService\"" ]
|
||||
|
||||
deps = [
|
||||
":quickfix_manager_interface",
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
|
@ -61,7 +61,7 @@ sptr<AppExecFwk::IQuickFixManager> QuickFixUtil::GetBundleQuickFixMgrProxy()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("function finished.");
|
||||
HILOG_DEBUG("Function finished.");
|
||||
return bundleQuickFixMgr;
|
||||
}
|
||||
} // namespace AAFwk
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define OHOS_ABILITY_RUNTIME_BUNDLE_MGR_HELPER_H
|
||||
|
||||
#include <singleton.h>
|
||||
|
||||
#include "bundle_mgr_interface.h"
|
||||
|
||||
namespace OHOS {
|
||||
@ -26,7 +27,7 @@ using Want = OHOS::AAFwk::Want;
|
||||
class BundleMgrHelper : public std::enable_shared_from_this<BundleMgrHelper> {
|
||||
public:
|
||||
DISALLOW_COPY_AND_MOVE(BundleMgrHelper);
|
||||
ErrCode GetNameForUid(const int uid, std::string &name);
|
||||
ErrCode GetNameForUid(const int32_t uid, std::string &name);
|
||||
bool GetBundleInfo(const std::string &bundleName, const BundleFlag flag, BundleInfo &bundleInfo, int32_t userId);
|
||||
ErrCode InstallSandboxApp(const std::string &bundleName, int32_t dlpType, int32_t userId, int32_t &appIndex);
|
||||
ErrCode UninstallSandboxApp(const std::string &bundleName, int32_t appIndex, int32_t userId);
|
||||
@ -58,7 +59,7 @@ public:
|
||||
bool QueryExtensionAbilityInfos(const Want &want, const int32_t &flag, const int32_t &userId,
|
||||
std::vector<ExtensionAbilityInfo> &extensionInfos);
|
||||
bool GetApplicationInfo(
|
||||
const std::string &appName, const ApplicationFlag flag, const int userId, ApplicationInfo &appInfo);
|
||||
const std::string &appName, const ApplicationFlag flag, const int32_t userId, ApplicationInfo &appInfo);
|
||||
bool GetApplicationInfo(const std::string &appName, int32_t flags, int32_t userId, ApplicationInfo &appInfo);
|
||||
ErrCode GetJsonProfile(ProfileType profileType, const std::string &bundleName,
|
||||
const std::string &moduleName, std::string &profile, int32_t userId = Constants::UNSPECIFIED_USERID);
|
||||
@ -73,14 +74,15 @@ public:
|
||||
void UpgradeAtomicService(const Want &want, int32_t userId);
|
||||
bool ImplicitQueryInfos(const Want &want, int32_t flags, int32_t userId, bool withDefault,
|
||||
std::vector<AbilityInfo> &abilityInfos, std::vector<ExtensionAbilityInfo> &extensionInfos);
|
||||
bool CleanBundleDataFiles(const std::string &bundleName, const int userId = Constants::DEFAULT_USERID);
|
||||
bool CleanBundleDataFiles(const std::string &bundleName, const int32_t userId = Constants::DEFAULT_USERID);
|
||||
bool QueryDataGroupInfos(const std::string &bundleName, int32_t userId, std::vector<DataGroupInfo> &infos);
|
||||
bool GetBundleGidsByUid(const std::string &bundleName, const int &uid, std::vector<int> &gids);
|
||||
bool GetBundleGidsByUid(const std::string &bundleName, const int32_t &uid, std::vector<int32_t> &gids);
|
||||
bool RegisterBundleEventCallback(const sptr<IBundleEventCallback> &bundleEventCallback);
|
||||
bool GetBundleInfos(
|
||||
const BundleFlag flag, std::vector<BundleInfo> &bundleInfos, int32_t userId = Constants::UNSPECIFIED_USERID);
|
||||
bool GetHapModuleInfo(const AbilityInfo &abilityInfo, int32_t userId, HapModuleInfo &hapModuleInfo);
|
||||
int GetUidByBundleName(const std::string &bundleName, const int userId);
|
||||
bool QueryAppGalleryBundleName(std::string &bundleName);
|
||||
ErrCode GetUidByBundleName(const std::string &bundleName, const int32_t userId);
|
||||
sptr<IDefaultApp> GetDefaultAppProxy();
|
||||
|
||||
private:
|
||||
@ -97,4 +99,4 @@ private:
|
||||
};
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
||||
#endif // OHOS_ABILITY_RUNTIME_BUNDLE_MGR_HELPER_H
|
||||
#endif // OHOS_ABILITY_RUNTIME_BUNDLE_MGR_HELPER_H
|
||||
|
@ -42,7 +42,7 @@ bool ServiceRouterDataMgr::LoadAllBundleInfos()
|
||||
auto flags = (BundleFlag::GET_BUNDLE_WITH_ABILITIES | BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO);
|
||||
std::vector<BundleInfo> bundleInfos;
|
||||
if (!bundleMgrHelper->GetBundleInfos(flags, bundleInfos, SrSamgrHelper::GetCurrentActiveUserId())) {
|
||||
APP_LOGE("SRDM bms->GetBundleInfos return false");
|
||||
APP_LOGE("Return false.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ bool ServiceRouterDataMgr::LoadBundleInfo(const std::string &bundleName)
|
||||
BundleInfo bundleInfo;
|
||||
auto flags = (BundleFlag::GET_BUNDLE_WITH_ABILITIES | BundleFlag::GET_BUNDLE_WITH_EXTENSION_INFO);
|
||||
if (!bundleMgrHelper->GetBundleInfo(bundleName, flags, bundleInfo, SrSamgrHelper::GetCurrentActiveUserId())) {
|
||||
APP_LOGE("SRDM bms->GetBundleInfos return false");
|
||||
APP_LOGE("Return false.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1608,7 +1608,7 @@ bool AbilityConnectManager::IsAbilityNeedKeepAlive(const std::shared_ptr<Ability
|
||||
bool getBundleInfos = bundleMgrHelper->GetBundleInfos(
|
||||
OHOS::AppExecFwk::GET_BUNDLE_DEFAULT, bundleInfos, USER_ID_NO_HEAD);
|
||||
if (!getBundleInfos) {
|
||||
HILOG_ERROR("Handle ability died task, get bundle infos failed");
|
||||
HILOG_ERROR("Handle ability died task, get bundle infos failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ bool CrowdTestInterceptor::CheckCrowdtest(const Want &want, int32_t userId)
|
||||
// get bms
|
||||
auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("GetBundleManager failed");
|
||||
HILOG_ERROR("GetBundleManager failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ bool CrowdTestInterceptor::CheckCrowdtest(const Want &want, int32_t userId)
|
||||
system_clock::now().time_since_epoch()).count();
|
||||
if (appDistributionType == AppExecFwk::Constants::APP_DISTRIBUTION_TYPE_CROWDTESTING &&
|
||||
appCrowdtestDeadline < now) {
|
||||
HILOG_INFO("The application is expired, expired time is %{public}s",
|
||||
HILOG_INFO("The application is expired, expired time is %{public}s.",
|
||||
std::to_string(appCrowdtestDeadline).c_str());
|
||||
return true;
|
||||
}
|
||||
@ -142,7 +142,7 @@ bool ControlInterceptor::CheckControl(const Want &want, int32_t userId,
|
||||
// get bms
|
||||
auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("GetBundleManager failed");
|
||||
HILOG_ERROR("GetBundleManager failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -150,13 +150,13 @@ bool ControlInterceptor::CheckControl(const Want &want, int32_t userId,
|
||||
std::string bundleName = want.GetBundle();
|
||||
auto appControlMgr = bundleMgrHelper->GetAppControlProxy();
|
||||
if (appControlMgr == nullptr) {
|
||||
HILOG_ERROR("Get appControlMgr failed");
|
||||
HILOG_ERROR("Get appControlMgr failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
auto ret = IN_PROCESS_CALL(appControlMgr->GetAppRunningControlRule(bundleName, userId, controlRule));
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_DEBUG("Get No AppRunningControlRule");
|
||||
HILOG_DEBUG("Get No AppRunningControlRule.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@ -214,17 +214,17 @@ bool DisposedRuleInterceptor::CheckControl(const Want &want, int32_t userId,
|
||||
AppExecFwk::DisposedRule &disposedRule)
|
||||
{
|
||||
// get bms
|
||||
auto bms = AbilityUtil::GetBundleManagerHelper();
|
||||
if (!bms) {
|
||||
HILOG_ERROR("GetBundleManager failed");
|
||||
auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("GetBundleManager failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// get disposed status
|
||||
std::string bundleName = want.GetBundle();
|
||||
auto appControlMgr = bms->GetAppControlProxy();
|
||||
auto appControlMgr = bundleMgrHelper->GetAppControlProxy();
|
||||
if (appControlMgr == nullptr) {
|
||||
HILOG_ERROR("Get appControlMgr failed");
|
||||
HILOG_ERROR("Get appControlMgr failed.");
|
||||
return false;
|
||||
}
|
||||
std::vector<AppExecFwk::DisposedRule> disposedRuleList;
|
||||
@ -232,7 +232,7 @@ bool DisposedRuleInterceptor::CheckControl(const Want &want, int32_t userId,
|
||||
auto ret = IN_PROCESS_CALL(appControlMgr->GetAbilityRunningControlRule(bundleName,
|
||||
userId, disposedRuleList));
|
||||
if (ret != ERR_OK || disposedRuleList.empty()) {
|
||||
HILOG_DEBUG("Get No DisposedRule");
|
||||
HILOG_DEBUG("Get No DisposedRule.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -337,13 +337,13 @@ void EcologicalRuleInterceptor::GetEcologicalCallerInfo(const Want &want, ErmsCa
|
||||
if (!getTargetResult) {
|
||||
HILOG_ERROR("Get targetAppInfo failed.");
|
||||
} else if (targetAppInfo.bundleType == AppExecFwk::BundleType::ATOMIC_SERVICE) {
|
||||
HILOG_DEBUG("the target type is atomic service");
|
||||
HILOG_DEBUG("The target type is atomic service.");
|
||||
callerInfo.targetAppType = TYPE_HARMONY_SERVICE;
|
||||
} else if (targetAppInfo.bundleType == AppExecFwk::BundleType::APP) {
|
||||
HILOG_DEBUG("the target type is app");
|
||||
HILOG_DEBUG("The target type is app.");
|
||||
callerInfo.targetAppType = TYPE_HARMONY_APP;
|
||||
} else {
|
||||
HILOG_DEBUG("the target type is invalid type");
|
||||
HILOG_DEBUG("The target type is invalid type.");
|
||||
}
|
||||
|
||||
std::string callerBundleName;
|
||||
@ -358,13 +358,13 @@ void EcologicalRuleInterceptor::GetEcologicalCallerInfo(const Want &want, ErmsCa
|
||||
if (!getCallerResult) {
|
||||
HILOG_DEBUG("Get callerAppInfo failed.");
|
||||
} else if (callerAppInfo.bundleType == AppExecFwk::BundleType::ATOMIC_SERVICE) {
|
||||
HILOG_DEBUG("the caller type is atomic service");
|
||||
HILOG_DEBUG("The caller type is atomic service.");
|
||||
callerInfo.callerAppType = TYPE_HARMONY_SERVICE;
|
||||
} else if (callerAppInfo.bundleType == AppExecFwk::BundleType::APP) {
|
||||
HILOG_DEBUG("the caller type is app");
|
||||
HILOG_DEBUG("The caller type is app.");
|
||||
callerInfo.callerAppType = TYPE_HARMONY_APP;
|
||||
} else {
|
||||
HILOG_DEBUG("the caller type is invalid type");
|
||||
HILOG_DEBUG("The caller type is invalid type.");
|
||||
}
|
||||
}
|
||||
#else
|
||||
@ -407,13 +407,13 @@ ErrCode AbilityJumpInterceptor::DoProcess(const Want &want, int requestCode, int
|
||||
IN_PROCESS_CALL_WITHOUT_RET(bundleMgrHelper->QueryAbilityInfo(want,
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION, userId, targetAbilityInfo));
|
||||
if (targetAbilityInfo.type != AppExecFwk::AbilityType::PAGE) {
|
||||
HILOG_INFO("Target is not page Ability, keep going, abilityType:%{public}d", targetAbilityInfo.type);
|
||||
HILOG_INFO("Target is not page Ability, keep going, abilityType:%{public}d.", targetAbilityInfo.type);
|
||||
return ERR_OK;
|
||||
}
|
||||
AppExecFwk::AppJumpControlRule controlRule;
|
||||
if (CheckControl(bundleMgrHelper, want, userId, controlRule)) {
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
HILOG_INFO("app jump need to be intercepted, caller:%{public}s, target:%{public}s",
|
||||
HILOG_INFO("App jump need to be intercepted, caller:%{public}s, target:%{public}s.",
|
||||
controlRule.callerPkg.c_str(), controlRule.targetPkg.c_str());
|
||||
auto sysDialogScheduler = DelayedSingleton<SystemDialogScheduler>::GetInstance();
|
||||
Want targetWant = want;
|
||||
@ -423,7 +423,7 @@ ErrCode AbilityJumpInterceptor::DoProcess(const Want &want, int requestCode, int
|
||||
int ret = IN_PROCESS_CALL(AbilityManagerClient::GetInstance()->StartAbility(dialogWant,
|
||||
requestCode, userId));
|
||||
if (ret != ERR_OK) {
|
||||
HILOG_INFO("AppInterceptor Dialog StartAbility error, ret:%{public}d", ret);
|
||||
HILOG_INFO("AppInterceptor Dialog StartAbility error, ret:%{public}d.", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
@ -433,7 +433,7 @@ ErrCode AbilityJumpInterceptor::DoProcess(const Want &want, int requestCode, int
|
||||
}
|
||||
|
||||
bool AbilityJumpInterceptor::CheckControl(std::shared_ptr<AppExecFwk::BundleMgrHelper> &bundleMgrHelper,
|
||||
const Want &want, int32_t userId, AppExecFwk::AppJumpControlRule &controlRule)
|
||||
const Want &want, int32_t userId, AppExecFwk::AppJumpControlRule &controlRule)
|
||||
{
|
||||
int callerUid = IPCSkeleton::GetCallingUid();
|
||||
std::string callerBundleName;
|
||||
@ -450,26 +450,26 @@ bool AbilityJumpInterceptor::CheckControl(std::shared_ptr<AppExecFwk::BundleMgrH
|
||||
return false;
|
||||
}
|
||||
if (controlRule.callerPkg == controlRule.targetPkg) {
|
||||
HILOG_INFO("jump within the same app.");
|
||||
HILOG_INFO("Jump within the same app.");
|
||||
return false;
|
||||
}
|
||||
if (CheckIfJumpExempt(bundleMgrHelper, controlRule, userId)) {
|
||||
HILOG_INFO("jump from or to system or exempt apps");
|
||||
HILOG_INFO("Jump from or to system or exempt apps.");
|
||||
return false;
|
||||
}
|
||||
// get disposed status
|
||||
auto appControlMgr = bundleMgrHelper->GetAppControlProxy();
|
||||
if (appControlMgr == nullptr) {
|
||||
HILOG_ERROR("Get appControlMgr failed");
|
||||
HILOG_ERROR("Get appControlMgr failed.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IN_PROCESS_CALL(appControlMgr->GetAppJumpControlRule(callerBundleName, targetBundleName,
|
||||
userId, controlRule)) != ERR_OK) {
|
||||
HILOG_INFO("no jump control rule found");
|
||||
HILOG_INFO("No jump control rule found.");
|
||||
return true;
|
||||
}
|
||||
HILOG_INFO("get appJumpControlRule, jumpMode:%d", controlRule.jumpMode);
|
||||
HILOG_INFO("Get appJumpControlRule, jumpMode:%d.", controlRule.jumpMode);
|
||||
return controlRule.jumpMode != AppExecFwk::AbilityJumpMode::DIRECT;
|
||||
}
|
||||
|
||||
@ -478,15 +478,15 @@ bool AbilityJumpInterceptor::CheckIfJumpExempt(std::shared_ptr<AppExecFwk::Bundl
|
||||
{
|
||||
if (CheckIfExemptByBundleName(bundleMgrHelper, controlRule.callerPkg,
|
||||
PermissionConstants::PERMISSION_EXEMPT_AS_CALLER, userId)) {
|
||||
HILOG_INFO("Jump from exempt caller app, No need to intercept");
|
||||
HILOG_INFO("Jump from exempt caller app, No need to intercept.");
|
||||
return true;
|
||||
}
|
||||
if (CheckIfExemptByBundleName(bundleMgrHelper, controlRule.targetPkg,
|
||||
PermissionConstants::PERMISSION_EXEMPT_AS_TARGET, userId)) {
|
||||
HILOG_INFO("Jump to exempt target app, No need to intercept");
|
||||
HILOG_INFO("Jump to exempt target app, No need to intercept.");
|
||||
return true;
|
||||
}
|
||||
HILOG_INFO("Third-party apps jump to third-party apps");
|
||||
HILOG_INFO("Third-party apps jump to third-party apps.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -496,19 +496,19 @@ bool AbilityJumpInterceptor::CheckIfExemptByBundleName(std::shared_ptr<AppExecFw
|
||||
AppExecFwk::ApplicationInfo appInfo;
|
||||
if (!IN_PROCESS_CALL(bundleMgrHelper->GetApplicationInfo(bundleName, AppExecFwk::BundleFlag::GET_BUNDLE_DEFAULT,
|
||||
userId, appInfo))) {
|
||||
HILOG_ERROR("VerifyPermission failed to get application info");
|
||||
HILOG_ERROR("VerifyPermission failed to get application info.");
|
||||
return false;
|
||||
}
|
||||
if (appInfo.isSystemApp) {
|
||||
HILOG_INFO("bundle:%{public}s is system app", bundleName.c_str());
|
||||
HILOG_INFO("bundle:%{public}s is system app.", bundleName.c_str());
|
||||
return true;
|
||||
}
|
||||
int32_t ret = Security::AccessToken::AccessTokenKit::VerifyAccessToken(appInfo.accessTokenId, permission);
|
||||
if (ret == Security::AccessToken::PermissionState::PERMISSION_DENIED) {
|
||||
HILOG_DEBUG("VerifyPermission %{public}d: PERMISSION_DENIED", appInfo.accessTokenId);
|
||||
HILOG_DEBUG("VerifyPermission %{public}d: PERMISSION_DENIED.", appInfo.accessTokenId);
|
||||
return false;
|
||||
}
|
||||
HILOG_INFO("bundle:%{public}s verify permission:%{public}s successed", bundleName.c_str(), permission.c_str());
|
||||
HILOG_INFO("Bundle:%{public}s verify permission:%{public}s successed.", bundleName.c_str(), permission.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2714,7 +2714,7 @@ void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName,
|
||||
return;
|
||||
}
|
||||
if (targetBundleName == SHELL_ASSISTANT_BUNDLENAME && collaboratorType_ == CollaboratorType::OTHERS_TYPE) {
|
||||
HILOG_DEBUG("reject shell application to grant uri permission");
|
||||
HILOG_DEBUG("Reject shell application to grant uri permission.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2734,19 +2734,19 @@ void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName,
|
||||
if (!uriStr.empty()) {
|
||||
uriVec.emplace_back(uriStr);
|
||||
}
|
||||
HILOG_DEBUG("GrantUriPermission uriVec size: %{public}zu", uriVec.size());
|
||||
HILOG_DEBUG("GrantUriPermission uriVec size: %{public}zu.", uriVec.size());
|
||||
if (uriVec.size() == 0) {
|
||||
return;
|
||||
}
|
||||
if (uriVec.size() > MAX_URI_COUNT) {
|
||||
HILOG_ERROR("size of uriVec is more than %{public}i", MAX_URI_COUNT);
|
||||
HILOG_ERROR("Size of uriVec is more than %{public}i.", MAX_URI_COUNT);
|
||||
return;
|
||||
}
|
||||
|
||||
auto callerPkg = want.GetStringParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME);
|
||||
if (callerPkg == SHELL_ASSISTANT_BUNDLENAME
|
||||
&& GrantPermissionToShell(uriVec, want.GetFlags(), targetBundleName)) {
|
||||
HILOG_INFO("permission to shell");
|
||||
HILOG_INFO("Permission to shell.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2767,14 +2767,14 @@ void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName,
|
||||
for (auto&& str : uriVec) {
|
||||
Uri uri(str);
|
||||
auto&& scheme = uri.GetScheme();
|
||||
HILOG_INFO("uri scheme is %{public}s.", scheme.c_str());
|
||||
HILOG_INFO("Uri scheme is %{public}s.", scheme.c_str());
|
||||
// only support file scheme
|
||||
if (scheme != "file") {
|
||||
HILOG_WARN("only support file uri.");
|
||||
HILOG_WARN("Only support file uri.");
|
||||
continue;
|
||||
}
|
||||
auto&& authority = uri.GetAuthority();
|
||||
HILOG_INFO("uri authority is %{public}s.", authority.c_str());
|
||||
HILOG_INFO("Uri authority is %{public}s.", authority.c_str());
|
||||
bool authorityFlag = authority == "media" || authority == "docs";
|
||||
uint32_t flag = want.GetFlags();
|
||||
if (authorityFlag && !isGrantPersistableUriPermissionEnable_) {
|
||||
@ -2804,7 +2804,7 @@ void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName,
|
||||
uriBundleInfo.applicationInfo.accessTokenId != callerAccessTokenId_ &&
|
||||
uriBundleInfo.applicationInfo.accessTokenId != callerTokenId;
|
||||
if (notBelong2Caller) {
|
||||
HILOG_ERROR("the uri does not belong to caller.");
|
||||
HILOG_ERROR("The uri does not belong to caller.");
|
||||
continue;
|
||||
}
|
||||
flag &= (~Want::FLAG_AUTH_PERSISTABLE_URI_PERMISSION);
|
||||
|
@ -636,7 +636,7 @@ void DataAbilityManager::RestartDataAbility(const std::shared_ptr<AbilityRecord>
|
||||
bool getBundleInfos = bundleMgrHelper->GetBundleInfos(
|
||||
OHOS::AppExecFwk::GET_BUNDLE_DEFAULT, bundleInfos, USER_ID_NO_HEAD);
|
||||
if (!getBundleInfos) {
|
||||
HILOG_ERROR("Handle ability died task, get bundle infos failed");
|
||||
HILOG_ERROR("Handle ability died task, get bundle infos failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -659,7 +659,7 @@ void DataAbilityManager::RestartDataAbility(const std::shared_ptr<AbilityRecord>
|
||||
bool getDataAbilityUri = OHOS::DelayedSingleton<AbilityManagerService>::GetInstance()->GetDataAbilityUri(
|
||||
hapModuleInfo.abilityInfos, mainElement, uriStr);
|
||||
if (getDataAbilityUri) {
|
||||
HILOG_INFO("restart data ability: %{public}s, uri: %{public}s",
|
||||
HILOG_INFO("Restart data ability: %{public}s, uri: %{public}s.",
|
||||
abilityRecord->GetAbilityInfo().name.c_str(), uriStr.c_str());
|
||||
Uri uri(uriStr);
|
||||
OHOS::DelayedSingleton<AbilityManagerService>::GetInstance()->AcquireDataAbility(uri, true, nullptr);
|
||||
|
@ -105,7 +105,6 @@ int FreeInstallManager::StartFreeInstall(const Want &want, int32_t userId, int r
|
||||
if (isAsync) {
|
||||
PostTimeoutTask(want);
|
||||
}
|
||||
|
||||
if (IN_PROCESS_CALL(bundleMgrHelper->QueryAbilityInfo(info.want, flag, info.userId, abilityInfo, callback))) {
|
||||
HILOG_INFO("The app has installed.");
|
||||
}
|
||||
@ -364,9 +363,9 @@ int FreeInstallManager::ConnectFreeInstall(const Want &want, int32_t userId,
|
||||
AppExecFwk::AbilityInfo abilityInfo;
|
||||
std::vector<AppExecFwk::ExtensionAbilityInfo> extensionInfos;
|
||||
if (!IN_PROCESS_CALL(bundleMgrHelper->QueryAbilityInfo(
|
||||
want, AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION, userId,abilityInfo)) &&
|
||||
want, AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION, userId,abilityInfo)) &&
|
||||
!IN_PROCESS_CALL(bundleMgrHelper->QueryExtensionAbilityInfos(
|
||||
want, AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION, userId, extensionInfos))) {
|
||||
want, AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION, userId, extensionInfos))) {
|
||||
HILOG_INFO("AbilityManagerService::ConnectFreeInstall. try to StartFreeInstall");
|
||||
int result = StartFreeInstall(want, userId, DEFAULT_INVAL_VALUE, callerToken);
|
||||
if (result) {
|
||||
|
@ -231,7 +231,7 @@ std::string ImplicitStartProcessor::MatchTypeAndUri(const AAFwk::Want &want)
|
||||
int ImplicitStartProcessor::GenerateAbilityRequestByAction(int32_t userId,
|
||||
AbilityRequest &request, std::vector<DialogAppInfo> &dialogAppInfos, std::string &deviceType, bool isMoreHapList)
|
||||
{
|
||||
HILOG_DEBUG("%{public}s", __func__);
|
||||
HILOG_DEBUG("%{public}s.", __func__);
|
||||
// get abilityinfos from bms
|
||||
auto bundleMgrHelper = GetBundleManagerHelper();
|
||||
CHECK_POINTER_AND_RETURN(bundleMgrHelper, GET_ABILITY_SERVICE_FAILED);
|
||||
@ -243,7 +243,7 @@ int ImplicitStartProcessor::GenerateAbilityRequestByAction(int32_t userId,
|
||||
withDefault = request.want.GetBoolParam(SHOW_DEFAULT_PICKER_FLAG, withDefault) ? false : true;
|
||||
|
||||
if (IPCSkeleton::GetCallingUid() == 1027 && !request.want.GetStringArrayParam(PARAM_ABILITY_APPINFOS).empty()) {
|
||||
HILOG_INFO("The NFCNeed caller source is NFC");
|
||||
HILOG_INFO("The NFCNeed caller source is NFC.");
|
||||
|
||||
ImplicitStartProcessor::queryBmsAppInfos(request, userId, dialogAppInfos);
|
||||
return ERR_OK;
|
||||
@ -252,14 +252,14 @@ int ImplicitStartProcessor::GenerateAbilityRequestByAction(int32_t userId,
|
||||
IN_PROCESS_CALL_WITHOUT_RET(bundleMgrHelper->ImplicitQueryInfos(
|
||||
request.want, abilityInfoFlag, userId, withDefault, abilityInfos, extensionInfos));
|
||||
|
||||
HILOG_INFO("ImplicitQueryInfos, abilityInfo size : %{public}zu, extensionInfos size: %{public}zu",
|
||||
HILOG_INFO("ImplicitQueryInfos, abilityInfo size : %{public}zu, extensionInfos size: %{public}zu.",
|
||||
abilityInfos.size(), extensionInfos.size());
|
||||
|
||||
if (abilityInfos.size() + extensionInfos.size() > 1) {
|
||||
HILOG_INFO("More than one target application, filter by erms");
|
||||
HILOG_INFO("More than one target application, filter by erms.");
|
||||
bool ret = FilterAbilityList(request.want, abilityInfos, extensionInfos, userId);
|
||||
if (!ret) {
|
||||
HILOG_ERROR("FilterAbilityList failed");
|
||||
HILOG_ERROR("FilterAbilityList failed.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,10 +296,10 @@ int ImplicitStartProcessor::GenerateAbilityRequestByAction(int32_t userId,
|
||||
IN_PROCESS_CALL(defaultMgr->GetDefaultApplication(userId, typeName, bundleInfo));
|
||||
if (ret == ERR_OK) {
|
||||
if (bundleInfo.abilityInfos.size() == 1) {
|
||||
HILOG_INFO("find default ability.");
|
||||
HILOG_INFO("Find default ability.");
|
||||
isDefaultFlag = true;
|
||||
} else if (bundleInfo.extensionInfos.size() == 1) {
|
||||
HILOG_INFO("find default extension.");
|
||||
HILOG_INFO("Find default extension.");
|
||||
isDefaultFlag = true;
|
||||
} else {
|
||||
HILOG_INFO("GetDefaultApplication failed.");
|
||||
@ -468,6 +468,9 @@ std::shared_ptr<AppExecFwk::BundleMgrHelper> ImplicitStartProcessor::GetBundleMa
|
||||
sptr<AppExecFwk::IDefaultApp> ImplicitStartProcessor::GetDefaultAppProxy()
|
||||
{
|
||||
auto bundleMgrHelper = GetBundleManagerHelper();
|
||||
if(bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("Failed to get bundle manager helper.");
|
||||
}
|
||||
auto defaultAppProxy = bundleMgrHelper->GetDefaultAppProxy();
|
||||
if (defaultAppProxy == nullptr) {
|
||||
HILOG_ERROR("Get default app proxy failed.");
|
||||
|
@ -65,7 +65,7 @@ std::string InsightIntentUtils::GetSrcEntry(const std::string &bundleName, const
|
||||
srcEntry = info.srcEntry;
|
||||
}
|
||||
}
|
||||
HILOG_DEBUG("srcEntry: %{public}s", srcEntry.c_str());
|
||||
HILOG_DEBUG("SrcEntry: %{public}s.", srcEntry.c_str());
|
||||
return srcEntry;
|
||||
}
|
||||
} // namespace AbilityRuntime
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "constants.h"
|
||||
#include "ability_record.h"
|
||||
#include "ability_util.h"
|
||||
#include "app_gallery_enable_util.h"
|
||||
#include "app_scheduler.h"
|
||||
#include "dm_common.h"
|
||||
#include "display_manager.h"
|
||||
@ -362,14 +363,14 @@ Want SystemDialogScheduler::GetSelectorDialogWant(const std::vector<DialogAppInf
|
||||
HILOG_DEBUG("set callertoken to targetWant");
|
||||
targetWant.SetParam(CALLER_TOKEN, callerToken);
|
||||
}
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
auto bms = GetBundleManager();
|
||||
if (!bms) {
|
||||
if (AppGalleryEnableUtil::IsEnableAppGallerySelector() && Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("GetBundleManager failed");
|
||||
return targetWant;
|
||||
}
|
||||
std::string bundleName;
|
||||
auto ret = IN_PROCESS_CALL(bms->QueryAppGalleryBundleName(bundleName));
|
||||
auto ret = IN_PROCESS_CALL(bundleMgrHelper->QueryAppGalleryBundleName(bundleName));
|
||||
if (ret) {
|
||||
targetWant.SetElementName(bundleName, ABILITY_NAME_APPGALLERY_SELECTOR_DIALOG);
|
||||
targetWant.SetParam(UIEXTENSION_TYPE_KEY, UIEXTENSION_SYS_COMMON_UI);
|
||||
@ -407,7 +408,7 @@ const std::string SystemDialogScheduler::GetSelectorParams(const std::vector<Dia
|
||||
Want SystemDialogScheduler::GetPcSelectorDialogWant(const std::vector<DialogAppInfo> &dialogAppInfos,
|
||||
Want &targetWant, const std::string &type, int32_t userId, const sptr<IRemoteObject> &callerToken)
|
||||
{
|
||||
HILOG_DEBUG("GetPcSelectorDialogWant start");
|
||||
HILOG_DEBUG("GetPcSelectorDialogWant start.");
|
||||
DialogPosition position;
|
||||
GetDialogPositionAndSize(DialogType::DIALOG_SELECTOR, position, static_cast<int>(dialogAppInfos.size()));
|
||||
|
||||
@ -422,14 +423,14 @@ Want SystemDialogScheduler::GetPcSelectorDialogWant(const std::vector<DialogAppI
|
||||
} else {
|
||||
targetWant.SetParam(CALLER_TOKEN, callerToken);
|
||||
}
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
auto bms = GetBundleManager();
|
||||
if (!bms) {
|
||||
HILOG_ERROR("GetBundleManager failed");
|
||||
if (AppGalleryEnableUtil::IsEnableAppGallerySelector() && Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) {
|
||||
auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("GetBundleManager failed.");
|
||||
return targetWant;
|
||||
}
|
||||
std::string bundleName;
|
||||
auto ret = IN_PROCESS_CALL(bms->QueryAppGalleryBundleName(bundleName));
|
||||
auto ret = IN_PROCESS_CALL(bundleMgrHelper->QueryAppGalleryBundleName(bundleName));
|
||||
if (ret) {
|
||||
targetWant.SetElementName(bundleName, ABILITY_NAME_APPGALLERY_SELECTOR_DIALOG);
|
||||
targetWant.SetParam(UIEXTENSION_TYPE_KEY, UIEXTENSION_SYS_COMMON_UI);
|
||||
@ -616,7 +617,7 @@ void SystemDialogScheduler::GetAppNameFromResource(int32_t labelId,
|
||||
{
|
||||
std::shared_ptr<Global::Resource::ResourceManager> resourceManager(Global::Resource::CreateResourceManager());
|
||||
if (resourceManager == nullptr) {
|
||||
HILOG_ERROR("resourceManager init failed!");
|
||||
HILOG_ERROR("ResourceManager init failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -638,7 +639,7 @@ void SystemDialogScheduler::GetAppNameFromResource(int32_t labelId,
|
||||
std::string(AbilityBase::Constants::FILE_SEPARATOR) + bundleInfo.name);
|
||||
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
std::string loadPath;
|
||||
HILOG_DEBUG("make a judgment");
|
||||
HILOG_DEBUG("Make a judgment.");
|
||||
if (!hapModuleInfo.hapPath.empty()) {
|
||||
loadPath = hapModuleInfo.hapPath;
|
||||
} else {
|
||||
@ -647,13 +648,13 @@ void SystemDialogScheduler::GetAppNameFromResource(int32_t labelId,
|
||||
if (loadPath.empty()) {
|
||||
continue;
|
||||
}
|
||||
HILOG_DEBUG("GetAppNameFromResource loadPath: %{public}s", loadPath.c_str());
|
||||
HILOG_DEBUG("GetAppNameFromResource loadPath: %{public}s.", loadPath.c_str());
|
||||
if (!resourceManager->AddResource(loadPath.c_str())) {
|
||||
HILOG_ERROR("ResourceManager add %{public}s resource path failed!", bundleInfo.name.c_str());
|
||||
HILOG_ERROR("ResourceManager add %{public}s resource path failed.", bundleInfo.name.c_str());
|
||||
}
|
||||
}
|
||||
resourceManager->GetStringById(static_cast<uint32_t>(labelId), appName);
|
||||
HILOG_DEBUG("Get app display info, labelId: %{public}d, appname: %{public}s", labelId, appName.c_str());
|
||||
HILOG_DEBUG("Get app display info, labelId: %{public}d, appname: %{public}s.", labelId, appName.c_str());
|
||||
}
|
||||
|
||||
Want SystemDialogScheduler::GetSwitchUserDialogWant()
|
||||
|
@ -298,6 +298,10 @@ sptr<IAmsMgr> AppMgrService::GetAmsMgr()
|
||||
int32_t AppMgrService::ClearUpApplicationData(const std::string &bundleName)
|
||||
{
|
||||
std::shared_ptr<RemoteClientManager> remoteClientManager = std::make_shared<RemoteClientManager>();
|
||||
if(remoteClientManager == nullptr) {
|
||||
HILOG_ERROR("Remote client manager is nullptr.");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
auto bundleMgrHelper = remoteClientManager->GetBundleManagerHelper();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("Get bundle manager helper is nullptr.");
|
||||
@ -315,7 +319,7 @@ int32_t AppMgrService::ClearUpApplicationData(const std::string &bundleName)
|
||||
auto isCallingPerm = AAFwk::PermissionVerification::GetInstance()->VerifyCallingPermission(
|
||||
AAFwk::PermissionConstants::PERMISSION_CLEAN_APPLICATION_DATA);
|
||||
if (!isCallingPerm) {
|
||||
HILOG_ERROR("Permission verification failed");
|
||||
HILOG_ERROR("Permission verification failed.");
|
||||
return ERR_PERMISSION_DENIED;
|
||||
}
|
||||
}
|
||||
@ -482,26 +486,30 @@ int AppMgrService::StartUserTestProcess(const AAFwk::Want &want, const sptr<IRem
|
||||
int AppMgrService::FinishUserTest(const std::string &msg, const int64_t &resultCode, const std::string &bundleName)
|
||||
{
|
||||
if (!IsReady()) {
|
||||
HILOG_ERROR("not ready");
|
||||
HILOG_ERROR("Not ready");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
std::shared_ptr<RemoteClientManager> remoteClientManager = std::make_shared<RemoteClientManager>();
|
||||
if(remoteClientManager == nullptr) {
|
||||
HILOG_ERROR("Remote client manager is nullptr.");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
auto bundleMgrHelper = remoteClientManager->GetBundleManagerHelper();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("AppMgrService::FinishUserTest GetBundleManager is nullptr");
|
||||
HILOG_ERROR("AppMgrService::FinishUserTest GetBundleManager is nullptr.");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
int32_t callingUid = IPCSkeleton::GetCallingUid();
|
||||
std::string callerBundleName;
|
||||
auto result = IN_PROCESS_CALL(bundleMgrHelper->GetNameForUid(callingUid, callerBundleName));
|
||||
if (result == ERR_OK) {
|
||||
HILOG_INFO("FinishUserTest callingPid_ is %{public}s", callerBundleName.c_str());
|
||||
HILOG_INFO("FinishUserTest callingPid_ is %{public}s.", callerBundleName.c_str());
|
||||
if (bundleName != callerBundleName) {
|
||||
HILOG_ERROR("AppMgrService::FinishUserTest Not this process call.");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
} else {
|
||||
HILOG_ERROR("GetBundleName failed: %{public}d", result);
|
||||
HILOG_ERROR("GetBundleName failed: %{public}d.", result);
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
pid_t callingPid = IPCSkeleton::GetCallingPid();
|
||||
|
@ -517,7 +517,7 @@ bool AppMgrServiceInner::GetBundleAndHapInfo(const AbilityInfo &abilityInfo,
|
||||
}
|
||||
|
||||
auto userId = GetUserIdByUid(appInfo->uid);
|
||||
HILOG_INFO("userId:%{public}d", userId);
|
||||
HILOG_INFO("UserId:%{public}d.", userId);
|
||||
bool bundleMgrResult;
|
||||
if (appIndex == 0) {
|
||||
bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfo(appInfo->bundleName,
|
||||
@ -528,7 +528,7 @@ bool AppMgrServiceInner::GetBundleAndHapInfo(const AbilityInfo &abilityInfo,
|
||||
}
|
||||
|
||||
if (!bundleMgrResult) {
|
||||
HILOG_ERROR("GetBundleInfo is fail");
|
||||
HILOG_ERROR("GetBundleInfo is fail.");
|
||||
return false;
|
||||
}
|
||||
if (appIndex == 0) {
|
||||
@ -537,7 +537,7 @@ bool AppMgrServiceInner::GetBundleAndHapInfo(const AbilityInfo &abilityInfo,
|
||||
bundleMgrResult = (bundleMgrHelper->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo) == 0);
|
||||
}
|
||||
if (!bundleMgrResult) {
|
||||
HILOG_ERROR("GetHapModuleInfo is fail");
|
||||
HILOG_ERROR("GetHapModuleInfo is fail.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -783,24 +783,24 @@ void AppMgrServiceInner::ApplicationTerminated(const int32_t recordId)
|
||||
int32_t AppMgrServiceInner::UpdateApplicationInfoInstalled(const std::string &bundleName, const int uid)
|
||||
{
|
||||
if (!appRunningManager_) {
|
||||
HILOG_ERROR("appRunningManager_ is nullptr");
|
||||
HILOG_ERROR("AppRunningManager_ is nullptr.");
|
||||
return ERR_NO_INIT;
|
||||
}
|
||||
|
||||
int32_t result = VerifyRequestPermission();
|
||||
if (result != ERR_OK) {
|
||||
HILOG_ERROR("Permission verification failed");
|
||||
HILOG_ERROR("Permission verification failed.");
|
||||
return result;
|
||||
}
|
||||
|
||||
if (remoteClientManager_ == nullptr) {
|
||||
HILOG_ERROR("remoteClientManager_ fail");
|
||||
HILOG_ERROR("RemoteClientManager_ fail.");
|
||||
return ERR_NO_INIT;
|
||||
}
|
||||
|
||||
auto bundleMgrHelper = remoteClientManager_->GetBundleManagerHelper();
|
||||
if (bundleMgrHelper == nullptr) {
|
||||
HILOG_ERROR("Get bundle manager helper fail");
|
||||
HILOG_ERROR("Get bundle manager helper fail.");
|
||||
return ERR_NO_INIT;
|
||||
}
|
||||
auto userId = GetUserIdByUid(uid);
|
||||
@ -809,14 +809,14 @@ int32_t AppMgrServiceInner::UpdateApplicationInfoInstalled(const std::string &bu
|
||||
bool bundleMgrResult = bundleMgrHelper->GetApplicationInfo(bundleName,
|
||||
ApplicationFlag::GET_BASIC_APPLICATION_INFO, userId, appInfo);
|
||||
if (!bundleMgrResult) {
|
||||
HILOG_ERROR("GetApplicationInfo is fail");
|
||||
HILOG_ERROR("GetApplicationInfo is fail.");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
HILOG_DEBUG("uid value is %{public}d", uid);
|
||||
result = appRunningManager_->ProcessUpdateApplicationInfoInstalled(appInfo);
|
||||
if (result != ERR_OK) {
|
||||
HILOG_INFO("The process corresponding to the package name did not start");
|
||||
HILOG_INFO("The process corresponding to the package name did not start.");
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -58,9 +58,9 @@ bool QuickFixManagerService::Init()
|
||||
int32_t QuickFixManagerService::ApplyQuickFix(const std::vector<std::string> &quickFixFiles, bool isDebug)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
HILOG_DEBUG("function called.");
|
||||
HILOG_DEBUG("Function called.");
|
||||
if (!AAFwk::PermissionVerification::GetInstance()->JudgeCallerIsAllowedToUseSystemAPI()) {
|
||||
HILOG_ERROR("The caller is not system-app, can not use system-api");
|
||||
HILOG_ERROR("The caller is not system-app, can not use system-api.");
|
||||
return QUICK_FIX_NOT_SYSTEM_APP;
|
||||
}
|
||||
if (!AAFwk::PermissionVerification::GetInstance()->VerifyInstallBundlePermission()) {
|
||||
@ -82,7 +82,7 @@ int32_t QuickFixManagerService::ApplyQuickFix(const std::vector<std::string> &qu
|
||||
AddApplyTask(applyTask);
|
||||
applyTask->Run(quickFixFiles, isDebug);
|
||||
|
||||
HILOG_DEBUG("function finished.");
|
||||
HILOG_DEBUG("Function finished.");
|
||||
return QUICK_FIX_OK;
|
||||
}
|
||||
|
||||
@ -131,12 +131,12 @@ int32_t QuickFixManagerService::RevokeQuickFix(const std::string &bundleName)
|
||||
|
||||
if (!AAFwk::PermissionVerification::GetInstance()->VerifyGetBundleInfoPrivilegedPermission() ||
|
||||
!AAFwk::PermissionVerification::GetInstance()->VerifyInstallBundlePermission()) {
|
||||
HILOG_ERROR("Permission verification failed");
|
||||
HILOG_ERROR("Permission verification failed.");
|
||||
return QUICK_FIX_VERIFY_PERMISSION_FAILED;
|
||||
}
|
||||
|
||||
if (CheckTaskRunningState(bundleName)) {
|
||||
HILOG_ERROR("Has a apply quick fix task");
|
||||
HILOG_ERROR("Has a apply quick fix task.");
|
||||
return QUICK_FIX_DEPLOYING_TASK;
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,6 @@ public:
|
||||
private:
|
||||
template<typename T>
|
||||
void ConnectManager(sptr<T> &mgr, int32_t serviceId);
|
||||
void ConnectManager(std::shared_ptr<AppExecFwk::BundleMgrHelper> &mgr, int32_t serviceId);
|
||||
int32_t GetCurrentAccountId() const;
|
||||
int GrantUriPermissionImpl(const Uri &uri, unsigned int flag,
|
||||
TokenId fromTokenId, TokenId targetTokenId, int autoremove);
|
||||
|
@ -621,16 +621,12 @@ void UriPermissionManagerStubImpl::ConnectManager(sptr<T> &mgr, int32_t serviceI
|
||||
}
|
||||
}
|
||||
|
||||
void UriPermissionManagerStubImpl::ConnectManager(std::shared_ptr<AppExecFwk::BundleMgrHelper> &mgr, int32_t serviceId)
|
||||
uint32_t UriPermissionManagerStubImpl::GetTokenIdByBundleName(const std::string bundleName, int32_t appIndex)
|
||||
{
|
||||
if (bundleMgrHelper_ == nullptr) {
|
||||
bundleMgrHelper_ = DelayedSingleton<AppExecFwk::BundleMgrHelper>::GetInstance();
|
||||
return BUNDLE_MGR_SERVICE_SYS_ABILITY_ID;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t UriPermissionManagerStubImpl::GetTokenIdByBundleName(const std::string bundleName, int32_t appIndex)
|
||||
{
|
||||
ConnectManager(bundleMgrHelper_, BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
if (bundleMgrHelper_ == nullptr) {
|
||||
HILOG_WARN("Failed to get bms.");
|
||||
return GET_BUNDLE_MANAGER_SERVICE_FAILED;
|
||||
@ -645,7 +641,7 @@ uint32_t UriPermissionManagerStubImpl::GetTokenIdByBundleName(const std::string
|
||||
}
|
||||
} else {
|
||||
if (IN_PROCESS_CALL(bundleMgrHelper_->GetSandboxBundleInfo(
|
||||
bundleName, appIndex, userId, bundleInfo) != ERR_OK)) {
|
||||
bundleName, appIndex, userId, bundleInfo) != ERR_OK)) {
|
||||
HILOG_WARN("Failed to get bundle info according to appIndex.");
|
||||
return GET_BUNDLE_INFO_FAILED;
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ HWTEST_F(AbilityInterceptorTest, ControlInterceptor_005, TestSize.Level1)
|
||||
ElementName element("", "com.test.control", "MainAbility");
|
||||
want.SetElement(element);
|
||||
int userId = 100;
|
||||
auto bms = AbilityUtil::GetBundleManagerHelper();
|
||||
auto bundleMgrHelper = AbilityUtil::GetBundleManagerHelper();
|
||||
// make appControlRule become nullptr by crowdtest interceptor
|
||||
executer->AddInterceptor(std::make_shared<CrowdTestInterceptor>());
|
||||
executer->AddInterceptor(std::make_shared<ControlInterceptor>());
|
||||
|
@ -64,7 +64,7 @@ std::shared_ptr<AppMgrServiceInner> AmsMgrKillProcessTest::GetAppMgrServiceInner
|
||||
{
|
||||
auto appMgrServiceInner = std::make_shared<AppMgrServiceInner>();
|
||||
EXPECT_NE(appMgrServiceInner, nullptr);
|
||||
std::shared_ptr<BundleMgrHelper> bundleMgr = DelayedSingleton<BundleMgrHelper>::GetInstance();
|
||||
auto bundleMgr = DelayedSingleton<BundleMgrHelper>::GetInstance();
|
||||
appMgrServiceInner->remoteClientManager_->SetBundleManagerHelper(bundleMgr);
|
||||
|
||||
return appMgrServiceInner;
|
||||
|
@ -235,7 +235,7 @@ HWTEST_F(AbilityContextTest, AaFwk_AbilityContext_GetBundleManager_0100, Functio
|
||||
{
|
||||
std::shared_ptr<ContextDeal> deal = std::make_shared<ContextDeal>();
|
||||
context_->AttachBaseContext(deal);
|
||||
std::shared_ptr<BundleMgrHelper> ptr = context_->GetBundleManager();
|
||||
auto ptr = context_->GetBundleManager();
|
||||
|
||||
EXPECT_NE(nullptr, ptr);
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetBundleManager_0100
|
||||
{
|
||||
context_->AttachBaseContext(contextDeal_);
|
||||
|
||||
std::shared_ptr<BundleMgrHelper> ptr = context_->GetBundleManager();
|
||||
auto ptr = context_->GetBundleManager();
|
||||
|
||||
EXPECT_NE(ptr, nullptr);
|
||||
}
|
||||
@ -120,7 +120,7 @@ HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetBundleManager_0100
|
||||
*/
|
||||
HWTEST_F(ContextContainerTest, AppExecFwk_ContextContainer_GetBundleManager_0200, Function | MediumTest | Level3)
|
||||
{
|
||||
std::shared_ptr<BundleMgrHelper> ptr = context_->GetBundleManager();
|
||||
auto ptr = context_->GetBundleManager();
|
||||
EXPECT_EQ(ptr, nullptr);
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetBundleName_0200, Function |
|
||||
*/
|
||||
HWTEST_F(ContextDealTest, AppExecFwk_ContextDeal_GetBundleManager_0100, Function | MediumTest | Level3)
|
||||
{
|
||||
std::shared_ptr<BundleMgrHelper> ptr = context_->GetBundleManager();
|
||||
auto ptr = context_->GetBundleManager();
|
||||
EXPECT_NE(ptr, nullptr);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user