Merge branch 'master' into 0717_hilog

Change-Id: I01475cb172cc2a3276b052c145148d9b67a3d4f3
This commit is contained in:
zhuhan 2024-07-26 11:16:04 +08:00
commit d023d4b6a1
54 changed files with 411 additions and 142 deletions

View File

@ -93,7 +93,7 @@ declare_args() {
background_task_mgr_continuous_task_enable = true
resource_schedule_service_enable = true
ability_runtime_power = true
ability_runtime_feature_sandboxmanager = true
ability_runtime_feature_sandboxmanager = false
ability_runtime_relational = true
ability_runtime_ces = true
ability_runtime_resource = true
@ -107,6 +107,7 @@ declare_args() {
"com.ohos.textautofill/entry/TextAutoFillAbility"
cj_frontend = true
ability_runtime_app_no_response_dialog = false
ability_runtime_app_no_response_bundlename = "com.ohos.taskmanager"
include_app_domain_verify = true
if (!defined(global_parts_info) ||
@ -183,4 +184,9 @@ declare_args() {
} else {
form_fwk_enable = false
}
if (defined(global_parts_info) &&
defined(global_parts_info.accesscontrol_sandbox_manager)) {
ability_runtime_feature_sandboxmanager = true
}
}

View File

@ -26,7 +26,8 @@
"ability_runtime_auto_fill_ability",
"ability_runtime_graphics",
"ability_runtime_power",
"ability_runtime_app_no_response_dialog"
"ability_runtime_app_no_response_dialog",
"ability_runtime_app_no_response_bundlename"
],
"adapted_system_type": [
"standard"
@ -57,6 +58,7 @@
"ets_runtime",
"ets_utils",
"faultloggerd",
"app_file_service",
"ffrt",
"form_fwk",
"graphic_2d",
@ -87,8 +89,8 @@
"resource_management",
"resource_schedule_service",
"safwk",
"sandbox_manager",
"samgr",
"sandbox_manager",
"screenlock_mgr",
"storage_service",
"toolchain",

View File

@ -696,9 +696,9 @@ napi_value JsAbilityManagerInit(napi_env env, napi_value exportObj)
env, exportObj, "getForegroundUIAbilities", moduleName, JsAbilityManager::GetForegroundUIAbilities);
BindNativeFunction(env, exportObj, "on", moduleName, JsAbilityManager::On);
BindNativeFunction(env, exportObj, "off", moduleName, JsAbilityManager::Off);
BindNativeFunction(env, exportObj, "isEmbeddedOpenAllowed", moduleName, JsAbilityManager::IsEmbeddedOpenAllowed);
BindNativeFunction(
env, exportObj, "notifyDebugAssertResult", moduleName, JsAbilityManager::NotifyDebugAssertResult);
BindNativeFunction(env, exportObj, "isEmbeddedOpenAllowed", moduleName, JsAbilityManager::IsEmbeddedOpenAllowed);
BindNativeFunction(
env, exportObj, "setResidentProcessEnabled", moduleName, JsAbilityManager::SetResidentProcessEnabled);
TAG_LOGD(AAFwkTag::ABILITYMGR, "end");

View File

@ -38,8 +38,8 @@ napi_value CreateJSToken(napi_env env, const sptr<IRemoteObject> target)
env, "TokenClass", NAPI_AUTO_LENGTH, constructorcb, nullptr, 0, nullptr, &tokenClass);
napi_value jsToken = nullptr;
napi_new_instance(env, tokenClass, 0, nullptr, &jsToken);
auto finalizercb = [](napi_env env, void *data, void *hint) {};
napi_wrap(env, jsToken, static_cast<void *>(target.GetRefPtr()), finalizercb, nullptr, nullptr);
auto finalizecb = [](napi_env env, void *data, void *hint) {};
napi_wrap(env, jsToken, static_cast<void *>(target.GetRefPtr()), finalizecb, nullptr, nullptr);
return jsToken;
}

View File

@ -20,7 +20,7 @@ class AsyncTaskCallback {
this.__impl__ = object;
}
onAsyncTaskCompleted(startupName, startupResult) {
onAsyncTaskCompleted(startupName, startupResult): void {
console.log('AsyncTaskCallback onAsyncTaskCompleted called, startupName: ' + startupName);
this.__impl__.onAsyncTaskCompleted(startupName, startupResult);
}

View File

@ -13,19 +13,19 @@
* limitations under the License.
*/
async function concurrentFunc(startup, asyncCallback, context, startupName) {
async function concurrentFunc(startup, asyncCallback, context, startupName): void {
'use concurrent';
console.log('concurrentFunc start.');
let startupResult;
await startup.init(context).then((result: Object) => {
startupResult = result
startupResult = result;
let taskPool = requireNapi('taskpool');
taskPool.Task.sendData(asyncCallback, startupName, startupResult);
});
console.log('concurrentFunc end.');
}
function receiveResult(asyncCallback, startupName, startupResult) {
function receiveResult(asyncCallback, startupName, startupResult): void {
console.log('receiveResult called.');
asyncCallback.onAsyncTaskCompleted(startupName, startupResult);
console.log('receiveResult end.');

View File

@ -702,7 +702,6 @@ private:
{
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
std::vector<int32_t> missionIds;
if (argc < ARGC_ONE) {
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToBackground Not enough params");
ThrowTooFewParametersError(env);
@ -726,7 +725,6 @@ private:
}
missionIds.push_back(missionId);
}
NapiAsyncTask::CompleteCallback complete =
[missionIds](napi_env env, NapiAsyncTask &task, int32_t status) {
std::vector<int32_t> resultMissionIds;
@ -744,7 +742,6 @@ private:
CreateJsErrorByNativeErr(env, ret, PermissionConstants::PERMISSION_MANAGE_MISSION));
}
};
napi_value lastParam = (argc <= 1) ? nullptr : argv[1];
napi_value result = nullptr;
NapiAsyncTask::ScheduleHighQos("MissionManager::OnMoveMissionsToBackground",

View File

@ -566,6 +566,11 @@ std::string ApplicationContext::GetTempDir()
return (contextImpl_ != nullptr) ? contextImpl_->GetTempDir() : "";
}
std::string ApplicationContext::GetResourceDir()
{
return (contextImpl_ != nullptr) ? contextImpl_->GetResourceDir() : "";
}
void ApplicationContext::GetAllTempDir(std::vector<std::string> &tempPaths)
{
if (contextImpl_ == nullptr) {
@ -575,11 +580,6 @@ void ApplicationContext::GetAllTempDir(std::vector<std::string> &tempPaths)
contextImpl_->GetAllTempDir(tempPaths);
}
std::string ApplicationContext::GetResourceDir()
{
return (contextImpl_ != nullptr) ? contextImpl_->GetResourceDir() : "";
}
std::string ApplicationContext::GetFilesDir()
{
return (contextImpl_ != nullptr) ? contextImpl_->GetFilesDir() : "";

View File

@ -268,6 +268,20 @@ std::string ContextImpl::GetTempDir()
return dir;
}
std::string ContextImpl::GetResourceDir()
{
std::shared_ptr<AppExecFwk::HapModuleInfo> hapModuleInfoPtr = GetHapModuleInfo();
if (hapModuleInfoPtr == nullptr || hapModuleInfoPtr->moduleName.empty()) {
return "";
}
std::string dir = std::string(LOCAL_CODE_PATH) + CONTEXT_FILE_SEPARATOR +
hapModuleInfoPtr->moduleName + CONTEXT_RESOURCE_END;
if (OHOS::FileExists(dir)) {
return dir;
}
return "";
}
void ContextImpl::GetAllTempDir(std::vector<std::string> &tempPaths)
{
// Application temp dir
@ -299,20 +313,6 @@ void ContextImpl::GetAllTempDir(std::vector<std::string> &tempPaths)
}
}
std::string ContextImpl::GetResourceDir()
{
std::shared_ptr<AppExecFwk::HapModuleInfo> hapModuleInfoPtr = GetHapModuleInfo();
if (hapModuleInfoPtr == nullptr || hapModuleInfoPtr->moduleName.empty()) {
return "";
}
std::string dir = std::string(LOCAL_CODE_PATH) + CONTEXT_FILE_SEPARATOR +
hapModuleInfoPtr->moduleName + CONTEXT_RESOURCE_END;
if (OHOS::FileExists(dir)) {
return dir;
}
return "";
}
std::string ContextImpl::GetFilesDir()
{
std::string dir = GetBaseDir() + CONTEXT_FILES;

View File

@ -243,6 +243,15 @@ AppExecFwk::AbilityType ServiceExtensionContext::GetAbilityInfoType() const
return info->type;
}
ErrCode ServiceExtensionContext::AddFreeInstallObserver(const sptr<AbilityRuntime::IFreeInstallObserver> &observer)
{
ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->AddFreeInstallObserver(token_, observer);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "AddFreeInstallObserver error, ret: %{public}d", ret);
}
return ret;
}
ErrCode ServiceExtensionContext::PreStartMission(const std::string& bundleName, const std::string& moduleName,
const std::string& abilityName, const std::string& startTime)
{
@ -253,14 +262,5 @@ ErrCode ServiceExtensionContext::PreStartMission(const std::string& bundleName,
}
return err;
}
ErrCode ServiceExtensionContext::AddFreeInstallObserver(const sptr<AbilityRuntime::IFreeInstallObserver> &observer)
{
ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->AddFreeInstallObserver(token_, observer);
if (ret != ERR_OK) {
TAG_LOGE(AAFwkTag::APPKIT, "ret: %{public}d", ret);
}
return ret;
}
} // namespace AbilityRuntime
} // namespace OHOS

