1 /*
2  * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef DLP_PERMISSION_STUB_H
17 #define DLP_PERMISSION_STUB_H
18 
19 #include <map>
20 #include "i_dlp_permission_service.h"
21 #include "iremote_stub.h"
22 #include "nocopyable.h"
23 
24 namespace OHOS {
25 namespace Security {
26 namespace DlpPermission {
27 
28 using RequestFuncType = std::function<int32_t(MessageParcel&, MessageParcel&)>;
29 class DlpPermissionStub : public IRemoteStub<IDlpPermissionService> {
30 public:
31     DlpPermissionStub();
32     virtual ~DlpPermissionStub();
33 
34     int OnRemoteRequest(uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option) override;
35     virtual void StartTimer() = 0;
36 private:
37     void InitMDMPolicy();
38     void InitTimerFuncMap();
39 
40     int32_t GenerateDlpCertificateInner(MessageParcel& data, MessageParcel& reply);
41     int32_t ParseDlpCertificateInner(MessageParcel& data, MessageParcel& reply);
42     int32_t InstallDlpSandboxInner(MessageParcel& data, MessageParcel& reply);
43     int32_t UninstallDlpSandboxInner(MessageParcel& data, MessageParcel& reply);
44     int32_t GetSandboxExternalAuthorizationInner(MessageParcel& data, MessageParcel& reply);
45 
46     int32_t QueryDlpFileCopyableByTokenIdInner(MessageParcel& data, MessageParcel& reply);
47     int32_t QueryDlpFileAccessInner(MessageParcel& data, MessageParcel& reply);
48     int32_t IsInDlpSandboxInner(MessageParcel& data, MessageParcel& reply);
49     int32_t GetDlpSupportFileTypeInner(MessageParcel& data, MessageParcel& reply);
50     int32_t RegisterDlpSandboxChangeCallbackInner(MessageParcel &data, MessageParcel &reply);
51     int32_t UnRegisterDlpSandboxChangeCallbackInner(MessageParcel &data, MessageParcel &reply);
52     int32_t RegisterOpenDlpFileCallbackInner(MessageParcel &data, MessageParcel &reply);
53     int32_t UnRegisterOpenDlpFileCallbackInner(MessageParcel &data, MessageParcel &reply);
54 
55     int32_t GetDlpGatheringPolicyInner(MessageParcel& data, MessageParcel& reply);
56     int32_t SetRetentionStateInner(MessageParcel& data, MessageParcel& reply);
57     int32_t CancelRetentionStateInner(MessageParcel& data, MessageParcel& reply);
58     int32_t GetRetentionSandboxListInner(MessageParcel& data, MessageParcel& reply);
59     int32_t ClearUnreservedSandboxInner(MessageParcel& data, MessageParcel& reply);
60     int32_t GetDLPFileVisitRecordInner(MessageParcel& data, MessageParcel& reply);
61     int32_t SetSandboxAppConfigInner(MessageParcel& data, MessageParcel& reply);
62     int32_t CleanSandboxAppConfigInner(MessageParcel& data, MessageParcel& reply);
63     int32_t GetSandboxAppConfigInner(MessageParcel& data, MessageParcel& reply);
64 
65     int32_t SetMDMPolicyInner(MessageParcel& data, MessageParcel& reply);
66     int32_t GetMDMPolicyInner(MessageParcel& data, MessageParcel& reply);
67     int32_t RemoveMDMPolicyInner(MessageParcel& data, MessageParcel& reply);
68     int32_t IsDLPFeatureProvidedInner(MessageParcel& data, MessageParcel& reply);
69     int32_t SetReadFlagInner(MessageParcel& data, MessageParcel& reply);
70 
71     typedef struct FuncInfo {
72         RequestFuncType funcType;
73         bool isNeedStartTimer = false;
74     } FuncInfo;
75     std::map<uint32_t, FuncInfo> requestFuncMap_;
76 };
77 }  // namespace DlpPermission
78 }  // namespace Security
79 }  // namespace OHOS
80 #endif  // DLP_PERMISSION_STUB_H
81