1 /* 2 * Copyright (c) 2021-2023 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 OHOS_ABILITY_RUNTIME_APP_STATE_CALLBACK_PROXY_H 17 #define OHOS_ABILITY_RUNTIME_APP_STATE_CALLBACK_PROXY_H 18 19 #include "iremote_proxy.h" 20 21 #include "app_mgr_constants.h" 22 #include "bundle_info.h" 23 #include "iapp_state_callback.h" 24 25 namespace OHOS { 26 namespace AppExecFwk { 27 class AppStateCallbackProxy : public IRemoteProxy<IAppStateCallback> { 28 public: 29 explicit AppStateCallbackProxy(const sptr<IRemoteObject> &impl); 30 virtual ~AppStateCallbackProxy() = default; 31 32 /** 33 * AbilityMgr's request is done. 34 * 35 * @param token Ability token. 36 * @param state Application state. 37 */ 38 virtual void OnAbilityRequestDone(const sptr<IRemoteObject> &token, const AbilityState state) override; 39 40 /** 41 * Application state changed callback. 42 * 43 * @param appProcessData Process data 44 */ 45 virtual void OnAppStateChanged(const AppProcessData &appProcessData) override; 46 47 /** 48 * @brief Notify application update system environment changes. 49 * @param config System environment change parameters. 50 * @param userId userId Designation User ID. 51 */ 52 virtual void NotifyConfigurationChange(const AppExecFwk::Configuration &config, int32_t userId) override; 53 54 /** 55 * @brief Notify abilityms start resident process. 56 * @param bundleInfos resident process bundle infos. 57 */ 58 virtual void NotifyStartResidentProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos) override; 59 60 /** 61 * @brief Notify abilityms start keep-alive process. 62 * @param bundleInfos resident process bundle infos. 63 */ 64 virtual void NotifyStartKeepAliveProcess(std::vector<AppExecFwk::BundleInfo> &bundleInfos) override; 65 66 /** 67 * @brief Notify abilityms app process OnRemoteDied 68 * @param abilityTokens abilities in died process. 69 */ 70 virtual void OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens) override; 71 72 virtual void OnStartProcessFailed(const std::vector<sptr<IRemoteObject>> &abilityTokens) override; 73 74 /** 75 * @brief Notify abilityms app process pre cache 76 * @param pid process pid. 77 * @param userId userId Designation User ID. 78 */ 79 virtual void NotifyAppPreCache(int32_t pid, int32_t userId) override; 80 81 virtual void OnCacheExitInfo(uint32_t accessTokenId, const RunningProcessInfo &exitInfo, 82 const std::string &bundleName, const std::vector<std::string> &abilityNames, 83 const std::vector<std::string> &uiExtensionNames) override; 84 85 private: 86 bool WriteInterfaceToken(MessageParcel &data); 87 static inline BrokerDelegator<AppStateCallbackProxy> delegator_; 88 int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 89 }; 90 } // namespace AppExecFwk 91 } // namespace OHOS 92 #endif // OHOS_ABILITY_RUNTIME_APP_STATE_CALLBACK_PROXY_H 93