View File

@ -128,7 +128,7 @@ void AppfreezeInner::SendProcessKillEvent(const std::string& killReason)
std::string processName = applicationInfo->process;
int result = HiSysEventWrite(HiviewDFX::HiSysEvent::Domain::FRAMEWORK, "PROCESS_KILL",
HiviewDFX::HiSysEvent::EventType::FAULT, EVENT_PID, pid,
EVENT_PROCESS_NAME, applicationInfo->process, EVENT_MESSAGE, killReason);
EVENT_PROCESS_NAME, processName, EVENT_MESSAGE, killReason);
TAG_LOGI(AAFwkTag::APPDFR, "hisysevent write result=%{public}d, send event [FRAMEWORK,PROCESS_KILL],"
" pid=%{public}d, processName=%{public}s, msg=%{public}s", result, pid, processName.c_str(),
killReason.c_str());

View File

@ -41,7 +41,6 @@ class AbilityManagerClient {
public:
virtual ~AbilityManagerClient();
static std::shared_ptr<AbilityManagerClient> GetInstance();
void RemoveDeathRecipient();
/**
@ -1407,6 +1406,13 @@ public:
int32_t UpdateSessionInfoBySCB(std::list<SessionInfo> &sessionInfos, int32_t userId,
std::vector<int32_t> &sessionIds);
/**
* @brief Restart app self.
* @param want The ability type must be UIAbility.
* @return Returns ERR_OK on success, others on failure.
*/
int32_t RestartApp(const AAFwk::Want &want);
/**
* @brief Get host info of root caller.
*
@ -1429,13 +1435,6 @@ public:
ErrCode GetUIExtensionSessionInfo(const sptr<IRemoteObject> token, UIExtensionSessionInfo &uiExtensionSessionInfo,
int32_t userId = DEFAULT_INVAL_VALUE);
/**
* @brief Restart app self.
* @param want The ability type must be UIAbility.
* @return Returns ERR_OK on success, others on failure.
*/
int32_t RestartApp(const AAFwk::Want &want);
/**
* Pop-up launch of full-screen atomic service.
*

View File

@ -462,7 +462,7 @@ enum {
* Native error(2097240) for memory size state unchanged.
*/
ERR_NATIVE_MEMORY_SIZE_STATE_UNCHANGED,
/**
* Native error(2097241) for target bundle not exist.
*/

View File

@ -1505,6 +1505,16 @@ public:
return 0;
}
/**
* @brief Restart app self.
* @param want The ability type must be UIAbility.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int32_t RestartApp(const AAFwk::Want &want)
{
return 0;
}
/**
* @brief Get host info of root caller.
*
@ -1533,16 +1543,6 @@ public:
return 0;
}
/**
* @brief Restart app self.
* @param want The ability type must be UIAbility.
* @return Returns ERR_OK on success, others on failure.
*/
virtual int32_t RestartApp(const AAFwk::Want &want)
{
return 0;
}
/**
* Open link of ability and atomic service.
*

View File

@ -377,7 +377,7 @@ enum class AbilityManagerInterfaceCode {
// request modal UIExtension by want
REQUESET_MODAL_UIEXTENSION = 1056,
// get root host info of uiextesnion
// get root host info of uiextension
GET_UI_EXTENSION_ROOT_HOST_INFO = 1057,
// change current ability visibility

View File

@ -342,6 +342,15 @@ public:
return true;
}
/**
* whether the abilities of process specified by pid type only UIAbility.
* @return Returns true is only UIAbility, otherwise return false
*/
virtual bool IsProcessContainsOnlyUIAbility(const pid_t pid)
{
return false;
}
enum class Message {
LOAD_ABILITY = 0,
TERMINATE_ABILITY,
@ -384,11 +393,12 @@ public:
KILL_PROCESSES_BY_PIDS,
ATTACH_PID_TO_PARENT,
IS_MEMORY_SIZE_SUFFICIENT,
SET_KEEP_ALIVE_ENABLE_STATE,
NOTIFY_APP_MGR_RECORD_EXIT_REASON,
SET_KEEP_ALIVE_ENABLE_STATE,
ATTACHED_TO_STATUS_BAR,
BLOCK_PROCESS_CACHE_BY_PIDS,
IS_KILLED_FOR_UPGRADE_WEB,
IS_PROCESS_CONTAINS_ONLY_UI_EXTENSION,
FORCE_KILL_APPLICATION,
};
};

View File

