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_ABILITY_H 17 #define OHOS_ABILITY_RUNTIME_ABILITY_H 18 19 #include <functional> 20 #include <string> 21 #include <unistd.h> 22 23 #include "ability_context.h" 24 #include "ability_continuation_interface.h" 25 #include "ability_event_interface.h" 26 #include "ability_lifecycle_executor.h" 27 #include "ability_lifecycle_interface.h" 28 #include "ability_transaction_callback_info.h" 29 #include "appexecfwk_errors.h" 30 #include "configuration.h" 31 #include "context.h" 32 #include "continuation_handler.h" 33 #include "continuation_state.h" 34 #include "dummy_notification_request.h" 35 #include "iability_callback.h" 36 #include "iremote_object.h" 37 #include "pac_map.h" 38 #include "want.h" 39 #include "want_agent.h" 40 #include "foundation/ability/ability_runtime/interfaces/kits/native/ability/ability_runtime/ability_context.h" 41 42 #ifdef SUPPORT_GRAPHICS 43 #include "ability_window.h" 44 #include "display_manager.h" 45 #include "form_constants.h" 46 #include "form_provider_info.h" 47 #include "form_state_info.h" 48 #include "foundation/multimodalinput/input/interfaces/native/innerkits/event/include/key_event.h" 49 #include "foundation/multimodalinput/input/interfaces/native/innerkits/event/include/pointer_event.h" 50 #include "session_info.h" 51 #include "window_option.h" 52 #include "window_scene.h" 53 #include "wm_common.h" 54 #endif 55 56 namespace OHOS { 57 namespace NativeRdb { 58 class AbsSharedResultSet; 59 class DataAbilityPredicates; 60 class ValuesBucket; 61 } // namespace NativeRdb 62 namespace AbilityRuntime { 63 class Runtime; 64 } 65 #ifdef SUPPORT_GRAPHICS 66 class KeyEvent; 67 namespace Ace { 68 class UIContent; 69 } 70 #endif 71 namespace AppExecFwk { 72 using FeatureAbilityTask = std::function<void(int, const AAFwk::Want&)>; 73 class DataAbilityResult; 74 class DataAbilityOperation; 75 class AbilityPostEventTimeout; 76 class OHOSApplication; 77 class AbilityHandler; 78 #ifdef SUPPORT_GRAPHICS 79 class AbilityWindow; 80 #endif 81 class ILifeCycle; 82 class ContinuationManager; 83 class AbilityRecovery; 84 class ContinuationRegisterManager; 85 class Ability : public IAbilityEvent, 86 public ILifeCycle, 87 public AbilityContext, 88 public IAbilityContinuation, 89 public IAbilityCallback, 90 public std::enable_shared_from_this<Ability> { 91 public: 92 friend class NewAbilityImpl; 93 94 static Ability* Create(const std::unique_ptr<AbilityRuntime::Runtime>& runtime); 95 96 Ability() = default; 97 virtual ~Ability() = default; 98 99 /** 100 * @brief Obtains the AbilityContext object of the ability. 101 * 102 * @return Returns the AbilityContext object of the ability. 103 */ GetAbilityContext()104 std::shared_ptr<AbilityRuntime::AbilityContext> GetAbilityContext() 105 { 106 return abilityContext_; 107 } 108 109 /** 110 * @brief Obtains the Lifecycle object of the current ability. 111 * 112 * @return Returns the Lifecycle object. 113 */ 114 std::shared_ptr<LifeCycle> GetLifecycle() override final; 115 116 /** 117 * @brief Obtains a resource manager. 118 * 119 * @return Returns a ResourceManager object. 120 */ 121 std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager() const override; 122 123 /** 124 * Start other ability for result. 125 * 126 * @param want information of other ability 127 * @param requestCode request code for abilityMS to return result 128 * 129 * @return errCode ERR_OK on success, others on failure. 130 */ 131 virtual ErrCode StartAbilityForResult(const Want &want, int requestCode) final; 132 133 /** 134 * Starts an ability with specific start settings and returns the execution result when the ability is destroyed. 135 * When the ability is destroyed, onAbilityResult(int,int,ohos.aafwk.content.Want) is called and the returned 136 * requestCode is transferred to the current method. The given requestCode is customized and cannot be a negative 137 * number. 138 * 139 * @param want Indicates the ability to start. 140 * @param requestCode Indicates the request code returned after the ability is started. You can define the request 141 * code to identify the results returned by abilities. The value ranges from 0 to 65535. 142 * @param abilityStartSetting Indicates the setting ability used to start. 143 * 144 * @return errCode ERR_OK on success, others on failure. 145 */ 146 virtual ErrCode StartAbilityForResult( 147 const Want &want, int requestCode, AbilityStartSetting abilityStartSetting) final; 148 149 /** 150 * Starts a new ability with specific start settings. 151 * A Page or Service ability uses this method to start a specific ability. 152 * The system locates the target ability from installed abilities based on 153 * the value of the want parameter and then starts it. You can specify the 154 * ability to start using the want parameter. 155 * 156 * @param want Indicates the ability to start. 157 * @param abilityStartSetting Indicates the setting ability used to start. 158 * 159 * @return errCode ERR_OK on success, others on failure. 160 */ 161 using AbilityContext::StartAbility; 162 ErrCode StartAbility(const Want &want, AbilityStartSetting abilityStartSetting); 163 164 /** 165 * @brief A Page or Service ability uses this method to start a specific ability. The system locates the target 166 * ability from installed abilities based on the value of the want parameter and then starts it. You can specify 167 * the ability to start using the want parameter. 168 * 169 * @param want Indicates the ability to start. 170 * 171 * @return errCode ERR_OK on success, others on failure. 172 */ 173 virtual ErrCode StartAbility(const Want &want) final; 174 175 ErrCode StartFeatureAbilityForResult(const Want &want, int requestCode, FeatureAbilityTask &&task); 176 177 virtual void Init(const std::shared_ptr<AbilityInfo> &abilityInfo, 178 const std::shared_ptr<OHOSApplication> application, std::shared_ptr<AbilityHandler> &handler, 179 const sptr<IRemoteObject> &token); 180 181 void AttachAbilityContext(const std::shared_ptr<AbilityRuntime::AbilityContext> &abilityContext); 182 183 /** 184 * @brief Called when this ability is started. You must override this function if you want to perform some 185 * initialization operations during ability startup. 186 * 187 * This function can be called only once in the entire lifecycle of an ability. 188 * @param Want Indicates the {@link Want} structure containing startup information about the ability. 189 * @param sessionInfo Indicates the sessionInfo. 190 */ 191 virtual void OnStart(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo = nullptr); 192 193 /** 194 * @brief Called when this ability enters the <b>STATE_STOP</b> state. 195 * 196 * The ability in the <b>STATE_STOP</b> is being destroyed. 197 * You can override this function to implement your own processing logic. 198 */ 199 virtual void OnStop(); 200 201 /** 202 * @brief Called when this ability enters the <b>STATE_STOP</b> state. 203 * 204 * The ability in the <b>STATE_STOP</b> is being destroyed. 205 * You can override this function to implement your own processing logic. 206 * 207 * @param callbackInfo Indicates the lifecycle transaction callback information 208 * @param isAsyncCallback Indicates whether it is an asynchronous lifecycle callback 209 */ 210 virtual void OnStop(AbilityTransactionCallbackInfo<> *callbackInfo, bool &isAsyncCallback); 211 212 /** 213 * @brief The callback of OnStop. 214 */ 215 virtual void OnStopCallback(); 216 217 /** 218 * @brief Called when this ability enters the <b>STATE_ACTIVE</b> state. 219 * 220 * The ability in the <b>STATE_ACTIVE</b> state is visible and has focus. 221 * You can override this function to implement your own processing logic. 222 * 223 * @param Want Indicates the {@link Want} structure containing activation information about the ability. 224 */ 225 virtual void OnActive(); 226 227 /** 228 * @brief Called when this ability enters the <b>STATE_INACTIVE</b> state. 229 * 230 * <b>STATE_INACTIVE</b> is an instantaneous state. The ability in this state may be visible but does not have 231 * focus.You can override this function to implement your own processing logic. 232 */ 233 virtual void OnInactive(); 234 235 /** 236 * @brief Called when this Service ability is connected for the first time. 237 * 238 * You can override this function to implement your own processing logic. 239 * 240 * @param want Indicates the {@link Want} structure containing connection information about the Service ability. 241 * @return Returns a pointer to the <b>sid</b> of the connected Service ability. 242 */ 243 virtual sptr<IRemoteObject> OnConnect(const Want &want); 244 245 /** 246 * @brief Called when all abilities connected to this Service ability are disconnected. 247 * 248 * You can override this function to implement your own processing logic. 249 * 250 */ 251 virtual void OnDisconnect(const Want &want); 252 253 virtual std::shared_ptr<AppExecFwk::PacMap> Call( 254 const Uri &uri, const std::string &method, const std::string &arg, const AppExecFwk::PacMap &pacMap); 255 256 /** 257 * @brief Called to set caller information for the application. The default implementation returns null. 258 * 259 * @return Returns the caller information. 260 */ 261 virtual Uri OnSetCaller(); 262 263 /** 264 * @brief request a remote object of callee from this ability. 265 * @return Returns the remote object of callee. 266 */ 267 virtual sptr<IRemoteObject> CallRequest(); 268 269 /** 270 * @brief Called when the system configuration is updated. 271 * 272 * @param configuration Indicates the updated configuration information. 273 */ 274 virtual void OnConfigurationUpdated(const Configuration &configuration); 275 276 /** 277 * @brief Called when the system configuration is updated. 278 * 279 * @param configuration Indicates the updated configuration information. 280 */ 281 void OnConfigurationUpdatedNotify(const Configuration &configuration); 282 283 /** 284 * @brief Update context.config when configuration is updated. 285 * 286 */ UpdateContextConfiguration()287 virtual void UpdateContextConfiguration() {} 288 289 /** 290 * @brief Checks whether the configuration of this ability is changing. 291 * 292 * @return Returns true if the configuration of this ability is changing and false otherwise. 293 */ 294 bool IsUpdatingConfigurations() override; 295 296 /** 297 * @brief Called when the system configuration is updated. 298 * 299 * @param level Indicates the memory trim level, which shows the current memory usage status. 300 * 301 */ 302 virtual void OnMemoryLevel(int level); 303 304 /** 305 * @brief This is like openFile, open a file that need to be able to return sub-sections of files,often assets 306 * inside of their .hap. 307 * 308 * @param uri Indicates the path of the file to open. 309 * @param mode Indicates the file open mode, which can be "r" for read-only access, "w" for write-only access 310 * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing file, 311 * "wa" for write-only access to append to any existing data, "rw" for read and write access on any existing 312 * data, or "rwt" for read and write access that truncates any existing file. 313 * 314 * @return Returns the RawFileDescriptor object containing file descriptor. 315 */ 316 virtual int OpenRawFile(const Uri &uri, const std::string &mode); 317 318 /** 319 * @brief Updates one or more data records in the database. This method should be implemented by a Data ability. 320 * 321 * @param uri Indicates the database table storing the data to update. 322 * @param value Indicates the data to update. This parameter can be null. 323 * @param predicates Indicates filter criteria. If this parameter is null, all data records will be updated by 324 * default. 325 * 326 * @return Returns the number of data records updated. 327 */ 328 virtual int Update( 329 const Uri &uri, const NativeRdb::ValuesBucket &value, const NativeRdb::DataAbilityPredicates &predicates); 330 331 /** 332 * @brief get application witch the ability belong 333 * 334 * @return Returns the application ptr 335 */ 336 std::shared_ptr<OHOSApplication> GetApplication(); 337 338 /** 339 * @brief Obtains the class name in this ability name, without the prefixed bundle name. 340 * 341 * @return Returns the class name of this ability. 342 */ 343 std::string GetAbilityName(); 344 345 /** 346 * @brief OChecks whether the current ability is being destroyed. 347 * An ability is being destroyed if you called terminateAbility() on it or someone else requested to destroy it. 348 * 349 * @return Returns true if the current ability is being destroyed; returns false otherwise. 350 */ 351 bool IsTerminating(); 352 353 /** 354 * @brief Obtains the mole name in this ability name, without the prefixed bundle name. 355 * 356 * @return Returns the module name of this ability. 357 */ 358 std::string GetModuleName(); 359 360 /** 361 * @brief Called when startAbilityForResult(ohos.aafwk.content.Want,int) is called to start an ability and the 362 * result is returned. This method is called only on Page abilities. You can start a new ability to perform some 363 * calculations and use setResult (int,ohos.aafwk.content.Want) to return the calculation result. Then the system 364 * calls back the current method to use the returned data to execute its own logic. 365 * 366 * @param requestCode Indicates the request code returned after the ability is started. You can define the request 367 * code to identify the results returned by abilities. The value ranges from 0 to 65535. 368 * @param resultCode Indicates the result code returned after the ability is started. You can define the result code 369 * to identify an error. 370 * @param want Indicates the data returned after the ability is started. You can define the data returned. The 371 * value can be null. 372 * 373 */ 374 virtual void OnAbilityResult(int requestCode, int resultCode, const Want &want); 375 376 virtual void OnFeatureAbilityResult(int requestCode, int resultCode, const Want &want); 377 378 /** 379 * @brief Called back when the Back key is pressed. 380 * The default implementation destroys the ability. You can override this method. 381 * 382 */ 383 void OnBackPressed() override; 384 385 /** 386 * @brief Called when the launch mode of an ability is set to singleInstance. This happens when you re-launch an 387 * ability that has been at the top of the ability stack. 388 * 389 * @param want Indicates the new Want containing information about the ability. 390 */ 391 virtual void OnNewWant(const Want &want); 392 393 /** 394 * @brief Restores data and states of an ability when it is restored by the system. This method should be 395 * implemented by a Page ability. This method is called if an ability was destroyed at a certain time due to 396 * resource reclaim or was unexpectedly destroyed and the onSaveAbilityState(ohos.utils.PacMap) method was called to 397 * save its user data and states. Generally, this method is called after the onStart(ohos.aafwk.content.Want) 398 * method. 399 * 400 * @param inState Indicates the PacMap object used for storing data and states. This parameter can not be null. 401 * 402 */ 403 virtual void OnRestoreAbilityState(const PacMap &inState); 404 405 /** 406 * @brief Saves temporary data and states of this ability. This method should be implemented by a Page ability. 407 * This method is called when the system determines that the ability may be destroyed in an unexpected situation, 408 * for example, when the screen orientation changes or the user touches the Home key. Generally, this method is used 409 * only to save temporary states. 410 * 411 * @param outState Indicates the PacMap object used for storing user data and states. This parameter cannot be 412 * null. 413 * 414 */ 415 virtual void OnSaveAbilityState(PacMap &outState); 416 417 /** 418 * @brief Called every time a key, touch, or trackball event is dispatched to this ability. 419 * You can override this callback method if you want to know that the user has interacted with 420 * the device in a certain way while this ability is running. This method, together with onLeaveForeground(), 421 * is designed to help abilities intelligently manage status bar notifications. Specifically, they help 422 * abilities determine when to cancel a notification. 423 * 424 */ 425 virtual void OnEventDispatch(); 426 427 /** 428 * @brief Sets the want object that can be obtained by calling getWant(). 429 * 430 * @param Want information of other ability 431 */ 432 void SetWant(const AAFwk::Want &want); 433 434 /** 435 * @brief Obtains the Want object that starts this ability. 436 * 437 * @return Returns the Want object that starts this ability. 438 */ 439 std::shared_ptr<AAFwk::Want> GetWant(); 440 441 /** 442 * @brief Sets the result code and data to be returned by this Page ability to the caller. 443 * When a Page ability is destroyed, the caller overrides the AbilitySlice#onAbilityResult(int, int, Want) method to 444 * receive the result set in the current method. This method can be called only after the ability has been 445 * initialized. 446 * 447 * @param resultCode Indicates the result code returned after the ability is destroyed. You can define the result 448 * code to identify an error. 449 * @param resultData Indicates the data returned after the ability is destroyed. You can define the data returned. 450 * This parameter can be null. 451 */ 452 virtual void SetResult(int resultCode, const Want &resultData) final; 453 454 /** 455 * @brief Called back when Service is started. 456 * This method can be called only by Service. You can use the StartAbility(ohos.aafwk.content.Want) method to start 457 * Service. Then the system calls back the current method to use the transferred want parameter to execute its own 458 * logic. 459 * 460 * @param want Indicates the want of Service to start. 461 * @param restart Indicates the startup mode. The value true indicates that Service is restarted after being 462 * destroyed, and the value false indicates a normal startup. 463 * @param startId Indicates the number of times the Service ability has been started. The startId is incremented by 464 * 1 every time the ability is started. For example, if the ability has been started for six times, the value of 465 * startId is 6. 466 */ 467 virtual void OnCommand(const AAFwk::Want &want, bool restart, int startId); 468 469 /** 470 * @brief dump ability info 471 * 472 * @param extra dump ability info 473 */ 474 virtual void Dump(const std::string &extra); 475 476 /** 477 * @brief dump ability info 478 * 479 * @param params dump params that indicate different dump targets 480 * @param info dump ability info 481 */ 482 virtual void Dump(const std::vector<std::string> ¶ms, std::vector<std::string> &info); 483 484 /** 485 * @brief Obtains the MIME type matching the data specified by the URI of the Data ability. This method should be 486 * implemented by a Data ability. Data abilities supports general data types, including text, HTML, and JPEG. 487 * 488 * @param uri Indicates the URI of the data. 489 * 490 * @return Returns the MIME type that matches the data specified by uri. 491 */ 492 virtual std::string GetType(const Uri &uri); 493 494 /** 495 * @brief Inserts a data record into the database. This method should be implemented by a Data ability. 496 * 497 * @param uri Indicates the position where the data is to insert. 498 * @param value Indicates the data to insert. 499 * 500 * @return Returns the index of the newly inserted data record. 501 */ 502 virtual int Insert(const Uri &uri, const NativeRdb::ValuesBucket &value); 503 504 /** 505 * @brief Converts the given uri that refer to the Data ability into a normalized URI. A normalized URI can be used 506 * across devices, persisted, backed up, and restored. It can refer to the same item in the Data ability even if the 507 * context has changed. If you implement URI normalization for a Data ability, you must also implement 508 * denormalizeUri(ohos.utils.net.Uri) to enable URI denormalization. After this feature is enabled, URIs passed to 509 * any method that is called on the Data ability must require normalization verification and denormalization. The 510 * default implementation of this method returns null, indicating that this Data ability does not support URI 511 * normalization. 512 * 513 * @param uri Indicates the Uri object to normalize. 514 * 515 * @return Returns the normalized Uri object if the Data ability supports URI normalization; returns null otherwise. 516 */ 517 virtual Uri NormalizeUri(const Uri &uri); 518 519 /** 520 * @brief Converts the given normalized uri generated by normalizeUri(ohos.utils.net.Uri) into a denormalized one. 521 * The default implementation of this method returns the original URI passed to it. 522 * 523 * @param uri uri Indicates the Uri object to denormalize. 524 * 525 * @return Returns the denormalized Uri object if the denormalization is successful; returns the original Uri passed 526 * to this method if there is nothing to do; returns null if the data identified by the original Uri cannot be found 527 * in the current environment. 528 */ 529 virtual Uri DenormalizeUri(const Uri &uri); 530 531 /** 532 * @brief Deletes one or more data records. This method should be implemented by a Data ability. 533 * 534 * @param uri Indicates the database table storing the data to delete. 535 * @param predicates Indicates filter criteria. If this parameter is null, all data records will be deleted by 536 * default. 537 * 538 * @return Returns the number of data records deleted. 539 */ 540 virtual int Delete(const Uri &uri, const NativeRdb::DataAbilityPredicates &predicates); 541 542 /** 543 * @brief Obtains the MIME type of files. This method should be implemented by a Data ability. 544 * 545 * @param uri Indicates the path of the files to obtain. 546 * @param mimeTypeFilter Indicates the MIME type of the files to obtain. This parameter cannot be set to null. 547 * 1. * / *: Obtains all types supported by a Data ability. 548 * 2. image/ *: Obtains files whose main type is image of any subtype. 549 * 3. * /jpg: Obtains files whose subtype is JPG of any main type. 550 * 551 * @return Returns the MIME type of the matched files; returns null if there is no type that matches the Data 552 * ability. 553 */ 554 virtual std::vector<std::string> GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter); 555 556 /** 557 * @brief Opens a file. This method should be implemented by a Data ability. 558 * 559 * @param uri Indicates the path of the file to open. 560 * @param mode Indicates the open mode, which can be "r" for read-only access, "w" for write-only access 561 * (erasing whatever data is currently in the file), "wt" for write access that truncates any existing file, 562 * "wa" for write-only access to append to any existing data, "rw" for read and write access on any existing data, 563 * or "rwt" for read and write access that truncates any existing file. 564 * 565 * @return Returns the FileDescriptor object of the file descriptor. 566 */ 567 virtual int OpenFile(const Uri &uri, const std::string &mode); 568 569 /** 570 * @brief Queries one or more data records in the database. This method should be implemented by a Data ability. 571 * 572 * @param uri Indicates the database table storing the data to query. 573 * @param columns Indicates the columns to be queried, in array, for example, {"name","age"}. You should define the 574 * processing logic when this parameter is null. 575 * @param predicates Indicates filter criteria. If this parameter is null, all data records will be queried by 576 * default. 577 * 578 * @return Returns the queried data. 579 */ 580 virtual std::shared_ptr<NativeRdb::AbsSharedResultSet> Query( 581 const Uri &uri, const std::vector<std::string> &columns, const NativeRdb::DataAbilityPredicates &predicates); 582 583 /** 584 * @brief Reloads data in the database. 585 * 586 * @param uri Indicates the position where the data is to reload. This parameter is mandatory. 587 * @param extras Indicates the PacMap object containing the additional parameters to be passed in this call. This 588 * parameter can be null. If a custom Sequenceable object is put in the PacMap object and will be transferred across 589 * processes, you must call BasePacMap.setClassLoader(ClassLoader) to set a class loader for the custom object. 590 * 591 * @return Returns true if the data is successfully reloaded; returns false otherwise. 592 */ 593 virtual bool Reload(const Uri &uri, const PacMap &extras); 594 595 /** 596 * @brief Inserts multiple data records into the database. 597 * 598 * @param uri Indicates the path of the data to operate. 599 * @param values Indicates the data records to insert. 600 * 601 * @return Returns the number of data records inserted. 602 */ 603 virtual int BatchInsert(const Uri &uri, const std::vector<NativeRdb::ValuesBucket> &values); 604 605 /** 606 * @brief Performs batch operations on the database. 607 * 608 * @param operations Indicates a list of database operations on the database. 609 * @return Returns the result of each operation, in array. 610 */ 611 virtual std::vector<std::shared_ptr<DataAbilityResult>> ExecuteBatch( 612 const std::vector<std::shared_ptr<DataAbilityOperation>> &operations); 613 614 /** 615 * @brief Executes an operation among the batch operations to be executed. 616 * 617 * @param operation Indicates the operation to execute. 618 * @param results Indicates a set of results of the batch operations. 619 * @param index Indicates the index of the current operation result in the batch operation results. 620 */ 621 void ExecuteOperation(std::shared_ptr<DataAbilityOperation> &operation, 622 std::vector<std::shared_ptr<DataAbilityResult>> &results, int index); 623 624 /** 625 * @brief Save user data of local Ability generated at runtime. 626 * 627 * @param saveData Indicates the user data to be saved. 628 * @return If the data is saved successfully, it returns true; otherwise, it returns false. 629 */ 630 bool OnSaveData(WantParams &saveData) override; 631 632 /** 633 * @brief After creating the Ability on the remote device, 634 * immediately restore the user data saved during the migration of the Ability on the remote device. 635 * @param restoreData Indicates the user data to be restored. 636 * @return If the data is restored successfully, it returns true; otherwise, it returns false . 637 */ 638 bool OnRestoreData(WantParams &restoreData) override; 639 640 /** 641 * @brief Migrates this ability to the given device on the same distributed network in a reversible way that allows 642 * this ability to be migrated back to the local device through reverseContinueAbility(). The ability to migrate and 643 * its ability slices must implement the IAbilityContinuation interface. Otherwise, an exception is thrown, 644 * indicating that the ability does not support migration. 645 * 646 * @param deviceId Indicates the ID of the target device where this ability will be migrated to. If this parameter 647 * is null, this method has the same effect as ContinueAbilityReversibly(). 648 * 649 */ 650 virtual void ContinueAbilityReversibly(const std::string &deviceId) final; 651 652 /** 653 * @brief Obtains the ID of the source device from which this ability is migrated. 654 * 655 * @return Returns the source device ID. 656 */ 657 virtual std::string GetOriginalDeviceId() final; 658 659 /** 660 * @brief Obtains the migration state of this ability. 661 * @return Returns the migration state. 662 */ 663 virtual ContinuationState GetContinuationState() final; 664 665 /** 666 * @brief Obtains the lifecycle state of this ability. 667 * 668 * @return Returns the lifecycle state of this ability. 669 */ 670 virtual AbilityLifecycleExecutor::LifecycleState GetState() final; 671 672 /** 673 * @brief Release the ability instance. 674 */ 675 void DestroyInstance(); 676 677 /** 678 * @brief Posts a scheduled Runnable task to a new non-UI thread. 679 * The task posted via this method will be executed in a new thread, which allows you to perform certain 680 * time-consuming operations. To use this method, you must also override the supportHighPerformanceUI() method. 681 * Additionally, the usage of this method must comply with the following constraints: 1、This method can only be 682 * used to initialize the component tree in parallel mode. 2、The task can only be processed during system cold 683 * start. 3、If the parallel loading mechanism is used, the component tree-related operations to be performed in 684 * onActive() and onStop() of the ability slice must also be added to the parallel thread. 4、You must run 685 * setUIContent(ohos.agp.components.ComponentContainer) to unlock the UI thread and wait until the component tree is 686 * ready. 5、Other time-consuming operations, such as I/O and network processing, cannot be added to the parallel 687 * task queue. 688 * 689 * @param task Indicates the Runnable task to post. 690 * 691 * @param delayTime Indicates the number of milliseconds after which the task will be executed. 692 * 693 * @return - 694 */ 695 void PostTask(std::function<void()> task, long delayTime); 696 697 /** 698 * @brief Create a PostEvent timeout task. The default delay is 5000ms 699 * 700 * @return Return a smart pointer to a timeout object 701 */ 702 std::shared_ptr<AbilityPostEventTimeout> CreatePostEventTimeouter(std::string taskstr); 703 704 /** 705 * @brief Keeps this Service ability in the background and displays a notification bar. 706 * To use this method, you need to request the ohos.permission.KEEP_BACKGROUND_RUNNING permission from the system. 707 * The ohos.permission.KEEP_BACKGROUND_RUNNING permission is of the normal level. 708 * This method can be called only by Service abilities after the onStart(ohos.aafwk.content.Want) method is called. 709 * 710 * @param id Identifies the notification bar information. 711 * @param notificationRequest Indicates the NotificationRequest instance containing information for displaying a 712 * notification bar. 713 */ 714 virtual void KeepBackgroundRunning(int id, const NotificationRequest ¬ificationRequest) final; 715 716 /** 717 * @brief Cancels background running of this ability to free up system memory. 718 * This method can be called only by Service abilities when the onStop() method is called. 719 * 720 */ 721 virtual void CancelBackgroundRunning() final; 722 723 /** 724 * @brief Keep this Service ability in the background and displays a notification bar. 725 * 726 * @param wantAgent Indicates which ability to start when user click the notification bar. 727 * @return the method result code, 0 means succeed 728 */ 729 virtual int StartBackgroundRunning(const AbilityRuntime::WantAgent::WantAgent &wantAgent) final; 730 731 /** 732 * @brief Cancel background running of this ability to free up system memory. 733 * 734 * @return the method result code, 0 means succeed 735 */ 736 virtual int StopBackgroundRunning() final; 737 738 /** 739 * @brief Acquire a bundle manager, if it not existed, 740 * @return returns the bundle manager ipc object, or nullptr for failed. 741 */ 742 sptr<IBundleMgr> GetBundleMgr(); 743 744 /** 745 * @brief Add the bundle manager instance for debug. 746 * @param bundleManager the bundle manager ipc object. 747 */ 748 void SetBundleManager(const sptr<IBundleMgr> &bundleManager); 749 750 /** 751 * @brief Prepare user data of local Ability. 752 * 753 * @param wantParams Indicates the user data to be saved. 754 * @return If the ability is willing to continue and data saved successfully, it returns 0; 755 * otherwise, it returns errcode. 756 */ 757 virtual int32_t OnContinue(WantParams &wantParams); 758 759 /** 760 * @brief Migrates this ability to the given device on the same distributed network. The ability to migrate and its 761 * ability slices must implement the IAbilityContinuation interface. 762 * 763 * @param deviceId Indicates the ID of the target device where this ability will be migrated to. 764 * @param versionCode Target bundle version. 765 */ 766 virtual void ContinueAbilityWithStack(const std::string &deviceId, uint32_t versionCode) final; 767 768 /** 769 * @brief Migrates this ability to the given device on the same distributed network. The ability to migrate and its 770 * ability slices must implement the IAbilityContinuation interface. 771 * 772 * @param deviceId Indicates the ID of the target device where this ability will be migrated to. If this parameter 773 * is null, this method has the same effect as continueAbility(). 774 * 775 */ 776 virtual void ContinueAbility(const std::string &deviceId) final; 777 778 /** 779 * @brief Callback function to ask the user whether to start the migration . 780 * 781 * @return If the user allows migration, it returns true; otherwise, it returns false. 782 */ 783 virtual bool OnStartContinuation() override; 784 785 /** 786 * @brief This function can be used to implement the processing logic after the migration is completed. 787 * 788 * @param result Migration result code. 0 means the migration was successful, -1 means the migration failed. 789 * @return None. 790 */ 791 virtual void OnCompleteContinuation(int result) override; 792 793 /** 794 * @brief Used to notify the local Ability that the remote Ability has been destroyed. 795 * 796 * @return None. 797 */ 798 virtual void OnRemoteTerminated() override; 799 800 /** 801 * @brief Prepare user data of local Ability. 802 * 803 * @param reason the reason why framework invoke this function 804 * @param wantParams Indicates the user data to be saved. 805 * @return result code defined in abilityConstants 806 */ 807 virtual int32_t OnSaveState(int32_t reason, WantParams &wantParams); 808 809 /** 810 * @brief enable ability recovery. 811 * 812 * @param abilityRecovery shared_ptr of abilityRecovery 813 */ 814 void EnableAbilityRecovery(const std::shared_ptr<AbilityRecovery>& abilityRecovery); 815 816 /** 817 * @brief Callback when the ability is shared.You can override this function to implement your own sharing logic. 818 * 819 * @param wantParams Indicates the user data to be saved. 820 * @return the result of OnShare 821 */ 822 virtual int32_t OnShare(WantParams &wantParams); 823 824 #ifdef SUPPORT_GRAPHICS 825 public: 826 friend class PageAbilityImpl; 827 uint32_t sceneFlag_ = 0; 828 829 /** 830 * @brief Sets the background color of the window in RGB color mode. 831 * 832 * @param red The value ranges from 0 to 255. 833 * 834 * @param green The value ranges from 0 to 255. 835 * 836 * @param blue The value ranges from 0 to 255. 837 * 838 * @return Returns the result of SetWindowBackgroundColor 839 */ 840 virtual int SetWindowBackgroundColor(int red, int green, int blue) final; 841 842 /** 843 * @brief Informs the system of the time required for drawing this Page ability. 844 * 845 * @return Returns the notification is successful or fail 846 */ 847 bool PrintDrawnCompleted() override; 848 849 /** 850 * @brief Called after instantiating WindowScene. 851 * 852 * 853 * You can override this function to implement your own processing logic. 854 */ 855 virtual void OnSceneCreated(); 856 857 /** 858 * @brief Called after ability stoped. 859 * 860 * 861 * You can override this function to implement your own processing logic. 862 */ 863 virtual void onSceneDestroyed(); 864 865 /** 866 * @brief Called after ability restored. 867 * 868 * 869 * You can override this function to implement your own processing logic. 870 */ 871 virtual void OnSceneRestored(); 872 873 /** 874 * @brief Called when this ability enters the <b>STATE_FOREGROUND</b> state. 875 * 876 * 877 * The ability in the <b>STATE_FOREGROUND</b> state is visible. 878 * You can override this function to implement your own processing logic. 879 */ 880 virtual void OnForeground(const Want &want); 881 882 /** 883 * @brief Called when this ability enters the <b>STATE_BACKGROUND</b> state. 884 * 885 * 886 * The ability in the <b>STATE_BACKGROUND</b> state is invisible. 887 * You can override this function to implement your own processing logic. 888 */ 889 virtual void OnBackground(); 890 891 /** 892 * @brief Called when back press is dispatched. 893 * 894 * @return Return true if ability will be moved to background; return false if will be terminated. 895 */ 896 virtual bool OnBackPress() override; 897 898 /** 899 * @brief Called when ability prepare terminate. 900 * 901 * @return Return true if ability need to stop terminating; return false if ability need to terminate. 902 */ 903 virtual bool OnPrepareTerminate(); 904 905 /** 906 * @brief Called when a key is pressed. When any component in the Ability gains focus, the key-down event for 907 * the component will be handled first. This callback will not be invoked if the callback triggered for the 908 * key-down event of the component returns true. The default implementation of this callback does nothing 909 * and returns false. 910 * 911 * @param keyEvent Indicates the key-down event. 912 * 913 * @return Returns true if this event is handled and will not be passed further; returns false if this event 914 * is not handled and should be passed to other handlers. 915 */ 916 virtual void OnKeyDown(const std::shared_ptr<MMI::KeyEvent>& keyEvent); 917 918 /** 919 * @brief Called when a key is released. When any component in the Ability gains focus, the key-up event for 920 * the component will be handled first. This callback will not be invoked if the callback triggered for the 921 * key-up event of the component returns true. The default implementation of this callback does nothing and 922 * returns false. 923 * 924 * @param keyEvent Indicates the key-up event. 925 * 926 * @return Returns true if this event is handled and will not be passed further; returns false if this event 927 * is not handled and should be passed to other handlers. 928 */ 929 virtual void OnKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent); 930 931 /** 932 * @brief Called when a touch event is dispatched to this ability. The default implementation of this callback 933 * does nothing and returns false. 934 * 935 * @param event Indicates information about the touch event. 936 * 937 * @return Returns true if the event is handled; returns false otherwise. 938 */ 939 virtual void OnPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent); 940 941 /** 942 * @brief Called when this ability gains or loses window focus. 943 * 944 * @param hasFocus Specifies whether this ability has focus. 945 */ 946 virtual void OnWindowFocusChanged(bool hasFocus); 947 948 /** 949 * @brief Called when this ability is moved to or removed from the top of the stack. 950 * 951 * @param topActive Specifies whether this ability is moved to or removed from the top of the stack. The value true 952 * indicates that it is moved to the top, and false indicates that it is removed from the top of the stack. 953 */ 954 virtual void OnTopActiveAbilityChanged(bool topActive); 955 956 /** 957 * @brief Inflates UI controls by using windowOption. 958 * 959 * @param windowOption Indicates the window option defined by the user. 960 */ 961 virtual void InitWindow(int32_t displayId, sptr<Rosen::WindowOption> option); 962 963 /** 964 * @brief Get the window belong to the ability. 965 * 966 * @return Returns a Window object pointer. 967 */ 968 virtual const sptr<Rosen::Window> GetWindow(); 969 970 /** 971 * @brief get the scene belong to the ability. 972 * 973 * @return Returns a WindowScene object pointer. 974 */ 975 std::shared_ptr<Rosen::WindowScene> GetScene(); 976 977 /** 978 * @brief Checks whether the main window of this ability has window focus. 979 * 980 * @return Returns true if this ability currently has window focus; returns false otherwise. 981 */ 982 bool HasWindowFocus(); 983 984 void SetShowOnLockScreen(bool showOnLockScreen); 985 986 /** 987 * @brief When the ability starts, set whether to wake up the screen. 988 * 989 * @param wakeUp Set true to wake up, false to not wake up. 990 */ 991 void SetWakeUpScreen(bool wakeUp); 992 993 /** 994 * @brief Set the display orientation of the main window. 995 * 996 * @param orientation Indicates the display orientation of the window. 997 */ 998 void SetDisplayOrientation(int orientation); 999 1000 /** 1001 * @brief Get the display orientation of the main window. 1002 * 1003 * @return Returns the display orientation of the window. 1004 */ 1005 int GetDisplayOrientation() override; 1006 1007 /** 1008 * @brief Called when this ability is about to leave the foreground and enter the background due to a user 1009 * operation, for example, when the user touches the Home key. 1010 * 1011 */ 1012 virtual void OnLeaveForeground(); 1013 1014 /** 1015 * @brief Sets the type of audio whose volume will be adjusted by the volume button. 1016 * 1017 * @param volumeType Indicates the AudioManager.AudioVolumeType to set. 1018 */ 1019 virtual void SetVolumeTypeAdjustedByKey(int volumeType); 1020 1021 /** 1022 * @brief Called to return a FormProviderInfo object. 1023 * 1024 * <p>You must override this method if your ability will serve as a form provider to provide a form for clients. 1025 * The default implementation returns nullptr. </p> 1026 * 1027 * @param want Indicates the detailed information for creating a FormProviderInfo. 1028 * The Want object must include the form ID, form name of the form, 1029 * which can be obtained from Ability#PARAM_FORM_IDENTITY_KEY, 1030 * Ability#PARAM_FORM_NAME_KEY, and Ability#PARAM_FORM_DIMENSION_KEY, 1031 * respectively. Such form information must be managed as persistent data for further form 1032 * acquisition, update, and deletion. 1033 * 1034 * @return Returns the created FormProviderInfo object. 1035 */ 1036 virtual FormProviderInfo OnCreate(const Want &want); 1037 1038 virtual bool OnShare(int64_t formId, AAFwk::WantParams &wantParams); 1039 1040 /** 1041 * @brief Called to notify the form provider that a specified form has been deleted. Override this method if 1042 * you want your application, as the form provider, to be notified of form deletion. 1043 * 1044 * @param formId Indicates the ID of the deleted form. 1045 * @return None. 1046 */ 1047 virtual void OnDelete(const int64_t formId); 1048 1049 /** 1050 * @brief Called when the form provider is notified that a temporary form is successfully converted to 1051 * a normal form. 1052 * 1053 * @param formId Indicates the ID of the form. 1054 * @return None. 1055 */ 1056 virtual void OnCastTemptoNormal(const int64_t formId); 1057 1058 /** 1059 * @brief Called to notify the form provider to update a specified form. 1060 * 1061 * @param formId Indicates the ID of the form to update. 1062 * @return none. 1063 */ 1064 virtual void OnUpdate(const int64_t formId); 1065 1066 /** 1067 * @brief Called when the form provider receives form events from the fms. 1068 * 1069 * @param formEventsMap Indicates the form events occurred. The key in the Map object indicates the form ID, 1070 * and the value indicates the event type, which can be either FORM_VISIBLE 1071 * or FORM_INVISIBLE. FORM_VISIBLE means that the form becomes visible, 1072 * and FORM_INVISIBLE means that the form becomes invisible. 1073 * @return none. 1074 */ 1075 virtual void OnVisibilityChanged(const std::map<int64_t, int32_t> &formEventsMap); 1076 /** 1077 * @brief Called to notify the form provider to update a specified form. 1078 * 1079 * @param formId Indicates the ID of the form to update. 1080 * @param message Form event message. 1081 */ 1082 virtual void OnTriggerEvent(const int64_t formId, const std::string &message); 1083 /** 1084 * @brief Called to notify the form supplier to acquire form state. 1085 * 1086 * @param want Indicates the detailed information about the form to be obtained, including 1087 * the bundle name, module name, ability name, form name and form dimension. 1088 */ 1089 virtual FormState OnAcquireFormState(const Want &want); 1090 1091 /** 1092 * @brief Get page ability stack info. 1093 * 1094 * @return A string represents page ability stack info, empty if failed; 1095 */ 1096 virtual std::string GetContentInfo(); 1097 1098 /** 1099 * @brief Set WindowScene listener 1100 * 1101 * @param listener WindowScene listener 1102 * @return None. 1103 */ 1104 void SetSceneListener(const sptr<Rosen::IWindowLifeCycle> &listener); 1105 1106 /** 1107 * @brief Called back at ability context. 1108 * 1109 * @return current window mode of the ability. 1110 */ 1111 virtual int GetCurrentWindowMode() override; 1112 1113 /** 1114 * @brief Set mission label of this ability. 1115 * 1116 * @param label the label of this ability. 1117 * @return Returns ERR_OK if success. 1118 */ 1119 virtual ErrCode SetMissionLabel(const std::string &label) override; 1120 1121 /** 1122 * @brief Set mission icon of this ability. 1123 * 1124 * @param icon the icon of this ability. 1125 * @return Returns ERR_OK if success. 1126 */ 1127 virtual ErrCode SetMissionIcon(const std::shared_ptr<OHOS::Media::PixelMap> &icon) override; 1128 1129 /** 1130 * @brief Get window rectangle of this ability. 1131 * 1132 * @param the left position of window rectangle. 1133 * @param the top position of window rectangle. 1134 * @param the width position of window rectangle. 1135 * @param the height position of window rectangle. 1136 */ 1137 virtual void GetWindowRect(int32_t &left, int32_t &top, int32_t &width, int32_t &height) override; 1138 1139 /** 1140 * @brief Get ui content object. 1141 * 1142 * @return UIContent object of ACE. 1143 */ 1144 Ace::UIContent* GetUIContent() override; 1145 1146 protected: 1147 class AbilityDisplayListener : public OHOS::Rosen::DisplayManager::IDisplayListener { 1148 public: AbilityDisplayListener(const std::weak_ptr<Ability> & ability)1149 explicit AbilityDisplayListener(const std::weak_ptr<Ability>& ability) 1150 { 1151 ability_ = ability; 1152 } 1153 OnCreate(Rosen::DisplayId displayId)1154 void OnCreate(Rosen::DisplayId displayId) override 1155 { 1156 auto sptr = ability_.lock(); 1157 if (sptr != nullptr) { 1158 sptr->OnCreate(displayId); 1159 } 1160 } 1161 OnDestroy(Rosen::DisplayId displayId)1162 void OnDestroy(Rosen::DisplayId displayId) override 1163 { 1164 auto sptr = ability_.lock(); 1165 if (sptr != nullptr) { 1166 sptr->OnDestroy(displayId); 1167 } 1168 } 1169 OnChange(Rosen::DisplayId displayId)1170 void OnChange(Rosen::DisplayId displayId) override 1171 { 1172 auto sptr = ability_.lock(); 1173 if (sptr != nullptr) { 1174 sptr->OnChange(displayId); 1175 } 1176 } 1177 private: 1178 std::weak_ptr<Ability> ability_; 1179 }; 1180 1181 /** 1182 * @brief override Rosen::DisplayManager::IDisplayListener virtual callback function 1183 * 1184 * @param displayId displayId 1185 */ 1186 void OnCreate(Rosen::DisplayId displayId); 1187 void OnDestroy(Rosen::DisplayId displayId); 1188 void OnChange(Rosen::DisplayId displayId); 1189 1190 class AbilityDisplayMoveListener : public OHOS::Rosen::IDisplayMoveListener { 1191 public: AbilityDisplayMoveListener(std::weak_ptr<Ability> && ability)1192 explicit AbilityDisplayMoveListener(std::weak_ptr<Ability>&& ability) : ability_(ability) {} 1193 OnDisplayMove(Rosen::DisplayId from,Rosen::DisplayId to)1194 void OnDisplayMove(Rosen::DisplayId from, Rosen::DisplayId to) override 1195 { 1196 auto sptr = ability_.lock(); 1197 if (sptr != nullptr) { 1198 sptr->OnDisplayMove(from, to); 1199 } 1200 } 1201 private: 1202 std::weak_ptr<Ability> ability_; 1203 }; 1204 1205 /** 1206 * @brief override Rosen::IDisplayMoveListener virtual callback function 1207 * 1208 * @param from the displayId before display move 1209 * @param to the displayId after display move 1210 */ 1211 void OnDisplayMove(Rosen::DisplayId from, Rosen::DisplayId to); 1212 1213 /** 1214 * @brief process when foreground executed. 1215 * 1216 * You can override this function to implement your own processing logic 1217 */ 1218 virtual void DoOnForeground(const Want& want); 1219 1220 /** 1221 * @brief request focus for current window. 1222 * 1223 * You can override this function to implement your own processing logic 1224 */ 1225 virtual void RequestFocus(const Want &want); 1226 1227 /** 1228 * @brief Acquire the window option. 1229 * @return window option. 1230 */ 1231 sptr<Rosen::WindowOption> GetWindowOption(const Want &want); 1232 1233 /** 1234 * @brief Restore window stage data and scene in ability continuation. 1235 * 1236 */ 1237 virtual void ContinuationRestore(const Want &want); 1238 1239 std::shared_ptr<Rosen::WindowScene> scene_ = nullptr; 1240 sptr<Rosen::IWindowLifeCycle> sceneListener_ = nullptr; 1241 sptr<AbilityDisplayListener> abilityDisplayListener_ = nullptr; 1242 sptr<Rosen::IDisplayMoveListener> abilityDisplayMoveListener_ = nullptr; 1243 #endif 1244 1245 protected: 1246 /** 1247 * @brief Acquire the launch parameter. 1248 * @return launch parameter. 1249 */ 1250 const AAFwk::LaunchParam& GetLaunchParam() const; 1251 1252 /** 1253 * @brief judge where invoke restoreWindowStage in continuation 1254 * @return true if invoked restoreWindowStage in continuation. 1255 */ 1256 bool IsRestoredInContinuation() const; 1257 1258 /** 1259 * @brief Notify continuation 1260 * 1261 * @param want the want param. 1262 * @param success whether continuation success. 1263 */ 1264 void NotifyContinuationResult(const Want& want, bool success); 1265 1266 /** 1267 * @brief judge whether we should restore state 1268 * @return true if we we should restore state 1269 */ 1270 bool ShouldRecoverState(const Want& want); 1271 1272 bool IsUseNewStartUpRule(); 1273 1274 std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext_ = nullptr; 1275 std::shared_ptr<AbilityStartSetting> setting_ = nullptr; 1276 std::shared_ptr<AbilityRecovery> abilityRecovery_ = nullptr; 1277 std::shared_ptr<AbilityInfo> abilityInfo_ = nullptr; 1278 LaunchParam launchParam_; 1279 int32_t appIndex_ = 0; 1280 bool securityFlag_ = false; 1281 1282 private: 1283 std::shared_ptr<NativeRdb::DataAbilityPredicates> ParsePredictionArgsReference( 1284 std::vector<std::shared_ptr<DataAbilityResult>> &results, std::shared_ptr<DataAbilityOperation> &operation, 1285 int numRefs); 1286 1287 std::shared_ptr<NativeRdb::ValuesBucket> ParseValuesBucketReference( 1288 std::vector<std::shared_ptr<DataAbilityResult>> &results, std::shared_ptr<DataAbilityOperation> &operation, 1289 int numRefs); 1290 1291 int ChangeRef2Value(std::vector<std::shared_ptr<DataAbilityResult>> &results, int numRefs, int index); 1292 1293 bool CheckAssertQueryResult(std::shared_ptr<NativeRdb::AbsSharedResultSet> &queryResult, 1294 std::shared_ptr<NativeRdb::ValuesBucket> &&valuesBucket); 1295 1296 void DispatchLifecycleOnForeground(const Want &want); 1297 1298 friend class AbilityImpl; 1299 bool VerifySupportForContinuation(); 1300 void HandleCreateAsContinuation(const Want &want); 1301 bool IsFlagExists(unsigned int flag, unsigned int flagSet); 1302 void HandleCreateAsRecovery(const Want &want); 1303 /** 1304 * @brief Set the start ability setting. 1305 * @param setting the start ability setting. 1306 */ 1307 void SetStartAbilitySetting(std::shared_ptr<AbilityStartSetting> setting); 1308 1309 /** 1310 * @brief Set the launch param. 1311 * 1312 * @param launchParam the launch param. 1313 */ 1314 void SetLaunchParam(const AAFwk::LaunchParam &launchParam); 1315 1316 void InitConfigurationProperties(const Configuration& changeConfiguration, std::string& language, 1317 std::string& colormode, std::string& hasPointerDevice); 1318 1319 std::shared_ptr<ContinuationHandler> continuationHandler_ = nullptr; 1320 std::shared_ptr<ContinuationManager> continuationManager_ = nullptr; 1321 std::shared_ptr<ContinuationRegisterManager> continuationRegisterManager_ = nullptr; 1322 std::shared_ptr<AbilityHandler> handler_ = nullptr; 1323 std::shared_ptr<LifeCycle> lifecycle_ = nullptr; 1324 std::shared_ptr<AbilityLifecycleExecutor> abilityLifecycleExecutor_ = nullptr; 1325 std::shared_ptr<OHOSApplication> application_ = nullptr; 1326 std::vector<std::string> types_; 1327 std::map<int, FeatureAbilityTask> resultCallbacks_; 1328 std::shared_ptr<AAFwk::Want> setWant_ = nullptr; 1329 sptr<IRemoteObject> reverseContinuationSchedulerReplica_ = nullptr; 1330 1331 static const std::string SYSTEM_UI; 1332 static const std::string STATUS_BAR; 1333 static const std::string NAVIGATION_BAR; 1334 static const std::string KEYGUARD; 1335 sptr<IRemoteObject> providerRemoteObject_ = nullptr; 1336 // Keep consistent with DMS defines. Used to callback to DMS. 1337 static const std::string DMS_SESSION_ID; 1338 1339 // The originating deviceId passed by DMS using want param. 1340 static const std::string DMS_ORIGIN_DEVICE_ID; 1341 1342 // If session id cannot get from want, assign it as default. 1343 static const int DEFAULT_DMS_SESSION_ID; 1344 sptr<IBundleMgr> iBundleMgr_; 1345 1346 bool isNewRuleFlagSetted_ = false; 1347 bool startUpNewRule_ = false; 1348 1349 #ifdef SUPPORT_GRAPHICS 1350 private: 1351 std::shared_ptr<AbilityWindow> abilityWindow_ = nullptr; 1352 bool bWindowFocus_ = false; 1353 bool showOnLockScreen_ = false; 1354 #endif 1355 }; 1356 } // namespace AppExecFwk 1357 } // namespace OHOS 1358 #endif // OHOS_ABILITY_RUNTIME_ABILITY_H