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 APP_GROUP_CALLBACK_INFO_H 17 #define APP_GROUP_CALLBACK_INFO_H 18 19 #include <memory> 20 21 #include "parcel.h" 22 23 namespace OHOS { 24 namespace DeviceUsageStats { 25 class AppGroupCallbackInfo : public Parcelable { 26 public: AppGroupCallbackInfo()27 AppGroupCallbackInfo() {}; 28 AppGroupCallbackInfo(int32_t userId, int32_t oldGroup, int32_t newGroup, uint32_t changeReason, 29 std::string bundleName); 30 31 /** 32 * @brief Get the user id. 33 * 34 * @return The id of user. 35 */ 36 int32_t GetUserId() const; 37 38 /** 39 * @brief Get the old group. 40 * 41 * @return old group of app. 42 */ 43 int32_t GetOldGroup() const; 44 45 /** 46 * @brief Get the new group. 47 * 48 * @return the new group of app. 49 */ 50 int32_t GetNewGroup() const; 51 52 /** 53 * @brief Get the reason of change group. 54 * 55 * @return the reason of change group. 56 */ 57 uint32_t GetChangeReason() const; 58 59 /** 60 * @brief Get the name of bundle. 61 * 62 * @return The name of bundle. 63 */ 64 std::string GetBundleName() const; 65 66 /** 67 * @brief Marshals a purpose into a parcel. 68 * 69 * @param parcel Indicates the parcel object for marshalling. 70 * @return True if success, else false. 71 */ 72 bool Marshalling(Parcel &parcel) const; 73 static AppGroupCallbackInfo* Unmarshalling(Parcel &parcel); 74 75 private: 76 bool ReadFromParcel(Parcel &parcel); 77 78 private: 79 int32_t oldGroup_ {0}; 80 int32_t newGroup_ {0}; 81 int32_t userId_ {-1}; 82 uint32_t changeReason_ {0}; 83 std::string bundleName_ {""}; 84 }; 85 } // namespace DeviceUsageStats 86 } // namespace OHOS 87 #endif // APP_GROUP_CALLBACK_INFO_H