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 app process OnRemoteDied 62 * @param abilityTokens abilities in died process. 63 */ 64 virtual void OnAppRemoteDied(const std::vector<sptr<IRemoteObject>> &abilityTokens) override; 65 66 /** 67 * @brief Notify abilityms app process pre cache 68 * @param pid process pid. 69 * @param userId userId Designation User ID. 70 */ 71 virtual void NotifyAppPreCache(int32_t pid, int32_t userId) override; 72 73 private: 74 bool WriteInterfaceToken(MessageParcel &data); 75 static inline BrokerDelegator<AppStateCallbackProxy> delegator_; 76 int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); 77 }; 78 } // namespace AppExecFwk 79 } // namespace OHOS 80 #endif // OHOS_ABILITY_RUNTIME_APP_STATE_CALLBACK_PROXY_H 81