1 /* 2 * Copyright (c) 2022 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 OHOS_AAFWK_DLP_STATE_ITME_H 17 #define OHOS_AAFWK_DLP_STATE_ITME_H 18 19 #include <list> 20 21 #include "ability_record.h" 22 #include "dlp_state_data.h" 23 24 namespace OHOS { 25 namespace AAFwk { 26 /** 27 * @class DlpStateItem 28 * DlpStateItem,This class is used to record connection state of a process. 29 */ 30 class DlpStateItem : public std::enable_shared_from_this<DlpStateItem> { 31 public: 32 DlpStateItem(int32_t dlpUid, int32_t dlpPid); 33 virtual ~DlpStateItem(); 34 35 /** 36 * add an opened dlp ability. 37 * 38 * @param record target dlp ability. 39 * @param data output relationship data. 40 * @return Returns true if need report relationship. 41 */ 42 bool AddDlpConnectionState(const std::shared_ptr<AbilityRecord> &record, AbilityRuntime::DlpStateData &data); 43 44 /** 45 * remove an closed dlp ability. 46 * 47 * @param record target dlp ability. 48 * @param data output relationship data. 49 * @return Returns true if need report relationship. 50 */ 51 bool RemoveDlpConnectionState(const std::shared_ptr<AbilityRecord> &record, AbilityRuntime::DlpStateData &data); 52 53 int32_t GetDlpUid() const; 54 int32_t GetOpenedAbilitySize() const; 55 56 private: 57 DISALLOW_COPY_AND_MOVE(DlpStateItem); 58 59 bool HandleDlpConnectionState(const std::shared_ptr<AbilityRecord> &record, bool isAdd, 60 AbilityRuntime::DlpStateData &data); 61 void GenerateDlpStateData(const std::shared_ptr<AbilityRecord> &dlpAbility, AbilityRuntime::DlpStateData &data); 62 63 int32_t dlpUid_ = 0; 64 int32_t dlpPid_ = 0; 65 std::list<sptr<IRemoteObject>> dlpAbilities_; 66 }; 67 } // namespace AAFwk 68 } // namespace OHOS 69 #endif // OHOS_AAFWK_DLP_STATE_ITME_H 70