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 FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_STATUS_CALLBACK_INTERFACE_H 17 #define FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_STATUS_CALLBACK_INTERFACE_H 18 19 #include "iremote_broker.h" 20 21 namespace OHOS { 22 namespace AppExecFwk { 23 enum class InstallType { INSTALL_CALLBACK, UNINSTALL_CALLBACK }; 24 25 class IBundleStatusCallback : public IRemoteBroker { 26 public: 27 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.appexecfwk.BundleStatusCallback"); 28 /** 29 * @brief Called when the installation, update, or uninstallation state of an application changes. 30 * @param installType Indicates the installation, update, or uninstallation state. 31 * The value <b>0</b> indicates that the application is being installed or updated, 32 * and <b>1</b> indicates that the application is being uninstalled. 33 * @param resultCode Indicates the status code returned for the application installation, update, or uninstallation 34 * result. 35 * @param resultMessage Indicates the result message returned with the status code. 36 * @param bundleName Indicates the name of the bundle whose state has changed. 37 */ 38 virtual void OnBundleStateChanged(const uint8_t installType, const int32_t resultCode, const std::string &resultMsg, 39 const std::string &bundleName) = 0; 40 /** 41 * @brief Called when a new application package has been installed on the device. 42 * @param bundleName Indicates the name of the bundle whose state has been installed. 43 * @param userId Indicates the id of the bundle whose state has been installed. 44 */ 45 virtual void OnBundleAdded(const std::string &bundleName, const int userId) = 0; 46 /** 47 * @brief Called when a new application package has been Updated on the device. 48 * @param bundleName Indicates the name of the bundle whose state has been Updated. 49 * @param userId Indicates the id of the bundle whose state has been Updated. 50 */ 51 virtual void OnBundleUpdated(const std::string &bundleName, const int userId) = 0; 52 /** 53 * @brief Called when a new application package has been Removed on the device. 54 * @param bundleName Indicates the name of the bundle whose state has been Removed. 55 * @param userId Indicates the id of the bundle whose state has been Removed. 56 */ 57 virtual void OnBundleRemoved(const std::string &bundleName, const int userId) = 0; 58 GetBundleName()59 std::string GetBundleName() 60 { 61 return bundleName_; 62 } 63 SetBundleName(const std::string & bundleName)64 void SetBundleName(const std::string &bundleName) 65 { 66 bundleName_ = bundleName; 67 } 68 69 private: 70 std::string bundleName_; 71 }; 72 } // namespace AppExecFwk 73 } // namespace OHOS 74 75 #endif // FOUNDATION_APPEXECFWK_INTERFACES_INNERKITS_APPEXECFWK_CORE_INCLUDE_BUNDLE_STATUS_CALLBACK_INTERFACE_H 76