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