mirror of
https://gitee.com/openharmony/ability_ability_runtime
synced 2024-10-07 00:13:56 +00:00
Merge branch 'master' of https://gitee.com/openharmony/ability_ability_runtime into wyz_new
Signed-off-by: jiangzhijun8 <jiangzhijun7@huawei.com>
This commit is contained in:
commit
e64cbb68bd
@ -11,6 +11,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//build/ohos.gni")
|
||||
|
||||
ability_runtime_path = "//foundation/ability/ability_runtime"
|
||||
ability_runtime_napi_path = "${ability_runtime_path}/frameworks/js/napi"
|
||||
ability_base_path = "//foundation/ability/ability_base"
|
||||
@ -20,6 +22,7 @@ ability_runtime_native_path = "${ability_runtime_path}/frameworks/native"
|
||||
ability_runtime_services_path = "${ability_runtime_path}/services"
|
||||
ability_runtime_abilitymgr_path = "${ability_runtime_services_path}/abilitymgr"
|
||||
ability_runtime_test_path = "${ability_runtime_path}/test"
|
||||
ability_runtime_utils_path = "${ability_runtime_path}/utils"
|
||||
ace_engine_path = "//foundation/arkui/ace_engine"
|
||||
arkui_path = "//foundation/arkui"
|
||||
previewer_path = "//ide/tools/previewer"
|
||||
@ -88,7 +91,6 @@ access_token_path = "//base/security/access_token"
|
||||
declare_args() {
|
||||
background_task_mgr_continuous_task_enable = true
|
||||
resource_schedule_service_enable = true
|
||||
ability_runtime_graphics = true
|
||||
ability_runtime_power = true
|
||||
ability_runtime_relational = true
|
||||
ability_runtime_ces = true
|
||||
@ -177,4 +179,11 @@ declare_args() {
|
||||
} else {
|
||||
hichecker_enabled = false
|
||||
}
|
||||
|
||||
if (!defined(global_parts_info) ||
|
||||
defined(global_parts_info.ability_form_fwk)) {
|
||||
form_fwk_enable = true
|
||||
} else {
|
||||
form_fwk_enable = false
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +105,8 @@ class Caller {
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Caller call msgData sendMessageRequest retval error');
|
||||
msgData.reclaim();
|
||||
msgReply.reclaim();
|
||||
reject(new BusinessError(ERROR_CODE_INNER_ERROR));
|
||||
return;
|
||||
}
|
||||
@ -160,6 +162,8 @@ class Caller {
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Caller callWithResult msgData sendMessageRequest retval error');
|
||||
msgData.reclaim();
|
||||
msgReply.reclaim();
|
||||
reject(new BusinessError(ERROR_CODE_INNER_ERROR));
|
||||
return;
|
||||
}
|
||||
|
@ -44,6 +44,8 @@ void AbilityConnection::OnAbilityConnectDone(
|
||||
|
||||
std::vector<sptr<AbilityConnectCallback>> callbacks = GetCallbackList();
|
||||
mutex_.unlock();
|
||||
sptr<AbilityConnection> connection(this);
|
||||
ConnectionManager::GetInstance().DisconnectNonexistentService(element, connection);
|
||||
|
||||
auto item = callbacks.begin();
|
||||
while (item != callbacks.end()) {
|
||||
|
@ -395,13 +395,13 @@ ErrCode AbilityContextImpl::ConnectAbilityWithAccount(const AAFwk::Want& want, i
|
||||
}
|
||||
|
||||
void AbilityContextImpl::DisconnectAbility(const AAFwk::Want& want,
|
||||
const sptr<AbilityConnectCallback>& connectCallback)
|
||||
const sptr<AbilityConnectCallback>& connectCallback, int32_t accountId)
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "DisconnectAbility begin, caller:%{public}s.",
|
||||
abilityInfo_ == nullptr ? "" : abilityInfo_->name.c_str());
|
||||
ErrCode ret =
|
||||
ConnectionManager::GetInstance().DisconnectAbility(token_, want, connectCallback);
|
||||
ConnectionManager::GetInstance().DisconnectAbility(token_, want, connectCallback, accountId);
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::CONTEXT, "error, ret=%{public}d", ret);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ ErrCode ConnectionManager::ConnectAbilityInner(const sptr<IRemoteObject>& connec
|
||||
std::lock_guard<std::recursive_mutex> lock(connectionsLock_);
|
||||
auto connectionIter = abilityConnections_.begin();
|
||||
for (; connectionIter != abilityConnections_.end(); ++connectionIter) {
|
||||
if (MatchConnection(connectCaller, want, *connectionIter)) {
|
||||
if (MatchConnection(connectCaller, want, accountId, *connectionIter)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -89,9 +89,12 @@ ErrCode ConnectionManager::ConnectAbilityInner(const sptr<IRemoteObject>& connec
|
||||
}
|
||||
|
||||
bool ConnectionManager::MatchConnection(
|
||||
const sptr<IRemoteObject>& connectCaller, const AAFwk::Want& connectReceiver,
|
||||
const sptr<IRemoteObject>& connectCaller, const AAFwk::Want& connectReceiver, int32_t accountId,
|
||||
const std::map<ConnectionInfo, std::vector<sptr<AbilityConnectCallback>>>::value_type& connection)
|
||||
{
|
||||
if (accountId != connection.first.userid) {
|
||||
return false;
|
||||
}
|
||||
if (!connectReceiver.GetElement().GetAbilityName().empty()) {
|
||||
return connectCaller == connection.first.connectCaller &&
|
||||
connectReceiver.GetElement().GetBundleName() == connection.first.connectReceiver.GetBundleName() &&
|
||||
@ -120,7 +123,7 @@ ErrCode ConnectionManager::CreateConnection(const sptr<IRemoteObject>& connectCa
|
||||
want, abilityConnection, connectCaller, accountId);
|
||||
std::lock_guard<std::recursive_mutex> lock(connectionsLock_);
|
||||
if (ret == ERR_OK) {
|
||||
ConnectionInfo connectionInfo(connectCaller, want.GetOperation(), abilityConnection);
|
||||
ConnectionInfo connectionInfo(connectCaller, want.GetOperation(), abilityConnection, accountId);
|
||||
std::vector<sptr<AbilityConnectCallback>> callbacks;
|
||||
callbacks.push_back(connectCallback);
|
||||
abilityConnections_[connectionInfo] = callbacks;
|
||||
@ -139,7 +142,8 @@ ErrCode ConnectionManager::DisconnectAbility(const sptr<IRemoteObject>& connectC
|
||||
}
|
||||
|
||||
ErrCode ConnectionManager::DisconnectAbility(const sptr<IRemoteObject>& connectCaller,
|
||||
const AAFwk::Want& connectReceiver, const sptr<AbilityConnectCallback>& connectCallback)
|
||||
const AAFwk::Want& connectReceiver, const sptr<AbilityConnectCallback>& connectCallback,
|
||||
int32_t accountId)
|
||||
{
|
||||
if (connectCaller == nullptr || connectCallback == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::CONNECTION, "connectCaller or connectCallback is nullptr.");
|
||||
@ -151,8 +155,8 @@ ErrCode ConnectionManager::DisconnectAbility(const sptr<IRemoteObject>& connectC
|
||||
(element.GetBundleName() + ":" + element.GetAbilityName()).c_str());
|
||||
std::lock_guard<std::recursive_mutex> lock(connectionsLock_);
|
||||
auto item = std::find_if(abilityConnections_.begin(), abilityConnections_.end(),
|
||||
[&connectCaller, &connectReceiver, this](const auto& obj) {
|
||||
return MatchConnection(connectCaller, connectReceiver, obj);
|
||||
[&connectCaller, &connectReceiver, this, accountId](const auto& obj) {
|
||||
return MatchConnection(connectCaller, connectReceiver, accountId, obj);
|
||||
});
|
||||
if (item != abilityConnections_.end()) {
|
||||
TAG_LOGD(AAFwkTag::CONNECTION, "remove callback, Size:%{public}zu.", item->second.size());
|
||||
@ -237,6 +241,33 @@ bool ConnectionManager::RemoveConnection(const sptr<AbilityConnection> connectio
|
||||
return isDisconnect;
|
||||
}
|
||||
|
||||
void ConnectionManager::DisconnectNonexistentService(
|
||||
const AppExecFwk::ElementName& element, const sptr<AbilityConnection> connection)
|
||||
{
|
||||
bool exit = false;
|
||||
std::map<ConnectionInfo, std::vector<sptr<AbilityConnectCallback>>> abilityConnections;
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(connectionsLock_);
|
||||
abilityConnections = abilityConnections_;
|
||||
}
|
||||
HILOG_DEBUG("abilityConnectionsSize: %{public}zu", abilityConnections.size());
|
||||
|
||||
for (auto &&abilityConnection : abilityConnections) {
|
||||
ConnectionInfo connectionInfo = abilityConnection.first;
|
||||
if (connectionInfo.abilityConnection == connection &&
|
||||
connectionInfo.connectReceiver.GetBundleName() == element.GetBundleName() &&
|
||||
connectionInfo.connectReceiver.GetAbilityName() == element.GetAbilityName()) {
|
||||
HILOG_DEBUG("find connection.");
|
||||
exit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!exit) {
|
||||
HILOG_ERROR("this service need disconnect");
|
||||
AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(connection);
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionManager::ReportConnectionLeakEvent(const int pid, const int tid)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::CONNECTION, "pid:%{public}d, tid:%{public}d.", pid, tid);
|
||||
|
@ -638,15 +638,21 @@ ohos_shared_library("form_extension") {
|
||||
"c_utils:utils",
|
||||
"common_event_service:cesfwk_innerkits",
|
||||
"eventhandler:libeventhandler",
|
||||
"form_fwk:fmskit_native",
|
||||
"form_fwk:form_manager",
|
||||
"form_fwk:formutil_napi",
|
||||
"hilog:libhilog",
|
||||
"hitrace:hitrace_meter",
|
||||
"ipc:ipc_core",
|
||||
"ipc:ipc_napi",
|
||||
"napi:ace_napi",
|
||||
]
|
||||
|
||||
if (form_fwk_enable) {
|
||||
external_deps += [
|
||||
"form_fwk:fmskit_native",
|
||||
"form_fwk:fmskit_provider_client",
|
||||
"form_fwk:form_manager",
|
||||
"form_fwk:formutil_napi",
|
||||
]
|
||||
}
|
||||
}
|
||||
subsystem_name = "ability"
|
||||
part_name = "ability_runtime"
|
||||
|
@ -72,7 +72,6 @@ const int Ability::DEFAULT_DMS_SESSION_ID(0);
|
||||
const std::string LAUNCHER_BUNDLE_NAME = "com.ohos.launcher";
|
||||
const std::string LAUNCHER_ABILITY_NAME = "com.ohos.launcher.MainAbility";
|
||||
const std::string SHOW_ON_LOCK_SCREEN = "ShowOnLockScreen";
|
||||
const std::string DLP_INDEX = "ohos.dlp.params.index";
|
||||
const std::string DLP_PARAMS_SECURITY_FLAG = "ohos.dlp.params.securityFlag";
|
||||
const std::string COMPONENT_STARTUP_NEW_RULES = "component.startup.newRules";
|
||||
|
||||
@ -165,8 +164,6 @@ void Ability::OnStart(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo)
|
||||
return;
|
||||
}
|
||||
|
||||
appIndex_ = want.GetIntParam(DLP_INDEX, 0);
|
||||
(const_cast<Want &>(want)).RemoveParam(DLP_INDEX);
|
||||
securityFlag_ = want.GetBoolParam(DLP_PARAMS_SECURITY_FLAG, false);
|
||||
(const_cast<Want &>(want)).RemoveParam(DLP_PARAMS_SECURITY_FLAG);
|
||||
SetWant(want);
|
||||
@ -340,11 +337,6 @@ bool Ability::IsRestoredInContinuation() const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (abilityContext_->GetContentStorage() == nullptr) {
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "not Restored In Continuation");
|
||||
return false;
|
||||
}
|
||||
|
||||
TAG_LOGD(AAFwkTag::ABILITY, "Is Restored In Continuation");
|
||||
return true;
|
||||
}
|
||||
|
@ -78,6 +78,7 @@ constexpr const char* ERROR_MSG_TARGET_BUNDLE_NOT_EXIST = "The target bundle doe
|
||||
constexpr const char* ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN = "Can not set process cache state more than once.";
|
||||
constexpr const char* ERROR_MSG_NO_RESIDENT_PERMISSION =
|
||||
"The caller application can only set the resident status of the configured process.";
|
||||
constexpr const char* ERROR_MSG_APP_TWIN_INDEX_INVALID = "The target app twin with the specified index does not exist.";
|
||||
|
||||
// follow ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST of appexecfwk_errors.h in bundle_framework
|
||||
constexpr int32_t ERR_BUNDLE_MANAGER_BUNDLE_NOT_EXIST = 8521220;
|
||||
@ -131,6 +132,7 @@ static std::unordered_map<AbilityErrorCode, const char*> ERR_CODE_MAP = {
|
||||
{ AbilityErrorCode::ERROR_CODE_TARGET_BUNDLE_NOT_EXIST, ERROR_MSG_TARGET_BUNDLE_NOT_EXIST },
|
||||
{ AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN, ERROR_MSG_SET_SUPPORTED_PROCESS_CACHE_AGAIN },
|
||||
{ AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION, ERROR_MSG_NO_RESIDENT_PERMISSION },
|
||||
{ AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID, ERROR_MSG_APP_TWIN_INDEX_INVALID },
|
||||
};
|
||||
|
||||
static std::unordered_map<int32_t, AbilityErrorCode> INNER_TO_JS_ERROR_CODE_MAP {
|
||||
@ -187,6 +189,7 @@ static std::unordered_map<int32_t, AbilityErrorCode> INNER_TO_JS_ERROR_CODE_MAP
|
||||
{ERR_TARGET_BUNDLE_NOT_EXIST, AbilityErrorCode::ERROR_CODE_TARGET_BUNDLE_NOT_EXIST},
|
||||
{ERR_SET_SUPPORTED_PROCESS_CACHE_AGAIN, AbilityErrorCode::ERROR_CODE_SET_SUPPORTED_PROCESS_CACHE_AGAIN},
|
||||
{ERR_NO_RESIDENT_PERMISSION, AbilityErrorCode::ERROR_CODE_NO_RESIDENT_PERMISSION},
|
||||
{ERR_APP_TWIN_INDEX_INVALID, AbilityErrorCode::ERROR_APP_TWIN_INDEX_INVALID},
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ void RemoveConnection(int64_t connectId)
|
||||
}
|
||||
}
|
||||
|
||||
int64_t InsertConnection(sptr<JSAbilityConnection> connection, const AAFwk::Want &want)
|
||||
int64_t InsertConnection(sptr<JSAbilityConnection> connection, const AAFwk::Want &want, int32_t accountId = -1)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(gConnectsLock_);
|
||||
if (connection == nullptr) {
|
||||
@ -97,6 +97,7 @@ int64_t InsertConnection(sptr<JSAbilityConnection> connection, const AAFwk::Want
|
||||
ConnectionKey key;
|
||||
key.id = g_serialNumber;
|
||||
key.want = want;
|
||||
key.accountId = accountId;
|
||||
connection->SetConnectionId(key.id);
|
||||
g_connects.emplace(key, connection);
|
||||
if (g_serialNumber < INT32_MAX) {
|
||||
@ -1236,7 +1237,7 @@ napi_value JsAbilityContext::OnConnectAbilityWithAccount(napi_env env, NapiCallb
|
||||
// unwarp connection
|
||||
sptr<JSAbilityConnection> connection = new JSAbilityConnection(env);
|
||||
connection->SetJsConnectionObject(info.argv[INDEX_TWO]);
|
||||
int64_t connectId = InsertConnection(connection, want);
|
||||
int64_t connectId = InsertConnection(connection, want, accountId);
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[weak = context_, want, accountId, connection, connectId](
|
||||
napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
@ -1277,6 +1278,7 @@ napi_value JsAbilityContext::OnDisconnectAbility(napi_env env, NapiCallbackInfo&
|
||||
// unwrap connectId
|
||||
int64_t connectId = -1;
|
||||
sptr<JSAbilityConnection> connection = nullptr;
|
||||
int32_t accountId = -1;
|
||||
napi_get_value_int64(env, info.argv[INDEX_ZERO], &connectId);
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "DisconnectAbility, connection:%{public}d.", static_cast<int32_t>(connectId));
|
||||
auto item = std::find_if(g_connects.begin(),
|
||||
@ -1288,12 +1290,13 @@ napi_value JsAbilityContext::OnDisconnectAbility(napi_env env, NapiCallbackInfo&
|
||||
// match id
|
||||
want = item->first.want;
|
||||
connection = item->second;
|
||||
accountId = item->first.accountId;
|
||||
} else {
|
||||
TAG_LOGI(AAFwkTag::CONTEXT, "not find conn exist.");
|
||||
}
|
||||
// begin disconnect
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[weak = context_, want, connection](
|
||||
[weak = context_, want, connection, accountId](
|
||||
napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
@ -1307,7 +1310,7 @@ napi_value JsAbilityContext::OnDisconnectAbility(napi_env env, NapiCallbackInfo&
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::CONTEXT, "context->DisconnectAbility");
|
||||
context->DisconnectAbility(want, connection);
|
||||
context->DisconnectAbility(want, connection, accountId);
|
||||
task.Resolve(env, CreateJsUndefined(env));
|
||||
};
|
||||
|
||||
|
@ -1279,11 +1279,14 @@ napi_value JsUIAbility::CallObjectMethod(const char *name, napi_value const *arg
|
||||
}
|
||||
return handleEscape.Escape(result);
|
||||
}
|
||||
int64_t timeStart = AbilityRuntime::TimeUtil::SystemTimeMillisecond();
|
||||
napi_call_function(env, obj, methodOnCreate, argc, argv, nullptr);
|
||||
int64_t timeEnd = AbilityRuntime::TimeUtil::SystemTimeMillisecond();
|
||||
if (tryCatch.HasCaught()) {
|
||||
reinterpret_cast<NativeEngine*>(env)->HandleUncaughtException();
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::UIABILITY, "Lifecycle: the end of %{public}s", name);
|
||||
TAG_LOGI(AAFwkTag::UIABILITY, "Lifecycle: the end of %{public}s, time: %{public}s",
|
||||
name, std::to_string(timeEnd - timeStart).c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -503,7 +503,7 @@ bool DistributedClient::WriteInfosToParcel(MessageParcel& data, const OHOS::AAFw
|
||||
const sptr<IRemoteObject>& connect)
|
||||
{
|
||||
int32_t callerUid = IPCSkeleton::GetCallingUid();
|
||||
int32_t callerPid = IPCSkeleton::GetCallingPid();
|
||||
int32_t callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
uint32_t accessToken = IPCSkeleton::GetCallingTokenID();
|
||||
if (!data.WriteInterfaceToken(DMS_PROXY_INTERFACE_TOKEN)) {
|
||||
return false;
|
||||
|
@ -723,7 +723,7 @@ private:
|
||||
if (!CheckStartAbilityWithAccountInputParam(env, info, want, accountId, unwrapArgc)) {
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
if (!CheckConnectionParam(env, info.argv[INDEX_TWO], connection, want)) {
|
||||
if (!CheckConnectionParam(env, info.argv[INDEX_TWO], connection, want, accountId)) {
|
||||
ThrowInvalidParamError(env, "Parse param options failed, must be a ConnectOptions");
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
@ -755,7 +755,7 @@ private:
|
||||
}
|
||||
|
||||
bool CheckConnectionParam(napi_env env, napi_value value,
|
||||
sptr<JSServiceExtensionConnection>& connection, AAFwk::Want& want) const
|
||||
sptr<JSServiceExtensionConnection>& connection, AAFwk::Want& want, int32_t accountId = -1) const
|
||||
{
|
||||
if (!CheckTypeForNapiValue(env, value, napi_object)) {
|
||||
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Failed to get connection object");
|
||||
@ -767,6 +767,7 @@ private:
|
||||
std::lock_guard guard(g_connectsMutex);
|
||||
key.id = g_serialNumber;
|
||||
key.want = want;
|
||||
key.accountId = accountId;
|
||||
connection->SetConnectionId(key.id);
|
||||
g_connects.emplace(key, connection);
|
||||
if (g_serialNumber < INT32_MAX) {
|
||||
@ -795,10 +796,11 @@ private:
|
||||
|
||||
AAFwk::Want want;
|
||||
sptr<JSServiceExtensionConnection> connection = nullptr;
|
||||
FindConnection(want, connection, connectId);
|
||||
int32_t accountId = -1;
|
||||
FindConnection(want, connection, connectId, accountId);
|
||||
// begin disconnect
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[weak = context_, want, connection](
|
||||
[weak = context_, want, connection, accountId](
|
||||
napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
auto context = weak.lock();
|
||||
if (!context) {
|
||||
@ -812,7 +814,7 @@ private:
|
||||
return;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "context->DisconnectAbility");
|
||||
auto innerErrorCode = context->DisconnectAbility(want, connection);
|
||||
auto innerErrorCode = context->DisconnectAbility(want, connection, accountId);
|
||||
if (innerErrorCode == 0) {
|
||||
task.Resolve(env, CreateJsUndefined(env));
|
||||
} else {
|
||||
@ -827,7 +829,8 @@ private:
|
||||
return result;
|
||||
}
|
||||
|
||||
void FindConnection(AAFwk::Want& want, sptr<JSServiceExtensionConnection>& connection, int64_t& connectId) const
|
||||
void FindConnection(AAFwk::Want& want, sptr<JSServiceExtensionConnection>& connection, int64_t& connectId,
|
||||
int32_t &accountId) const
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::SERVICE_EXT, "Disconnect ability begin, connection:%{public}d.",
|
||||
static_cast<int32_t>(connectId));
|
||||
@ -841,6 +844,7 @@ private:
|
||||
// match id
|
||||
want = item->first.want;
|
||||
connection = item->second;
|
||||
accountId = item->first.accountId;
|
||||
TAG_LOGD(AAFwkTag::SERVICE_EXT, "find conn ability exist");
|
||||
}
|
||||
return;
|
||||
|
@ -36,7 +36,6 @@ constexpr int32_t DEFAULT_DMS_SESSION_ID = 0;
|
||||
constexpr char LAUNCHER_BUNDLE_NAME[] = "com.ohos.launcher";
|
||||
constexpr char LAUNCHER_ABILITY_NAME[] = "com.ohos.launcher.MainAbility";
|
||||
constexpr char SHOW_ON_LOCK_SCREEN[] = "ShowOnLockScreen";
|
||||
constexpr char DLP_INDEX[] = "ohos.dlp.params.index";
|
||||
constexpr char DLP_PARAMS_SECURITY_FLAG[] = "ohos.dlp.params.securityFlag";
|
||||
constexpr char COMPONENT_STARTUP_NEW_RULES[] = "component.startup.newRules";
|
||||
constexpr int32_t ERR_INVALID_VALUE = -1;
|
||||
@ -152,8 +151,6 @@ void UIAbility::OnStart(const AAFwk::Want &want, sptr<AAFwk::SessionInfo> sessio
|
||||
return;
|
||||
}
|
||||
|
||||
appIndex_ = want.GetIntParam(DLP_INDEX, 0);
|
||||
(const_cast<AAFwk::Want &>(want)).RemoveParam(DLP_INDEX);
|
||||
securityFlag_ = want.GetBoolParam(DLP_PARAMS_SECURITY_FLAG, false);
|
||||
(const_cast<AAFwk::Want &>(want)).RemoveParam(DLP_PARAMS_SECURITY_FLAG);
|
||||
SetWant(want);
|
||||
|
@ -90,6 +90,7 @@ ohos_shared_library("appkit_native") {
|
||||
"${ability_runtime_path}/utils/global/time/include",
|
||||
"${ability_runtime_services_path}/abilitymgr/include",
|
||||
"${ability_runtime_napi_path}/inner/napi_common",
|
||||
"${ability_runtime_utils_path}/global/constant",
|
||||
]
|
||||
|
||||
if (ability_runtime_graphics) {
|
||||
@ -422,6 +423,7 @@ ohos_shared_library("appkit_manager_helper") {
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper",
|
||||
"${ability_runtime_services_path}/common/include",
|
||||
"${ability_runtime_path}/interfaces/kits/native/ability/native",
|
||||
"${ability_runtime_utils_path}/global/constant",
|
||||
]
|
||||
|
||||
configs = [ ":appkit_config" ]
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "bundle_mgr_helper.h"
|
||||
|
||||
#include "bundle_mgr_service_death_recipient.h"
|
||||
#include "global_constant.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
@ -81,7 +82,7 @@ ErrCode BundleMgrHelper::InstallSandboxApp(const std::string &bundleName, int32_
|
||||
ErrCode BundleMgrHelper::UninstallSandboxApp(const std::string &bundleName, int32_t appIndex, int32_t userId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
if (bundleName.empty() || appIndex <= Constants::INITIAL_APP_INDEX) {
|
||||
if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
@ -112,7 +113,7 @@ ErrCode BundleMgrHelper::GetSandboxBundleInfo(
|
||||
const std::string &bundleName, int32_t appIndex, int32_t userId, BundleInfo &info)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
if (bundleName.empty() || appIndex <= Constants::INITIAL_APP_INDEX) {
|
||||
if (bundleName.empty() || appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
@ -130,7 +131,7 @@ ErrCode BundleMgrHelper::GetSandboxAbilityInfo(const Want &want, int32_t appInde
|
||||
AbilityInfo &abilityInfo)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
if (appIndex <= Constants::INITIAL_APP_INDEX || appIndex > Constants::MAX_APP_INDEX) {
|
||||
if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
@ -151,7 +152,7 @@ ErrCode BundleMgrHelper::GetSandboxExtAbilityInfos(const Want &want, int32_t app
|
||||
int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
if (appIndex <= Constants::INITIAL_APP_INDEX || appIndex > Constants::MAX_APP_INDEX) {
|
||||
if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
@ -169,7 +170,7 @@ ErrCode BundleMgrHelper::GetSandboxHapModuleInfo(const AbilityInfo &abilityInfo,
|
||||
HapModuleInfo &hapModuleInfo)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
if (appIndex <= Constants::INITIAL_APP_INDEX || appIndex > Constants::MAX_APP_INDEX) {
|
||||
if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "The params are invalid.");
|
||||
return ERR_APPEXECFWK_SANDBOX_INSTALL_PARAM_ERROR;
|
||||
}
|
||||
@ -797,5 +798,31 @@ ErrCode BundleMgrHelper::GetLaunchWantForBundle(const std::string &bundleName, W
|
||||
return bundleMgr->GetLaunchWantForBundle(bundleName, want, userId);
|
||||
}
|
||||
|
||||
ErrCode BundleMgrHelper::QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t appTwinIndex,
|
||||
AbilityInfo &abilityInfo, int32_t userId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
auto bundleMgr = Connect();
|
||||
if (bundleMgr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "Failed to connect.");
|
||||
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
return bundleMgr->QueryCloneAbilityInfo(element, flags, appTwinIndex, abilityInfo, userId);
|
||||
}
|
||||
|
||||
ErrCode BundleMgrHelper::GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appTwinIndex,
|
||||
BundleInfo &bundleInfo, int32_t userId)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::BUNDLEMGRHELPER, "Called.");
|
||||
auto bundleMgr = Connect();
|
||||
if (bundleMgr == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::BUNDLEMGRHELPER, "Failed to connect.");
|
||||
return ERR_APPEXECFWK_SERVICE_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
return bundleMgr->GetCloneBundleInfo(bundleName, flags, appTwinIndex, bundleInfo, userId);
|
||||
}
|
||||
|
||||
} // namespace AppExecFwk
|
||||
} // namespace OHOS
|
@ -690,13 +690,13 @@ napi_value JsApplicationContextUtils::OnPreloadUIExtensionAbility(napi_env env,
|
||||
auto innerErrCode = std::make_shared<ErrCode>(ERR_OK);
|
||||
NapiAsyncTask::ExecuteCallback execute = [applicationContext = applicationContext_, want, innerErrCode]() {
|
||||
auto context = applicationContext.lock();
|
||||
auto hostBundleName = context->GetBundleName();
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "HostBundleName is %{public}s.", hostBundleName.c_str());
|
||||
if (!context) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "context is released");
|
||||
*innerErrCode = static_cast<int>(AbilityErrorCode::ERROR_CODE_INVALID_CONTEXT);
|
||||
return;
|
||||
}
|
||||
auto hostBundleName = context->GetBundleName();
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "HostBundleName is %{public}s.", hostBundleName.c_str());
|
||||
*innerErrCode = AAFwk::AbilityManagerClient::GetInstance()->PreloadUIExtensionAbility(want, hostBundleName);
|
||||
};
|
||||
NapiAsyncTask::CompleteCallback complete = [innerErrCode](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
@ -1432,7 +1432,7 @@ napi_value JsApplicationContextUtils::OnSetSupportedProcessCacheSelf(napi_env en
|
||||
bool isSupport = false;
|
||||
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], isSupport)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "Parse isSupport failed");
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INTERNAL_ERROR);
|
||||
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
|
||||
return CreateJsUndefined(env);
|
||||
}
|
||||
|
||||
|
@ -183,12 +183,12 @@ ErrCode ServiceExtensionContext::ConnectAbilityWithAccount(
|
||||
return ret;
|
||||
}
|
||||
|
||||
ErrCode ServiceExtensionContext::DisconnectAbility(
|
||||
const AAFwk::Want &want, const sptr<AbilityConnectCallback> &connectCallback) const
|
||||
ErrCode ServiceExtensionContext::DisconnectAbility(const AAFwk::Want &want,
|
||||
const sptr<AbilityConnectCallback> &connectCallback, int32_t accountId) const
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "begin.");
|
||||
ErrCode ret =
|
||||
ConnectionManager::GetInstance().DisconnectAbility(token_, want, connectCallback);
|
||||
ConnectionManager::GetInstance().DisconnectAbility(token_, want, connectCallback, accountId);
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "%{public}s end DisconnectAbility error, ret=%{public}d", __func__, ret);
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "child_process_manager.h"
|
||||
#include "configuration_convertor.h"
|
||||
#include "common_event_manager.h"
|
||||
#include "global_constant.h"
|
||||
#include "context_deal.h"
|
||||
#include "context_impl.h"
|
||||
#include "exit_reason.h"
|
||||
@ -49,6 +50,7 @@
|
||||
#include "extension_module_loader.h"
|
||||
#include "extension_plugin_info.h"
|
||||
#include "extract_resource_manager.h"
|
||||
#include "ffrt.h"
|
||||
#include "file_path_utils.h"
|
||||
#include "freeze_util.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
@ -101,7 +103,6 @@ using AbilityRuntime::FreezeUtil;
|
||||
namespace AppExecFwk {
|
||||
using namespace OHOS::AbilityBase::Constants;
|
||||
std::weak_ptr<OHOSApplication> MainThread::applicationForDump_;
|
||||
std::shared_ptr<EventHandler> MainThread::signalHandler_ = nullptr;
|
||||
std::shared_ptr<MainThread::MainHandler> MainThread::mainHandler_ = nullptr;
|
||||
const std::string PERFCMD_PROFILE = "profile";
|
||||
const std::string PERFCMD_DUMPHEAP = "dumpheap";
|
||||
@ -902,11 +903,6 @@ void MainThread::HandleTerminateApplicationLocal()
|
||||
}
|
||||
applicationImpl_->PerformTerminateStrong();
|
||||
|
||||
std::shared_ptr<EventRunner> signalRunner = signalHandler_->GetEventRunner();
|
||||
if (signalRunner) {
|
||||
signalRunner->Stop();
|
||||
}
|
||||
|
||||
std::shared_ptr<EventRunner> runner = mainHandler_->GetEventRunner();
|
||||
if (runner == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "get manHandler error");
|
||||
@ -1191,7 +1187,7 @@ bool GetBundleForLaunchApplication(std::shared_ptr<BundleMgrHelper> bundleMgrHel
|
||||
int32_t appIndex, BundleInfo &bundleInfo)
|
||||
{
|
||||
bool queryResult;
|
||||
if (appIndex != 0) {
|
||||
if (appIndex > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "The bundleName = %{public}s.", bundleName.c_str());
|
||||
queryResult = (bundleMgrHelper->GetSandboxBundleInfo(bundleName,
|
||||
appIndex, UNSPECIFIED_USERID, bundleInfo) == 0);
|
||||
@ -1344,16 +1340,7 @@ void MainThread::HandleLaunchApplication(const AppLaunchData &appLaunchData, con
|
||||
|
||||
std::map<std::string, std::string> pkgContextInfoJsonStringMap;
|
||||
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
|
||||
std::string pkgContextInfoJsonString;
|
||||
ErrCode errCode = bundleMgrHelper->GetJsonProfile(
|
||||
AppExecFwk::PKG_CONTEXT_PROFILE, appInfo.bundleName, hapModuleInfo.moduleName, pkgContextInfoJsonString,
|
||||
AppExecFwk::OsAccountManagerWrapper::GetCurrentActiveAccountId());
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "GetJsonProfile failed: %{public}d.", ret);
|
||||
}
|
||||
if (!pkgContextInfoJsonString.empty()) {
|
||||
pkgContextInfoJsonStringMap[hapModuleInfo.moduleName] = pkgContextInfoJsonString;
|
||||
}
|
||||
pkgContextInfoJsonStringMap[hapModuleInfo.moduleName] = hapModuleInfo.hapPath;
|
||||
}
|
||||
|
||||
AppLibPathMap appLibPaths {};
|
||||
@ -2137,11 +2124,6 @@ void MainThread::HandleTerminateApplication(bool isLastProcess)
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "PerformTerminate() failed.");
|
||||
}
|
||||
|
||||
std::shared_ptr<EventRunner> signalRunner = signalHandler_->GetEventRunner();
|
||||
if (signalRunner) {
|
||||
signalRunner->Stop();
|
||||
}
|
||||
|
||||
std::shared_ptr<EventRunner> runner = mainHandler_->GetEventRunner();
|
||||
if (runner == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "get manHandler error");
|
||||
@ -2248,7 +2230,6 @@ void MainThread::Init(const std::shared_ptr<EventRunner> &runner)
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "Start");
|
||||
mainHandler_ = std::make_shared<MainHandler>(runner, this);
|
||||
watchdog_ = std::make_shared<Watchdog>();
|
||||
signalHandler_ = std::make_shared<EventHandler>(EventRunner::Create(SIGNAL_HANDLER));
|
||||
extensionConfigMgr_ = std::make_unique<AbilityRuntime::ExtensionConfigMgr>();
|
||||
wptr<MainThread> weak = this;
|
||||
auto task = [weak]() {
|
||||
@ -2313,7 +2294,7 @@ void MainThread::HandleSignal(int signal, [[maybe_unused]] siginfo_t *siginfo, v
|
||||
}
|
||||
case SignalType::SIGNAL_FORCE_FULLGC: {
|
||||
auto forceFullGCFunc = std::bind(&MainThread::ForceFullGC);
|
||||
signalHandler_->PostTask(forceFullGCFunc, "MainThread:SIGNAL_FORCE_FULLGC");
|
||||
ffrt::submit(forceFullGCFunc);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -2329,8 +2310,12 @@ void MainThread::HandleDumpHeapPrepare()
|
||||
return;
|
||||
}
|
||||
auto app = applicationForDump_.lock();
|
||||
if (app == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "HandleDumpHeapPrepare app is nullptr");
|
||||
return;
|
||||
}
|
||||
auto &runtime = app->GetRuntime();
|
||||
if (app == nullptr || runtime == nullptr) {
|
||||
if (runtime == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "HandleDumpHeapPrepare runtime is nullptr");
|
||||
return;
|
||||
}
|
||||
@ -2345,12 +2330,17 @@ void MainThread::HandleDumpHeap(bool isPrivate)
|
||||
return;
|
||||
}
|
||||
auto app = applicationForDump_.lock();
|
||||
if (app == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "HandleDumpHeap app is nullptr");
|
||||
return;
|
||||
}
|
||||
auto &runtime = app->GetRuntime();
|
||||
if (app == nullptr || runtime == nullptr) {
|
||||
if (runtime == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "HandleDumpHeap runtime is nullptr");
|
||||
return;
|
||||
}
|
||||
auto taskFork = [&runtime, &isPrivate] {
|
||||
TAG_LOGD(AAFwkTag::APPKIT, "HandleDump Heap taskFork start.");
|
||||
time_t startTime = time(nullptr);
|
||||
int pid = -1;
|
||||
if ((pid = fork()) < 0) {
|
||||
@ -2382,10 +2372,8 @@ void MainThread::HandleDumpHeap(bool isPrivate)
|
||||
usleep(DEFAULT_SLEEP_TIME);
|
||||
}
|
||||
};
|
||||
if (!signalHandler_->PostTask(taskFork, "MainThread::HandleDumpHeap",
|
||||
0, AppExecFwk::EventQueue::Priority::IMMEDIATE)) {
|
||||
TAG_LOGE(AAFwkTag::APPKIT, "HandleDumpHeap postTask false");
|
||||
}
|
||||
|
||||
ffrt::submit(taskFork, {}, {}, ffrt::task_attr().qos(ffrt::qos_user_initiated));
|
||||
runtime->DumpCpuProfile(isPrivate);
|
||||
}
|
||||
|
||||
|
@ -430,7 +430,8 @@ void JsRuntime::StartProfiler(const DebugOption dOption)
|
||||
jsEnv_->StartProfiler(ARK_DEBUGGER_LIB_PATH, instanceId_, profiler, interval, getproctid(), isDebugApp);
|
||||
}
|
||||
|
||||
bool JsRuntime::GetFileBuffer(const std::string& filePath, std::string& fileFullName, std::vector<uint8_t>& buffer)
|
||||
bool JsRuntime::GetFileBuffer(const std::string& filePath, std::string& fileFullName, std::vector<uint8_t>& buffer,
|
||||
bool isABC)
|
||||
{
|
||||
Extractor extractor(filePath);
|
||||
if (!extractor.Init()) {
|
||||
@ -439,7 +440,11 @@ bool JsRuntime::GetFileBuffer(const std::string& filePath, std::string& fileFull
|
||||
}
|
||||
|
||||
std::vector<std::string> fileNames;
|
||||
extractor.GetSpecifiedTypeFiles(fileNames, ".abc");
|
||||
if (isABC) {
|
||||
extractor.GetSpecifiedTypeFiles(fileNames, ".abc");
|
||||
} else {
|
||||
extractor.GetSpecifiedTypeFiles(fileNames, ".map");
|
||||
}
|
||||
if (fileNames.empty()) {
|
||||
TAG_LOGW(
|
||||
AAFwkTag::JSRUNTIME, "GetFileBuffer, There's no abc file in hap or hqf %{private}s.", filePath.c_str());
|
||||
@ -465,6 +470,21 @@ bool JsRuntime::LoadRepairPatch(const std::string& hqfFile, const std::string& h
|
||||
auto vm = GetEcmaVm();
|
||||
CHECK_POINTER_AND_RETURN(vm, false);
|
||||
|
||||
std::string patchSoureMapFile;
|
||||
std::vector<uint8_t> soureMapBuffer;
|
||||
if (!GetFileBuffer(hqfFile, patchSoureMapFile, soureMapBuffer, false)) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "LoadRepairPatch, get patchSoureMap file buffer failed.");
|
||||
return false;
|
||||
}
|
||||
std::string str(soureMapBuffer.begin(), soureMapBuffer.end());
|
||||
auto sourceMapOperator = jsEnv_->GetSourceMapOperator();
|
||||
if (sourceMapOperator != nullptr) {
|
||||
auto sourceMapObj = sourceMapOperator->GetSourceMapObj();
|
||||
if (sourceMapObj != nullptr) {
|
||||
sourceMapObj->SplitSourceMap(str);
|
||||
}
|
||||
}
|
||||
|
||||
std::string patchFile;
|
||||
std::vector<uint8_t> patchBuffer;
|
||||
if (!GetFileBuffer(hqfFile, patchFile, patchBuffer)) {
|
||||
@ -1569,15 +1589,28 @@ void JsRuntime::GetPkgContextInfoListMap(const std::map<std::string, std::string
|
||||
{
|
||||
for (auto it = contextInfoMap.begin(); it != contextInfoMap.end(); it++) {
|
||||
std::vector<std::vector<std::string>> pkgContextInfoList;
|
||||
auto jsonObject = nlohmann::json::parse(it->second);
|
||||
std::string filePath = it->second;
|
||||
bool newCreate = false;
|
||||
std::shared_ptr<Extractor> extractor = ExtractorUtil::GetExtractor(
|
||||
ExtractorUtil::GetLoadFilePath(filePath), newCreate, false);
|
||||
if (!extractor) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "moduleName: %{public}s load hapPath failed", it->first.c_str());
|
||||
continue;
|
||||
}
|
||||
std::ostringstream outStream;
|
||||
if (!extractor->ExtractByName("pkgContextInfo.json", outStream)) {
|
||||
TAG_LOGW(AAFwkTag::JSRUNTIME, "moduleName: %{public}s get pkgContextInfo failed", it->first.c_str());
|
||||
continue;
|
||||
}
|
||||
auto jsonObject = nlohmann::json::parse(outStream.str(), nullptr, false);
|
||||
if (jsonObject.is_discarded()) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "moduleName: %{public}s parse json error", it->first.c_str());
|
||||
continue;
|
||||
}
|
||||
for (nlohmann::json::iterator it = jsonObject.begin(); it != jsonObject.end(); it++) {
|
||||
for (nlohmann::json::iterator jsonIt = jsonObject.begin(); jsonIt != jsonObject.end(); jsonIt++) {
|
||||
std::vector<std::string> items;
|
||||
items.emplace_back(it.key());
|
||||
nlohmann::json itemObject = it.value();
|
||||
items.emplace_back(jsonIt.key());
|
||||
nlohmann::json itemObject = jsonIt.value();
|
||||
std::string pkgName = "";
|
||||
items.emplace_back(PACKAGE_NAME);
|
||||
if (itemObject[PACKAGE_NAME].is_null() || !itemObject[PACKAGE_NAME].is_string()) {
|
||||
|
@ -26,16 +26,13 @@
|
||||
namespace OHOS {
|
||||
namespace AbilityRuntime {
|
||||
namespace {
|
||||
void PostTaskToHandler(void* handler, uv_io_cb func, void* data, int priority)
|
||||
void PostTaskToHandler(void* handler, uv_io_cb func, void* work, int status, int priority)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Enter.");
|
||||
if (!handler || !func || !data) {
|
||||
if (!handler || !func || !work) {
|
||||
TAG_LOGE(AAFwkTag::JSRUNTIME, "Invalid parameters!");
|
||||
return;
|
||||
}
|
||||
uv_parm_t* uvData = static_cast<uv_parm_t*>(data);
|
||||
uv_work_t* work = uvData->work;
|
||||
int status = uvData->status;
|
||||
|
||||
auto task = [func, work, status]() {
|
||||
TAG_LOGD(AAFwkTag::JSRUNTIME, "Do uv work.");
|
||||
|
@ -504,6 +504,11 @@ enum {
|
||||
* Native error(2097249) no resident process permissions set.
|
||||
*/
|
||||
ERR_NO_RESIDENT_PERMISSION,
|
||||
|
||||
/**
|
||||
* Result(2097250) for app twin index does not exist.
|
||||
*/
|
||||
ERR_APP_TWIN_INDEX_INVALID,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -31,6 +31,8 @@ struct RenderProcessInfo : public Parcelable {
|
||||
std::int32_t pid_;
|
||||
std::int32_t uid_;
|
||||
std::int32_t hostUid_;
|
||||
std::int32_t hostPid_;
|
||||
std::int32_t state_;
|
||||
|
||||
bool ReadFromParcel(Parcel &parcel);
|
||||
virtual bool Marshalling(Parcel &parcel) const override;
|
||||
|
@ -37,6 +37,12 @@ bool RenderProcessInfo::ReadFromParcel(Parcel &parcel)
|
||||
int32_t hostUidData;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, hostUidData);
|
||||
hostUid_ = static_cast<int32_t>(hostUidData);
|
||||
int32_t hostPidData;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, hostPidData);
|
||||
hostPid_ = static_cast<int32_t>(hostPidData);
|
||||
int32_t stateData;
|
||||
READ_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, stateData);
|
||||
state_ = static_cast<int32_t>(stateData);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -58,6 +64,8 @@ bool RenderProcessInfo::Marshalling(Parcel &parcel) const
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(pid_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(uid_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(hostUid_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(hostPid_));
|
||||
WRITE_PARCEL_AND_RETURN_FALSE_IF_FAIL(Int32, parcel, static_cast<int32_t>(state_));
|
||||
return true;
|
||||
}
|
||||
} // namespace AppExecFwk
|
||||
|
@ -150,6 +150,8 @@ const std::map<int32_t, std::string> ERROR_MSG_MAP = {
|
||||
"Restart too frequently. Try again at least 10s later." },
|
||||
{ ERR_ABILITY_RUNTIME_EXTERNAL_NOT_SYSTEM_HSP,
|
||||
"The input bundleName and moduleName is not system HSP" },
|
||||
{ ERR_ABILITY_RUNTIME_SET_SUPPORTED_PROCESS_CACHE_AGAIN,
|
||||
"The supported process cache state cannot be set more than once" },
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@ ohos_shared_library("runtime") {
|
||||
"${ability_runtime_path}/services/abilitymgr/include",
|
||||
"${bundlefwk_path}/interfaces/kits/js/common",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper",
|
||||
"${ability_runtime_utils_path}/global/constant",
|
||||
]
|
||||
|
||||
sources = [
|
||||
|
@ -114,7 +114,8 @@ public:
|
||||
|
||||
void UpdateModuleNameAndAssetPath(const std::string& moduleName);
|
||||
void RegisterQuickFixQueryFunc(const std::map<std::string, std::string>& moduleAndPath) override;
|
||||
static bool GetFileBuffer(const std::string& filePath, std::string& fileFullName, std::vector<uint8_t>& buffer);
|
||||
static bool GetFileBuffer(const std::string& filePath, std::string& fileFullName, std::vector<uint8_t>& buffer,
|
||||
bool isABC = true);
|
||||
|
||||
void InitSourceMap(const std::shared_ptr<JsEnv::SourceMapOperator> operatorImpl);
|
||||
void FreeNativeReference(std::unique_ptr<NativeReference> reference);
|
||||
|
@ -198,7 +198,8 @@ public:
|
||||
* @param connectCallback Indicates the callback object when the target ability is connected.
|
||||
* is set up. The IAbilityConnection object uniquely identifies a connection between two abilities.
|
||||
*/
|
||||
virtual void DisconnectAbility(const AAFwk::Want &want, const sptr<AbilityConnectCallback> &connectCallback) = 0;
|
||||
virtual void DisconnectAbility(const AAFwk::Want &want, const sptr<AbilityConnectCallback> &connectCallback,
|
||||
int32_t accountId = -1) = 0;
|
||||
|
||||
/**
|
||||
* @brief get ability info of the current ability
|
||||
|
@ -84,8 +84,8 @@ public:
|
||||
const sptr<AbilityConnectCallback> &connectCallback) override;
|
||||
ErrCode ConnectAbilityWithAccount(const AAFwk::Want &want, int accountId,
|
||||
const sptr<AbilityConnectCallback> &connectCallback) override;
|
||||
void DisconnectAbility(const AAFwk::Want &want,
|
||||
const sptr<AbilityConnectCallback> &connectCallback) override;
|
||||
void DisconnectAbility(const AAFwk::Want &want, const sptr<AbilityConnectCallback> &connectCallback,
|
||||
int32_t accountId = -1) override;
|
||||
std::shared_ptr<AppExecFwk::HapModuleInfo> GetHapModuleInfo() const override;
|
||||
std::shared_ptr<AppExecFwk::AbilityInfo> GetAbilityInfo() const override;
|
||||
void MinimizeAbility(bool fromUser = false) override;
|
||||
|
@ -35,14 +35,19 @@ struct ConnectionInfo {
|
||||
// connection
|
||||
sptr<AbilityConnection> abilityConnection;
|
||||
|
||||
int32_t userid;
|
||||
|
||||
ConnectionInfo(const sptr<IRemoteObject> &connectCaller, const AAFwk::Operation &connectReceiver,
|
||||
const sptr<AbilityConnection> &abilityConnection) : connectCaller(connectCaller),
|
||||
connectReceiver(connectReceiver), abilityConnection(abilityConnection)
|
||||
const sptr<AbilityConnection> &abilityConnection, int32_t accountId = -1) : connectCaller(connectCaller),
|
||||
connectReceiver(connectReceiver), abilityConnection(abilityConnection), userid(accountId)
|
||||
{
|
||||
}
|
||||
|
||||
inline bool operator < (const ConnectionInfo &that) const
|
||||
{
|
||||
if (userid < that.userid) {
|
||||
return true;
|
||||
}
|
||||
if (connectCaller < that.connectCaller) {
|
||||
return true;
|
||||
}
|
||||
@ -128,8 +133,8 @@ public:
|
||||
* @param connectCallback The connection callback.
|
||||
* @return Returns the result of disconnecting ability connection.
|
||||
*/
|
||||
ErrCode DisconnectAbility(const sptr<IRemoteObject> &connectCaller,
|
||||
const AAFwk::Want &connectReceiver, const sptr<AbilityConnectCallback> &connectCallback);
|
||||
ErrCode DisconnectAbility(const sptr<IRemoteObject> &connectCaller, const AAFwk::Want &connectReceiver,
|
||||
const sptr<AbilityConnectCallback> &connectCallback, int32_t accountId = -1);
|
||||
|
||||
/**
|
||||
* @brief check the ability connection of caller is disconnect.
|
||||
@ -154,13 +159,16 @@ public:
|
||||
* @param tid The thread id.
|
||||
*/
|
||||
void ReportConnectionLeakEvent(const int pid, const int tid);
|
||||
|
||||
void DisconnectNonexistentService(const AppExecFwk::ElementName& element,
|
||||
const sptr<AbilityConnection> connection);
|
||||
private:
|
||||
ConnectionManager() = default;
|
||||
bool IsConnectCallerEqual(const sptr<IRemoteObject> &connectCaller, const sptr<IRemoteObject> &connectCallerOther);
|
||||
bool IsConnectReceiverEqual(AAFwk::Operation &connectReceiver,
|
||||
const AppExecFwk::ElementName &connectReceiverOther);
|
||||
bool MatchConnection(
|
||||
const sptr<IRemoteObject>& connectCaller, const AAFwk::Want& connectReceiver,
|
||||
const sptr<IRemoteObject>& connectCaller, const AAFwk::Want& connectReceiver, int32_t accountId,
|
||||
const std::map<ConnectionInfo, std::vector<sptr<AbilityConnectCallback>>>::value_type& connection);
|
||||
std::recursive_mutex connectionsLock_;
|
||||
std::map<ConnectionInfo, std::vector<sptr<AbilityConnectCallback>>> abilityConnections_;
|
||||
|
@ -1295,7 +1295,6 @@ protected:
|
||||
std::shared_ptr<AbilityStartSetting> setting_ = nullptr;
|
||||
std::shared_ptr<AbilityInfo> abilityInfo_ = nullptr;
|
||||
LaunchParam launchParam_;
|
||||
int32_t appIndex_ = 0;
|
||||
bool securityFlag_ = false;
|
||||
|
||||
private:
|
||||
|
@ -141,6 +141,9 @@ enum class AbilityErrorCode {
|
||||
// Ability already running.
|
||||
ERROR_ABILITY_ALREADY_RUNNING = 16000068,
|
||||
|
||||
// app twin index does not exist.
|
||||
ERROR_APP_TWIN_INDEX_INVALID = 16000073,
|
||||
|
||||
// invalid caller.
|
||||
ERROR_CODE_INVALID_CALLER = 16200001,
|
||||
|
||||
|
@ -170,6 +170,7 @@ private:
|
||||
struct ConnectionKey {
|
||||
AAFwk::Want want;
|
||||
int64_t id;
|
||||
int32_t accountId;
|
||||
};
|
||||
|
||||
struct KeyCompare {
|
||||
|
@ -52,6 +52,7 @@ private:
|
||||
struct ConnectionKey {
|
||||
AAFwk::Want want;
|
||||
int64_t id;
|
||||
int32_t accountId;
|
||||
};
|
||||
|
||||
struct key_compare {
|
||||
|
@ -331,7 +331,6 @@ protected:
|
||||
std::shared_ptr<AppExecFwk::AbilityRecovery> abilityRecovery_ = nullptr;
|
||||
std::shared_ptr<AppExecFwk::AbilityInfo> abilityInfo_ = nullptr;
|
||||
AAFwk::LaunchParam launchParam_;
|
||||
int32_t appIndex_ = 0;
|
||||
bool securityFlag_ = false;
|
||||
|
||||
private:
|
||||
|
@ -91,6 +91,10 @@ public:
|
||||
const uint32_t flag, const int32_t userId, std::vector<ExtensionAbilityInfo> &extensionInfos);
|
||||
sptr<IDefaultApp> GetDefaultAppProxy();
|
||||
ErrCode GetLaunchWantForBundle(const std::string &bundleName, Want &want, int32_t userId);
|
||||
ErrCode QueryCloneAbilityInfo(const ElementName &element, int32_t flags, int32_t appTwinIndex,
|
||||
AbilityInfo &abilityInfo, int32_t userId);
|
||||
ErrCode GetCloneBundleInfo(const std::string &bundleName, int32_t flags, int32_t appTwinIndex,
|
||||
BundleInfo &bundleInfo, int32_t userId);
|
||||
|
||||
private:
|
||||
sptr<IBundleMgr> Connect();
|
||||
|
@ -146,8 +146,8 @@ public:
|
||||
*
|
||||
* @return errCode ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode DisconnectAbility(
|
||||
const AAFwk::Want &want, const sptr<AbilityConnectCallback> &connectCallback) const;
|
||||
ErrCode DisconnectAbility(const AAFwk::Want &want, const sptr<AbilityConnectCallback> &connectCallback,
|
||||
int32_t accountId = -1) const;
|
||||
|
||||
/**
|
||||
* @brief Destroys the current ability.
|
||||
@ -155,7 +155,7 @@ public:
|
||||
* @return errCode ERR_OK on success, others on failure.
|
||||
*/
|
||||
ErrCode TerminateAbility();
|
||||
|
||||
|
||||
ErrCode RequestModalUIExtension(const Want &want);
|
||||
|
||||
using SelfType = ServiceExtensionContext;
|
||||
|
@ -624,7 +624,6 @@ private:
|
||||
std::string aceApplicationName_ = "AceApplication";
|
||||
std::string pathSeparator_ = "/";
|
||||
std::string abilityLibraryType_ = ".so";
|
||||
static std::shared_ptr<EventHandler> signalHandler_;
|
||||
static std::weak_ptr<OHOSApplication> applicationForDump_;
|
||||
|
||||
#ifdef ABILITY_LIBRARY_LOADER
|
||||
|
@ -183,6 +183,7 @@ std::string SourceMap::TranslateBySourceMap(const std::string& stackStr)
|
||||
|
||||
void SourceMap::SplitSourceMap(const std::string& sourceMapData)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(sourceMapMutex_);
|
||||
if (!isModular_) {
|
||||
if (!nonModularMap_) {
|
||||
nonModularMap_ = std::make_shared<SourceMapData>();
|
||||
@ -205,7 +206,7 @@ void SourceMap::SplitSourceMap(const std::string& sourceMapData)
|
||||
std::string value = sourceMapData.substr(leftBracket, rightBracket);
|
||||
std::shared_ptr<SourceMapData> modularMap = std::make_shared<SourceMapData>();
|
||||
ExtractSourceMapData(value, modularMap);
|
||||
sourceMaps_.emplace(key, modularMap);
|
||||
sourceMaps_[key] = modularMap;
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,6 +295,8 @@ void SourceMap::ExtractSourceMapData(const std::string& sourceMapData, std::shar
|
||||
}
|
||||
curMapData->mappings_.clear();
|
||||
curMapData->mappings_.shrink_to_fit();
|
||||
sourceKey.clear();
|
||||
sourceKey.shrink_to_fit();
|
||||
}
|
||||
|
||||
MappingInfo SourceMap::Find(int32_t row, int32_t col, const SourceMapData& targetMap)
|
||||
@ -520,7 +523,7 @@ bool SourceMap::TranslateUrlPositionBySourceMap(std::string& url, int& line, int
|
||||
if (isModular_) {
|
||||
auto iter = sourceMaps_.find(url);
|
||||
if (iter != sourceMaps_.end()) {
|
||||
return GetLineAndColumnNumbers(line, column, *(iter->second));
|
||||
return GetLineAndColumnNumbers(line, column, *(iter->second), url);
|
||||
}
|
||||
JSENV_LOG_E("TranslateUrlPositionBySourceMap: stageMode sourceMaps find fail");
|
||||
return false;
|
||||
@ -528,7 +531,7 @@ bool SourceMap::TranslateUrlPositionBySourceMap(std::string& url, int& line, int
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SourceMap::GetLineAndColumnNumbers(int& line, int& column, SourceMapData& targetMap)
|
||||
bool SourceMap::GetLineAndColumnNumbers(int& line, int& column, SourceMapData& targetMap, std::string& url)
|
||||
{
|
||||
int32_t offSet = 0;
|
||||
MappingInfo mapInfo;
|
||||
@ -542,6 +545,7 @@ bool SourceMap::GetLineAndColumnNumbers(int& line, int& column, SourceMapData& t
|
||||
} else {
|
||||
line = mapInfo.row;
|
||||
column = mapInfo.col;
|
||||
url = mapInfo.sources;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -48,6 +48,11 @@ public:
|
||||
return engine_;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceMapOperator> GetSourceMapOperator() const
|
||||
{
|
||||
return sourceMapOperator_;
|
||||
}
|
||||
|
||||
panda::ecmascript::EcmaVM* GetVM() const
|
||||
{
|
||||
return vm_;
|
||||
|
@ -80,11 +80,11 @@ public:
|
||||
static bool ReadSourceMapData(const std::string& hapPath, const std::string& sourceMapPath, std::string& content);
|
||||
static void RegisterGetHapPathCallback(GetHapPathCallback getFunc);
|
||||
static void GetHapPath(const std::string &bundleName, std::vector<std::string> &hapList);
|
||||
bool GetLineAndColumnNumbers(int& line, int& column, SourceMapData& targetMap);
|
||||
bool GetLineAndColumnNumbers(int& line, int& column, SourceMapData& targetMap, std::string& url);
|
||||
static void ExtractStackInfo(const std::string& stackStr, std::vector<std::string>& res);
|
||||
|
||||
private:
|
||||
void SplitSourceMap(const std::string& sourceMapData);
|
||||
|
||||
private:
|
||||
void ExtractSourceMapData(const std::string& sourceMapData, std::shared_ptr<SourceMapData>& curMapData);
|
||||
void ExtractKeyInfo(const std::string& sourceMap, std::vector<std::string>& sourceKeyInfo);
|
||||
std::vector<std::string> HandleMappings(const std::string& mapping);
|
||||
|
@ -83,6 +83,11 @@ public:
|
||||
return (initStatus_ == InitStatus::EXECUTED_SUCCESSFULLY);
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceMap> GetSourceMapObj() const
|
||||
{
|
||||
return sourceMapObj_;
|
||||
}
|
||||
|
||||
private:
|
||||
const std::string bundleName_;
|
||||
bool isModular_ = false;
|
||||
|
@ -49,6 +49,8 @@ config("abilityms_config") {
|
||||
"${ability_runtime_innerkits_path}/session_handler/include",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper",
|
||||
"${ability_runtime_utils_path}/global/constant",
|
||||
"${ability_runtime_utils_path}/server/constant",
|
||||
"${bgtaskmgr_frameworks_path}/common/include",
|
||||
"${bgtaskmgr_frameworks_path}/include",
|
||||
"${init_path}/interfaces/innerkits/include/syspara/",
|
||||
@ -126,6 +128,7 @@ ohos_shared_library("abilityms") {
|
||||
"${ability_runtime_native_path}/ability/native:auto_startup_callback",
|
||||
"${ability_runtime_native_path}/appkit:appkit_manager_helper",
|
||||
"${ability_runtime_path}/utils/global/freeze:freeze_util",
|
||||
"${ability_runtime_path}/utils/server/startup:startup_util",
|
||||
"${ability_runtime_services_path}/common:app_util",
|
||||
"${ability_runtime_services_path}/common:event_report",
|
||||
"${ability_runtime_services_path}/common:perm_verification",
|
||||
|
@ -116,14 +116,15 @@ public:
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int PreloadUIExtensionAbilityLocked(const AbilityRequest &abilityRequest, std::string &hostBundleName);
|
||||
|
||||
/**
|
||||
* UnloadUIExtension, unload uiextension ability.
|
||||
* UnloadUIExtensionAbility, unload uiextension ability.
|
||||
*
|
||||
* @param abilityRecord, uiextension ability record.
|
||||
* @param hostBundleName, the caller application bundle name.
|
||||
* @return Returns ERR_OK on success, others on failure.
|
||||
*/
|
||||
int UnloadUIExtension(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord, std::string &bundleName);
|
||||
int UnloadUIExtensionAbility(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord, std::string &bundleName);
|
||||
|
||||
/**
|
||||
* DisconnectAbilityLocked, disconnect session with callback.
|
||||
|
@ -383,7 +383,7 @@ public:
|
||||
int PreloadUIExtensionAbility(const Want &want, std::string &hostBundleName,
|
||||
int32_t userId = DEFAULT_INVAL_VALUE) override;
|
||||
|
||||
int UnloadUIExtension(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord, std::string &bundleName);
|
||||
int UnloadUIExtensionAbility(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord, std::string &bundleName);
|
||||
|
||||
int ChangeAbilityVisibility(sptr<IRemoteObject> token, bool isShow) override;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#ifdef WITH_DLP
|
||||
#include "dlp_permission_kit.h"
|
||||
#endif // WITH_DLP
|
||||
#include "global_constant.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "in_process_call_wrapper.h"
|
||||
@ -49,7 +50,7 @@ using Dlp = Security::DlpPermission::DlpPermissionKit;
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Ability has already been destroyed.");
|
||||
return true;
|
||||
}
|
||||
if (abilityRecord->GetAppIndex() == 0) {
|
||||
if (abilityRecord->GetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
return true;
|
||||
}
|
||||
if (abilityRecord->GetApplicationInfo().bundleName == want.GetElement().GetBundleName()) {
|
||||
@ -74,7 +75,8 @@ using Dlp = Security::DlpPermission::DlpPermissionKit;
|
||||
{
|
||||
if (callerToken != nullptr) {
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(callerToken);
|
||||
if (abilityRecord != nullptr && abilityRecord->GetAppIndex() != 0) {
|
||||
if (abilityRecord != nullptr &&
|
||||
abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
|
||||
virtual void Update(const AAFwk::AbilityRequest &abilityRequest);
|
||||
|
||||
void UnLoadUIExtension();
|
||||
void UnloadUIExtensionAbility();
|
||||
|
||||
int32_t RegisterStateObserver(const std::string &hostBundleName);
|
||||
|
||||
|
@ -25,10 +25,10 @@ namespace AbilityRuntime {
|
||||
class ExtensionRecord;
|
||||
}
|
||||
namespace AAFwk {
|
||||
class PreLoadUIExtStateObserver : public AppExecFwk::ApplicationStateObserverStub {
|
||||
class PreLoadUIExtStateObserver final : public AppExecFwk::ApplicationStateObserverStub {
|
||||
public:
|
||||
PreLoadUIExtStateObserver(std::weak_ptr<AbilityRuntime::ExtensionRecord> extensionRecord);
|
||||
virtual void OnProcessDied(const AppExecFwk::ProcessData &processData) override;
|
||||
void OnProcessDied(const AppExecFwk::ProcessData &processData) override;
|
||||
|
||||
private:
|
||||
std::weak_ptr<AbilityRuntime::ExtensionRecord> extensionRecord_ = std::weak_ptr<AbilityRuntime::ExtensionRecord>();
|
||||
|
@ -19,6 +19,10 @@
|
||||
{
|
||||
"type": "finance",
|
||||
"typePicker": "sysPicker/appSelector"
|
||||
},
|
||||
{
|
||||
"type": "filePicker",
|
||||
"typePicker": "sysPicker/filePicker"
|
||||
}
|
||||
]
|
||||
}
|
@ -256,7 +256,6 @@ int AbilityConnectManager::StartAbilityLocked(const AbilityRequest &abilityReque
|
||||
|
||||
if (!isLoadedAbility) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Target service has not been loaded.");
|
||||
targetService->GrantUriPermissionForServiceExtension();
|
||||
SetLastExitReason(abilityRequest, targetService);
|
||||
if (IsUIExtensionAbility(targetService)) {
|
||||
targetService->SetLaunchReason(LaunchReason::LAUNCHREASON_START_ABILITY);
|
||||
@ -265,7 +264,6 @@ int AbilityConnectManager::StartAbilityLocked(const AbilityRequest &abilityReque
|
||||
} 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);
|
||||
@ -568,6 +566,10 @@ int AbilityConnectManager::PreloadUIExtensionAbilityInner(const AbilityRequest &
|
||||
//get target service ability record, and check whether it has been loaded.
|
||||
std::shared_ptr<AbilityRecord> targetService = AbilityRecord::CreateAbilityRecord(abilityRequest);
|
||||
CHECK_POINTER_AND_RETURN(targetService, ERR_INVALID_VALUE);
|
||||
if (!UIExtensionUtils::IsUIExtension(targetService->GetAbilityInfo().extensionAbilityType)) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Can't preload non-uiextension type.");
|
||||
return ERR_WRONG_INTERFACE_CALL;
|
||||
}
|
||||
std::shared_ptr<ExtensionRecord> extensionRecord = nullptr;
|
||||
CHECK_POINTER_AND_RETURN(uiExtensionAbilityRecordMgr_, ERR_NULL_OBJECT);
|
||||
int32_t extensionRecordId = INVALID_EXTENSION_RECORD_ID;
|
||||
@ -586,11 +588,12 @@ int AbilityConnectManager::PreloadUIExtensionAbilityInner(const AbilityRequest &
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
int AbilityConnectManager::UnloadUIExtension(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord,
|
||||
int AbilityConnectManager::UnloadUIExtensionAbility(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord,
|
||||
std::string &hostBundleName)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "call");
|
||||
//Get preLoadUIExtensionInfo
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
auto preLoadUIExtensionInfo = std::make_tuple(abilityRecord->GetWant().GetElement().GetAbilityName(),
|
||||
abilityRecord->GetWant().GetElement().GetBundleName(),
|
||||
abilityRecord->GetWant().GetElement().GetModuleName(), hostBundleName);
|
||||
@ -804,6 +807,8 @@ int AbilityConnectManager::AttachAbilityThreadLocked(
|
||||
}
|
||||
}
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
std::string element = abilityRecord->GetURI();
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "Ability: %{public}s", element.c_str());
|
||||
if (taskHandler_ != nullptr) {
|
||||
int recordId = abilityRecord->GetRecordId();
|
||||
std::string taskName = std::string("LoadTimeout_") + std::to_string(recordId);
|
||||
@ -813,8 +818,6 @@ int AbilityConnectManager::AttachAbilityThreadLocked(
|
||||
eventHandler_->RemoveEvent(AbilityManagerService::LOAD_TIMEOUT_MSG,
|
||||
abilityRecord->GetAbilityRecordId());
|
||||
}
|
||||
std::string element = abilityRecord->GetURI();
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Ability: %{public}s", element.c_str());
|
||||
if (abilityRecord->IsSceneBoard()) {
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "Attach Ability: %{public}s", element.c_str());
|
||||
sceneBoardTokenId_ = abilityRecord->GetAbilityInfo().applicationInfo.accessTokenId;
|
||||
@ -1089,7 +1092,7 @@ int AbilityConnectManager::ScheduleCommandAbilityWindowDone(
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(token);
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
std::string element = abilityRecord->GetURI();
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR,
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR,
|
||||
"Ability: %{public}s, persistentId: %{private}d, winCmd: %{public}d, abilityCmd: %{public}d", element.c_str(),
|
||||
sessionInfo->persistentId, winCmd, abilityCmd);
|
||||
|
||||
@ -1429,7 +1432,7 @@ void AbilityConnectManager::HandleStartTimeoutTask(const std::shared_ptr<Ability
|
||||
CHECK_POINTER(abilityRecord);
|
||||
if (UIExtensionUtils::IsUIExtension(abilityRecord->GetAbilityInfo().extensionAbilityType)) {
|
||||
if (uiExtensionAbilityRecordMgr_ != nullptr && IsCallerValid(abilityRecord)) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Start load timeout.");
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "Start load timeout.");
|
||||
uiExtensionAbilityRecordMgr_->LoadTimeout(abilityRecord->GetUIExtensionAbilityId());
|
||||
}
|
||||
PrintTimeOutLog(abilityRecord, AbilityManagerService::LOAD_TIMEOUT_MSG);
|
||||
@ -2883,7 +2886,7 @@ EventInfo AbilityConnectManager::BuildEventInfo(const std::shared_ptr<AbilityRec
|
||||
eventInfo.time = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::system_clock::now().time_since_epoch()).count();
|
||||
auto callerPid = abilityRecord->GetWant().GetIntParam(Want::PARAM_RESV_CALLER_PID, -1);
|
||||
eventInfo.callerPid = callerPid == -1 ? IPCSkeleton::GetCallingPid() : callerPid;
|
||||
eventInfo.callerPid = callerPid == -1 ? IPCSkeleton::GetCallingRealPid() : callerPid;
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->GetRunningProcessInfoByPid(eventInfo.callerPid, processInfo);
|
||||
eventInfo.callerPid = processInfo.pid_;
|
||||
eventInfo.callerProcessName = processInfo.processName_;
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "errors.h"
|
||||
#include "extension_config.h"
|
||||
#include "freeze_util.h"
|
||||
#include "global_constant.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hisysevent.h"
|
||||
@ -86,11 +87,13 @@
|
||||
#include "restart_app_manager.h"
|
||||
#include "sa_mgr_client.h"
|
||||
#include "scene_board_judgement.h"
|
||||
#include "server_constant.h"
|
||||
#include "session_info.h"
|
||||
#include "softbus_bus_center.h"
|
||||
#include "start_ability_handler/start_ability_sandbox_savefile.h"
|
||||
#include "start_options.h"
|
||||
#include "start_ability_utils.h"
|
||||
#include "startup_util.h"
|
||||
#include "status_bar_delegate_interface.h"
|
||||
#include "string_ex.h"
|
||||
#include "string_wrapper.h"
|
||||
@ -252,7 +255,6 @@ const std::string DMS_API_VERSION = "dmsApiVersion";
|
||||
const std::string DMS_IS_CALLER_BACKGROUND = "dmsIsCallerBackGround";
|
||||
const std::string DMS_PROCESS_NAME = "distributedsched";
|
||||
const std::string DMS_MISSION_ID = "dmsMissionId";
|
||||
const std::string DLP_INDEX = "ohos.dlp.params.index";
|
||||
const std::string BOOTEVENT_APPFWK_READY = "bootevent.appfwk.ready";
|
||||
const std::string BOOTEVENT_BOOT_COMPLETED = "bootevent.boot.completed";
|
||||
const std::string BOOTEVENT_BOOT_ANIMATION_STARTED = "bootevent.bootanimation.started";
|
||||
@ -1778,7 +1780,7 @@ int32_t AbilityManagerService::ReportDrawnCompleted(const sptr<IRemoteObject> &c
|
||||
|
||||
EventInfo eventInfo;
|
||||
eventInfo.userId = IPCSkeleton::GetCallingUid() / BASE_USER_RANGE;
|
||||
eventInfo.pid = IPCSkeleton::GetCallingPid();
|
||||
eventInfo.pid = IPCSkeleton::GetCallingRealPid();
|
||||
eventInfo.bundleName = abilityInfo.bundleName;
|
||||
eventInfo.moduleName = abilityInfo.moduleName;
|
||||
eventInfo.abilityName = abilityInfo.name;
|
||||
@ -2438,12 +2440,16 @@ int AbilityManagerService::PreloadUIExtensionAbilityInner(const Want &want, std:
|
||||
return connectManager->PreloadUIExtensionAbilityLocked(abilityRequest, hostBundleName);
|
||||
}
|
||||
|
||||
int AbilityManagerService::UnloadUIExtension(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord,
|
||||
int AbilityManagerService::UnloadUIExtensionAbility(const std::shared_ptr<AAFwk::AbilityRecord> &abilityRecord,
|
||||
std::string &hostBundleName)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "Call.");
|
||||
auto connectManager = GetConnectManagerByToken(abilityRecord->GetToken());
|
||||
return connectManager->UnloadUIExtension(abilityRecord, hostBundleName);
|
||||
if (connectManager == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "connectManager is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
return connectManager->UnloadUIExtensionAbility(abilityRecord, hostBundleName);
|
||||
}
|
||||
|
||||
int AbilityManagerService::RequestModalUIExtension(const Want &want)
|
||||
@ -3527,7 +3533,8 @@ int AbilityManagerService::ConnectAbilityCommon(
|
||||
Want abilityWant = want;
|
||||
AbilityRequest abilityRequest;
|
||||
std::string uri = abilityWant.GetUri().ToString();
|
||||
if (!uri.empty()) {
|
||||
bool isFileUri = (abilityWant.GetUri().GetScheme() == "file");
|
||||
if (!uri.empty() && !isFileUri) {
|
||||
// if the want include uri, it may only has uri information. it is probably a datashare extension.
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR,
|
||||
"%{public}s called. uri:%{public}s, userId %{public}d", __func__, uri.c_str(), validUserId);
|
||||
@ -3921,9 +3928,9 @@ int AbilityManagerService::StartContinuation(const Want &want, const sptr<IRemot
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "AbilityManagerService::StartContinuation failed to get missionId.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
AAFWK::ContinueRadar::GetInstance().SaveDataRemoteWant("StartContinuation");
|
||||
DistributedClient dmsClient;
|
||||
auto result = dmsClient.StartContinuation(want, missionId, appUid, status, accessToken);
|
||||
AAFWK::ContinueRadar::GetInstance().SaveDataRemoteWant("StartContinuation", result);
|
||||
if (result != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "StartContinuation failed, result = %{public}d, notify caller", result);
|
||||
NotifyContinuationResult(missionId, result);
|
||||
@ -5616,9 +5623,9 @@ int AbilityManagerService::GenerateAbilityRequest(
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(callerToken);
|
||||
if (abilityRecord && abilityRecord->GetAppIndex() != 0 &&
|
||||
if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX &&
|
||||
abilityRecord->GetApplicationInfo().bundleName == want.GetElement().GetBundleName()) {
|
||||
(const_cast<Want &>(want)).SetParam(DLP_INDEX, abilityRecord->GetAppIndex());
|
||||
(const_cast<Want &>(want)).SetParam(AbilityRuntime::ServerConstant::DLP_INDEX, abilityRecord->GetAppIndex());
|
||||
}
|
||||
|
||||
if (abilityRecord != nullptr) {
|
||||
@ -5632,11 +5639,12 @@ int AbilityManagerService::GenerateAbilityRequest(
|
||||
|
||||
auto abilityInfo = StartAbilityUtils::startAbilityInfo;
|
||||
if (abilityInfo == nullptr || abilityInfo->GetAppBundleName() != want.GetElement().GetBundleName()) {
|
||||
abilityInfo = StartAbilityInfo::CreateStartAbilityInfo(want, userId, want.GetIntParam(DLP_INDEX, 0));
|
||||
abilityInfo = StartAbilityInfo::CreateStartAbilityInfo(want, userId,
|
||||
AbilityRuntime::StartupUtil::GetAppTwinIndex(want));
|
||||
}
|
||||
CHECK_POINTER_AND_RETURN(abilityInfo, GET_ABILITY_SERVICE_FAILED);
|
||||
if (abilityInfo->status == RESOLVE_ABILITY_ERR) {
|
||||
return RESOLVE_ABILITY_ERR;
|
||||
if (abilityInfo->status != ERR_OK) {
|
||||
return abilityInfo->status;
|
||||
}
|
||||
request.abilityInfo = abilityInfo->abilityInfo;
|
||||
request.extensionProcessMode = abilityInfo->extensionProcessMode;
|
||||
@ -5687,9 +5695,9 @@ int AbilityManagerService::GenerateExtensionAbilityRequest(
|
||||
const Want &want, AbilityRequest &request, const sptr<IRemoteObject> &callerToken, int32_t userId)
|
||||
{
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(callerToken);
|
||||
if (abilityRecord && abilityRecord->GetAppIndex() != 0 &&
|
||||
if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX &&
|
||||
abilityRecord->GetApplicationInfo().bundleName == want.GetElement().GetBundleName()) {
|
||||
(const_cast<Want &>(want)).SetParam(DLP_INDEX, abilityRecord->GetAppIndex());
|
||||
(const_cast<Want &>(want)).SetParam(AbilityRuntime::ServerConstant::DLP_INDEX, abilityRecord->GetAppIndex());
|
||||
}
|
||||
request.want = want;
|
||||
request.callerToken = callerToken;
|
||||
@ -5697,11 +5705,12 @@ int AbilityManagerService::GenerateExtensionAbilityRequest(
|
||||
|
||||
auto abilityInfo = StartAbilityUtils::startAbilityInfo;
|
||||
if (abilityInfo == nullptr || abilityInfo->GetAppBundleName() != want.GetElement().GetBundleName()) {
|
||||
abilityInfo = StartAbilityInfo::CreateStartExtensionInfo(want, userId, want.GetIntParam(DLP_INDEX, 0));
|
||||
abilityInfo = StartAbilityInfo::CreateStartExtensionInfo(want, userId,
|
||||
AbilityRuntime::StartupUtil::GetAppTwinIndex(want));
|
||||
}
|
||||
CHECK_POINTER_AND_RETURN(abilityInfo, GET_ABILITY_SERVICE_FAILED);
|
||||
if (abilityInfo->status == RESOLVE_ABILITY_ERR) {
|
||||
return RESOLVE_ABILITY_ERR;
|
||||
if (abilityInfo->status != ERR_OK) {
|
||||
return abilityInfo->status;
|
||||
}
|
||||
|
||||
auto result = InitialAbilityRequest(request, *abilityInfo);
|
||||
@ -5905,8 +5914,8 @@ int32_t AbilityManagerService::UpgradeApp(const std::string &bundleName, const i
|
||||
int32_t AbilityManagerService::UninstallAppInner(const std::string &bundleName, const int32_t uid, const bool isUpgrade,
|
||||
const std::string &exitMsg)
|
||||
{
|
||||
pid_t callingPid = IPCSkeleton::GetCallingPid();
|
||||
pid_t pid = getpid();
|
||||
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
|
||||
pid_t pid = getprocpid();
|
||||
if (callingPid != pid) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s: Not bundleMgr call.", __func__);
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
@ -7507,7 +7516,7 @@ int AbilityManagerService::DelegatorDoAbilityForeground(const sptr<IRemoteObject
|
||||
CHECK_POINTER_AND_RETURN(token, ERR_INVALID_VALUE);
|
||||
auto &&abilityRecord = Token::GetAbilityRecordByToken(token);
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
int32_t callerPid = IPCSkeleton::GetCallingPid();
|
||||
int32_t callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
int32_t appPid = abilityRecord->GetPid();
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "callerPid: %{public}d, appPid: %{public}d", callerPid, appPid);
|
||||
if (callerPid != appPid) {
|
||||
@ -7543,7 +7552,7 @@ int AbilityManagerService::DelegatorDoAbilityBackground(const sptr<IRemoteObject
|
||||
auto &&abilityRecord = Token::GetAbilityRecordByToken(token);
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
int32_t appPid = abilityRecord->GetPid();
|
||||
int32_t callerPid = IPCSkeleton::GetCallingPid();
|
||||
int32_t callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "callerPid: %{public}d, appPid: %{public}d", callerPid, appPid);
|
||||
if (callerPid != appPid) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Caller is not the application itself");
|
||||
@ -7620,7 +7629,7 @@ void AbilityManagerService::UpdateCallerInfo(Want& want, const sptr<IRemoteObjec
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
int32_t tokenId = static_cast<int32_t>(IPCSkeleton::GetCallingTokenID());
|
||||
int32_t callerUid = IPCSkeleton::GetCallingUid();
|
||||
int32_t callerPid = IPCSkeleton::GetCallingPid();
|
||||
int32_t callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
want.RemoveParam(Want::PARAM_RESV_CALLER_TOKEN);
|
||||
want.SetParam(Want::PARAM_RESV_CALLER_TOKEN, tokenId);
|
||||
want.RemoveParam(Want::PARAM_RESV_CALLER_UID);
|
||||
@ -8775,7 +8784,7 @@ int AbilityManagerService::IsCallFromBackground(const AbilityRequest &abilityReq
|
||||
return ERR_OK;
|
||||
}
|
||||
} else {
|
||||
auto callerPid = IPCSkeleton::GetCallingPid();
|
||||
auto callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->GetRunningProcessInfoByPid(callerPid, processInfo);
|
||||
if (processInfo.processName_.empty()) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "Can not find caller application by callerPid: %{private}d.", callerPid);
|
||||
@ -8947,7 +8956,7 @@ int AbilityManagerService::CheckDlpForExtension(
|
||||
|
||||
bool AbilityManagerService::JudgeSelfCalled(const std::shared_ptr<AbilityRecord> &abilityRecord)
|
||||
{
|
||||
if (IPCSkeleton::GetCallingPid() == getpid()) {
|
||||
if (IPCSkeleton::GetCallingRealPid() == getprocpid()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -10021,10 +10030,10 @@ int32_t AbilityManagerService::SetResidentProcessEnabled(const std::string &bund
|
||||
HILOG_ERROR("Get resident proces mgr is nullptr");
|
||||
return INNER_ERR;
|
||||
}
|
||||
|
||||
|
||||
std::string callerName;
|
||||
int32_t uid = 0;
|
||||
auto callerPid = IPCSkeleton::GetCallingPid();
|
||||
auto callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->GetBundleNameByPid(callerPid, callerName, uid);
|
||||
if (callerName.empty()) {
|
||||
HILOG_ERROR("Failed to obtain caller name.");
|
||||
@ -10281,9 +10290,7 @@ int32_t AbilityManagerService::CheckRestartAppWant(const AAFwk::Want &want)
|
||||
|
||||
auto bms = GetBundleManager();
|
||||
CHECK_POINTER_AND_RETURN(bms, GET_ABILITY_SERVICE_FAILED);
|
||||
auto abilityInfoFlag = (AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_PERMISSION |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_METADATA);
|
||||
auto abilityInfoFlag = AbilityRuntime::StartupUtil::BuildAbilityInfoFlag();
|
||||
auto userId = IPCSkeleton::GetCallingUid() / BASE_USER_RANGE;
|
||||
AppExecFwk::AbilityInfo abilityInfo;
|
||||
bool queryResult = IN_PROCESS_CALL(bms->QueryAbilityInfo(want, abilityInfoFlag, userId, abilityInfo));
|
||||
|
@ -1498,8 +1498,8 @@ int AbilityManagerStub::ContinueAbilityInner(MessageParcel &data, MessageParcel
|
||||
std::string deviceId = data.ReadString();
|
||||
int32_t missionId = data.ReadInt32();
|
||||
uint32_t versionCode = data.ReadUint32();
|
||||
AAFWK::ContinueRadar::GetInstance().SaveDataContinue("ContinueAbility");
|
||||
int32_t result = ContinueAbility(deviceId, missionId, versionCode);
|
||||
AAFWK::ContinueRadar::GetInstance().SaveDataContinue("ContinueAbility", result);
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "ContinueAbilityInner result = %{public}d", result);
|
||||
return result;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "configuration_convertor.h"
|
||||
#include "connection_state_manager.h"
|
||||
#include "freeze_util.h"
|
||||
#include "global_constant.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "image_source.h"
|
||||
#include "in_process_call_wrapper.h"
|
||||
@ -47,6 +48,8 @@
|
||||
#include "parameters.h"
|
||||
#include "ui_extension_host_info.h"
|
||||
#include "scene_board_judgement.h"
|
||||
#include "start_ability_utils.h"
|
||||
#include "startup_util.h"
|
||||
#include "system_ability_token_callback.h"
|
||||
#include "ui_extension_utils.h"
|
||||
#include "uri_permission_manager_client.h"
|
||||
@ -77,7 +80,6 @@ const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId";
|
||||
const std::string ABILITY_OWNER_USERID = "AbilityMS_Owner_UserId";
|
||||
const std::u16string SYSTEM_ABILITY_TOKEN_CALLBACK = u"ohos.aafwk.ISystemAbilityTokenCallback";
|
||||
const std::string SHOW_ON_LOCK_SCREEN = "ShowOnLockScreen";
|
||||
const std::string DLP_INDEX = "ohos.dlp.params.index";
|
||||
const std::string DLP_BUNDLE_NAME = "com.ohos.dlpmanager";
|
||||
const std::string COMPONENT_STARTUP_NEW_RULES = "component.startup.newRules";
|
||||
const std::string KEY_MISSION_ID = "ohos.anco.param.missionId";
|
||||
@ -226,7 +228,6 @@ AbilityRecord::AbilityRecord(const Want &want, const AppExecFwk::AbilityInfo &ab
|
||||
want_.SetParam(COMPONENT_STARTUP_NEW_RULES, flag);
|
||||
}
|
||||
restartCount_ = restartMax_;
|
||||
appIndex_ = want.GetIntParam(DLP_INDEX, 0);
|
||||
isAppAutoStartup_ = want_.GetBoolParam(Want::PARAM_APP_AUTO_STARTUP_LAUNCH_REASON, false);
|
||||
if (want_.HasParameter(Want::PARAM_APP_AUTO_STARTUP_LAUNCH_REASON)) {
|
||||
want_.RemoveParam(Want::PARAM_APP_AUTO_STARTUP_LAUNCH_REASON);
|
||||
@ -251,7 +252,7 @@ std::shared_ptr<AbilityRecord> AbilityRecord::CreateAbilityRecord(const AbilityR
|
||||
abilityRequest.want, abilityRequest.abilityInfo, abilityRequest.appInfo, abilityRequest.requestCode);
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, nullptr);
|
||||
abilityRecord->SetUid(abilityRequest.uid);
|
||||
abilityRecord->SetAppIndex(abilityRequest.want.GetIntParam(DLP_INDEX, 0));
|
||||
abilityRecord->SetAppIndex(AbilityRuntime::StartupUtil::GetAppTwinIndex(abilityRequest.want));
|
||||
abilityRecord->SetCallerAccessTokenId(abilityRequest.callerAccessTokenId);
|
||||
abilityRecord->sessionInfo_ = abilityRequest.sessionInfo;
|
||||
if (!abilityRecord->Init()) {
|
||||
@ -1422,7 +1423,7 @@ void AbilityRecord::SetScheduler(const sptr<IAbilityScheduler> &scheduler)
|
||||
if (IsSceneBoard()) {
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "Sceneboard DeathRecipient Added");
|
||||
}
|
||||
pid_ = static_cast<int32_t>(IPCSkeleton::GetCallingPid()); // set pid when ability attach to service.
|
||||
pid_ = static_cast<int32_t>(IPCSkeleton::GetCallingRealPid()); // set pid when ability attach to service.
|
||||
// add collaborator mission bind pid
|
||||
NotifyMissionBindPid();
|
||||
HandleDlpAttached();
|
||||
@ -1606,6 +1607,7 @@ void AbilityRecord::ConnectAbility()
|
||||
if (isConnected) {
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "connect state error.");
|
||||
}
|
||||
GrantUriPermissionForServiceExtension();
|
||||
lifecycleDeal_->ConnectAbility(GetWant());
|
||||
isConnected = true;
|
||||
}
|
||||
@ -1637,6 +1639,7 @@ void AbilityRecord::CommandAbility()
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "startId_:%{public}d.", startId_);
|
||||
CHECK_POINTER(lifecycleDeal_);
|
||||
GrantUriPermissionForServiceExtension();
|
||||
lifecycleDeal_->CommandAbility(GetWant(), false, startId_);
|
||||
}
|
||||
|
||||
@ -1747,7 +1750,7 @@ void AbilityRecord::SendResultToCallers(bool schedulerdied)
|
||||
}
|
||||
std::shared_ptr<AbilityRecord> callerAbilityRecord = caller->GetCaller();
|
||||
if (callerAbilityRecord != nullptr && callerAbilityRecord->GetResult() != nullptr) {
|
||||
bool isSandboxApp = appIndex_ > 0 ? true : false;
|
||||
bool isSandboxApp = appIndex_ > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX ? true : false;
|
||||
callerAbilityRecord->SendResult(isSandboxApp, applicationInfo_.accessTokenId);
|
||||
} else {
|
||||
std::shared_ptr<SystemAbilityCallerRecord> callerSystemAbilityRecord = caller->GetSaCaller();
|
||||
@ -3020,7 +3023,7 @@ void AbilityRecord::GrantUriPermission(Want &want, std::string targetBundleName,
|
||||
// reject sandbox to grant uri permission by start ability
|
||||
if (!callerList_.empty() && callerList_.back()) {
|
||||
auto caller = callerList_.back()->GetCaller();
|
||||
if (caller && caller->appIndex_ > 0) {
|
||||
if (caller && caller->appIndex_ > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Sandbox can not grant UriPermission by start ability.");
|
||||
return;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ void AssertFaultCallbackDeathMgr::AddAssertFaultCallback(sptr<IRemoteObject> &re
|
||||
});
|
||||
|
||||
remote->AddDeathRecipient(deathRecipient);
|
||||
auto callerPid = IPCSkeleton::GetCallingPid();
|
||||
auto callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
uint64_t assertFaultSessionId = reinterpret_cast<uint64_t>(remote.GetRefPtr());
|
||||
std::unique_lock<std::mutex> lock(assertFaultSessionMutex_);
|
||||
assertFaultSessionDialogs_[assertFaultSessionId] = {callerPid, remote, deathRecipient, callback};
|
||||
|
@ -268,7 +268,7 @@ void ConnectionRecord::AttachCallerInfo()
|
||||
}
|
||||
|
||||
callerUid_ = static_cast<int32_t>(IPCSkeleton::GetCallingUid());
|
||||
callerPid_ = static_cast<int32_t>(IPCSkeleton::GetCallingPid());
|
||||
callerPid_ = static_cast<int32_t>(IPCSkeleton::GetCallingRealPid());
|
||||
callerName_ = ConnectionStateManager::GetProcessNameByPid(callerPid_);
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "app_mgr_interface.h"
|
||||
#include "connection_observer_errors.h"
|
||||
#include "global_constant.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
@ -486,7 +487,7 @@ bool ConnectionStateManager::HandleDlpAbilityInner(const std::shared_ptr<Ability
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dlpAbility->GetAppIndex() == 0) {
|
||||
if (dlpAbility->GetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
TAG_LOGD(AAFwkTag::CONNECTION, "this is not dlp ability, do not report connection stat.");
|
||||
return false;
|
||||
}
|
||||
|
@ -683,7 +683,7 @@ void DataAbilityManager::ReportDataAbilityAcquired(const sptr<IRemoteObject> &cl
|
||||
{
|
||||
DataAbilityCaller caller;
|
||||
caller.isNotHap = isNotHap;
|
||||
caller.callerPid = IPCSkeleton::GetCallingPid();
|
||||
caller.callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
caller.callerUid = IPCSkeleton::GetCallingUid();
|
||||
caller.callerToken = client;
|
||||
if (client && !isNotHap) {
|
||||
@ -703,7 +703,7 @@ void DataAbilityManager::ReportDataAbilityReleased(const sptr<IRemoteObject> &cl
|
||||
{
|
||||
DataAbilityCaller caller;
|
||||
caller.isNotHap = isNotHap;
|
||||
caller.callerPid = IPCSkeleton::GetCallingPid();
|
||||
caller.callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
caller.callerUid = IPCSkeleton::GetCallingUid();
|
||||
caller.callerToken = client;
|
||||
DelayedSingleton<ConnectionStateManager>::GetInstance()->RemoveDataAbilityConnection(caller, record);
|
||||
|
@ -228,7 +228,7 @@ int DataAbilityRecord::AddClient(const sptr<IRemoteObject> &client, bool tryBind
|
||||
clientInfo.client = client;
|
||||
clientInfo.tryBind = tryBind;
|
||||
clientInfo.isNotHap = isNotHap;
|
||||
clientInfo.clientPid = IPCSkeleton::GetCallingPid();
|
||||
clientInfo.clientPid = IPCSkeleton::GetCallingRealPid();
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
#include "dlp_state_item.h"
|
||||
|
||||
#include "global_constant.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
|
||||
@ -53,7 +54,7 @@ int32_t DlpStateItem::GetOpenedAbilitySize() const
|
||||
bool DlpStateItem::HandleDlpConnectionState(const std::shared_ptr<AbilityRecord> &record, bool isAdd,
|
||||
AbilityRuntime::DlpStateData &data)
|
||||
{
|
||||
if (!record || record->GetAppIndex() == 0) {
|
||||
if (!record || record->GetAppIndex() <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "invalid dlp ability.");
|
||||
return false;
|
||||
}
|
||||
|
@ -46,14 +46,14 @@ void ExtensionRecord::SetRootCallerToken(sptr<IRemoteObject> &rootCallerToken)
|
||||
rootCallerToken_ = rootCallerToken;
|
||||
}
|
||||
|
||||
void ExtensionRecord::UnLoadUIExtension()
|
||||
void ExtensionRecord::UnloadUIExtensionAbility()
|
||||
{
|
||||
auto ret = DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance()->UnregisterApplicationStateObserver(
|
||||
preLoadUIExtStateObserver_);
|
||||
if (ret != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Unregister application state observer error.");
|
||||
}
|
||||
auto result = DelayedSingleton<AAFwk::AbilityManagerService>::GetInstance()->UnloadUIExtension(
|
||||
auto result = DelayedSingleton<AAFwk::AbilityManagerService>::GetInstance()->UnloadUIExtensionAbility(
|
||||
abilityRecord_, hostBundleName_);
|
||||
if (result != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "Unload UIExtension error.");
|
||||
@ -62,8 +62,7 @@ void ExtensionRecord::UnLoadUIExtension()
|
||||
|
||||
int32_t ExtensionRecord::RegisterStateObserver(const std::string &hostBundleName)
|
||||
{
|
||||
preLoadUIExtStateObserver_ = sptr<AAFwk::PreLoadUIExtStateObserver>(
|
||||
new AAFwk::PreLoadUIExtStateObserver(weak_from_this()));
|
||||
preLoadUIExtStateObserver_ = sptr<AAFwk::PreLoadUIExtStateObserver>::MakeSptr(weak_from_this());
|
||||
auto ret = IN_PROCESS_CALL(
|
||||
DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance()->RegisterApplicationStateObserver(
|
||||
preLoadUIExtStateObserver_, {hostBundleName}));
|
||||
|
@ -274,10 +274,12 @@ int32_t ExtensionRecordManager::AddPreloadUIExtensionRecord(const std::shared_pt
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "call");
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE);
|
||||
std::shared_ptr<ExtensionRecord> extensionRecord = nullptr;
|
||||
auto extensionRecordId = abilityRecord->GetUIExtensionAbilityId();
|
||||
if (extensionRecords_.find(extensionRecordId) != extensionRecords_.end()) {
|
||||
extensionRecord = extensionRecords_[extensionRecordId];
|
||||
CHECK_POINTER_AND_RETURN(extensionRecord, ERR_INVALID_VALUE);
|
||||
auto hostBundleName = extensionRecord->hostBundleName_;
|
||||
auto preLoadUIExtensionInfo = std::make_tuple(abilityRecord->GetWant().GetElement().GetAbilityName(),
|
||||
abilityRecord->GetWant().GetElement().GetBundleName(),
|
||||
|
@ -384,11 +384,6 @@ int ImplicitStartProcessor::GenerateAbilityRequestByAction(int32_t userId,
|
||||
ProcessLinkType(abilityInfos);
|
||||
}
|
||||
|
||||
if (abilityInfos.size() == 1) {
|
||||
auto skillUri = abilityInfos.front().skillUri;
|
||||
SetTargetLinkInfo(skillUri, request.want);
|
||||
}
|
||||
|
||||
if (abilityInfos.size() + extensionInfos.size() > 1) {
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "More than one target application, filter by erms");
|
||||
bool ret = FilterAbilityList(request.want, abilityInfos, extensionInfos, userId);
|
||||
@ -425,6 +420,11 @@ int ImplicitStartProcessor::GenerateAbilityRequestByAction(int32_t userId,
|
||||
}
|
||||
}
|
||||
|
||||
if (abilityInfos.size() == 1) {
|
||||
auto skillUri = abilityInfos.front().skillUri;
|
||||
SetTargetLinkInfo(skillUri, request.want);
|
||||
}
|
||||
|
||||
{
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "for (const auto &info : abilityInfos)");
|
||||
for (const auto &info : abilityInfos) {
|
||||
@ -632,7 +632,7 @@ void ImplicitStartProcessor::GetEcologicalCallerInfo(const Want &want, ErmsCalle
|
||||
{
|
||||
callerInfo.packageName = want.GetStringParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME);
|
||||
callerInfo.uid = want.GetIntParam(Want::PARAM_RESV_CALLER_UID, IPCSkeleton::GetCallingUid());
|
||||
callerInfo.pid = want.GetIntParam(Want::PARAM_RESV_CALLER_PID, IPCSkeleton::GetCallingPid());
|
||||
callerInfo.pid = want.GetIntParam(Want::PARAM_RESV_CALLER_PID, IPCSkeleton::GetCallingRealPid());
|
||||
callerInfo.targetAppType = ErmsCallerInfo::TYPE_INVALID;
|
||||
callerInfo.callerAppType = ErmsCallerInfo::TYPE_INVALID;
|
||||
|
||||
@ -779,7 +779,7 @@ void ImplicitStartProcessor::SetTargetLinkInfo(const std::vector<AppExecFwk::Ski
|
||||
if (want.GetBoolParam(OPEN_LINK_APP_LINKING_ONLY, false)) {
|
||||
want.SetParam("send_to_erms_targetLinkType", AbilityCallerInfo::LINK_TYPE_UNIVERSAL_LINK);
|
||||
} else if ((iter.scheme == "https" || iter.scheme == "http") &&
|
||||
want.GetAction().compare(ACTION_VIEW)) {
|
||||
want.GetAction().compare(ACTION_VIEW) == 0) {
|
||||
want.SetParam("send_to_erms_targetLinkType", AbilityCallerInfo::LINK_TYPE_WEB_LINK);
|
||||
} else {
|
||||
want.SetParam("send_to_erms_targetLinkType", AbilityCallerInfo::LINK_TYPE_DEEP_LINK);
|
||||
|
@ -172,7 +172,7 @@ void EcologicalRuleInterceptor::InitErmsCallerInfo(Want &want, ErmsCallerInfo &c
|
||||
{
|
||||
callerInfo.packageName = want.GetStringParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME);
|
||||
callerInfo.uid = want.GetIntParam(Want::PARAM_RESV_CALLER_UID, IPCSkeleton::GetCallingUid());
|
||||
callerInfo.pid = want.GetIntParam(Want::PARAM_RESV_CALLER_PID, IPCSkeleton::GetCallingPid());
|
||||
callerInfo.pid = want.GetIntParam(Want::PARAM_RESV_CALLER_PID, IPCSkeleton::GetCallingRealPid());
|
||||
callerInfo.targetAppType = ErmsCallerInfo::TYPE_INVALID;
|
||||
callerInfo.callerAppType = ErmsCallerInfo::TYPE_INVALID;
|
||||
callerInfo.targetLinkFeature = want.GetStringParam("send_to_erms_targetLinkFeature");
|
||||
|
@ -110,7 +110,7 @@ bool StartOtherAppInterceptor::GetApplicationInfo(const sptr<IRemoteObject> &cal
|
||||
AppExecFwk::ApplicationInfo &applicationInfo)
|
||||
{
|
||||
if (callerToken == nullptr) {
|
||||
int32_t callerPid = IPCSkeleton::GetCallingPid();
|
||||
int32_t callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
auto appScheduler = DelayedSingleton<AppScheduler>::GetInstance();
|
||||
bool debug;
|
||||
if (appScheduler != nullptr &&
|
||||
@ -148,7 +148,7 @@ bool StartOtherAppInterceptor::IsDelegatorCall(const Want want)
|
||||
{
|
||||
AppExecFwk::RunningProcessInfo processInfo;
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->
|
||||
GetRunningProcessInfoByPid(IPCSkeleton::GetCallingPid(), processInfo);
|
||||
GetRunningProcessInfoByPid(IPCSkeleton::GetCallingRealPid(), processInfo);
|
||||
if (processInfo.isTestProcess && want.GetBoolParam(IS_DELEGATOR_CALL, false)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -22,13 +22,16 @@
|
||||
#include "ability_util.h"
|
||||
#include "app_exit_reason_data_manager.h"
|
||||
#include "appfreeze_manager.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "errors.h"
|
||||
#include "global_constant.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hisysevent.h"
|
||||
#include "mission_info_mgr.h"
|
||||
#include "in_process_call_wrapper.h"
|
||||
#include "server_constant.h"
|
||||
#include "startup_util.h"
|
||||
#ifdef RESOURCE_SCHEDULE_SERVICE_ENABLE
|
||||
#include "res_sched_client.h"
|
||||
#include "res_type.h"
|
||||
@ -55,7 +58,6 @@ constexpr uint64_t NANO_SECOND_PER_SEC = 1000000000; // ns
|
||||
const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId";
|
||||
const std::string DMS_MISSION_ID = "dmsMissionId";
|
||||
const int DEFAULT_DMS_MISSION_ID = -1;
|
||||
const std::string DLP_INDEX = "ohos.dlp.params.index";
|
||||
#ifdef SUPPORT_ASAN
|
||||
const int KILL_TIMEOUT_MULTIPLE = 45;
|
||||
#else
|
||||
@ -544,7 +546,7 @@ bool MissionListManager::HandleReusedMissionAndAbility(const AbilityRequest &abi
|
||||
|
||||
std::string MissionListManager::GetMissionName(const AbilityRequest &abilityRequest) const
|
||||
{
|
||||
int32_t appIndex = abilityRequest.want.GetIntParam(DLP_INDEX, 0);
|
||||
int32_t appIndex = AbilityRuntime::StartupUtil::GetAppTwinIndex(abilityRequest.want);
|
||||
return AbilityUtil::ConvertBundleNameSingleton(abilityRequest.abilityInfo.bundleName,
|
||||
abilityRequest.abilityInfo.name, abilityRequest.abilityInfo.moduleName, appIndex);
|
||||
}
|
||||
@ -673,7 +675,8 @@ void MissionListManager::BuildInnerMissionInfo(InnerMissionInfo &info, const std
|
||||
info.missionInfo.want = abilityRequest.want;
|
||||
info.missionInfo.unclearable = abilityRequest.abilityInfo.unclearableMission;
|
||||
info.isTemporary = abilityRequest.abilityInfo.removeMissionAfterTerminate;
|
||||
if (abilityRequest.want.GetIntParam(DLP_INDEX, 0) != 0) {
|
||||
auto dlpIndex = abilityRequest.want.GetIntParam(AbilityRuntime::ServerConstant::DLP_INDEX, 0);
|
||||
if (dlpIndex > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
info.isTemporary = true;
|
||||
}
|
||||
info.specifiedFlag = abilityRequest.specifiedFlag;
|
||||
@ -1785,8 +1788,8 @@ void MissionListManager::CompleteTerminateAndUpdateMission(const std::shared_ptr
|
||||
terminateAbilityList_.remove(it);
|
||||
// update inner mission info time
|
||||
bool excludeFromMissions = abilityRecord->GetAbilityInfo().excludeFromMissions;
|
||||
if ((abilityRecord->GetAppIndex() != 0) || abilityRecord->GetAbilityInfo().removeMissionAfterTerminate ||
|
||||
excludeFromMissions) {
|
||||
if ((abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) ||
|
||||
abilityRecord->GetAbilityInfo().removeMissionAfterTerminate || excludeFromMissions) {
|
||||
RemoveMissionLocked(abilityRecord->GetMissionId(), excludeFromMissions);
|
||||
return;
|
||||
}
|
||||
@ -2007,7 +2010,7 @@ void MissionListManager::UpdateSnapShot(const sptr<IRemoteObject> &token,
|
||||
return;
|
||||
}
|
||||
int32_t missionId = abilityRecord->GetMissionId();
|
||||
auto isPrivate = abilityRecord->GetAppIndex() != 0;
|
||||
auto isPrivate = abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX;
|
||||
DelayedSingleton<MissionInfoMgr>::GetInstance()->UpdateMissionSnapshot(missionId, pixelMap, isPrivate);
|
||||
if (listenerController_) {
|
||||
listenerController_->NotifyMissionSnapshotChanged(missionId);
|
||||
@ -2169,7 +2172,7 @@ void MissionListManager::UpdateMissionSnapshot(const std::shared_ptr<AbilityReco
|
||||
}
|
||||
int32_t missionId = abilityRecord->GetMissionId();
|
||||
MissionSnapshot snapshot;
|
||||
snapshot.isPrivate = (abilityRecord->GetAppIndex() != 0);
|
||||
snapshot.isPrivate = (abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX);
|
||||
DelayedSingleton<MissionInfoMgr>::GetInstance()->UpdateMissionSnapshot(missionId, abilityRecord->GetToken(),
|
||||
snapshot);
|
||||
if (listenerController_) {
|
||||
@ -2694,8 +2697,8 @@ void MissionListManager::HandleAbilityDiedByDefault(std::shared_ptr<AbilityRecor
|
||||
// update running state.
|
||||
auto missionId = mission->GetMissionId();
|
||||
if (!ability->IsUninstallAbility()) {
|
||||
if ((ability->GetAppIndex() != 0) || ability->GetAbilityInfo().removeMissionAfterTerminate ||
|
||||
ability->GetAbilityInfo().excludeFromMissions) {
|
||||
if ((ability->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) ||
|
||||
ability->GetAbilityInfo().removeMissionAfterTerminate || ability->GetAbilityInfo().excludeFromMissions) {
|
||||
RemoveMissionLocked(missionId, ability->GetAbilityInfo().excludeFromMissions);
|
||||
} else {
|
||||
InnerMissionInfo info;
|
||||
@ -3607,7 +3610,8 @@ bool MissionListManager::GetMissionSnapshot(int32_t missionId, const sptr<IRemot
|
||||
auto abilityRecord = GetAbilityRecordByTokenInner(abilityToken);
|
||||
if (abilityRecord && abilityRecord->IsAbilityState(FOREGROUND)) {
|
||||
forceSnapshot = true;
|
||||
missionSnapshot.isPrivate = (abilityRecord->GetAppIndex() != 0);
|
||||
missionSnapshot.isPrivate =
|
||||
(abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX);
|
||||
}
|
||||
}
|
||||
return DelayedSingleton<MissionInfoMgr>::GetInstance()->GetMissionSnapshot(
|
||||
|
@ -29,7 +29,7 @@ void PreLoadUIExtStateObserver::OnProcessDied(const AppExecFwk::ProcessData &pro
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "called.");
|
||||
auto extensionRecord = extensionRecord_.lock();
|
||||
if (extensionRecord != nullptr) {
|
||||
extensionRecord->UnLoadUIExtension();
|
||||
extensionRecord->UnloadUIExtensionAbility();
|
||||
} else {
|
||||
TAG_LOGW(AAFwkTag::ABILITYMGR, "extensionRecord null");
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ void RestartAppManager::AddRestartAppHistory(const RestartAppKeyType &key, time_
|
||||
bool RestartAppManager::IsForegroundToRestartApp() const
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "IsForegroundToRestartApp, called.");
|
||||
auto callerPid = IPCSkeleton::GetCallingPid();
|
||||
auto callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
AppExecFwk::RunningProcessInfo processInfo;
|
||||
DelayedSingleton<AppScheduler>::GetInstance()->GetRunningProcessInfoByPid(callerPid, processInfo);
|
||||
if (processInfo.state_ == AppProcessState::APP_STATE_FOREGROUND || processInfo.isFocused ||
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "scene_board/status_bar_delegate_manager.h"
|
||||
#include "session_info.h"
|
||||
#include "session_manager_lite.h"
|
||||
#include "startup_util.h"
|
||||
#ifdef SUPPORT_GRAPHICS
|
||||
#include "ability_first_frame_state_observer_manager.h"
|
||||
#endif
|
||||
@ -43,12 +44,6 @@ using AbilityRuntime::FreezeUtil;
|
||||
namespace AAFwk {
|
||||
namespace {
|
||||
constexpr const char* SEPARATOR = ":";
|
||||
constexpr char EVENT_KEY_UID[] = "UID";
|
||||
constexpr char EVENT_KEY_PID[] = "PID";
|
||||
constexpr char EVENT_KEY_MESSAGE[] = "MSG";
|
||||
constexpr char EVENT_KEY_PACKAGE_NAME[] = "PACKAGE_NAME";
|
||||
constexpr char EVENT_KEY_PROCESS_NAME[] = "PROCESS_NAME";
|
||||
const std::string DLP_INDEX = "ohos.dlp.params.index";
|
||||
constexpr int32_t PREPARE_TERMINATE_TIMEOUT_MULTIPLE = 10;
|
||||
const std::string PARAM_MISSION_AFFINITY_KEY = "ohos.anco.param.missionAffinity";
|
||||
const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId";
|
||||
@ -1286,7 +1281,7 @@ bool UIAbilityLifecycleManager::CheckProperties(const std::shared_ptr<AbilityRec
|
||||
return abilityInfo.launchMode == launchMode && abilityRequest.abilityInfo.name == abilityInfo.name &&
|
||||
abilityRequest.abilityInfo.bundleName == abilityInfo.bundleName &&
|
||||
abilityRequest.abilityInfo.moduleName == abilityInfo.moduleName &&
|
||||
abilityRequest.want.GetIntParam(DLP_INDEX, 0) == abilityRecord->GetAppIndex();
|
||||
AbilityRuntime::StartupUtil::GetAppTwinIndex(abilityRequest.want) == abilityRecord->GetAppIndex();
|
||||
}
|
||||
|
||||
void UIAbilityLifecycleManager::OnTimeOut(uint32_t msgId, int64_t abilityRecordId, bool isHalf)
|
||||
|
@ -28,7 +28,6 @@ namespace AAFwk {
|
||||
namespace {
|
||||
const std::string DLP_BUNDLE_NAME = "com.ohos.dlpmanager";
|
||||
const std::string DLP_ABILITY_NAME = "SaveAsAbility";
|
||||
const std::string DLP_INDEX = "ohos.dlp.params.index";
|
||||
|
||||
class EmptyConnection : public IRemoteStub<IAbilityConnection> {
|
||||
public:
|
||||
|
@ -19,14 +19,16 @@
|
||||
#include "ability_util.h"
|
||||
#include "bundle_constants.h"
|
||||
#include "bundle_mgr_helper.h"
|
||||
#include "global_constant.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "server_constant.h"
|
||||
#include "startup_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
namespace {
|
||||
constexpr const char* DLP_INDEX = "ohos.dlp.params.index";
|
||||
constexpr const char* SCREENSHOT_BUNDLE_NAME = "com.huawei.ohos.screenshot";
|
||||
constexpr const char* SCREENSHOT_ABILITY_NAME = "com.huawei.ohos.screenshot.ServiceExtAbility";
|
||||
}
|
||||
@ -37,12 +39,16 @@ thread_local bool StartAbilityUtils::skipErms = false;
|
||||
|
||||
int32_t StartAbilityUtils::GetAppIndex(const Want &want, sptr<IRemoteObject> callerToken)
|
||||
{
|
||||
int32_t appIndex = want.GetIntParam(AbilityRuntime::ServerConstant::APP_TWIN_INDEX, 0);
|
||||
if (appIndex > 0 && appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
return appIndex;
|
||||
}
|
||||
auto abilityRecord = Token::GetAbilityRecordByToken(callerToken);
|
||||
if (abilityRecord && abilityRecord->GetAppIndex() != 0 &&
|
||||
if (abilityRecord && abilityRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX &&
|
||||
abilityRecord->GetApplicationInfo().bundleName == want.GetElement().GetBundleName()) {
|
||||
return abilityRecord->GetAppIndex();
|
||||
}
|
||||
return want.GetIntParam(DLP_INDEX, 0);
|
||||
return want.GetIntParam(AbilityRuntime::ServerConstant::DLP_INDEX, 0);
|
||||
}
|
||||
|
||||
bool StartAbilityUtils::GetApplicationInfo(const std::string &bundleName, int32_t userId,
|
||||
@ -145,11 +151,17 @@ std::shared_ptr<StartAbilityInfo> StartAbilityInfo::CreateStartAbilityInfo(const
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto bms = AbilityUtil::GetBundleManagerHelper();
|
||||
CHECK_POINTER_AND_RETURN(bms, nullptr);
|
||||
auto abilityInfoFlag = (AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_PERMISSION |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_METADATA |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_SKILL);
|
||||
auto abilityInfoFlag = AbilityRuntime::StartupUtil::BuildAbilityInfoFlag() |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_SKILL;
|
||||
auto request = std::make_shared<StartAbilityInfo>();
|
||||
if (appIndex != 0 && appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
IN_PROCESS_CALL_WITHOUT_RET(bms->QueryCloneAbilityInfo(want.GetElement(), abilityInfoFlag, appIndex,
|
||||
request->abilityInfo, userId));
|
||||
if (request->abilityInfo.name.empty() || request->abilityInfo.bundleName.empty()) {
|
||||
request->status = ERR_APP_TWIN_INDEX_INVALID;
|
||||
}
|
||||
return request;
|
||||
}
|
||||
if (appIndex == 0) {
|
||||
IN_PROCESS_CALL_WITHOUT_RET(bms->QueryAbilityInfo(want, abilityInfoFlag, userId, request->abilityInfo));
|
||||
} else {
|
||||
@ -191,10 +203,8 @@ std::shared_ptr<StartAbilityInfo> StartAbilityInfo::CreateStartExtensionInfo(con
|
||||
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
|
||||
auto bms = AbilityUtil::GetBundleManagerHelper();
|
||||
CHECK_POINTER_AND_RETURN(bms, nullptr);
|
||||
auto abilityInfoFlag = (AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_PERMISSION |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_METADATA |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_SKILL);
|
||||
auto abilityInfoFlag = AbilityRuntime::StartupUtil::BuildAbilityInfoFlag() |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_SKILL;
|
||||
auto abilityInfo = std::make_shared<StartAbilityInfo>();
|
||||
|
||||
std::vector<AppExecFwk::ExtensionAbilityInfo> extensionInfos;
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
int AppfreezeHandle(const FaultData& faultData, const AppfreezeManager::AppInfo& appInfo);
|
||||
int AppfreezeHandleWithStack(const FaultData& faultData, const AppfreezeManager::AppInfo& appInfo);
|
||||
int LifecycleTimeoutHandle(const ParamInfo& info, std::unique_ptr<FreezeUtil::LifecycleFlow> flow = nullptr);
|
||||
bool WriteToFile(const std::string& fileName, std::string& content);
|
||||
std::string WriteToFile(const std::string& fileName, std::string& content);
|
||||
bool IsHandleAppfreeze(const std::string& bundleName);
|
||||
bool IsProcessDebug(int32_t pid, std::string processName);
|
||||
|
||||
|
@ -48,7 +48,6 @@ constexpr char BINDER_INFO[] = "BINDER_INFO";
|
||||
constexpr char APP_RUNNING_UNIQUE_ID[] = "APP_RUNNING_UNIQUE_ID";
|
||||
constexpr int MAX_LAYER = 8;
|
||||
const std::string LOG_FILE_PATH = "data/log/eventlog";
|
||||
std::string g_fullStackPath = "";
|
||||
}
|
||||
std::shared_ptr<AppfreezeManager> AppfreezeManager::instance_ = nullptr;
|
||||
ffrt::mutex AppfreezeManager::singletonMutex_;
|
||||
@ -133,16 +132,17 @@ int AppfreezeManager::AppfreezeHandleWithStack(const FaultData& faultData, const
|
||||
std::string fileName = faultData.errorObject.name + "_" + std::to_string(appInfo.pid) + "_stack";
|
||||
std::string catcherStack = "";
|
||||
std::string catchJsonStack = "";
|
||||
std::string fullStackPath = "";
|
||||
|
||||
if (faultData.errorObject.name == AppFreezeType::LIFECYCLE_HALF_TIMEOUT
|
||||
|| faultData.errorObject.name == AppFreezeType::LIFECYCLE_TIMEOUT) {
|
||||
catcherStack += CatcherStacktrace(appInfo.pid);
|
||||
WriteToFile(fileName, catcherStack);
|
||||
faultNotifyData.errorObject.stack = g_fullStackPath;
|
||||
fullStackPath = WriteToFile(fileName, catcherStack);
|
||||
faultNotifyData.errorObject.stack = fullStackPath;
|
||||
} else {
|
||||
catchJsonStack += CatchJsonStacktrace(appInfo.pid);
|
||||
WriteToFile(fileName, catchJsonStack);
|
||||
faultNotifyData.errorObject.stack = g_fullStackPath;
|
||||
fullStackPath = WriteToFile(fileName, catchJsonStack);
|
||||
faultNotifyData.errorObject.stack = fullStackPath;
|
||||
}
|
||||
|
||||
if (faultNotifyData.errorObject.name == AppFreezeType::APP_INPUT_BLOCK) {
|
||||
@ -153,28 +153,27 @@ int AppfreezeManager::AppfreezeHandleWithStack(const FaultData& faultData, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AppfreezeManager::WriteToFile(const std::string& fileName, std::string& content)
|
||||
std::string AppfreezeManager::WriteToFile(const std::string& fileName, std::string& content)
|
||||
{
|
||||
std::string dir_name = "freeze";
|
||||
std::string dir_path = LOG_FILE_PATH + "/" + dir_name;
|
||||
std::string dir_path = LOG_FILE_PATH + "/freeze";
|
||||
constexpr mode_t defaultLogDirMode = 0770;
|
||||
if (!OHOS::FileExists(dir_path)) {
|
||||
OHOS::ForceCreateDirectory(dir_path);
|
||||
OHOS::ChangeModeDirectory(dir_path, defaultLogDirMode);
|
||||
}
|
||||
|
||||
g_fullStackPath = dir_path + "/" + fileName;
|
||||
std::string stackPath = dir_path + "/" + fileName;
|
||||
constexpr mode_t defaultLogFileMode = 0664;
|
||||
auto fd = open(g_fullStackPath.c_str(), O_CREAT | O_WRONLY | O_TRUNC, defaultLogFileMode);
|
||||
auto fd = open(stackPath.c_str(), O_CREAT | O_WRONLY | O_TRUNC, defaultLogFileMode);
|
||||
if (fd < 0) {
|
||||
TAG_LOGI(AAFwkTag::APPDFR, "Failed to create g_fullStackPath");
|
||||
return false;
|
||||
TAG_LOGI(AAFwkTag::APPDFR, "Failed to create stackPath");
|
||||
return "";
|
||||
} else {
|
||||
TAG_LOGI(AAFwkTag::APPDFR, "g_fullStackPath = %{public}s", g_fullStackPath.c_str());
|
||||
TAG_LOGI(AAFwkTag::APPDFR, "stackPath = %{public}s", stackPath.c_str());
|
||||
}
|
||||
OHOS::SaveStringToFd(fd, content);
|
||||
close(fd);
|
||||
return true;
|
||||
return stackPath;
|
||||
}
|
||||
|
||||
int AppfreezeManager::LifecycleTimeoutHandle(const ParamInfo& info, std::unique_ptr<FreezeUtil::LifecycleFlow> flow)
|
||||
@ -233,8 +232,8 @@ int AppfreezeManager::AcquireStack(const FaultData& faultData, const AppfreezeMa
|
||||
}
|
||||
|
||||
std::string fileName = faultData.errorObject.name + "_" + std::to_string(appInfo.pid) + "_binder";
|
||||
WriteToFile(fileName, binderInfo);
|
||||
binderInfo = g_fullStackPath;
|
||||
std::string fullStackPath = WriteToFile(fileName, binderInfo);
|
||||
binderInfo = fullStackPath;
|
||||
|
||||
ret = NotifyANR(faultNotifyData, appInfo, binderInfo);
|
||||
return ret;
|
||||
|
@ -24,6 +24,7 @@ config("appmgr_config") {
|
||||
"${ability_runtime_path}/tools/aa/include",
|
||||
"${ability_runtime_path}/utils/global/time/include",
|
||||
"${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper",
|
||||
"${ability_runtime_utils_path}/global/constant",
|
||||
]
|
||||
}
|
||||
|
||||
@ -96,6 +97,7 @@ ohos_shared_library("libappms") {
|
||||
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
|
||||
"${ability_runtime_native_path}/appkit:appkit_manager_helper",
|
||||
"${ability_runtime_path}/utils/global/freeze:freeze_util",
|
||||
"${ability_runtime_path}/utils/server/startup:startup_util",
|
||||
"${ability_runtime_services_path}/common:app_util",
|
||||
"${ability_runtime_services_path}/common:event_report",
|
||||
"${ability_runtime_services_path}/common:perm_verification",
|
||||
|
@ -1336,7 +1336,6 @@ private:
|
||||
bool JudgeSelfCalledByToken(const sptr<IRemoteObject> &token, const PageStateData &pageStateData);
|
||||
|
||||
void ParseServiceExtMultiProcessWhiteList();
|
||||
int32_t GetFlag() const;
|
||||
void ClearData(std::shared_ptr<AppRunningRecord> appRecord);
|
||||
|
||||
/**
|
||||
|
@ -87,6 +87,8 @@ public:
|
||||
void SetScheduler(const sptr<IRenderScheduler> &scheduler);
|
||||
void SetDeathRecipient(const sptr<AppDeathRecipient> recipient);
|
||||
void RegisterDeathRecipient();
|
||||
void SetState(int32_t state);
|
||||
int32_t GetState() const;
|
||||
|
||||
private:
|
||||
void SetHostUid(const int32_t hostUid);
|
||||
@ -103,6 +105,7 @@ private:
|
||||
int32_t ipcFd_ = 0;
|
||||
int32_t sharedFd_ = 0;
|
||||
int32_t crashFd_ = 0;
|
||||
int32_t state_ = 0;
|
||||
ProcessType processType_ = ProcessType::RENDER;
|
||||
std::weak_ptr<AppRunningRecord> host_; // nweb host
|
||||
sptr<IRenderScheduler> renderScheduler_ = nullptr;
|
||||
|
@ -211,8 +211,8 @@ void AmsMgrScheduler::KillProcessesByPids(std::vector<int32_t> &pids)
|
||||
return;
|
||||
}
|
||||
|
||||
pid_t callingPid = IPCSkeleton::GetCallingPid();
|
||||
pid_t pid = getpid();
|
||||
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
|
||||
pid_t pid = getprocpid();
|
||||
if (callingPid != pid) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Not allow other process to call.");
|
||||
return;
|
||||
@ -229,8 +229,8 @@ void AmsMgrScheduler::AttachPidToParent(const sptr<IRemoteObject> &token, const
|
||||
return;
|
||||
}
|
||||
|
||||
pid_t callingPid = IPCSkeleton::GetCallingPid();
|
||||
pid_t pid = getpid();
|
||||
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
|
||||
pid_t pid = getprocpid();
|
||||
if (callingPid != pid) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Not allow other process to call.");
|
||||
return;
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "app_death_recipient.h"
|
||||
#include "app_mgr_constants.h"
|
||||
#include "datetime_ex.h"
|
||||
#include "global_constant.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "in_process_call_wrapper.h"
|
||||
@ -200,7 +201,7 @@ void AppMgrService::AttachApplication(const sptr<IRemoteObject> &app)
|
||||
return;
|
||||
}
|
||||
|
||||
pid_t pid = IPCSkeleton::GetCallingPid();
|
||||
pid_t pid = IPCSkeleton::GetCallingRealPid();
|
||||
std::function<void()> attachApplicationFunc =
|
||||
std::bind(&AppMgrServiceInner::AttachApplication, appMgrServiceInner_, pid, iface_cast<IAppScheduler>(app));
|
||||
taskHandler_->SubmitTask(attachApplicationFunc, AAFwk::TaskAttribute{
|
||||
@ -304,8 +305,8 @@ void AppMgrService::StartupResidentProcess(const std::vector<AppExecFwk::BundleI
|
||||
if (!IsReady()) {
|
||||
return;
|
||||
}
|
||||
pid_t callingPid = IPCSkeleton::GetCallingPid();
|
||||
pid_t pid = getpid();
|
||||
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
|
||||
pid_t pid = getprocpid();
|
||||
if (callingPid != pid) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Not this process call.");
|
||||
return;
|
||||
@ -355,7 +356,7 @@ int32_t AppMgrService::ClearUpApplicationData(const std::string &bundleName, con
|
||||
}
|
||||
}
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
pid_t pid = IPCSkeleton::GetCallingPid();
|
||||
pid_t pid = IPCSkeleton::GetCallingRealPid();
|
||||
appMgrServiceInner_->ClearUpApplicationData(bundleName, uid, pid, userId);
|
||||
return ERR_OK;
|
||||
}
|
||||
@ -366,7 +367,7 @@ int32_t AppMgrService::ClearUpApplicationDataBySelf(int32_t userId)
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
pid_t pid = IPCSkeleton::GetCallingPid();
|
||||
pid_t pid = IPCSkeleton::GetCallingRealPid();
|
||||
return appMgrServiceInner_->ClearUpApplicationDataBySelf(uid, pid, userId);
|
||||
}
|
||||
|
||||
@ -402,7 +403,7 @@ int32_t AppMgrService::JudgeSandboxByPid(pid_t pid, bool &isSandbox)
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
auto appRunningRecord = appMgrServiceInner_->GetAppRunningRecordByPid(pid);
|
||||
if (appRunningRecord && appRunningRecord->GetAppIndex() > 0) {
|
||||
if (appRunningRecord && appRunningRecord->GetAppIndex() > AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
isSandbox = true;
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "current app is a sandbox.");
|
||||
return ERR_OK;
|
||||
@ -585,7 +586,7 @@ int AppMgrService::FinishUserTest(const std::string &msg, const int64_t &resultC
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "GetBundleName failed: %{public}d.", result);
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
pid_t callingPid = IPCSkeleton::GetCallingPid();
|
||||
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
|
||||
std::function<void()> finishUserTestProcessFunc =
|
||||
std::bind(&AppMgrServiceInner::FinishUserTest, appMgrServiceInner_, msg, resultCode, bundleName, callingPid);
|
||||
taskHandler_->SubmitTask(finishUserTestProcessFunc, TASK_FINISH_USER_TEST);
|
||||
@ -809,7 +810,7 @@ int32_t AppMgrService::PreStartNWebSpawnProcess()
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
return appMgrServiceInner_->PreStartNWebSpawnProcess(IPCSkeleton::GetCallingPid());
|
||||
return appMgrServiceInner_->PreStartNWebSpawnProcess(IPCSkeleton::GetCallingRealPid());
|
||||
}
|
||||
|
||||
int32_t AppMgrService::StartRenderProcess(const std::string &renderParam, int32_t ipcFd,
|
||||
@ -820,7 +821,7 @@ int32_t AppMgrService::StartRenderProcess(const std::string &renderParam, int32_
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
|
||||
return appMgrServiceInner_->StartRenderProcess(IPCSkeleton::GetCallingPid(),
|
||||
return appMgrServiceInner_->StartRenderProcess(IPCSkeleton::GetCallingRealPid(),
|
||||
renderParam, ipcFd, sharedFd, crashFd, renderPid);
|
||||
}
|
||||
|
||||
@ -832,7 +833,7 @@ void AppMgrService::AttachRenderProcess(const sptr<IRemoteObject> &scheduler)
|
||||
return;
|
||||
}
|
||||
|
||||
auto pid = IPCSkeleton::GetCallingPid();
|
||||
auto pid = IPCSkeleton::GetCallingRealPid();
|
||||
auto fun = std::bind(&AppMgrServiceInner::AttachRenderProcess,
|
||||
appMgrServiceInner_, pid, iface_cast<IRenderScheduler>(scheduler));
|
||||
taskHandler_->SubmitTask(fun, AAFwk::TaskAttribute{
|
||||
@ -1188,8 +1189,8 @@ int32_t AppMgrService::StartChildProcess(const std::string &srcEntry, pid_t &chi
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "StartChildProcess failed, AppMgrService not ready.");
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
return appMgrServiceInner_->StartChildProcess(IPCSkeleton::GetCallingPid(), srcEntry, childPid, childProcessCount,
|
||||
isStartWithDebug);
|
||||
return appMgrServiceInner_->StartChildProcess(IPCSkeleton::GetCallingRealPid(), srcEntry, childPid,
|
||||
childProcessCount, isStartWithDebug);
|
||||
}
|
||||
|
||||
int32_t AppMgrService::GetChildProcessInfoForSelf(ChildProcessInfo &info)
|
||||
@ -1212,7 +1213,7 @@ void AppMgrService::AttachChildProcess(const sptr<IRemoteObject> &childScheduler
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "taskHandler_ is null.");
|
||||
return;
|
||||
}
|
||||
pid_t pid = IPCSkeleton::GetCallingPid();
|
||||
pid_t pid = IPCSkeleton::GetCallingRealPid();
|
||||
std::function<void()> task = std::bind(&AppMgrServiceInner::AttachChildProcess,
|
||||
appMgrServiceInner_, pid, iface_cast<IChildScheduler>(childScheduler));
|
||||
taskHandler_->SubmitTask(task, AAFwk::TaskAttribute{
|
||||
@ -1231,7 +1232,7 @@ void AppMgrService::ExitChildProcessSafely()
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "taskHandler_ is null.");
|
||||
return;
|
||||
}
|
||||
pid_t pid = IPCSkeleton::GetCallingPid();
|
||||
pid_t pid = IPCSkeleton::GetCallingRealPid();
|
||||
std::function<void()> task = std::bind(&AppMgrServiceInner::ExitChildProcessSafelyByChildPid,
|
||||
appMgrServiceInner_, pid);
|
||||
taskHandler_->SubmitTask(task, AAFwk::TaskAttribute{
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "distributed_data_mgr.h"
|
||||
#include "exit_resident_process_manager.h"
|
||||
#include "freeze_util.h"
|
||||
#include "global_constant.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
@ -66,8 +67,9 @@
|
||||
#include "permission_constants.h"
|
||||
#include "permission_verification.h"
|
||||
#include "render_state_observer_manager.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "startup_util.h"
|
||||
#include "string_ex.h"
|
||||
#include "system_ability_definition.h"
|
||||
#include "time_util.h"
|
||||
#include "ui_extension_utils.h"
|
||||
#include "uri_permission_manager_client.h"
|
||||
@ -124,7 +126,6 @@ const std::string PERF_CMD = "perfCmd";
|
||||
const std::string MULTI_THREAD = "multiThread";
|
||||
const std::string DEBUG_CMD = "debugCmd";
|
||||
const std::string ENTER_SANDBOX = "sandboxApp";
|
||||
const std::string DLP_PARAMS_INDEX = "ohos.dlp.params.index";
|
||||
const std::string PERMISSION_INTERNET = "ohos.permission.INTERNET";
|
||||
const std::string PERMISSION_MANAGE_VPN = "ohos.permission.MANAGE_VPN";
|
||||
const std::string PERMISSION_ACCESS_BUNDLE_DIR = "ohos.permission.ACCESS_BUNDLE_DIR";
|
||||
@ -190,6 +191,7 @@ constexpr int32_t ROOT_UID = 0;
|
||||
constexpr int32_t FOUNDATION_UID = 5523;
|
||||
constexpr int32_t QUICKFIX_UID = 5524;
|
||||
constexpr int32_t DEFAULT_USER_ID = 0;
|
||||
constexpr int32_t CURRENT_USER_ID = -1;
|
||||
|
||||
constexpr int32_t BLUETOOTH_GROUPID = 1002;
|
||||
|
||||
@ -246,7 +248,7 @@ void AppMgrServiceInner::StartSpecifiedProcess(const AAFwk::Want &want, const Ap
|
||||
HapModuleInfo hapModuleInfo;
|
||||
auto appInfo = std::make_shared<ApplicationInfo>(abilityInfo.applicationInfo);
|
||||
|
||||
int32_t appIndex = want.GetIntParam(DLP_PARAMS_INDEX, 0);
|
||||
int32_t appIndex = AbilityRuntime::StartupUtil::GetAppTwinIndex(want);
|
||||
if (!GetBundleAndHapInfo(abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) {
|
||||
return;
|
||||
}
|
||||
@ -296,6 +298,9 @@ int32_t AppMgrServiceInner::PreloadApplication(const std::string &bundleName, in
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication appPreloader is nullptr.");
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
if (userId == CURRENT_USER_ID) {
|
||||
userId = currentUserId_;
|
||||
}
|
||||
auto allowPreload = appPreloader_->PreCheck(bundleName, preloadMode);
|
||||
if (!allowPreload) {
|
||||
HILOG_ERROR("BundleName: %{public}s preload preCheck failed.", bundleName.c_str());
|
||||
@ -393,7 +398,7 @@ void AppMgrServiceInner::LoadAbility(sptr<IRemoteObject> token, sptr<IRemoteObje
|
||||
|
||||
BundleInfo bundleInfo;
|
||||
HapModuleInfo hapModuleInfo;
|
||||
int32_t appIndex = (want == nullptr) ? 0 : want->GetIntParam(DLP_PARAMS_INDEX, 0);
|
||||
int32_t appIndex = (want == nullptr) ? 0 : AbilityRuntime::StartupUtil::GetAppTwinIndex(*want);
|
||||
if (!GetBundleAndHapInfo(*abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "GetBundleAndHapInfo failed");
|
||||
return;
|
||||
@ -637,7 +642,7 @@ void AppMgrServiceInner::LoadAbilityNoAppRecord(const std::shared_ptr<AppRunning
|
||||
}
|
||||
}
|
||||
uint32_t startFlags = (want == nullptr) ? 0 : AppspawnUtil::BuildStartFlags(*want, *abilityInfo);
|
||||
int32_t bundleIndex = (want == nullptr) ? 0 : want->GetIntParam(DLP_PARAMS_INDEX, 0);
|
||||
int32_t bundleIndex = (want == nullptr) ? 0 : AbilityRuntime::StartupUtil::GetAppTwinIndex(*want);
|
||||
StartProcess(abilityInfo->applicationName, processName, startFlags, appRecord,
|
||||
appInfo->uid, bundleInfo, appInfo->bundleName, bundleIndex, appExistFlag, isPreload);
|
||||
std::string perfCmd = (want == nullptr) ? "" : want->GetStringParam(PERF_CMD);
|
||||
@ -717,25 +722,29 @@ bool AppMgrServiceInner::GetBundleAndHapInfo(const AbilityInfo &abilityInfo,
|
||||
|
||||
auto userId = GetUserIdByUid(appInfo->uid);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "UserId:%{public}d.", userId);
|
||||
bool bundleMgrResult;
|
||||
int32_t bundleMgrResult;
|
||||
if (appIndex == 0) {
|
||||
bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfo(appInfo->bundleName,
|
||||
BundleFlag::GET_BUNDLE_DEFAULT, bundleInfo, userId));
|
||||
bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetBundleInfoV9(appInfo->bundleName,
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION), bundleInfo, userId));
|
||||
} else if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetCloneBundleInfo(appInfo->bundleName,
|
||||
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION), appIndex, bundleInfo, userId));
|
||||
} else {
|
||||
bundleMgrResult = (IN_PROCESS_CALL(bundleMgrHelper->GetSandboxBundleInfo(appInfo->bundleName,
|
||||
appIndex, userId, bundleInfo)) == 0);
|
||||
bundleMgrResult = IN_PROCESS_CALL(bundleMgrHelper->GetSandboxBundleInfo(appInfo->bundleName,
|
||||
appIndex, userId, bundleInfo));
|
||||
}
|
||||
|
||||
if (!bundleMgrResult) {
|
||||
if (bundleMgrResult != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "GetBundleInfo is fail.");
|
||||
return false;
|
||||
}
|
||||
if (appIndex == 0) {
|
||||
bundleMgrResult = bundleMgrHelper->GetHapModuleInfo(abilityInfo, userId, hapModuleInfo);
|
||||
bool hapQueryResult = false;
|
||||
if (appIndex <= AbilityRuntime::GlobalConstant::MAX_APP_TWIN_INDEX) {
|
||||
hapQueryResult = bundleMgrHelper->GetHapModuleInfo(abilityInfo, userId, hapModuleInfo);
|
||||
} else {
|
||||
bundleMgrResult = (bundleMgrHelper->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo) == 0);
|
||||
hapQueryResult = (bundleMgrHelper->GetSandboxHapModuleInfo(abilityInfo, appIndex, userId, hapModuleInfo) == 0);
|
||||
}
|
||||
if (!bundleMgrResult) {
|
||||
if (!hapQueryResult) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "GetHapModuleInfo is fail.");
|
||||
return false;
|
||||
}
|
||||
@ -893,7 +902,8 @@ void AppMgrServiceInner::ApplicationForegrounded(const int32_t recordId)
|
||||
eventInfo.pid = appRecord->GetPriorityObject()->GetPid();
|
||||
eventInfo.processName = appRecord->GetProcessName();
|
||||
eventInfo.processType = static_cast<int32_t>(appRecord->GetProcessType());
|
||||
int32_t callerPid = appRecord->GetCallerPid() == -1 ? IPCSkeleton::GetCallingPid() : appRecord->GetCallerPid();
|
||||
int32_t callerPid = appRecord->GetCallerPid() == -1 ?
|
||||
IPCSkeleton::GetCallingRealPid() : appRecord->GetCallerPid();
|
||||
auto callerRecord = GetAppRunningRecordByPid(callerPid);
|
||||
if (callerRecord != nullptr) {
|
||||
eventInfo.callerBundleName = callerRecord->GetBundleName();
|
||||
@ -1161,7 +1171,7 @@ int32_t AppMgrServiceInner::KillApplicationSelf()
|
||||
return ERR_NO_INIT;
|
||||
}
|
||||
|
||||
auto callerPid = IPCSkeleton::GetCallingPid();
|
||||
auto callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
auto appRecord = GetAppRunningRecordByPid(callerPid);
|
||||
if (!appRecord) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord, callerPid:%{public}d", callerPid);
|
||||
@ -1426,7 +1436,7 @@ int32_t AppMgrServiceInner::GetProcessRunningInformation(RunningProcessInfo &inf
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ is nullptr");
|
||||
return ERR_NO_INIT;
|
||||
}
|
||||
auto callerPid = IPCSkeleton::GetCallingPid();
|
||||
auto callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
auto appRecord = GetAppRunningRecordByPid(callerPid);
|
||||
if (!appRecord) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord, callerPid:%{public}d", callerPid);
|
||||
@ -1585,6 +1595,8 @@ void AppMgrServiceInner::GetRenderProcesses(const std::shared_ptr<AppRunningReco
|
||||
renderProcessInfo.pid_ = renderRecord->GetPid();
|
||||
renderProcessInfo.uid_ = renderRecord->GetUid();
|
||||
renderProcessInfo.hostUid_ = renderRecord->GetHostUid();
|
||||
renderProcessInfo.hostPid_ = renderRecord->GetHostPid();
|
||||
renderProcessInfo.state_ = renderRecord->GetState();
|
||||
info.emplace_back(renderProcessInfo);
|
||||
}
|
||||
}
|
||||
@ -1739,7 +1751,7 @@ std::shared_ptr<AppRunningRecord> AppMgrServiceInner::CreateAppRunningRecord(spt
|
||||
}
|
||||
appRecord->SetPerfCmd(want->GetStringParam(PERF_CMD));
|
||||
appRecord->SetMultiThread(want->GetBoolParam(MULTI_THREAD, false));
|
||||
appRecord->SetAppIndex(want->GetIntParam(DLP_PARAMS_INDEX, 0));
|
||||
appRecord->SetAppIndex(AbilityRuntime::StartupUtil::GetAppTwinIndex(*want));
|
||||
appRecord->SetSecurityFlag(want->GetBoolParam(DLP_PARAMS_SECURITY_FLAG, false));
|
||||
appRecord->SetRequestProcCode(want->GetIntParam(Want::PARAM_RESV_REQUEST_PROC_CODE, 0));
|
||||
appRecord->SetCallerPid(want->GetIntParam(Want::PARAM_RESV_CALLER_PID, -1));
|
||||
@ -1918,8 +1930,8 @@ void AppMgrServiceInner::SetBundleManagerHelper(const std::shared_ptr<BundleMgrH
|
||||
|
||||
void AppMgrServiceInner::RegisterAppStateCallback(const sptr<IAppStateCallback> &callback)
|
||||
{
|
||||
pid_t callingPid = IPCSkeleton::GetCallingPid();
|
||||
pid_t pid = getpid();
|
||||
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
|
||||
pid_t pid = getprocpid();
|
||||
if (callingPid != pid) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "%{public}s: Not abilityMgr call.", __func__);
|
||||
return;
|
||||
@ -2670,7 +2682,8 @@ bool AppMgrServiceInner::SendProcessStartEvent(const std::shared_ptr<AppRunningR
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "Abilities nullptr!");
|
||||
}
|
||||
|
||||
eventInfo.callerPid = appRecord->GetCallerPid() == -1 ? IPCSkeleton::GetCallingPid() : appRecord->GetCallerPid();
|
||||
eventInfo.callerPid = appRecord->GetCallerPid() == -1 ?
|
||||
IPCSkeleton::GetCallingRealPid() : appRecord->GetCallerPid();
|
||||
auto callerAppRecord = GetAppRunningRecordByPid(eventInfo.callerPid);
|
||||
if (callerAppRecord == nullptr) {
|
||||
Security::AccessToken::NativeTokenInfo nativeTokenInfo = {};
|
||||
@ -2697,10 +2710,6 @@ bool AppMgrServiceInner::SendProcessStartEvent(const std::shared_ptr<AppRunningR
|
||||
eventInfo.pid = appRecord->GetPriorityObject()->GetPid();
|
||||
}
|
||||
AAFwk::EventReport::SendProcessStartEvent(AAFwk::EventName::PROCESS_START, eventInfo);
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "%{public}s. time : %{public}" PRId64 ", abilityType : %{public}d, bundle : %{public}s,\
|
||||
uid : %{public}d, process : %{public}s",
|
||||
__func__, eventInfo.time, eventInfo.abilityType, eventInfo.callerBundleName.c_str(), eventInfo.callerUid,
|
||||
eventInfo.callerProcessName.c_str());
|
||||
SendReStartProcessEvent(eventInfo, appRecord);
|
||||
|
||||
return true;
|
||||
@ -3445,10 +3454,10 @@ int AppMgrServiceInner::StartEmptyProcess(const AAFwk::Want &want, const sptr<IR
|
||||
testRecord->userId = userId;
|
||||
appRecord->SetUserTestInfo(testRecord);
|
||||
|
||||
int32_t bundleIndex = want.GetIntParam(DLP_PARAMS_INDEX, 0);
|
||||
int32_t appIndex = AbilityRuntime::StartupUtil::GetAppTwinIndex(want);
|
||||
uint32_t startFlags = AppspawnUtil::BuildStartFlags(want, info.applicationInfo);
|
||||
StartProcess(appInfo->name, processName, startFlags, appRecord, appInfo->uid, info, appInfo->bundleName,
|
||||
bundleIndex, appExistFlag);
|
||||
appIndex, appExistFlag);
|
||||
|
||||
// If it is empty, the startup failed
|
||||
if (!appRecord) {
|
||||
@ -3535,7 +3544,7 @@ void AppMgrServiceInner::StartSpecifiedAbility(const AAFwk::Want &want, const Ap
|
||||
HapModuleInfo hapModuleInfo;
|
||||
auto appInfo = std::make_shared<ApplicationInfo>(abilityInfo.applicationInfo);
|
||||
|
||||
int32_t appIndex = want.GetIntParam(DLP_PARAMS_INDEX, 0);
|
||||
int32_t appIndex = AbilityRuntime::StartupUtil::GetAppTwinIndex(want);
|
||||
if (!GetBundleAndHapInfo(abilityInfo, appInfo, bundleInfo, hapModuleInfo, appIndex)) {
|
||||
return;
|
||||
}
|
||||
@ -3587,9 +3596,8 @@ void AppMgrServiceInner::StartSpecifiedAbility(const AAFwk::Want &want, const Ap
|
||||
appRecord->SendEventForSpecifiedAbility(AMSEventHandler::START_PROCESS_SPECIFIED_ABILITY_TIMEOUT_MSG,
|
||||
AMSEventHandler::START_PROCESS_SPECIFIED_ABILITY_TIMEOUT);
|
||||
uint32_t startFlags = AppspawnUtil::BuildStartFlags(want, abilityInfo);
|
||||
int32_t bundleIndex = want.GetIntParam(DLP_PARAMS_INDEX, 0);
|
||||
StartProcess(appInfo->name, processName, startFlags, appRecord, appInfo->uid, bundleInfo, appInfo->bundleName,
|
||||
bundleIndex, appExistFlag);
|
||||
appIndex, appExistFlag);
|
||||
|
||||
appRecord->SetSpecifiedAbilityFlagAndWant(true, want, hapModuleInfo.moduleName);
|
||||
appRecord->AddModules(appInfo, hapModules);
|
||||
@ -3620,8 +3628,8 @@ void AppMgrServiceInner::RegisterStartSpecifiedAbilityResponse(const sptr<IStart
|
||||
return;
|
||||
}
|
||||
|
||||
pid_t callingPid = IPCSkeleton::GetCallingPid();
|
||||
pid_t pid = getpid();
|
||||
pid_t callingPid = IPCSkeleton::GetCallingRealPid();
|
||||
pid_t pid = getprocpid();
|
||||
if (callingPid != pid) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "%{public}s: Not abilityMgr call.", __func__);
|
||||
return;
|
||||
@ -3964,7 +3972,7 @@ int AppMgrServiceInner::GetAbilityRecordsByProcessID(const int pid, std::vector<
|
||||
}
|
||||
|
||||
auto isSaCall = AAFwk::PermissionVerification::GetInstance()->IsSACall();
|
||||
auto callingPid = IPCSkeleton::GetCallingPid();
|
||||
auto callingPid = IPCSkeleton::GetCallingRealPid();
|
||||
if (!isSaCall && callingPid != pid) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Permission verify failed.");
|
||||
return ERR_PERMISSION_DENIED;
|
||||
@ -4032,7 +4040,7 @@ int AppMgrServiceInner::VerifyProcessPermission(const std::string &bundleName) c
|
||||
auto isCallingPerm = AAFwk::PermissionVerification::GetInstance()->VerifyCallingPermission(
|
||||
AAFwk::PermissionConstants::PERMISSION_CLEAN_BACKGROUND_PROCESSES);
|
||||
if (isCallingPerm) {
|
||||
auto callerPid = IPCSkeleton::GetCallingPid();
|
||||
auto callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
auto appRecord = GetAppRunningRecordByPid(callerPid);
|
||||
if (!appRecord || appRecord->GetBundleName() != bundleName) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Permission verification failed.");
|
||||
@ -4082,7 +4090,7 @@ bool AppMgrServiceInner::CheckCallerIsAppGallery()
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ is nullptr");
|
||||
return false;
|
||||
}
|
||||
auto callerPid = IPCSkeleton::GetCallingPid();
|
||||
auto callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
auto appRecord = appRunningManager_->GetAppRunningRecordByPid(callerPid);
|
||||
if (!appRecord) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Get app running record by calling pid failed. callingPId: %{public}d", callerPid);
|
||||
@ -4116,7 +4124,7 @@ bool AppMgrServiceInner::VerifyAPL() const
|
||||
return false;
|
||||
}
|
||||
|
||||
auto callerPid = IPCSkeleton::GetCallingPid();
|
||||
auto callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
auto appRecord = appRunningManager_->GetAppRunningRecordByPid(callerPid);
|
||||
if (!appRecord) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Get app running record by calling pid failed. callingPId: %{public}d", callerPid);
|
||||
@ -4766,7 +4774,7 @@ int32_t AppMgrServiceInner::NotifyAppFault(const FaultData &faultData)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "called.");
|
||||
int32_t callerUid = IPCSkeleton::GetCallingUid();
|
||||
int32_t pid = IPCSkeleton::GetCallingPid();
|
||||
int32_t pid = IPCSkeleton::GetCallingRealPid();
|
||||
auto appRecord = GetAppRunningRecordByPid(pid);
|
||||
if (appRecord == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord");
|
||||
@ -5015,7 +5023,8 @@ int32_t AppMgrServiceInner::StartNativeProcessForDebugger(const AAFwk::Want &wan
|
||||
|
||||
AbilityInfo abilityInfo;
|
||||
auto userId = GetCurrentAccountId();
|
||||
IN_PROCESS_CALL_WITHOUT_RET(bundleMgrHelper->QueryAbilityInfo(want, GetFlag(), userId, abilityInfo));
|
||||
auto abilityInfoFlag = AbilityRuntime::StartupUtil::BuildAbilityInfoFlag();
|
||||
IN_PROCESS_CALL_WITHOUT_RET(bundleMgrHelper->QueryAbilityInfo(want, abilityInfoFlag, userId, abilityInfo));
|
||||
BundleInfo bundleInfo;
|
||||
HapModuleInfo hapModuleInfo;
|
||||
auto appInfo = std::make_shared<ApplicationInfo>(abilityInfo.applicationInfo);
|
||||
@ -5053,13 +5062,6 @@ int32_t AppMgrServiceInner::StartNativeProcessForDebugger(const AAFwk::Want &wan
|
||||
}
|
||||
}
|
||||
|
||||
int32_t AppMgrServiceInner::GetFlag() const
|
||||
{
|
||||
return AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_PERMISSION |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_METADATA;
|
||||
}
|
||||
|
||||
int32_t AppMgrServiceInner::GetCurrentAccountId() const
|
||||
{
|
||||
std::vector<int32_t> osActiveAccountIds;
|
||||
@ -5766,7 +5768,7 @@ int32_t AppMgrServiceInner::GetChildProcessInfoForSelf(ChildProcessInfo &info)
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "appRunningManager_ is null");
|
||||
return ERR_NO_INIT;
|
||||
}
|
||||
auto callingPid = IPCSkeleton::GetCallingPid();
|
||||
auto callingPid = IPCSkeleton::GetCallingRealPid();
|
||||
if (appRunningManager_->GetAppRunningRecordByPid(callingPid)) {
|
||||
TAG_LOGD(AAFwkTag::APPMGR, "record of callingPid is not child record.");
|
||||
return ERR_NAME_NOT_FOUND;
|
||||
@ -6056,7 +6058,8 @@ void AppMgrServiceInner::SendAppLaunchEvent(const std::shared_ptr<AppRunningReco
|
||||
eventInfo.pid = appRecord->GetPriorityObject()->GetPid();
|
||||
}
|
||||
eventInfo.processName = appRecord->GetProcessName();
|
||||
int32_t callerPid = appRecord->GetCallerPid() == -1 ? IPCSkeleton::GetCallingPid() : appRecord->GetCallerPid();
|
||||
int32_t callerPid = appRecord->GetCallerPid() == -1 ?
|
||||
IPCSkeleton::GetCallingRealPid() : appRecord->GetCallerPid();
|
||||
auto callerRecord = GetAppRunningRecordByPid(callerPid);
|
||||
if (callerRecord != nullptr) {
|
||||
eventInfo.callerBundleName = callerRecord->GetBundleName();
|
||||
@ -6080,7 +6083,7 @@ bool AppMgrServiceInner::IsFinalAppProcessByBundleName(const std::string &bundle
|
||||
|
||||
auto name = bundleName;
|
||||
if (bundleName.empty()) {
|
||||
auto callingPid = IPCSkeleton::GetCallingPid();
|
||||
auto callingPid = IPCSkeleton::GetCallingRealPid();
|
||||
auto appRecord = appRunningManager_->GetAppRunningRecordByPid(callingPid);
|
||||
if (appRecord == nullptr) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "Get app running record is nullptr.");
|
||||
@ -6198,7 +6201,7 @@ void AppMgrServiceInner::SetAppAssertionPauseState(int32_t pid, bool flag)
|
||||
|
||||
int32_t AppMgrServiceInner::UpdateRenderState(pid_t renderPid, int32_t state)
|
||||
{
|
||||
int32_t hostPid = IPCSkeleton::GetCallingPid();
|
||||
int32_t hostPid = IPCSkeleton::GetCallingRealPid();
|
||||
auto appRecord = GetAppRunningRecordByPid(hostPid);
|
||||
if (!appRecord) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "No such appRecord, hostPid:%{public}d", hostPid);
|
||||
@ -6210,6 +6213,7 @@ int32_t AppMgrServiceInner::UpdateRenderState(pid_t renderPid, int32_t state)
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "renderPid:%{pubclic}d not exist.", renderPid);
|
||||
return ERR_INVALID_VALUE;
|
||||
}
|
||||
renderRecord->SetState(state);
|
||||
return DelayedSingleton<RenderStateObserverManager>::GetInstance()->OnRenderStateChanged(
|
||||
renderRecord, state);
|
||||
}
|
||||
@ -6389,7 +6393,7 @@ int32_t AppMgrServiceInner::SetSupportedProcessCacheSelf(bool isSupport)
|
||||
return result;
|
||||
}
|
||||
|
||||
auto callerPid = IPCSkeleton::GetCallingPid();
|
||||
auto callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
auto appRecord = GetAppRunningRecordByPid(callerPid);
|
||||
if (!appRecord) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "no such appRecord, callerPid:%{public}d", callerPid);
|
||||
@ -6408,8 +6412,6 @@ int32_t AppMgrServiceInner::CheckSetProcessCachePermission() const
|
||||
HITRACE_METER_NAME(HITRACE_TAG_APP, __PRETTY_FUNCTION__);
|
||||
CHECK_CALLER_IS_SYSTEM_APP;
|
||||
auto isCallingPerm = AAFwk::PermissionVerification::GetInstance()->VerifySetProcessCachePermission();
|
||||
// for test purpose
|
||||
isCallingPerm = true;
|
||||
TAG_LOGI(AAFwkTag::APPMGR, "ProcessCache permission: %{public}d", isCallingPerm);
|
||||
return isCallingPerm ? ERR_OK : AAFwk::CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "hitrace_meter.h"
|
||||
#include "res_sched_client.h"
|
||||
#include "res_type.h"
|
||||
#include "startup_util.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AppExecFwk {
|
||||
@ -114,9 +115,7 @@ bool AppPreloader::GetLaunchAbilityInfo(const AAFwk::Want &want, int32_t userId,
|
||||
return false;
|
||||
}
|
||||
|
||||
auto abilityInfoFlag = (AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_APPLICATION |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_PERMISSION |
|
||||
AppExecFwk::AbilityInfoFlag::GET_ABILITY_INFO_WITH_METADATA);
|
||||
auto abilityInfoFlag = AbilityRuntime::StartupUtil::BuildAbilityInfoFlag();
|
||||
if (!IN_PROCESS_CALL(bundleMgrHelper->QueryAbilityInfo(want, abilityInfoFlag, userId, abilityInfo))) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication GetLaunchAbilityInfo failed.");
|
||||
return false;
|
||||
|
@ -178,6 +178,16 @@ void RenderRecord::RegisterDeathRecipient()
|
||||
}
|
||||
}
|
||||
|
||||
void RenderRecord::SetState(int32_t state)
|
||||
{
|
||||
state_ = state;
|
||||
}
|
||||
|
||||
int32_t RenderRecord::GetState() const
|
||||
{
|
||||
return state_;
|
||||
}
|
||||
|
||||
AppRunningRecord::AppRunningRecord(
|
||||
const std::shared_ptr<ApplicationInfo> &info, const int32_t recordId, const std::string &processName)
|
||||
: appRecordId_(recordId), processName_(processName)
|
||||
|
@ -52,6 +52,8 @@ config("common_config") {
|
||||
|
||||
#build so
|
||||
ohos_shared_library("perm_verification") {
|
||||
include_dirs = [ "${ability_runtime_utils_path}/server/constant" ]
|
||||
|
||||
public_configs = [ ":common_config" ]
|
||||
|
||||
sources = [ "src/permission_verification.cpp" ]
|
||||
|
@ -73,9 +73,9 @@ public:
|
||||
bool ClickIconContinue(const std::string& func);
|
||||
bool ClickIconStartAbility(const std::string& func, int32_t errCode);
|
||||
bool ClickIconRecvOver(const std::string& func);
|
||||
bool SaveDataContinue(const std::string& func, int32_t errCode);
|
||||
bool SaveDataContinue(const std::string& func);
|
||||
bool SaveDataRes(const std::string& func);
|
||||
bool SaveDataRemoteWant(const std::string& func, int32_t errCode);
|
||||
bool SaveDataRemoteWant(const std::string& func);
|
||||
};
|
||||
} // namespace AAFWK
|
||||
} // namespace OHOS
|
||||
|
@ -53,6 +53,7 @@ const std::unordered_set<AppExecFwk::ExtensionAbilityType> UI_EXTENSION_SET = {
|
||||
AppExecFwk::ExtensionAbilityType::SYSPICKER_NAVIGATION,
|
||||
AppExecFwk::ExtensionAbilityType::SYSPICKER_APPSELECTOR,
|
||||
AppExecFwk::ExtensionAbilityType::SYSPICKER_CAMERA,
|
||||
AppExecFwk::ExtensionAbilityType::SYSPICKER_FILEPICKER,
|
||||
AppExecFwk::ExtensionAbilityType::AUTO_FILL_SMART,
|
||||
AppExecFwk::ExtensionAbilityType::LIVEVIEW_LOCKSCREEN
|
||||
};
|
||||
|
@ -99,32 +99,17 @@ bool ContinueRadar::ClickIconRecvOver(const std::string& func)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContinueRadar::SaveDataContinue(const std::string& func, int32_t errCode)
|
||||
bool ContinueRadar::SaveDataContinue(const std::string& func)
|
||||
{
|
||||
int32_t res = ERR_OK;
|
||||
StageRes stageRes = (errCode == ERR_OK) ? StageRes::STAGE_SUCC : StageRes::STAGE_FAIL;
|
||||
if (stageRes == StageRes::STAGE_SUCC) {
|
||||
res = HiSysEventWrite(
|
||||
APP_CONTINUE_DOMAIN,
|
||||
APPLICATION_CONTINUE_BEHAVIOR,
|
||||
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
|
||||
ORG_PKG, ORG_PKG_NAME,
|
||||
FUNC, func,
|
||||
BIZ_SCENE, static_cast<int32_t>(BizScene::SAVE_DATA),
|
||||
BIZ_STAGE, static_cast<int32_t>(SaveData::SAVEDATA_CONTINUE),
|
||||
STAGE_RES, static_cast<int32_t>(StageRes::STAGE_SUCC));
|
||||
} else {
|
||||
res = HiSysEventWrite(
|
||||
APP_CONTINUE_DOMAIN,
|
||||
APPLICATION_CONTINUE_BEHAVIOR,
|
||||
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
|
||||
ORG_PKG, ORG_PKG_NAME,
|
||||
FUNC, func,
|
||||
BIZ_SCENE, static_cast<int32_t>(BizScene::SAVE_DATA),
|
||||
BIZ_STAGE, static_cast<int32_t>(SaveData::SAVEDATA_CONTINUE),
|
||||
STAGE_RES, static_cast<int32_t>(StageRes::STAGE_FAIL),
|
||||
ERROR_CODE, errCode);
|
||||
}
|
||||
int32_t res = HiSysEventWrite(
|
||||
APP_CONTINUE_DOMAIN,
|
||||
APPLICATION_CONTINUE_BEHAVIOR,
|
||||
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
|
||||
ORG_PKG, ORG_PKG_NAME,
|
||||
FUNC, func,
|
||||
BIZ_SCENE, static_cast<int32_t>(BizScene::SAVE_DATA),
|
||||
BIZ_STAGE, static_cast<int32_t>(SaveData::SAVEDATA_CONTINUE),
|
||||
STAGE_RES, static_cast<int32_t>(StageRes::STAGE_SUCC));
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "SaveDataContinue error, res:%{public}d", res);
|
||||
return false;
|
||||
@ -150,35 +135,18 @@ bool ContinueRadar::SaveDataRes(const std::string& func)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ContinueRadar::SaveDataRemoteWant(const std::string& func, int32_t errCode)
|
||||
bool ContinueRadar::SaveDataRemoteWant(const std::string& func)
|
||||
{
|
||||
int32_t res = ERR_OK;
|
||||
StageRes stageRes = (errCode == ERR_OK) ? StageRes::STAGE_SUCC : StageRes::STAGE_FAIL;
|
||||
if (stageRes == StageRes::STAGE_SUCC) {
|
||||
res = HiSysEventWrite(
|
||||
APP_CONTINUE_DOMAIN,
|
||||
APPLICATION_CONTINUE_BEHAVIOR,
|
||||
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
|
||||
ORG_PKG, ORG_PKG_NAME,
|
||||
FUNC, func,
|
||||
BIZ_SCENE, static_cast<int32_t>(BizScene::SAVE_DATA),
|
||||
BIZ_STAGE, static_cast<int32_t>(SaveData::SAVEDATA_REMOTE_WANT),
|
||||
STAGE_RES, static_cast<int32_t>(StageRes::STAGE_SUCC),
|
||||
TO_CALL_PKG, DMS_PKG_NAME);
|
||||
} else {
|
||||
res = HiSysEventWrite(
|
||||
APP_CONTINUE_DOMAIN,
|
||||
APPLICATION_CONTINUE_BEHAVIOR,
|
||||
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
|
||||
ORG_PKG, ORG_PKG_NAME,
|
||||
FUNC, func,
|
||||
BIZ_SCENE, static_cast<int32_t>(BizScene::SAVE_DATA),
|
||||
BIZ_STAGE, static_cast<int32_t>(SaveData::SAVEDATA_REMOTE_WANT),
|
||||
STAGE_RES, static_cast<int32_t>(StageRes::STAGE_FAIL),
|
||||
"BIZ_STATE", static_cast<int32_t>(BizState::BIZ_STATE_END),
|
||||
TO_CALL_PKG, DMS_PKG_NAME,
|
||||
ERROR_CODE, errCode);
|
||||
}
|
||||
int32_t res = HiSysEventWrite(
|
||||
APP_CONTINUE_DOMAIN,
|
||||
APPLICATION_CONTINUE_BEHAVIOR,
|
||||
HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
|
||||
ORG_PKG, ORG_PKG_NAME,
|
||||
FUNC, func,
|
||||
BIZ_SCENE, static_cast<int32_t>(BizScene::SAVE_DATA),
|
||||
BIZ_STAGE, static_cast<int32_t>(SaveData::SAVEDATA_REMOTE_WANT),
|
||||
STAGE_RES, static_cast<int32_t>(StageRes::STAGE_SUCC),
|
||||
TO_CALL_PKG, DMS_PKG_NAME);
|
||||
if (res != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "SaveDataRemoteWant error, res:%{public}d", res);
|
||||
return false;
|
||||
|
@ -149,6 +149,7 @@ void EventReport::SendAbilityEvent(const EventName &eventName, HiSysEventType ty
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "invalid eventName");
|
||||
return;
|
||||
}
|
||||
HILOG_DEBUG("EventName is %{public}s", name.c_str());
|
||||
switch (eventName) {
|
||||
case EventName::START_ABILITY_ERROR:
|
||||
case EventName::TERMINATE_ABILITY_ERROR:
|
||||
@ -216,6 +217,8 @@ void EventReport::SendAbilityEvent(const EventName &eventName, HiSysEventType ty
|
||||
EVENT_KEY_CALLER_BUNDLE_NAME, eventInfo.callerBundleName);
|
||||
break;
|
||||
case EventName::START_STANDARD_ABILITIES:
|
||||
HILOG_DEBUG("EventInfo is [%{public}d, %{public}s, %{public}s, %{public}s]", eventInfo.userId,
|
||||
eventInfo.bundleName.c_str(), eventInfo.moduleName.c_str(), eventInfo.abilityName.c_str());
|
||||
HiSysEventWrite(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
name,
|
||||
@ -334,7 +337,7 @@ void EventReport::SendAppForegroundEvent(const EventName &eventName, const Event
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "invalid eventName");
|
||||
return;
|
||||
}
|
||||
HiSysEventWrite(
|
||||
auto ret = HiSysEventWrite(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
name,
|
||||
HiSysEventType::BEHAVIOR,
|
||||
@ -346,6 +349,9 @@ void EventReport::SendAppForegroundEvent(const EventName &eventName, const Event
|
||||
EVENT_KEY_BUNDLE_TYPE, eventInfo.bundleType,
|
||||
EVENT_KEY_CALLER_BUNDLE_NAME, eventInfo.callerBundleName,
|
||||
EVENT_KEY_PROCESS_TYPE, eventInfo.processType);
|
||||
if (ret != 0) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Write event fail: %{public}s, ret %{public}d", name.c_str(), ret);
|
||||
}
|
||||
}
|
||||
|
||||
void EventReport::SendAppBackgroundEvent(const EventName &eventName, const EventInfo &eventInfo)
|
||||
@ -355,7 +361,7 @@ void EventReport::SendAppBackgroundEvent(const EventName &eventName, const Event
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "invalid eventName");
|
||||
return;
|
||||
}
|
||||
HiSysEventWrite(
|
||||
auto ret = HiSysEventWrite(
|
||||
HiSysEvent::Domain::AAFWK,
|
||||
name,
|
||||
HiSysEventType::BEHAVIOR,
|
||||
@ -366,6 +372,9 @@ void EventReport::SendAppBackgroundEvent(const EventName &eventName, const Event
|
||||
EVENT_KEY_PROCESS_NAME, eventInfo.processName,
|
||||
EVENT_KEY_BUNDLE_TYPE, eventInfo.bundleType,
|
||||
EVENT_KEY_PROCESS_TYPE, eventInfo.processType);
|
||||
if (ret != 0) {
|
||||
TAG_LOGE(AAFwkTag::DEFAULT, "Write event fail: %{public}s, ret %{public}d", name.c_str(), ret);
|
||||
}
|
||||
}
|
||||
|
||||
void EventReport::SendProcessStartEvent(const EventName &eventName, const EventInfo &eventInfo)
|
||||
|
@ -21,13 +21,13 @@
|
||||
#include "hilog_wrapper.h"
|
||||
#include "hitrace_meter.h"
|
||||
#include "permission_constants.h"
|
||||
#include "server_constant.h"
|
||||
#include "support_system_ability_permission.h"
|
||||
#include "tokenid_kit.h"
|
||||
#include "hilog_tag_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace AAFwk {
|
||||
const std::string DLP_PARAMS_INDEX = "ohos.dlp.params.index";
|
||||
const std::string DLP_PARAMS_SECURITY_FLAG = "ohos.dlp.params.securityFlag";
|
||||
namespace {
|
||||
const int32_t SHELL_START_EXTENSION_FLOOR = 0; // FORM
|
||||
@ -152,7 +152,7 @@ bool PermissionVerification::VerifyControllerPerm() const
|
||||
|
||||
bool PermissionVerification::VerifyDlpPermission(Want &want) const
|
||||
{
|
||||
if (want.GetIntParam(DLP_PARAMS_INDEX, 0) == 0) {
|
||||
if (want.GetIntParam(AbilityRuntime::ServerConstant::DLP_INDEX, 0) == 0) {
|
||||
want.RemoveParam(DLP_PARAMS_SECURITY_FLAG);
|
||||
return true;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
"app": {
|
||||
"bundleName": "com.ohos.amsdialog",
|
||||
"vendor": "example",
|
||||
"versionCode": 1000001,
|
||||
"versionCode": 1000002,
|
||||
"versionName": "1.0.0",
|
||||
"icon": "$media:app_icon",
|
||||
"label": "$string:app_name",
|
||||
|
@ -89,6 +89,9 @@
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.NOTIFY_DEBUG_ASSERT_RESULT"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.GET_BUNDLE_RESOURCES"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
Binary file not shown.
@ -134,6 +134,8 @@ private:
|
||||
|
||||
bool IsSAOrSystemAppCall();
|
||||
|
||||
bool IsLinuxFusionCall();
|
||||
|
||||
class ProxyDeathRecipient : public IRemoteObject::DeathRecipient {
|
||||
public:
|
||||
explicit ProxyDeathRecipient(ClearProxyCallback&& proxy) : proxy_(proxy) {}
|
||||
|
@ -47,6 +47,7 @@ constexpr int32_t ERR_OK = 0;
|
||||
constexpr uint32_t FLAG_READ_WRITE_URI = Want::FLAG_AUTH_READ_URI_PERMISSION | Want::FLAG_AUTH_WRITE_URI_PERMISSION;
|
||||
constexpr const char* CLOUND_DOCS_URI_MARK = "?networkid=";
|
||||
constexpr const char* FOUNDATION_PROCESS_NAME = "foundation";
|
||||
constexpr const char* LINUX_FUSION_SERVICE = "linux_fusion_service";
|
||||
}
|
||||
|
||||
bool UriPermissionManagerStubImpl::VerifyUriPermission(const Uri &uri, uint32_t flag, uint32_t tokenId)
|
||||
@ -133,7 +134,8 @@ int32_t UriPermissionManagerStubImpl::GrantUriPermissionPrivileged(const std::ve
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "callerTokenId is %{public}u, callerName is %{public}s",
|
||||
callerTokenId, callerName.c_str());
|
||||
auto permissionName = PermissionConstants::PERMISSION_GRANT_URI_PERMISSION_PRIVILEGED;
|
||||
if (!PermissionVerification::GetInstance()->VerifyPermissionByTokenId(callerTokenId, permissionName)) {
|
||||
if (!PermissionVerification::GetInstance()->VerifyPermissionByTokenId(callerTokenId, permissionName) &&
|
||||
!IsLinuxFusionCall()) {
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "No permission to call.");
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
}
|
||||
@ -215,7 +217,7 @@ int32_t UriPermissionManagerStubImpl::CheckCalledBySandBox()
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Get BundleManager failed!");
|
||||
return INNER_ERR;
|
||||
}
|
||||
auto callerPid = IPCSkeleton::GetCallingPid();
|
||||
auto callerPid = IPCSkeleton::GetCallingRealPid();
|
||||
bool isSandbox = false;
|
||||
if (appMgr_->JudgeSandboxByPid(callerPid, isSandbox) != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "JudgeSandboxByPid failed.");
|
||||
@ -441,12 +443,12 @@ int32_t UriPermissionManagerStubImpl::GrantBatchUriPermissionFor2In1Privileged(c
|
||||
policyInfo.mode = (flag & Want::FLAG_AUTH_WRITE_URI_PERMISSION) == 0 ? READ_MODE : WRITE_MODE;
|
||||
docsVec.emplace_back(policyInfo);
|
||||
}
|
||||
|
||||
|
||||
if (uriStrVec.empty() && docsVec.empty()) {
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "Valid uri list is empty.");
|
||||
return ERR_CODE_INVALID_URI_TYPE;
|
||||
}
|
||||
|
||||
|
||||
if (!uriStrVec.empty()) {
|
||||
auto ret = GrantBatchUriPermissionImpl(uriStrVec, flag, callerTokenId, targetTokenId, autoRemove);
|
||||
if (docsVec.empty()) {
|
||||
@ -556,7 +558,7 @@ int UriPermissionManagerStubImpl::RevokeUriPermissionManually(const Uri &uri, co
|
||||
if (ret != ERR_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
auto uriStr = uri.ToString();
|
||||
auto uriInner = uri;
|
||||
uint32_t authorityTokenId = 0;
|
||||
@ -836,6 +838,25 @@ bool UriPermissionManagerStubImpl::IsFoundationCall()
|
||||
return nativeInfo.processName == FOUNDATION_PROCESS_NAME;
|
||||
}
|
||||
|
||||
bool UriPermissionManagerStubImpl::IsLinuxFusionCall()
|
||||
{
|
||||
auto callerTokenId = IPCSkeleton::GetCallingTokenID();
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "callerTokenId is %{public}u", callerTokenId);
|
||||
auto tokenType = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(callerTokenId);
|
||||
if (tokenType != Security::AccessToken::ATokenTypeEnum::TOKEN_NATIVE) {
|
||||
TAG_LOGI(AAFwkTag::ABILITYMGR, "Is not native call");
|
||||
return false;
|
||||
}
|
||||
Security::AccessToken::NativeTokenInfo nativeInfo;
|
||||
auto result = Security::AccessToken::AccessTokenKit::GetNativeTokenInfo(callerTokenId, nativeInfo);
|
||||
if (result != ERR_OK) {
|
||||
TAG_LOGE(AAFwkTag::URIPERMMGR, "GetNativeTokenInfo failed, callerTokenId is %{public}u.", callerTokenId);
|
||||
return false;
|
||||
}
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "Caller process name : %{public}s", nativeInfo.processName.c_str());
|
||||
return nativeInfo.processName == LINUX_FUSION_SERVICE;
|
||||
}
|
||||
|
||||
std::string UriPermissionManagerStubImpl::GetTokenName(uint32_t callerTokenId)
|
||||
{
|
||||
auto tokenType = Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(callerTokenId);
|
||||
@ -931,6 +952,10 @@ bool UriPermissionManagerStubImpl::CheckUriPermission(Uri uri, uint32_t flag, To
|
||||
{
|
||||
auto &&authority = uri.GetAuthority();
|
||||
TAG_LOGD(AAFwkTag::URIPERMMGR, "Authority of uri is %{public}s", authority.c_str());
|
||||
if (IsLinuxFusionCall()) {
|
||||
TAG_LOGI(AAFwkTag::URIPERMMGR, "Caller is linux_fusion_service.");
|
||||
return true;
|
||||
}
|
||||
if (authority == "docs") {
|
||||
return AccessDocsUriPermission(tokenIdPermission, uri, flag);
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ public:
|
||||
MOCK_METHOD1(RegisterRenderStateObserver, int32_t(const sptr<IRenderStateObserver> &observer));
|
||||
MOCK_METHOD1(UnregisterRenderStateObserver, int32_t(const sptr<IRenderStateObserver> &observer));
|
||||
MOCK_METHOD2(UpdateRenderState, int32_t(pid_t renderPid, int32_t state));
|
||||
MOCK_METHOD1(SetSupportedProcessCacheSelf, int32_t(bool isSupported));
|
||||
|
||||
void AttachApplication(const sptr<IRemoteObject>& app)
|
||||
{
|
||||
|
@ -89,6 +89,28 @@ public:
|
||||
SetSelfTokenID(tokenId);
|
||||
Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
|
||||
}
|
||||
|
||||
static void IsMockProcessCachePermission()
|
||||
{
|
||||
uint64_t tokenId;
|
||||
const char* perms[] = {
|
||||
perms[0] = "ohos.permission.SET_PROCESS_CACHE_STATE",
|
||||
};
|
||||
|
||||
NativeTokenInfoParams infoInstance = {
|
||||
.dcapsNum = 0,
|
||||
.permsNum = static_cast<int32_t>(sizeof(perms)/sizeof(perms[0])),
|
||||
.aclsNum = 0,
|
||||
.dcaps = nullptr,
|
||||
.perms = perms,
|
||||
.acls = nullptr,
|
||||
.aplStr = "system_core",
|
||||
};
|
||||
infoInstance.processName = "distributedsched";
|
||||
tokenId = GetAccessTokenId(&infoInstance);
|
||||
SetSelfTokenID(tokenId);
|
||||
Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
|
||||
}
|
||||
};
|
||||
} // namespace OHOS::AAFwk
|
||||
#endif // UNITTEST_OHOS_ABILITY_RUNTIME_IS_SA_CALL_TEST_H
|
@ -61,6 +61,7 @@ ohos_moduletest("ability_timeout_module_test") {
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
|
||||
"${ability_runtime_native_path}/ability/native:abilitykit_native",
|
||||
"${ability_runtime_path}/utils/server/startup:startup_util",
|
||||
"${ability_runtime_services_path}/abilitymgr:abilityms",
|
||||
"${ability_runtime_services_path}/common:event_report",
|
||||
"${ability_runtime_services_path}/common:perm_verification",
|
||||
|
@ -63,6 +63,7 @@ ohos_moduletest("running_infos_module_test") {
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
|
||||
"${ability_runtime_native_path}/ability/native:abilitykit_native",
|
||||
"${ability_runtime_path}/utils/server/startup:startup_util",
|
||||
"${ability_runtime_services_path}/abilitymgr:abilityms",
|
||||
"${ability_runtime_services_path}/common:event_report",
|
||||
"${ability_runtime_services_path}/common:perm_verification",
|
||||
|
@ -218,6 +218,7 @@ ohos_source_set("abilityms_test_source") {
|
||||
"${ability_runtime_innerkits_path}/connectionobs_manager:connection_obs_manager",
|
||||
"${ability_runtime_innerkits_path}/uri_permission:uri_permission_mgr",
|
||||
"${ability_runtime_path}/utils/global/freeze:freeze_util",
|
||||
"${ability_runtime_path}/utils/server/startup:startup_util",
|
||||
"${ability_runtime_services_path}/abilitymgr:abilityms",
|
||||
"${ability_runtime_services_path}/common:task_handler_wrap",
|
||||
]
|
||||
@ -486,6 +487,7 @@ group("unittest") {
|
||||
"services/ability_util_test:unittest",
|
||||
"start_options_test:unittest",
|
||||
"start_other_app_interceptor_test:unittest",
|
||||
"startup_util_test:unittest",
|
||||
"stop_user_callback_proxy_test:unittest",
|
||||
"stop_user_callback_stub_test:unittest",
|
||||
"sys_mgr_client_test:unittest",
|
||||
|
@ -49,6 +49,7 @@ ohos_unittest("ability_interceptor_test") {
|
||||
"${ability_runtime_innerkits_path}/app_manager:app_manager",
|
||||
"${ability_runtime_native_path}/ability/native:abilitykit_native",
|
||||
"${ability_runtime_native_path}/appkit:appkit_manager_helper",
|
||||
"${ability_runtime_path}/utils/server/startup:startup_util",
|
||||
"${ability_runtime_services_path}/abilitymgr:abilityms",
|
||||
"${ability_runtime_services_path}/common:perm_verification",
|
||||
"${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/aakit:aakit_mock",
|
||||
|
@ -2763,5 +2763,45 @@ HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_RestartApp_0100, TestSize.
|
||||
proxy_->RestartApp(want);
|
||||
EXPECT_EQ(static_cast<uint32_t>(AbilityManagerInterfaceCode::RESTART_APP), mock_->code_);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbilityManagerProxy_ChangeAbilityVisibility_0100
|
||||
* @tc.desc: ChangeAbilityVisibility
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ChangeAbilityVisibility_0100, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin");
|
||||
|
||||
EXPECT_CALL(*mock_, SendRequest(_, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(mock_.GetRefPtr(), &AbilityManagerStubMock::InvokeSendRequest));
|
||||
|
||||
auto token = sptr<MockAbilityToken>::MakeSptr();
|
||||
proxy_->ChangeAbilityVisibility(token, true);
|
||||
EXPECT_EQ(static_cast<uint32_t>(AbilityManagerInterfaceCode::CHANGE_ABILITY_VISIBILITY), mock_->code_);
|
||||
|
||||
TAG_LOGI(AAFwkTag::TEST, "end");
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbilityManagerProxy_ChangeUIAbilityVisibilityBySCB_0100
|
||||
* @tc.desc: ChangeUIAbilityVisibilityBySCB
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(AbilityManagerProxyTest, AbilityManagerProxy_ChangeUIAbilityVisibilityBySCB_0100, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "begin");
|
||||
|
||||
EXPECT_CALL(*mock_, SendRequest(_, _, _, _))
|
||||
.Times(1)
|
||||
.WillOnce(Invoke(mock_.GetRefPtr(), &AbilityManagerStubMock::InvokeSendRequest));
|
||||
|
||||
sptr<SessionInfo> session = new (std::nothrow) SessionInfo();
|
||||
proxy_->ChangeUIAbilityVisibilityBySCB(session, true);
|
||||
EXPECT_EQ(static_cast<uint32_t>(AbilityManagerInterfaceCode::CHANGE_UI_ABILITY_VISIBILITY_BY_SCB), mock_->code_);
|
||||
|
||||
TAG_LOGI(AAFwkTag::TEST, "end");
|
||||
}
|
||||
} // namespace AAFwk
|
||||
} // namespace OHOS
|
||||
|
@ -1016,7 +1016,7 @@ HWTEST_F(AbilityManagerServiceFirstTest, StopExtensionAbility_002, TestSize.Leve
|
||||
abilityRecord->appIndex_ = -1;
|
||||
abilityRecord->applicationInfo_.bundleName = "com.ix.hiservcie";
|
||||
EXPECT_EQ(abilityMs_->StopExtensionAbility(want, abilityRecord->GetToken(), -1, ExtensionAbilityType::SERVICE),
|
||||
ERR_INVALID_CALLER);
|
||||
CHECK_PERMISSION_FAILED);
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFirstTest StopExtensionAbility_002 end");
|
||||
}
|
||||
|
||||
|
@ -248,10 +248,10 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_007, TestSize.Level1)
|
||||
sptr<IAbilityConnection> connect = new AbilityConnectCallback();
|
||||
WriteInterfaceToken(data);
|
||||
data.WriteParcelable(connect->AsObject());
|
||||
int res = stub_->OnRemoteRequest(static_cast<uint32_t>(AbilityManagerInterfaceCode::DISCONNECT_ABILITY),
|
||||
stub_->OnRemoteRequest(static_cast<uint32_t>(AbilityManagerInterfaceCode::DISCONNECT_ABILITY),
|
||||
data, reply, option);
|
||||
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
EXPECT_TRUE(stub_ != nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -273,10 +273,10 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_008, TestSize.Level1)
|
||||
WriteInterfaceToken(data);
|
||||
data.WriteParcelable(scheduler->AsObject());
|
||||
data.WriteParcelable(token);
|
||||
int res = stub_->OnRemoteRequest(static_cast<uint32_t>(AbilityManagerInterfaceCode::ATTACH_ABILITY_THREAD),
|
||||
stub_->OnRemoteRequest(static_cast<uint32_t>(AbilityManagerInterfaceCode::ATTACH_ABILITY_THREAD),
|
||||
data, reply, option);
|
||||
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
EXPECT_TRUE(stub_ != nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -442,10 +442,10 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_018, TestSize.Level1)
|
||||
WriteInterfaceToken(data);
|
||||
want.SetFlags(10);
|
||||
data.WriteParcelable(&want);
|
||||
int res = stub_->OnRemoteRequest(static_cast<uint32_t>(AbilityManagerInterfaceCode::START_CALL_ABILITY),
|
||||
stub_->OnRemoteRequest(static_cast<uint32_t>(AbilityManagerInterfaceCode::START_CALL_ABILITY),
|
||||
data, reply, option);
|
||||
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
EXPECT_TRUE(stub_ != nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -588,8 +588,8 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_AttachAbilityThreadInner_001
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->AttachAbilityThreadInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
stub_->AttachAbilityThreadInner(data, reply);
|
||||
EXPECT_TRUE(stub_ != nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -700,8 +700,8 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_ReleaseDataAbilityInner_001,
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->ReleaseDataAbilityInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
stub_->ReleaseDataAbilityInner(data, reply);
|
||||
EXPECT_TRUE(stub_ != nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -924,8 +924,8 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_DisconnectAbilityInner_001,
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
auto res = stub_->DisconnectAbilityInner(data, reply);
|
||||
EXPECT_EQ(res, NO_ERROR);
|
||||
stub_->DisconnectAbilityInner(data, reply);
|
||||
EXPECT_TRUE(stub_ != nullptr);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -86,7 +86,7 @@ HWTEST_F(AbilityManagerTest, AbilityManagerTest_0300, TestSize.Level1)
|
||||
{
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerTest_0300 is start");
|
||||
const std::string bundleName = "test";
|
||||
auto res = AbilityManager::GetInstance().ClearUpApplicationData(bundleName);
|
||||
auto res = AAFwk::AbilityManagerClient::GetInstance()->ClearUpApplicationData(bundleName);
|
||||
EXPECT_NE(res, ERR_NULL_OBJECT);
|
||||
TAG_LOGI(AAFwkTag::TEST, "AbilityManagerTest_0300 is end");
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user