@ -309,6 +309,12 @@ public:
*/
virtual bool IsKilledForUpgradeWeb(const std::string &bundleName) override;
/**
* whether the abilities of process specified by pid type only UIAbility.
* @return Returns true is only UIAbility, otherwise return false
*/
virtual bool IsProcessContainsOnlyUIAbility(const pid_t pid) override;
private:
bool WriteInterfaceToken(MessageParcel &data);
int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option);

View File

@ -95,6 +95,7 @@ private:
MessageParcel &reply, MessageOption &option);
int32_t HandleBlockProcessCacheByPids(MessageParcel &data, MessageParcel &reply);
int32_t HandleIsKilledForUpgradeWeb(MessageParcel &data, MessageParcel &reply);
int32_t HandleIsProcessContainsOnlyUIAbility(MessageParcel &data, MessageParcel &reply);
DISALLOW_COPY_AND_MOVE(AmsMgrStub);
};
} // namespace AppExecFwk

View File

@ -682,13 +682,6 @@ public:
*/
int32_t UnregisterAppRunningStatusListener(const sptr<IRemoteObject> &listener);
/**
* Whether the current application process is the last surviving process.
*
* @return Returns true is final application process, others return false.
*/
bool IsFinalAppProcess();
/**
* To clear the process by ability token.
*
@ -696,6 +689,13 @@ public:
*/
void ClearProcessByToken(sptr<IRemoteObject> token) const;
/**
* Whether the current application process is the last surviving process.
*
* @return Returns true is final application process, others return false.
*/
bool IsFinalAppProcess();
int32_t RegisterRenderStateObserver(const sptr<IRenderStateObserver> &observer);
int32_t UnregisterRenderStateObserver(const sptr<IRenderStateObserver> &observer);
@ -795,6 +795,12 @@ public:
*/
bool IsKilledForUpgradeWeb(const std::string &bundleName);
/**
* whether the abilities of process specified by pid type only UIAbility.
* @return Returns true is only UIAbility, otherwise return false
*/
bool IsProcessContainsOnlyUIAbility(const pid_t pid);
private:
void SetServiceManager(std::unique_ptr<AppServiceManager> serviceMgr);
/**

View File

@ -607,8 +607,6 @@ public:
*/
virtual int32_t NotifyMemorySizeStateChanged(bool isMemorySizeSufficent) override;
int32_t SetSupportedProcessCacheSelf(bool isSupport) override;
/**
* Set application assertion pause state.
*
@ -616,15 +614,7 @@ public:
*/
void SetAppAssertionPauseState(bool flag) override;
/**
* Start native child process, callde by ChildProcessManager.
* @param libName lib file name to be load in child process
* @param childProcessCount current started child process count
* @param callback callback for notify start result
* @return Returns ERR_OK on success, others on failure.
*/
int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount,
const sptr<IRemoteObject> &callback) override;
int32_t SetSupportedProcessCacheSelf(bool isSupport) override;
virtual void SaveBrowserChannel(sptr<IRemoteObject> browser) override;
@ -636,6 +626,16 @@ public:
*/
int32_t CheckCallingIsUserTestMode(const pid_t pid, bool &isUserTest) override;
/**
* Start native child process, callde by ChildProcessManager.
* @param libName lib file name to be load in child process
* @param childProcessCount current started child process count
* @param callback callback for notify start result
* @return Returns ERR_OK on success, others on failure.
*/
int32_t StartNativeChildProcess(const std::string &libName, int32_t childProcessCount,
const sptr<IRemoteObject> &callback) override;
virtual int32_t NotifyProcessDependedOnWeb() override;
virtual void KillProcessDependedOnWeb() override;

View File

@ -128,8 +128,8 @@ private:
int32_t HandleGetChildProcessInfoForSelf(MessageParcel &data, MessageParcel &reply);
int32_t HandleAttachChildProcess(MessageParcel &data, MessageParcel &reply);
int32_t HandleExitChildProcessSafely(MessageParcel &data, MessageParcel &reply);
int32_t HandleIsFinalAppProcess(MessageParcel &data, MessageParcel &reply);
int32_t HandleClearUpApplicationDataBySelf(MessageParcel &data, MessageParcel &reply);
int32_t HandleIsFinalAppProcess(MessageParcel &data, MessageParcel &reply);
int32_t HandleRegisterRenderStateObserver(MessageParcel &data, MessageParcel &reply);
int32_t HandleUnregisterRenderStateObserver(MessageParcel &data, MessageParcel &reply);
int32_t HandleUpdateRenderState(MessageParcel &data, MessageParcel &reply);
@ -138,11 +138,11 @@ private:
int32_t HandleGetAllUIExtensionRootHostPid(MessageParcel &data, MessageParcel &reply);
int32_t HandleGetAllUIExtensionProviderPid(MessageParcel &data, MessageParcel &reply);
int32_t HandleNotifyMemorySizeStateChanged(MessageParcel &data, MessageParcel &reply);
int32_t HandleSetSupportedProcessCacheSelf(MessageParcel &data, MessageParcel &reply);
int32_t HandleSetAppAssertionPauseState(MessageParcel &data, MessageParcel &reply);
int32_t HandleStartNativeChildProcess(MessageParcel &data, MessageParcel &reply);
int32_t HandleSetSupportedProcessCacheSelf(MessageParcel &data, MessageParcel &reply);
int32_t HandleSaveBrowserChannel(MessageParcel &data, MessageParcel &reply);
int32_t HandleCheckCallingIsUserTestMode(MessageParcel &data, MessageParcel &reply);
int32_t HandleStartNativeChildProcess(MessageParcel &data, MessageParcel &reply);
int32_t HandleNotifyProcessDependedOnWeb(MessageParcel &data, MessageParcel &reply);
int32_t HandleKillProcessDependedOnWeb(MessageParcel &data, MessageParcel &reply);
int32_t HandleRestartResidentProcessDependedOnWeb(MessageParcel &data, MessageParcel &reply);

View File

