Description: add precheck for dfx sreenshot interface

IssueNo:I5SWPU
Feature or Bugfix: Feature
Binary Source:No

Signed-off-by: jiadexiang <jiadexiang@huawei.com>
This commit is contained in:
jiadexiang
2022-09-24 11:33:18 +08:00
parent 2137f511d2
commit 58223ee0be
2 changed files with 12 additions and 0 deletions
+4
View File
@@ -79,6 +79,9 @@ executable("wms_server") {
include_dirs = [
"frameworks/ims",
"interfaces/innerkits",
"//base/security/permission_lite/services/pms_client/include",
"//base/security/permission_lite/interfaces/innerkits",
"//base/security/permission_lite/interfaces/kits",
"//drivers/peripheral/input/interfaces/include",
"//third_party/FreeBSD/sys/dev/evdev",
]
@@ -91,6 +94,7 @@ executable("wms_server") {
"-ldisplay_layer",
]
deps = [
"//base/security/permission_lite/services/pms_client:pms_client",
"//drivers/peripheral/input/hal:hdi_input",
"//foundation/graphic/utils:lite_graphic_hals",
]
+8
View File
@@ -17,6 +17,7 @@
#include "gfx_utils/graphic_log.h"
#include "lite_wm.h"
#include "lite_wm_type.h"
#include "pms_interface.h"
#include "surface.h"
#include "surface_impl.h"
@@ -214,6 +215,13 @@ void LiteWMS::GetEventData(IpcIo* req, IpcIo* reply)
void LiteWMS::Screenshot(IpcIo* req, IpcIo* reply)
{
const char *writeMediaImagePermissionName = "ohos.permission.WRITE_MEDIA_IMAGES";
pid_t uid = GetCallingUid();
if (CheckPermission(uid, writeMediaImagePermissionName) != GRANTED) {
GRAPHIC_LOGE("permission denied");
WriteInt32(reply, LiteWMS_EUNKNOWN);
return;
}
Surface* surface = SurfaceImpl::GenericSurfaceByIpcIo(*req);
bool ret = LiteWM::GetInstance()->OnScreenshot(surface);
WriteInt32(reply, ret ? LiteWMS_EOK : LiteWMS_EUNKNOWN);