1 /* 2 * Copyright (c) 2025 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_SERVICE_EXTENSION_H 17 #define OHOS_ABILITY_RUNTIME_APP_SERVICE_EXTENSION_H 18 19 #include "extension_base.h" 20 21 namespace OHOS { 22 namespace AbilityRuntime { 23 class AppServiceExtensionContext; 24 class Runtime; 25 /** 26 * @brief Basic service components. 27 */ 28 class AppServiceExtension : public ExtensionBase<AppServiceExtensionContext> { 29 public: 30 AppServiceExtension() = default; 31 virtual ~AppServiceExtension() = default; 32 33 /** 34 * @brief Create and init context. 35 * 36 * @param record the extension record. 37 * @param application the application info. 38 * @param handler the extension handler. 39 * @param token the remote token. 40 * @return The created context. 41 */ 42 virtual std::shared_ptr<AppServiceExtensionContext> CreateAndInitContext( 43 const std::shared_ptr<AbilityLocalRecord> &record, 44 const std::shared_ptr<OHOSApplication> &application, 45 std::shared_ptr<AbilityHandler> &handler, 46 const sptr<IRemoteObject> &token) override; 47 48 /** 49 * @brief Init the extension. 50 * 51 * @param record the extension record. 52 * @param application the application info. 53 * @param handler the extension handler. 54 * @param token the remote token. 55 */ 56 virtual void Init(const std::shared_ptr<AbilityLocalRecord> &record, 57 const std::shared_ptr<OHOSApplication> &application, 58 std::shared_ptr<AbilityHandler> &handler, 59 const sptr<IRemoteObject> &token) override; 60 61 /** 62 * @brief Create Extension. 63 * 64 * @param runtime The runtime. 65 * @return The AppServiceExtension instance. 66 */ 67 static AppServiceExtension* Create(const std::unique_ptr<Runtime>& runtime); 68 69 /** 70 * @brief Called when the system configuration is updated. 71 * 72 * @param configuration Indicates the updated configuration information. 73 */ 74 void OnConfigurationUpdated(const AppExecFwk::Configuration &configuration) override; 75 }; 76 } // namespace AbilityRuntime 77 } // namespace OHOS 78 #endif // OHOS_ABILITY_RUNTIME_APP_SERVICE_EXTENSION_H 79