1 /* 2 * Copyright (c) 2021 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 BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_BUNDLE_OPTION_H 17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_BUNDLE_OPTION_H 18 19 #include "parcel.h" 20 21 namespace OHOS { 22 namespace Notification { 23 class NotificationBundleOption : public Parcelable { 24 public: 25 NotificationBundleOption() = default; 26 27 /** 28 * @brief A constructor used to create a NotificationBundleOption instance based on the creator bundle name and uid. 29 * 30 * @param bundleName Indicates the creator bundle name. 31 * @param uid Indicates the creator uid. 32 */ 33 NotificationBundleOption(const std::string &bundleName, const int32_t uid); 34 35 virtual ~NotificationBundleOption(); 36 37 /** 38 * @brief Sets the creator bundle name. 39 * 40 * @param bundleName Indicates the creator bundle name. 41 */ 42 void SetBundleName(const std::string &bundleName); 43 44 /** 45 * @brief Obtains the creator bundle name. 46 * 47 * @return Returns the creator bundle name. 48 */ 49 std::string GetBundleName() const; 50 51 /** 52 * @brief Sets the creator uid. 53 * 54 * @param uid Indicates the creator uid. 55 */ 56 void SetUid(const int32_t uid); 57 58 /** 59 * @brief Obtains the creator uid. 60 * 61 * @return Returns the creator uid. 62 */ 63 int32_t GetUid() const; 64 65 /** 66 * @brief Returns a string representation of the object. 67 * 68 * @return Returns a string representation of the object. 69 */ 70 std::string Dump(); 71 72 /** 73 * @brief Marshal a object into a Parcel. 74 * 75 * @param parcel Indicates the object into the parcel 76 * @return Returns true if succeed; returns false otherwise. 77 */ 78 virtual bool Marshalling(Parcel &parcel) const override; 79 80 /** 81 * @brief Unmarshal object from a Parcel. 82 * 83 * @param parcel Indicates the parcel object. 84 * @return Returns the NotificationBundleOption 85 */ 86 static NotificationBundleOption *Unmarshalling(Parcel &parcel); 87 88 private: 89 /** 90 * @brief Read data from a Parcel. 91 * 92 * @param parcel Indicates the parcel object. 93 * @return Returns true if read success; returns false otherwise. 94 */ 95 bool ReadFromParcel(Parcel &parcel); 96 97 private: 98 std::string bundleName_ {}; 99 int32_t uid_ {}; 100 }; 101 } // namespace Notification 102 } // namespace OHOS 103 104 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_BUNDLE_OPTION_H 105