@ -29,6 +29,27 @@ constexpr int32_t MAX_APP_DEBUG_COUNT = 100;
AmsMgrProxy::AmsMgrProxy(const sptr<IRemoteObject> &impl) : IRemoteProxy<IAmsMgr>(impl)
{}
bool AmsMgrProxy::IsProcessContainsOnlyUIAbility(const pid_t pid)
{
TAG_LOGD(AAFwkTag::APPMGR, "IsProcessContainsOnlyUIAbility start");
MessageParcel data;
MessageParcel reply;
MessageOption option(MessageOption::TF_SYNC);
if (!WriteInterfaceToken(data)) {
return false;
}
data.WriteInt32(static_cast<int32_t>(pid));
int32_t ret =
SendTransactCmd(static_cast<uint32_t>(
IAmsMgr::Message::IS_PROCESS_CONTAINS_ONLY_UI_EXTENSION), data, reply, option);
if (ret != NO_ERROR) {
TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret);
return false;
}
TAG_LOGD(AAFwkTag::APPMGR, "IsProcessContainsOnlyUIAbility end");
return reply.ReadBool();
}
bool AmsMgrProxy::WriteInterfaceToken(MessageParcel &data)
{
if (!data.WriteInterfaceToken(AmsMgrProxy::GetDescriptor())) {

View File

@ -190,6 +190,8 @@ int32_t AmsMgrStub::OnRemoteRequestInnerThird(uint32_t code, MessageParcel &data
return HandleBlockProcessCacheByPids(data, reply);
case static_cast<uint32_t>(IAmsMgr::Message::IS_KILLED_FOR_UPGRADE_WEB):
return HandleIsKilledForUpgradeWeb(data, reply);
case static_cast<uint32_t>(IAmsMgr::Message::IS_PROCESS_CONTAINS_ONLY_UI_EXTENSION):
return HandleIsProcessContainsOnlyUIAbility(data, reply);
case static_cast<uint32_t>(IAmsMgr::Message::FORCE_KILL_APPLICATION):
return HandleForceKillApplication(data, reply);
}
@ -783,5 +785,17 @@ int32_t AmsMgrStub::HandleIsKilledForUpgradeWeb(MessageParcel &data, MessageParc
}
return NO_ERROR;
}
int32_t AmsMgrStub::HandleIsProcessContainsOnlyUIAbility(MessageParcel &data, MessageParcel &reply)
{
auto pid = data.ReadUint32();
auto result = IsProcessContainsOnlyUIAbility(pid);
if (!reply.WriteBool(result)) {
TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result in HandleIsProcessContainsOnlyUIAbility.");
return ERR_INVALID_VALUE;
}
return NO_ERROR;
}
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -490,6 +490,18 @@ AppMgrResultCode AppMgrClient::ConnectAppMgrService()
return AppMgrResultCode::ERROR_SERVICE_NOT_READY;
}
bool AppMgrClient::IsProcessContainsOnlyUIAbility(const pid_t pid)
{
sptr<IAppMgr> service = iface_cast<IAppMgr>(mgrHolder_->GetRemoteObject());
if (service != nullptr) {
sptr<IAmsMgr> amsService = service->GetAmsMgr();
if (amsService != nullptr) {
return amsService->IsProcessContainsOnlyUIAbility(pid);
}
}
return false;
}
void AppMgrClient::SetServiceManager(std::unique_ptr<AppServiceManager> serviceMgr)
{
if (!mgrHolder_) {

View File

@ -28,7 +28,6 @@ AppSchedulerHost::AppSchedulerHost()
InitMemberFuncMap();
}
void AppSchedulerHost::InitMemberFuncMap() {}
AppSchedulerHost::~AppSchedulerHost()
@ -480,6 +479,13 @@ int32_t AppSchedulerHost::HandleScheduleDumpIpcStat(MessageParcel &data, Message
return NO_ERROR;
}
int32_t AppSchedulerHost::HandleScheduleCacheProcess(MessageParcel &data, MessageParcel &reply)
{
HITRACE_METER(HITRACE_TAG_APP);
ScheduleCacheProcess();
return NO_ERROR;
}
int32_t AppSchedulerHost::HandleScheduleDumpFfrt(MessageParcel &data, MessageParcel &reply)
{
HITRACE_METER(HITRACE_TAG_APP);
@ -491,12 +497,5 @@ int32_t AppSchedulerHost::HandleScheduleDumpFfrt(MessageParcel &data, MessagePar
}
return NO_ERROR;
}
int32_t AppSchedulerHost::HandleScheduleCacheProcess(MessageParcel &data, MessageParcel &reply)
{
HITRACE_METER(HITRACE_TAG_APP);
ScheduleCacheProcess();
return NO_ERROR;
}
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -28,7 +28,7 @@ namespace {
#ifdef SUPPORT_GRAPHICS
constexpr const char* WANT_PARAMS_VIEW_DATA_KEY = "ohos.ability.params.viewData";
constexpr const char* WANT_PARAMS_AUTO_FILL_CMD_KEY = "ohos.ability.params.autoFillCmd";
constexpr const char* WANT_PARAMS_FILL_CONTENT = "ohos.ability.params.fillContent";
constexpr const char* WANT_PARAMS_FILL_CONTENT = "ohos.ability.params.fillContent";
constexpr const char* WANT_PARAMS_CUSTOM_DATA_KEY = "ohos.ability.params.customData";
constexpr const char* WANT_PARAMS_AUTO_FILL_EVENT_KEY = "ability.want.params.AutoFillEvent";
constexpr const char* WANT_PARAMS_UPDATE_POPUP_WIDTH = "ohos.ability.params.popupWidth";

View File

@ -222,9 +222,10 @@ public:
ErrCode ChangeAbilityVisibility(bool isShow) override;
ErrCode OpenLink(const AAFwk::Want& want, int requestCode) override;
ErrCode AddFreeInstallObserver(const sptr<AbilityRuntime::IFreeInstallObserver> &observer) override;
ErrCode OpenLink(const AAFwk::Want& want, int requestCode) override;
ErrCode OpenAtomicService(AAFwk::Want& want, const AAFwk::StartOptions &options, int requestCode,
RuntimeTask &&task) override;

View File

@ -256,7 +256,7 @@ public:
virtual void OnInsightIntentExecuteDone(const sptr<AAFwk::SessionInfo> &sessionInfo,
const AppExecFwk::InsightIntentExecuteResult &result);
virtual bool HandleInsightIntent(const AAFwk::Want &want);
virtual bool OnInsightIntentExecuteDone(uint64_t intentId, const AppExecFwk::InsightIntentExecuteResult &result);

View File

@ -117,10 +117,10 @@ protected:
napi_env env, NapiCallbackInfo& info, std::shared_ptr<int> &innerErrorCode);
void StartAbilityForResultRuntimeTask(napi_env env, AAFwk::Want &want,
std::shared_ptr<NapiAsyncTask> asyncTask, size_t& unwrapArgc, AAFwk::StartOptions startOptions);
void SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want,
NapiAsyncTask::CompleteCallback& complete);
bool CheckStartAbilityByTypeParam(napi_env env, NapiCallbackInfo& info, std::string& type,
AAFwk::WantParams& wantParam);
void SetCallbackForTerminateWithResult(int32_t resultCode, AAFwk::Want& want,
NapiAsyncTask::CompleteCallback& complete);
private:
sptr<AAFwk::SessionInfo> sessionInfo_;

View File

