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 BUNDLE_ACTIVE_FORM_RECORD_H 17 #define BUNDLE_ACTIVE_FORM_RECORD_H 18 19 #include <cstdint> 20 #include <iosfwd> 21 #include <memory> 22 #include "parcel.h" 23 24 namespace OHOS { 25 namespace DeviceUsageStats { 26 class BundleActiveFormRecord : public Parcelable { 27 public: 28 std::string formName_; 29 int32_t formDimension_; 30 int64_t formId_; 31 int64_t formLastUsedTime_; 32 int32_t count_; 33 int32_t userId_; 34 int32_t uid_; 35 36 public: 37 /* 38 * function: BundleActiveFormRecord, copy constructor. 39 * parameters: orig 40 */ 41 BundleActiveFormRecord(const BundleActiveFormRecord& orig); 42 /* 43 * function: BundleActiveFormRecord, default constructor. 44 */ 45 BundleActiveFormRecord(); 46 /* 47 * function: BundleActiveFormRecord, use formName, formDimension, formId, timeStamp, userId to construct object. 48 * parameters: formName, formDimension, formId, timeStamp, userId 49 */ 50 BundleActiveFormRecord(const std::string formName, const int32_t formDimension, const int64_t formId, 51 const int64_t timeStamp, const int32_t userId, const int32_t uid); 52 /* 53 * function: ~BundleActiveFormRecord, default destructor. 54 */ ~BundleActiveFormRecord()55 ~BundleActiveFormRecord() {} 56 /* 57 * function: UpdateFormRecord, update form record by timestamp. 58 * parameters: timeStamp 59 */ 60 void UpdateFormRecord(const int64_t timeStamp); 61 /* 62 * function: operator==, override operator ==. 63 * parameters: formRecord 64 * return: true if the formId_ is same. 65 */ 66 bool operator==(const BundleActiveFormRecord& formRecord) const 67 { 68 return (this->formId_ == formRecord.formId_); 69 } 70 /* 71 * function: operator==, override operator ==. 72 * parameters: formId 73 * return: true if the formId_ is same. 74 */ 75 bool operator==(const int64_t formId) const 76 { 77 return (this->formId_ == formId); 78 } 79 /* 80 * function: cmp, compare two BundleActiveFormRecord. 81 * parameters: formRecordA, formRecordB 82 * return: true if formRecordA.count_ > formRecordB. 83 */ 84 static bool cmp(const BundleActiveFormRecord& formRecordA, const BundleActiveFormRecord& formRecordB); 85 /* 86 * function: Marshalling, mashalling form record object to parcel. 87 * parameters: parcel 88 * return: result of mashalling, true means successful, flase means failed. 89 */ 90 bool Marshalling(Parcel &parcel) const override; 91 /* 92 * function: UnMarshalling, Unmashalling record object from parcel. 93 * parameters: parcel 94 * return: point to a BundleActiveFormRecord. 95 */ 96 static std::shared_ptr<BundleActiveFormRecord> UnMarshalling(Parcel &parcel); 97 /* 98 * function: ToString, change form record object to string. 99 * return: string of form name, form id, form dimension, last used time and touch count. 100 */ 101 std::string ToString(); 102 }; 103 } // namespace DeviceUsageStats 104 } // namespace OHOS 105 #endif // BUNDLE_ACTIVE_FORM_RECORD_H 106 107