mirror of
https://github.com/openharmony/ability_ability_runtime.git
synced 2026-08-25 12:23:20 -04:00
!13429 本地调试拦截放行
Merge pull request !13429 from songjindian/require_debug5
This commit is contained in:
@@ -552,7 +552,8 @@ int AbilityManagerService::StartAbility(const Want &want, int32_t userId, int re
|
||||
isDebugFromLocal);
|
||||
bool checkDeveloperModeFlag = (isDebugApp || hasWindowOptions || isNativeDebugApp || isDebugFromLocal);
|
||||
if (checkDeveloperModeFlag) {
|
||||
if (isDebugFromLocal && !AAFwk::PermissionVerification::GetInstance()-> VerifyStartLocalDebug()) {
|
||||
if (isDebugFromLocal &&
|
||||
!AAFwk::PermissionVerification::GetInstance()->VerifyStartLocalDebug(IPCSkeleton::GetCallingTokenID())) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "local debugging, permission denied");
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
} else if (!isDebugFromLocal && !system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) {
|
||||
@@ -6844,6 +6845,24 @@ int AbilityManagerService::GenerateAbilityRequest(const Want &want, int requestC
|
||||
}
|
||||
|
||||
if (ModalSystemDialogUtil::CheckDebugAppNotInDeveloperMode(request.abilityInfo.applicationInfo)) {
|
||||
// local debug do not show dialog.
|
||||
if (AAFwk::PermissionVerification::GetInstance()->VerifyStartLocalDebug(IPCSkeleton::GetCallingTokenID())) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "local debug");
|
||||
return ERR_OK;
|
||||
}
|
||||
if (AAFwk::PermissionVerification::GetInstance()->VerifyStartLocalDebug(
|
||||
request.want.GetIntParam(Want::PARAM_RESV_CALLER_TOKEN, 0))) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "real call is local debug");
|
||||
return ERR_OK;
|
||||
}
|
||||
if (abilityRecord != nullptr) {
|
||||
std::string targetBundleName = request.want.GetStringParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME);
|
||||
std::string callerBundleName = abilityRecord->GetApplicationInfo().bundleName;
|
||||
if (targetBundleName.compare(callerBundleName) ==0) {
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "same bundle");
|
||||
return ERR_OK;
|
||||
}
|
||||
}
|
||||
// service and extension do not show dialog.
|
||||
if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled() &&
|
||||
!(request.abilityInfo.type == AppExecFwk::AbilityType::SERVICE ||
|
||||
@@ -11364,7 +11383,8 @@ std::shared_ptr<AbilityDebugDeal> AbilityManagerService::ConnectInitAbilityDebug
|
||||
int32_t AbilityManagerService::AttachAppDebug(const std::string &bundleName, bool isDebugFromLocal)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
|
||||
if (isDebugFromLocal && !AAFwk::PermissionVerification::GetInstance()-> VerifyStartLocalDebug()) {
|
||||
if (isDebugFromLocal &&
|
||||
!AAFwk::PermissionVerification::GetInstance()->VerifyStartLocalDebug(IPCSkeleton::GetCallingTokenID())) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "local debugging, permission denied");
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
} else if (!isDebugFromLocal && !system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) {
|
||||
@@ -11392,7 +11412,8 @@ int32_t AbilityManagerService::AttachAppDebug(const std::string &bundleName, boo
|
||||
int32_t AbilityManagerService::DetachAppDebug(const std::string &bundleName, bool isDebugFromLocal)
|
||||
{
|
||||
TAG_LOGD(AAFwkTag::ABILITYMGR, "called");
|
||||
if (isDebugFromLocal && !AAFwk::PermissionVerification::GetInstance()-> VerifyStartLocalDebug()) {
|
||||
if (isDebugFromLocal &&
|
||||
!AAFwk::PermissionVerification::GetInstance()->VerifyStartLocalDebug(IPCSkeleton::GetCallingTokenID())) {
|
||||
TAG_LOGE(AAFwkTag::ABILITYMGR, "local debugging, permission denied");
|
||||
return CHECK_PERMISSION_FAILED;
|
||||
} else if (!isDebugFromLocal && !system::GetBoolParameter(DEVELOPER_MODE_STATE, false)) {
|
||||
|
||||
@@ -1191,7 +1191,8 @@ int32_t AppMgrService::StartNativeProcessForDebugger(const AAFwk::Want &want)
|
||||
return ERR_INVALID_OPERATION;
|
||||
}
|
||||
bool isShellCall = AAFwk::PermissionVerification::GetInstance()->IsShellCall();
|
||||
bool isLocalDebugCall = AAFwk::PermissionVerification::GetInstance()->VerifyStartLocalDebug();
|
||||
auto callingTokenId = IPCSkeleton::GetCallingTokenID();
|
||||
bool isLocalDebugCall = AAFwk::PermissionVerification::GetInstance()->VerifyStartLocalDebug(callingTokenId);
|
||||
if (!isShellCall && !isLocalDebugCall) {
|
||||
TAG_LOGE(AAFwkTag::APPMGR, "permission denied");
|
||||
return ERR_INVALID_OPERATION;
|
||||
|
||||
@@ -117,7 +117,7 @@ struct VerificationInfo {
|
||||
|
||||
bool VerifySuperviseKiaServicePermission() const;
|
||||
|
||||
bool VerifyStartLocalDebug() const;
|
||||
bool VerifyStartLocalDebug(int32_t tokenId) const;
|
||||
|
||||
bool VerifyStartSelfUIAbility(int tokenId) const;
|
||||
|
||||
|
||||
@@ -577,9 +577,9 @@ bool PermissionVerification::VerifySuperviseKiaServicePermission() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PermissionVerification::VerifyStartLocalDebug() const
|
||||
bool PermissionVerification::VerifyStartLocalDebug(int32_t tokenId) const
|
||||
{
|
||||
if (VerifyCallingPermission(PermissionConstants::PERMISSION_PERFORM_LOCAL_DEBUG)) {
|
||||
if (VerifyPermissionByTokenId(tokenId, PermissionConstants::PERMISSION_PERFORM_LOCAL_DEBUG)) {
|
||||
TAG_LOGD(AAFwkTag::DEFAULT, "Permission granted");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -753,7 +753,7 @@ HWTEST_F(PermissionVerificationTest, JudgeStartInvisibleAbility_0001, TestSize.L
|
||||
*/
|
||||
HWTEST_F(PermissionVerificationTest, CheckVerifyStartLocalDebug_0100, TestSize.Level0)
|
||||
{
|
||||
int result = AAFwk::PermissionVerification::GetInstance()->VerifyStartLocalDebug();
|
||||
int result = AAFwk::PermissionVerification::GetInstance()->VerifyStartLocalDebug(0);
|
||||
EXPECT_EQ(result, false);
|
||||
}
|
||||
} // namespace AAFwk
|
||||
|
||||
Reference in New Issue
Block a user