@ -269,8 +269,6 @@ public:
*/
void ScheduleProcessSecurityExit() override;
void ScheduleClearPageStack() override;
void ScheduleAcceptWant(const AAFwk::Want &want, const std::string &moduleName) override;
void ScheduleNewProcessRequest(const AAFwk::Want &want, const std::string &moduleName) override;
@ -341,6 +339,7 @@ public:
*/
int32_t ScheduleDumpIpcStat(std::string& result) override;
void ScheduleClearPageStack() override;
/**
* ScheduleDumpFfrt, call ScheduleDumpFfrt(std::string& result) through proxy project,
* Start querying the application's ffrt usage.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at

View File

@ -307,12 +307,6 @@ void JsEnvironment::GetHeapPrepare()
panda::DFXJSNApi::GetHeapPrepare(vm_);
}
void JsEnvironment::ReInitJsEnvImpl(std::unique_ptr<JsEnvironmentImpl> impl)
{
TAG_LOGD(AAFwkTag::JSENV, "ReInit jsenv impl.");
impl_ = std::move(impl);
}
void JsEnvironment::SetModuleLoadChecker(const std::shared_ptr<ModuleCheckerDelegate> moduleCheckerDelegate)
{
if (engine_ == nullptr) {
@ -323,6 +317,12 @@ void JsEnvironment::SetModuleLoadChecker(const std::shared_ptr<ModuleCheckerDele
engine_->SetModuleLoadChecker(moduleCheckerDelegate);
}
void JsEnvironment::ReInitJsEnvImpl(std::unique_ptr<JsEnvironmentImpl> impl)
{
TAG_LOGD(AAFwkTag::JSENV, "ReInit jsenv impl.");
impl_ = std::move(impl);
}
void JsEnvironment::SetRequestAotCallback(const RequestAotCallback& cb)
{
if (vm_ == nullptr) {

View File

@ -27,9 +27,9 @@
namespace OHOS {
namespace JsEnv {
class JsEnvironmentImpl;
using DebuggerPostTask = std::function<void(std::function<void()>&&)>;
using RequestAotCallback =
std::function<int32_t(const std::string& bundleName, const std::string& moduleName, int32_t triggerMode)>;
using DebuggerPostTask = std::function<void(std::function<void()>&&)>;
class JsEnvironment final : public std::enable_shared_from_this<JsEnvironment> {
public:
JsEnvironment() {}
@ -91,19 +91,19 @@ public:
bool LoadScript(const std::string& path, uint8_t* buffer, size_t len, bool isBundle);
DebuggerPostTask GetDebuggerPostTask();
void StartProfiler(const char* libraryPath,
uint32_t instanceId, PROFILERTYPE profiler, int32_t interval, int tid, bool isDebugApp);
DebuggerPostTask GetDebuggerPostTask();
void DestroyHeapProfiler();
void GetHeapPrepare();
void ReInitJsEnvImpl(std::unique_ptr<JsEnvironmentImpl> impl);
void SetModuleLoadChecker(const std::shared_ptr<ModuleCheckerDelegate> moduleCheckerDelegate);
void ReInitJsEnvImpl(std::unique_ptr<JsEnvironmentImpl> impl);
void SetRequestAotCallback(const RequestAotCallback& cb);
void SetDeviceDisconnectCallback(const std::function<bool()> &cb);

View File

@ -2286,6 +2286,8 @@ private:
bool ShouldPreventStartAbility(const AbilityRequest &abilityRequest);
void PrintStartAbilityInfo(AppExecFwk::AbilityInfo callerInfo, AppExecFwk::AbilityInfo calledInfo);
bool IsInWhiteList(const std::string &callerBundleName, const std::string &calleeBundleName,
const std::string &calleeAbilityName);

View File

@ -540,8 +540,6 @@ public:
std::shared_ptr<StartOptions> &startOptions, const std::shared_ptr<AbilityRecord> &callerAbility,
uint32_t sceneFlag = 0);
bool GrantUriPermissionForServiceExtension();
void ProcessForegroundAbility(const std::shared_ptr<AbilityRecord> &callerAbility, bool needExit = true,
uint32_t sceneFlag = 0);
void NotifyAnimationFromTerminatingAbility() const;
@ -554,6 +552,8 @@ public:
void SetColdStartFlag(bool isColdStart);
#endif
bool GrantUriPermissionForServiceExtension();
/**
* check whether the ability is launcher.
*
@ -1021,6 +1021,12 @@ public:
void SetSpecifyTokenId(const uint32_t specifyTokenId);
void SaveConnectWant(const Want &want);
void UpdateConnectWant();
void RemoveConnectWant();
protected:
void SendEvent(uint32_t msg, uint32_t timeOut, int32_t param = -1);
@ -1239,6 +1245,9 @@ private:
bool isRestartApp_ = false; // Only app calling RestartApp can be set to true
uint32_t specifyTokenId_ = 0;
std::shared_ptr<Want> connectWant_ = nullptr;
ffrt::mutex connectWantLock_;
};
} // namespace AAFwk
} // namespace OHOS

View File

@ -449,6 +449,12 @@ public:
bool IsKilledForUpgradeWeb(const std::string &bundleName);
/**
* whether the abilities of process specified by pid type only UIAbility.
* @return Returns true is only UIAbility, otherwise return false
*/
bool IsProcessContainsOnlyUIAbility(const pid_t pid);
protected:
/**
* OnAbilityRequestDone, app manager service call this interface after ability request done.

View File

@ -269,10 +269,12 @@ int AbilityConnectManager::StartAbilityLocked(const AbilityRequest &abilityReque
if (IsUIExtensionAbility(targetService)) {
targetService->SetLaunchReason(LaunchReason::LAUNCHREASON_START_ABILITY);
}
targetService->GrantUriPermissionForServiceExtension();
LoadAbility(targetService);
} else if (targetService->IsAbilityState(AbilityState::ACTIVE) && !IsUIExtensionAbility(targetService)) {
// It may have been started through connect
targetService->SetWant(abilityRequest.want);
targetService->GrantUriPermissionForServiceExtension();
CommandAbility(targetService);
} else if (IsUIExtensionAbility(targetService)) {
DoForegroundUIExtension(targetService, abilityRequest);
@ -684,7 +686,8 @@ int AbilityConnectManager::ConnectAbilityLocked(const AbilityRequest &abilityReq
targetService->SetWant(abilityRequest.want);
HandleActiveAbility(targetService, connectRecord);
} else {
TAG_LOGD(AAFwkTag::ABILITYMGR, "Target service is activating, wait for callback");
TAG_LOGI(AAFwkTag::ABILITYMGR, "Target service is activating, wait for callback");
targetService->SaveConnectWant(abilityRequest.want);
}
auto token = targetService->GetToken();
@ -1027,6 +1030,7 @@ int AbilityConnectManager::ScheduleConnectAbilityDoneLocked(
abilityRecord->GetAbilityState());
return INVALID_CONNECTION_STATE;
}
abilityRecord->RemoveConnectWant();
if (abilityRecord->GetAbilityInfo().type == AbilityType::SERVICE) {
DelayedSingleton<AppScheduler>::GetInstance()->UpdateAbilityState(
@ -1695,6 +1699,7 @@ int AbilityConnectManager::DispatchInactive(const std::shared_ptr<AbilityRecord>
CommandAbility(abilityRecord);
if (abilityRecord->GetConnectRecordList().size() > 0) {
// It means someone called connectAbility when service was loading
abilityRecord->UpdateConnectWant();
ConnectAbility(abilityRecord);
}
}

View File

@ -9074,6 +9074,14 @@ int AbilityManagerService::CheckCallServiceExtensionPermission(const AbilityRequ
verificationInfo.visible = abilityRequest.abilityInfo.visible;
verificationInfo.withContinuousTask = IsBackgroundTaskUid(IPCSkeleton::GetCallingUid());
verificationInfo.isBackgroundCall = false;
if (isParamStartAbilityEnable_) {
bool stopContinuousTaskFlag = ShouldPreventStartAbility(abilityRequest);
if (stopContinuousTaskFlag) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Do not have permission to start ServiceExtension");
return CHECK_PERMISSION_FAILED;
}
}
int result = AAFwk::PermissionVerification::GetInstance()->CheckCallServiceExtensionPermission(verificationInfo);
if (result != ERR_OK) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Do not have permission to start ServiceExtension or DataShareExtension");
@ -10838,15 +10846,20 @@ bool AbilityManagerService::ShouldPreventStartAbility(const AbilityRequest &abil
TAG_LOGD(AAFwkTag::ABILITYMGR, "No matched token pass");
return false;
}
auto abilityInfo = abilityRequest.abilityInfo;
auto callerAbilityInfo = abilityRecord->GetAbilityInfo();
PrintStartAbilityInfo(callerAbilityInfo, abilityInfo);
if (abilityRecord->GetApplicationInfo().apiTargetVersion % API_VERSION_MOD < API12) {
TAG_LOGD(AAFwkTag::ABILITYMGR, "API version %{public}d pass",
abilityRecord->GetApplicationInfo().apiTargetVersion % API_VERSION_MOD);
return false;
}
auto abilityInfo = abilityRequest.abilityInfo;
auto callerAbilityInfo = abilityRecord->GetAbilityInfo();
bool continuousFlag = false;
continuousFlag = IsBackgroundTaskUid(IPCSkeleton::GetCallingUid());
bool continuousFlag = IsBackgroundTaskUid(IPCSkeleton::GetCallingUid());
if(!IN_PROCESS_CALL(DelayedSingleton<AppScheduler>::GetInstance()->
IsProcessContainsOnlyUIAbility(abilityRecord->GetPid()))) {
TAG_LOGD(AAFwkTag::ABILITYMGR, "Process has other extension except UIAbility, pass");
return false;
}
if (abilityInfo.extensionAbilityType != AppExecFwk::ExtensionAbilityType::DATASHARE &&
abilityInfo.extensionAbilityType != AppExecFwk::ExtensionAbilityType::SERVICE) {
TAG_LOGD(AAFwkTag::ABILITYMGR, "Process did not call service or datashare extension Pass");
@ -10878,6 +10891,44 @@ bool AbilityManagerService::ShouldPreventStartAbility(const AbilityRequest &abil
return true;
}
void AbilityManagerService::PrintStartAbilityInfo(AppExecFwk::AbilityInfo callerInfo, AppExecFwk::AbilityInfo calledInfo)
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "calledAbilityInfo toString: "
"calledUid is: %{public}d, "
"name is: %{public}s, "
"bundleName is: %{public}s, "
"type is: %{public}d, "
"extensionAbilityType is: %{public}d, "
"moduleName is: %{public}s, "
"applicationName is: %{public}s",
calledInfo.applicationInfo.uid,
calledInfo.name.c_str(),
calledInfo.bundleName.c_str(),
static_cast<int32_t>(calledInfo.type),
static_cast<int32_t>(calledInfo.extensionAbilityType),
calledInfo.moduleName.c_str(),
calledInfo.applicationName.c_str());
TAG_LOGD(AAFwkTag::ABILITYMGR, "callerAbilityInfo toString: "
"callerUid is: %{public}d, "
"callerPid is: %{public}d, "
"name is: %{public}s, "
"bundleName is: %{public}s, "
"type is: %{public}d, "
"extensionAbilityType is: %{public}d, "
"moduleName is: %{public}s, "
"applicationName is: %{public}s",
IPCSkeleton::GetCallingUid(),
IPCSkeleton::GetCallingPid(),
callerInfo.name.c_str(),
callerInfo.bundleName.c_str(),
static_cast<int32_t>(callerInfo.type),
static_cast<int32_t>(callerInfo.extensionAbilityType),
callerInfo.moduleName.c_str(),
callerInfo.applicationName.c_str());
}
void AbilityManagerService::ReportPreventStartAbilityResult(const AppExecFwk::AbilityInfo &callerAbilityInfo,
const AppExecFwk::AbilityInfo &abilityInfo)
{

View File

@ -1635,9 +1635,7 @@ void AbilityRecord::ConnectAbility()
if (isConnected) {
TAG_LOGW(AAFwkTag::ABILITYMGR, "connect state error.");
}
#ifdef SUPPORT_SCREEN
GrantUriPermissionForServiceExtension();
#endif // SUPPORT_SCREEN
lifecycleDeal_->ConnectAbility(GetWant());
isConnected = true;
}
@ -1649,9 +1647,7 @@ void AbilityRecord::ConnectUIServiceExtAbility(const Want &want)
if (isConnected) {
TAG_LOGW(AAFwkTag::ABILITYMGR, "connect state error.");
}
#ifdef SUPPORT_SCREEN
GrantUriPermissionForServiceExtension();
#endif // SUPPORT_SCREEN
lifecycleDeal_->ConnectAbility(want);
isConnected = true;
}
@ -1682,7 +1678,6 @@ void AbilityRecord::DisconnectUIServiceExtAbility(const Want &want)
}
}
#ifdef SUPPORT_SCREEN
bool AbilityRecord::GrantUriPermissionForServiceExtension()
{
if (abilityInfo_.extensionAbilityType == AppExecFwk::ExtensionAbilityType::SERVICE) {
@ -1696,14 +1691,11 @@ bool AbilityRecord::GrantUriPermissionForServiceExtension()
}
return false;
}
#endif // SUPPORT_SCREEN
void AbilityRecord::CommandAbility()
{
TAG_LOGD(AAFwkTag::ABILITYMGR, "startId_:%{public}d.", startId_);
CHECK_POINTER(lifecycleDeal_);
#ifdef SUPPORT_SCREEN
GrantUriPermissionForServiceExtension();
#endif // SUPPORT_SCREEN
lifecycleDeal_->CommandAbility(GetWant(), false, startId_);
}
@ -3587,5 +3579,27 @@ void AbilityRecord::SetDebugAppByWaitingDebugFlag(Want &requestWant, const std::
DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance()->ClearNonPersistWaitingDebugFlag());
}
}
void AbilityRecord::SaveConnectWant(const Want &want)
{
std::lock_guard guard(connectWantLock_);
if (connectWant_ == nullptr) {
connectWant_ = std::make_shared<Want>(want);
}
}
void AbilityRecord::UpdateConnectWant()
{
std::lock_guard guard(connectWantLock_);
if (connectWant_ != nullptr) {
SetWant(*connectWant_);
}
}
void AbilityRecord::RemoveConnectWant()
{
std::lock_guard guard(connectWantLock_);
connectWant_.reset();
}
} // namespace AAFwk
} // namespace OHOS

View File

@ -630,5 +630,13 @@ bool AppScheduler::IsKilledForUpgradeWeb(const std::string &bundleName)
}
return appMgrClient_->IsKilledForUpgradeWeb(bundleName);
}
} // namespace AAFwk
bool AppScheduler::IsProcessContainsOnlyUIAbility(const pid_t pid)
{
if (!appMgrClient_) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "appMgrClient is nullptr");
return false;
}
return appMgrClient_->IsProcessContainsOnlyUIAbility(pid);
}
} // namespace AAFwk
} // namespace OHOS

View File

@ -172,7 +172,6 @@ std::shared_ptr<AbilityRecord> UIAbilityLifecycleManager::CreateAbilityRecord(Ab
TAG_LOGD(AAFwkTag::ABILITYMGR, "user id: %{public}d.", userId_);
uiAbilityRecord->SetOwnerMissionUserId(userId_);
SetRevicerInfo(abilityRequest, uiAbilityRecord);
SetLastExitReason(uiAbilityRecord);
return uiAbilityRecord;
}
@ -234,6 +233,7 @@ int UIAbilityLifecycleManager::AttachAbilityThread(const sptr<IAbilityScheduler>
auto&& abilityRecord = Token::GetAbilityRecordByToken(token);
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
TAG_LOGI(AAFwkTag::ABILITYMGR, "Lifecycle: name is %{public}s.", abilityRecord->GetAbilityInfo().name.c_str());
SetLastExitReason(abilityRecord);
auto handler = DelayedSingleton<AbilityManagerService>::GetInstance()->GetEventHandler();
CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler.");
@ -832,7 +832,6 @@ int UIAbilityLifecycleManager::CallAbilityLocked(const AbilityRequest &abilityRe
uiAbilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest);
uiAbilityRecord->SetOwnerMissionUserId(userId_);
SetRevicerInfo(abilityRequest, uiAbilityRecord);
SetLastExitReason(uiAbilityRecord);
} else {
uiAbilityRecord = sessionAbilityMap_.at(persistentId);
}

View File

@ -142,6 +142,11 @@ ohos_shared_library("libappms") {
external_deps += [ "netmanager_base:net_conn_manager_if" ]
}
if (ability_runtime_feature_sandboxmanager) {
external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ]
defines += [ "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER" ]
}
if (ability_runtime_graphics) {
defines += [
"SUPPORT_GRAPHICS",
@ -167,6 +172,7 @@ ohos_shared_library("libappms") {
if (ability_runtime_app_no_response_dialog) {
defines += [ "APP_NO_RESPONSE_DIALOG" ]
}
cflags += [ "-DAPP_NO_RESPONSE_BUNDLENAME=\"${ability_runtime_app_no_response_bundlename}\"" ]
version_script = "libappms.map"
subsystem_name = "ability"

View File

@ -317,6 +317,12 @@ public:
*/
virtual bool IsKilledForUpgradeWeb(const std::string &bundleName) override;
/**
* whether the abilities of process specified by pid type only UIAbility.
* @return Returns true is only UIAbility, otherwise return false
*/
virtual bool IsProcessContainsOnlyUIAbility(const pid_t pid) override;
private:
/**
* @brief Judge whether the application service is ready.

View File

@ -1151,6 +1151,8 @@ public:
bool IsKilledForUpgradeWeb(const std::string &bundleName) const;
bool IsProcessContainsOnlyUIAbility(const pid_t pid);
private:
int32_t ForceKillApplicationInner(const std::string &bundleName, const int userId = -1,
const int appIndex = 0);
@ -1522,8 +1524,8 @@ private:
*
* @return
*/
void NotifyAppStatusByCallerUid(const std::string &bundleName, const int32_t userId, const int32_t callerUid,
const std::string &eventData);
void NotifyAppStatusByCallerUid(const std::string &bundleName, const int32_t tokenId, const int32_t userId,
const int32_t callerUid, const std::string &eventData);
void SendHiSysEvent(const int32_t innerEventId, const int64_t eventId);
int FinishUserTestLocked(
const std::string &msg, const int64_t &resultCode, const std::shared_ptr<AppRunningRecord> &appRecord);

View File

@ -33,7 +33,6 @@
namespace OHOS {
namespace AppExecFwk {
constexpr const char* APP_NO_RESPONSE_BUNDLENAME = "com.ohos.taskmanager";
constexpr const char* APP_NO_RESPONSE_ABILITY = "AppAbnormalAbility";
class ModalSystemAppFreezeUIExtension {

View File

@ -666,5 +666,19 @@ bool AmsMgrScheduler::IsKilledForUpgradeWeb(const std::string &bundleName)
}
return amsMgrServiceInner_->IsKilledForUpgradeWeb(bundleName);
}
} // namespace AppExecFwk
bool AmsMgrScheduler::IsProcessContainsOnlyUIAbility(const pid_t pid)
{
if (!IsReady()) {
TAG_LOGE(AAFwkTag::APPMGR, "AmsMgrService is not ready.");
return false;
}
pid_t callingPid = IPCSkeleton::GetCallingPid();
pid_t procPid = getprocpid();
if (callingPid != procPid) {
TAG_LOGE(AAFwkTag::APPMGR, "Not allow other process to call.");
return false;
}
return amsMgrServiceInner_->IsProcessContainsOnlyUIAbility(pid);
}
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -70,6 +70,9 @@
#include "render_state_observer_manager.h"
#include "startup_util.h"
#include "string_ex.h"
#ifdef ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER
#include "sandbox_manager_kit.h"
#endif
#include "system_ability_definition.h"
#include "time_util.h"
#include "ui_extension_utils.h"
@ -134,6 +137,8 @@ constexpr int REGISTER_VISIBILITY_DELAY = 5000;
// Max render process number limitation for phone device.
constexpr int PHONE_MAX_RENDER_PROCESS_NUM = 40;
constexpr int PROCESS_RESTART_MARGIN_MICRO_SECONDS = 2000;
constexpr const int32_t API10 = 10;
constexpr const int32_t API_VERSION_MOD = 100;
constexpr const char* CLASS_NAME = "ohos.app.MainThread";
constexpr const char* FUNC_NAME = "main";
constexpr const char* RENDER_PARAM = "invalidparam";
@ -170,6 +175,7 @@ constexpr const char* GPU_PROCESS_NAME = ":gpu";
constexpr const char* GPU_PROCESS_TYPE = "gpu";
constexpr const char* FONT_WGHT_SCALE = "persist.sys.font_wght_scale_for_user0";
constexpr const char* FONT_SCALE = "persist.sys.font_scale_for_user0";
const std::string TOKEN_ID = "TOKEN_ID";
const int32_t SIGNAL_KILL = 9;
constexpr int32_t USER_SCALE = 200000;
#define ENUM_TO_STRING(s) #s
@ -1494,7 +1500,7 @@ int32_t AppMgrServiceInner::ClearUpApplicationDataByUserId(const std::string &bu
TAG_LOGW(
AAFwkTag::APPMGR, "Distributeddata clear app storage failed, bundleName:%{public}s", bundleName.c_str());
}
NotifyAppStatusByCallerUid(bundleName, userId, callerUid,
NotifyAppStatusByCallerUid(bundleName, tokenId, userId, callerUid,
EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_DATA_CLEARED);
return ERR_OK;
}
@ -2920,6 +2926,17 @@ void AppMgrServiceInner::StartProcess(const std::string &appName, const std::str
appRunningManager_->RemoveAppRunningRecordById(appRecord->GetRecordId());
return;
}
#ifdef ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER
bool checkApiVersion = (appInfo && (appInfo->apiTargetVersion % API_VERSION_MOD == API10));
TAG_LOGD(AAFwkTag::APPMGR, "version of api is %{public}d", appInfo->apiTargetVersion % API_VERSION_MOD);
if (checkApiVersion && AAFwk::AppUtils::GetInstance().IsGrantPersistUriPermission()) {
uint32_t tokenId = appInfo->accessTokenId;
auto sandboxRet = AccessControl::SandboxManager::SandboxManagerKit::StartAccessingByTokenId(tokenId);
TAG_LOGI(AAFwkTag::APPMGR, "tokenId = %{public}u, ret = %{public}d", tokenId, sandboxRet);
}
#endif
TAG_LOGI(AAFwkTag::APPMGR, "Start process success, pid: %{public}d, processName: %{public}s.",
pid, processName.c_str());
SetRunningSharedBundleList(bundleName, startMsg.hspList);
@ -3613,17 +3630,18 @@ void AppMgrServiceInner::NotifyAppStatus(const std::string &bundleName, const st
EventFwk::CommonEventManager::PublishCommonEvent(commonData);
}
void AppMgrServiceInner::NotifyAppStatusByCallerUid(const std::string &bundleName, const int32_t userId,
const int32_t callerUid, const std::string &eventData)
void AppMgrServiceInner::NotifyAppStatusByCallerUid(const std::string &bundleName, const int32_t tokenId,
const int32_t userId, const int32_t callerUid, const std::string &eventData)
{
TAG_LOGI(AAFwkTag::APPMGR,
"%{public}s called, bundle name is %{public}s, , userId is %{public}d, event is %{public}s", __func__,
"%{public}s called, bundle name is %{public}s, userId is %{public}d, event is %{public}s", __func__,
bundleName.c_str(), userId, eventData.c_str());
Want want;
want.SetAction(eventData);
ElementName element;
element.SetBundleName(bundleName);
want.SetElement(element);
want.SetParam(TOKEN_ID, tokenId);
want.SetParam(Constants::USER_ID, userId);
want.SetParam(Constants::UID, callerUid);
EventFwk::CommonEventData commonData {want};
@ -5346,6 +5364,14 @@ void AppMgrServiceInner::TimeoutNotifyApp(int32_t pid, int32_t uid,
.processName = bundleName,
};
AppExecFwk::AppfreezeManager::GetInstance()->AppfreezeHandleWithStack(faultData, info);
#ifdef APP_NO_RESPONSE_DIALOG
bool isDialogExist = appRunningManager_ ?
appRunningManager_->CheckAppRunningRecordIsExist(APP_NO_RESPONSE_BUNDLENAME, APP_NO_RESPONSE_ABILITY) :
false;
auto killFaultApp = std::bind(&AppMgrServiceInner::KillFaultApp, this, pid, bundleName, faultData);
ModalSystemAppFreezeUIExtension::GetInstance().ProcessAppFreeze(true, faultData, std::to_string(pid),
bundleName, killFaultApp, isDialogExist);
#endif
}
}
@ -7223,5 +7249,30 @@ bool AppMgrServiceInner::IsKilledForUpgradeWeb(const std::string &bundleName) co
}
return ExitResidentProcessManager::GetInstance().IsKilledForUpgradeWeb(bundleName);
}
} // namespace AppExecFwk
bool AppMgrServiceInner::IsProcessContainsOnlyUIAbility(const pid_t pid)
{
auto appRecord = GetAppRunningRecordByPid(pid);
if (appRecord == nullptr) {
return false;
}
auto abilityRecordList = appRecord->GetAbilities();
for (auto it = abilityRecordList.begin(); it != abilityRecordList.end(); ++it) {
if (it->second == nullptr) {
return false;
}
auto abilityInfo = it->second->GetAbilityInfo();
if (abilityInfo == nullptr) {
return false;
}
bool isUIAbility = (abilityInfo->type == AppExecFwk::AbilityType::PAGE);
if (!isUIAbility) {
return false;
}
}
return true;
}
} // namespace AppExecFwk
} // namespace OHOS

View File

@ -90,6 +90,11 @@ ohos_unittest("AmsAbilityRunningRecordTest") {
if (ability_runtime_graphics) {
external_deps += [ "window_manager:libwm" ]
}
if (ability_runtime_feature_sandboxmanager) {
external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ]
defines = [ "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER" ]
}
}
group("unittest") {

View File

@ -107,6 +107,11 @@ ohos_unittest("AmsServiceLoadAbilityProcessTest") {
"window_manager:libwsutils",
]
}
if (ability_runtime_feature_sandboxmanager) {
external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ]
defines = [ "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER" ]
}
}
group("unittest") {

View File

@ -95,6 +95,11 @@ ohos_unittest("AmsServiceStartupTest") {
if (ability_runtime_graphics) {
external_deps += [ "window_manager:libwm" ]
}
if (ability_runtime_feature_sandboxmanager) {
external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ]
defines = [ "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER" ]
}
}
group("unittest") {

View File

@ -102,6 +102,11 @@ ohos_unittest("AMSEventHandlerTest") {
"window_manager:libwsutils",
]
}
if (ability_runtime_feature_sandboxmanager) {
external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ]
defines = [ "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER" ]
}
}
group("unittest") {

View File

@ -84,6 +84,11 @@ ohos_unittest("AppMgrServiceInnerTest") {
if (background_task_mgr_continuous_task_enable) {
defines += [ "BGTASKMGR_CONTINUOUS_TASK_ENABLE" ]
}
if (ability_runtime_feature_sandboxmanager) {
external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ]
defines += [ "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER" ]
}
}
group("unittest") {

View File

@ -2293,7 +2293,7 @@ HWTEST_F(AppMgrServiceInnerTest, NotifyAppStatusByCallerUid_001, TestSize.Level0
std::string bundleName = "test_bundle_name";
std::string eventData = "test_event_data";
appMgrServiceInner->NotifyAppStatusByCallerUid(bundleName, 0, 0, eventData);
appMgrServiceInner->NotifyAppStatusByCallerUid(bundleName, 0, 0, 0, eventData);
TAG_LOGI(AAFwkTag::TEST, "NotifyAppStatusByCallerUid_001 end");
}

View File

@ -51,10 +51,9 @@ public:
enum FLAG {
IS_SA_CALL = 1,
IS_SHELL_CALL,
IS_SA_AND_SHELL_CALL
IS_SA_AND_SHELL_CALL,
};
static int flag_;
static bool isSACall_;
static bool permissionFileAccessManager_;
static bool permissionWriteImageVideo_;
static bool permissionReadImageVideo_;