1 /* 2 * Copyright (c) 2021-2022 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_OHOS_CONTEXT_H 17 #define FOUNDATION_APPEXECFWK_OHOS_CONTEXT_H 18 19 #include <memory> 20 21 #include "bundle_mgr_interface.h" 22 #include "ability_manager_interface.h" 23 #include "ability_info.h" 24 #include "process_info.h" 25 #include "resource_manager.h" 26 #include "dummy_hap_module_info.h" 27 #include "hap_module_info.h" 28 #include "task/task_priority.h" 29 #include "mission_information.h" 30 31 namespace OHOS { 32 namespace AppExecFwk { 33 using Want = OHOS::AAFwk::Want; 34 using AbilityStartSetting = AAFwk::AbilityStartSetting; 35 // Request permissions for user 36 #define OHOS_REQUEST_PERMISSION_BUNDLENAME "com.ohos.systemui" 37 #define OHOS_REQUEST_PERMISSION_ABILITY_NAME "com.ohos.systemui.systemdialog.MainAbility" 38 39 #define OHOS_REQUEST_PERMISSION_KEY "OHOS_REQUEST_PERMISSION_KEY" 40 #define OHOS_REQUEST_PERMISSIONS_LIST "OHOS_REQUEST_PERMISSIONS_LIST" 41 #define OHOS_REQUEST_PERMISSIONS_DES_LIST "OHOS_REQUEST_PERMISSIONS_DES_LIST" 42 #define OHOS_REQUEST_CALLER_BUNDLERNAME "OHOS_REQUEST_CALLER_BUNDLERNAME" 43 44 #define OHOS_RESULT_PERMISSION_KEY "OHOS_RESULT_PERMISSION_KEY" 45 #define OHOS_RESULT_PERMISSIONS_LIST "OHOS_RESULT_PERMISSIONS_LIST" 46 #define OHOS_RESULT_PERMISSIONS_LIST_YES "OHOS_RESULT_PERMISSIONS_LIST_YES" 47 #define OHOS_RESULT_PERMISSIONS_LIST_NO "OHOS_RESULT_PERMISSIONS_LIST_NO" 48 #define OHOS_RESULT_CALLER_BUNDLERNAME "OHOS_RESULT_CALLER_BUNDLERNAME" 49 50 #define OHOS_REQUEST_PERMISSION_VALUE 1 51 52 constexpr int INVALID_RESOURCE_VALUE = -1; // GetColor() Failed return Value 53 constexpr int DEFAULT_ACCOUNT_ID = -1; 54 55 class DataAbilityHelper; 56 class DataShareHelper; 57 class ContinuationConnector; 58 class IAbilityManager; 59 class TaskDispatcher; 60 class EventRunner; 61 class Context { 62 public: 63 Context() = default; 64 virtual ~Context() = default; 65 66 /** 67 * The value 0 indicates that there is no restriction on creating contexts for applications. 68 */ 69 int MODE_PRIVATE = 0x0000; 70 71 /** 72 * static final int CONTEXT_INCLUDE_CODE 73 * Indicates the flag used with createBundleContext(java.lang.String,int) for creating a Context 74 * object that includes the application code. 75 * 76 * The value is 0x00000001. 77 * 78 * @since 3 79 */ 80 int CONTEXT_INCLUDE_CODE = 0x00000001; 81 82 /** 83 * static final int CONTEXT_IGNORE_SECURITY 84 * Indicates the flag used with createBundleContext(java.lang.String,int) for creating a Context 85 * object that can always be loaded with all security restrictions ignored. 86 * 87 * The value is 0x00000002. 88 * 89 * @since 3 90 */ 91 int CONTEXT_IGNORE_SECURITY = 0x00000002; 92 93 /** 94 * static final int CONTEXT_RESTRICTED 95 * Indicates the flag used with createBundleContext(java.lang.String,int) for creating a Context 96 * object in which particular features may be disabled. 97 * 98 * The value is 0x00000004. 99 * 100 * @since 3 101 */ 102 int CONTEXT_RESTRICTED = 0x00000004; 103 104 int CONTEXT_RESOUCE_ONLY = 0x00000008; 105 106 /** 107 * Called when getting the ProcessInfo 108 * 109 * @return ProcessInfo 110 */ 111 virtual std::shared_ptr<ProcessInfo> GetProcessInfo() const = 0; 112 113 /** 114 * @brief Obtains information about the current application. The returned application information includes basic 115 * information such as the application name and application permissions. 116 * 117 * @return Returns the ApplicationInfo for the current application. 118 */ 119 virtual std::shared_ptr<ApplicationInfo> GetApplicationInfo() const = 0; 120 121 /** 122 * @brief Obtains the Context object of the application. 123 * 124 * @return Returns the Context object of the application. 125 */ 126 virtual std::shared_ptr<Context> GetApplicationContext() const = 0; 127 128 /** 129 * @brief Obtains the path of the package containing the current ability. The returned path contains the resources, 130 * source code, and configuration files of a module. 131 * 132 * @return Returns the path of the package file. 133 */ 134 virtual std::string GetBundleCodePath() = 0; 135 136 /** 137 * @brief Obtains information about the current ability. 138 * The returned information includes the class name, bundle name, and other information about the current ability. 139 * 140 * @return Returns the AbilityInfo object for the current ability. 141 */ 142 virtual const std::shared_ptr<AbilityInfo> GetAbilityInfo() = 0; 143 144 /** 145 * @brief Obtains the Context object of the application. 146 * 147 * @return Returns the Context object of the application. 148 */ 149 virtual std::shared_ptr<Context> GetContext() = 0; 150 151 /** 152 * @brief Obtains an IBundleMgr instance. 153 * You can use this instance to obtain information about the application bundle. 154 * 155 * @return Returns an IBundleMgr instance. 156 */ 157 virtual sptr<IBundleMgr> GetBundleManager() const = 0; 158 159 /** 160 * @brief Obtains a resource manager. 161 * 162 * @return Returns a ResourceManager object. 163 */ 164 virtual std::shared_ptr<Global::Resource::ResourceManager> GetResourceManager() const = 0; 165 166 /** 167 * @brief Deletes the specified private file associated with the application. 168 * 169 * @param fileName Indicates the name of the file to delete. The file name cannot contain path separators. 170 * 171 * @return Returns true if the file is deleted successfully; returns false otherwise. 172 */ 173 virtual bool DeleteFile(const std::string &fileName) = 0; 174 175 /** 176 * @brief Destroys another ability that uses the AbilityInfo.AbilityType.SERVICE template. 177 * The current ability using either the AbilityInfo.AbilityType.SERVICE or AbilityInfo.AbilityType.PAGE 178 * template can call this method to destroy another ability that uses the AbilityInfo.AbilityType.SERVICE 179 * template. The current ability itself can be destroyed by calling the terminateAbility() method. 180 * 181 * @param want Indicates the Want containing information about the ability to destroy. 182 * 183 * @return Returns true if the ability is destroyed successfully; returns false otherwise. 184 */ 185 virtual bool StopAbility(const AAFwk::Want &want) = 0; 186 187 /** 188 * @brief Obtains the application-specific cache directory on the device's internal storage. The system 189 * automatically deletes files from the cache directory if disk space is required elsewhere on the device. 190 * Older files are always deleted first. 191 * 192 * @return Returns the application-specific cache directory. 193 */ 194 virtual std::string GetCacheDir() = 0; 195 196 /** 197 * @brief Obtains the application-specific code-cache directory on the device's internal storage. 198 * The system will delete any files stored in this location both when your specific application is upgraded, 199 * and when the entire platform is upgraded. 200 * 201 * @return Returns the application-specific code-cache directory. 202 */ 203 virtual std::string GetCodeCacheDir() = 0; 204 205 /** 206 * @brief Obtains the local database path. 207 * If the local database path does not exist, the system creates one and returns the created path. 208 * 209 * @return Returns the local database file. 210 */ 211 virtual std::string GetDatabaseDir() = 0; 212 213 /** 214 * @brief Obtains the absolute path where all private data files of this application are stored. 215 * 216 * @return Returns the absolute path storing all private data files of this application. 217 */ 218 virtual std::string GetDataDir() = 0; 219 220 /** 221 * @brief Obtains the directory for storing custom data files of the application. 222 * You can use the returned File object to create and access files in this directory. The files 223 * can be accessible only by the current application. 224 * 225 * @param name Indicates the name of the directory to retrieve. This directory is created as part 226 * of your application data. 227 * @param mode Indicates the file operating mode. The value can be 0 or a combination of MODE_PRIVATE. 228 * 229 * @return Returns a File object for the requested directory. 230 */ 231 virtual std::string GetDir(const std::string &name, int mode) = 0; 232 233 /** 234 * @brief Obtains the absolute path to the application-specific cache directory 235 * on the primary external or shared storage device. 236 * 237 * @return Returns the absolute path to the application-specific cache directory on the external or 238 * shared storage device; returns null if the external or shared storage device is temporarily unavailable. 239 */ 240 virtual std::string GetExternalCacheDir() = 0; 241 242 /** 243 * @brief Obtains the absolute path to the directory for storing files for the application on the 244 * primary external or shared storage device. 245 * 246 * @param type Indicates the type of the file directory to return 247 * 248 * @return Returns the absolute path to the application file directory on the external or shared storage 249 * device; returns null if the external or shared storage device is temporarily unavailable. 250 */ 251 virtual std::string GetExternalFilesDir(std::string &type) = 0; 252 253 /** 254 * @brief Obtains the directory for storing files for the application on the device's internal storage. 255 * 256 * @return Returns the application file directory. 257 */ 258 virtual std::string GetFilesDir() = 0; 259 260 /** 261 * @brief Obtains the absolute path which app created and will be excluded from automatic backup to remote storage. 262 * The returned path maybe changed if the application is moved to an adopted storage device. 263 * 264 * @return The path of the directory holding application files that will not be automatically backed up to remote 265 * storage. 266 */ 267 virtual std::string GetNoBackupFilesDir() = 0; 268 269 /** 270 * @brief Checks whether the current process has the given permission. 271 * You need to call requestPermissionsFromUser(std::vector<std::string>,std::vector<int>, int) to request 272 * a permission only if the current process does not have the specific permission. 273 * 274 * @param permission Indicates the permission to check. This parameter cannot be null. 275 * 276 * @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission; 277 * returns -1 (IBundleManager.PERMISSION_DENIED) otherwise. 278 */ 279 virtual int VerifySelfPermission(const std::string &permission) = 0; 280 281 /** 282 * @brief Obtains the bundle name of the current ability. 283 * 284 * @return Returns the bundle name of the current ability. 285 */ 286 virtual std::string GetBundleName() const = 0; 287 288 /** 289 * @brief Obtains the path of the OHOS Ability Package (HAP} containing this ability. 290 * 291 * @return Returns the path of the HAP containing this ability. 292 */ 293 virtual std::string GetBundleResourcePath() = 0; 294 295 /** 296 * @brief Starts a new ability. 297 * An ability using the AbilityInfo.AbilityType.SERVICE or AbilityInfo.AbilityType.PAGE template uses this method 298 * to start a specific ability. The system locates the target ability from installed abilities based on the value 299 * of the want parameter and then starts it. You can specify the ability to start using the want parameter. 300 * 301 * @param want Indicates the Want containing information about the target ability to start. 302 * 303 * @param requestCode Indicates the request code returned after the ability using the AbilityInfo.AbilityType.PAGE 304 * template is started. You can define the request code to identify the results returned by abilities. The value 305 * ranges from 0 to 65535. This parameter takes effect only on abilities using the AbilityInfo.AbilityType.PAGE 306 * template. 307 * 308 * @return errCode ERR_OK on success, others on failure. 309 */ 310 virtual ErrCode StartAbility(const AAFwk::Want &want, int requestCode) = 0; 311 312 /** 313 * @brief Remove permissions for all users who have access to specific permissions 314 * 315 * @param permission Indicates the permission to unauth. This parameter cannot be null. 316 * @param uri Indicates the URI to unauth. This parameter cannot be null. 317 * @param uid Indicates the UID of the unauth to check. 318 * 319 */ 320 virtual void UnauthUriPermission(const std::string &permission, const Uri &uri, int uid) = 0; 321 322 /** 323 * @brief Obtains an ability manager. 324 * The ability manager provides information about running processes and memory usage of an application. 325 * 326 * @return Returns an IAbilityManager instance. 327 */ 328 virtual sptr<AAFwk::IAbilityManager> GetAbilityManager() = 0; 329 330 /** 331 * @brief Obtains the type of this application. 332 * 333 * @return Returns system if this application is a system application; 334 * returns normal if it is released in OHOS AppGallery; 335 * returns other if it is released by a third-party vendor; 336 * returns an empty string if the query fails. 337 */ 338 virtual std::string GetAppType() = 0; 339 340 /** 341 * @brief Destroys another ability you had previously started by calling Ability.startAbilityForResult 342 * (ohos.aafwk.content.Want, int, ohos.aafwk.ability.startsetting.AbilityStartSetting) with the same requestCode 343 * passed. 344 * 345 * @param requestCode Indicates the request code passed for starting the ability. 346 * 347 * @return errCode ERR_OK on success, others on failure. 348 */ 349 virtual ErrCode TerminateAbility(int requestCode) = 0; 350 351 /** 352 * @brief Destroys the current ability. 353 * 354 * @return errCode ERR_OK on success, others on failure. 355 */ 356 virtual ErrCode TerminateAbility() = 0; 357 358 /** 359 * @brief Query whether the application of the specified PID and UID has been granted a certain permission 360 * 361 * @param permissions Indicates the list of permissions to be requested. This parameter cannot be null. 362 * @param pid Process id 363 * @param uid 364 * @return Returns 0 (IBundleManager.PERMISSION_GRANTED) if the current process has the permission; 365 * returns -1 (IBundleManager.PERMISSION_DENIED) otherwise. 366 */ 367 virtual int VerifyPermission(const std::string &permission, int pid, int uid) = 0; 368 369 /** 370 * @brief Obtains the distributed file path. 371 * If the distributed file path does not exist, the system creates one and returns the created path. This method is 372 * applicable only to the context of an ability rather than that of an application. 373 * 374 * @return Returns the distributed file. 375 */ 376 virtual std::string GetDistributedDir() = 0; 377 378 /** 379 * @brief Sets the pattern of this Context based on the specified pattern ID. 380 * 381 * @param patternId Indicates the resource ID of the pattern to set. 382 */ 383 virtual void SetPattern(int patternId) = 0; 384 385 /** 386 * @brief Obtains the Context object of this ability. 387 * 388 * @return Returns the Context object of this ability. 389 */ 390 virtual std::shared_ptr<Context> GetAbilityPackageContext() = 0; 391 392 /** 393 * @brief Obtains the HapModuleInfo object of the application. 394 * 395 * @return Returns the HapModuleInfo object of the application. 396 */ 397 virtual std::shared_ptr<HapModuleInfo> GetHapModuleInfo() = 0; 398 399 /** 400 * @brief Obtains the name of the current process. 401 * 402 * @return Returns the current process name. 403 */ 404 virtual std::string GetProcessName() = 0; 405 406 /** 407 * @brief Obtains the bundle name of the ability that called the current ability. 408 * You can use the obtained bundle name to check whether the calling ability is allowed to receive the data you will 409 * send. If you did not use Ability.startAbilityForResult(ohos.aafwk.content.Want, int, 410 * ohos.aafwk.ability.startsetting.AbilityStartSetting) to start the calling ability, null is returned. 411 * 412 * @return Returns the bundle name of the calling ability; returns null if no calling ability is available. 413 */ 414 virtual std::string GetCallingBundle() = 0; 415 416 /** 417 * @brief Requests certain permissions from the system. 418 * This method is called for permission request. This is an asynchronous method. When it is executed, 419 * the Ability.onRequestPermissionsFromUserResult(int, String[], int[]) method will be called back. 420 * 421 * @param permissions Indicates the list of permissions to be requested. This parameter cannot be null. 422 * @param permissionsState Indicates the list of permissions' state to be requested. This parameter cannot be null. 423 * @param requestCode Indicates the request code to be passed to the Ability.onRequestPermissionsFromUserResult(int, 424 * String[], int[]) callback method. This code cannot be a negative number. 425 * 426 */ 427 virtual void RequestPermissionsFromUser(std::vector<std::string> &permissions, std::vector<int> &permissionsState, 428 int requestCode) = 0; 429 430 /** 431 * @brief Starts a new ability with special ability start setting. 432 * 433 * @param want Indicates the Want containing information about the target ability to start. 434 * @param requestCode Indicates the request code returned after the ability is started. You can define the request 435 * code to identify the results returned by abilities. The value ranges from 0 to 65535. 436 * @param abilityStartSetting Indicates the special start setting used in starting ability. 437 * 438 * @return errCode ERR_OK on success, others on failure. 439 */ 440 virtual ErrCode StartAbility(const Want &want, int requestCode, const AbilityStartSetting &abilityStartSetting) = 0; 441 442 /** 443 * @brief Connects the current ability to an ability using the AbilityInfo.AbilityType.SERVICE template. 444 * 445 * @param want Indicates the want containing information about the ability to connect 446 * 447 * @param conn Indicates the callback object when the target ability is connected. 448 * 449 * @return True means success and false means failure 450 */ 451 virtual bool ConnectAbility(const Want &want, const sptr<AAFwk::IAbilityConnection> &conn) = 0; 452 453 /** 454 * @brief Disconnects the current ability from an ability 455 * 456 * @param conn Indicates the IAbilityConnection callback object passed by connectAbility after the connection 457 * is set up. The IAbilityConnection object uniquely identifies a connection between two abilities. 458 * 459 * @return errCode ERR_OK on success, others on failure. 460 */ 461 virtual ErrCode DisconnectAbility(const sptr<AAFwk::IAbilityConnection> &conn) = 0; 462 463 /** 464 * @brief Obtains information about the caller of this ability. 465 * 466 * @return Returns the caller information. 467 */ 468 virtual Uri GetCaller() = 0; 469 470 /** 471 * @brief Get the string of this Context based on the specified resource ID. 472 * 473 * @param resId Indicates the resource ID of the string to get. 474 * 475 * @return Returns the string of this Context. 476 */ 477 virtual std::string GetString(int resId) = 0; 478 479 /** 480 * @brief Get the string array of this Context based on the specified resource ID. 481 * 482 * @param resId Indicates the resource ID of the string array to get. 483 * 484 * @return Returns the string array of this Context. 485 */ 486 virtual std::vector<std::string> GetStringArray(int resId) = 0; 487 488 /** 489 * @brief Get the integer array of this Context based on the specified resource ID. 490 * 491 * @param resId Indicates the resource ID of the integer array to get. 492 * 493 * @return Returns the integer array of this Context. 494 */ 495 virtual std::vector<int> GetIntArray(int resId) = 0; 496 497 /** 498 * @brief Obtains the theme of this Context. 499 * 500 * @return theme Returns the theme of this Context. 501 */ 502 virtual std::map<std::string, std::string> GetTheme() = 0; 503 504 /** 505 * @brief Sets the theme of this Context based on the specified theme ID. 506 * 507 * @param themeId Indicates the resource ID of the theme to set. 508 */ 509 virtual void SetTheme(int themeId) = 0; 510 511 /** 512 * @brief Obtains the pattern of this Context. 513 * 514 * @return getPattern in interface Context 515 */ 516 virtual std::map<std::string, std::string> GetPattern() = 0; 517 518 /** 519 * @brief Get the color of this Context based on the specified resource ID. 520 * 521 * @param resId Indicates the resource ID of the color to get. 522 * 523 * @return Returns the color value of this Context. 524 */ 525 virtual int GetColor(int resId) = 0; 526 527 /** 528 * @brief Obtains the theme id of this Context. 529 * 530 * @return int Returns the theme id of this Context. 531 */ 532 virtual int GetThemeId() = 0; 533 534 /** 535 * @brief 536 * Destroys this Service ability if the number of times it has been started equals the number represented by the 537 * given {@code startId}. This method is the same as calling {@link #terminateAbility} to destroy this Service 538 * ability, except that this method helps you avoid destroying it if a client has requested a Service 539 * ability startup in {@link ohos.aafwk.ability.Ability#onCommand} but you are unaware of it. 540 * 541 * @param startId Indicates the number of startup times of this Service ability passed to 542 * {@link ohos.aafwk.ability.Ability#onCommand}. The {@code startId} is 543 * incremented by 1 every time this ability is started. For example, 544 * if this ability has been started for six times, the value of {@code startId} is {@code 6}. 545 * 546 * @return Returns {@code true} if the {@code startId} matches the number of startup times 547 * and this Service ability will be destroyed; returns {@code false} otherwise. 548 */ 549 virtual bool TerminateAbilityResult(int startId) = 0; 550 551 /** 552 * @brief Obtains the current display orientation of this ability. 553 * 554 * @return Returns the current display orientation. 555 */ 556 virtual int GetDisplayOrientation() = 0; 557 558 /** 559 * @brief Obtains the path storing the preference file of the application. 560 * If the preference file path does not exist, the system creates one and returns the created path. 561 * 562 * @return Returns the preference file path . 563 */ 564 virtual std::string GetPreferencesDir() = 0; 565 566 /** 567 * @brief Set color mode 568 * 569 * @param the value of color mode. 570 */ 571 virtual void SetColorMode(int mode) = 0; 572 573 /** 574 * @brief Obtains color mode. 575 * 576 * @return Returns the color mode value. 577 */ 578 virtual int GetColorMode() = 0; 579 580 /** 581 * @brief Obtains the unique ID of the mission containing this ability. 582 * 583 * @return Returns the unique mission ID. 584 */ 585 virtual int GetMissionId() = 0; 586 587 /** 588 * @brief Call this when your ability should be closed and the mission should be completely removed as a part of 589 * finishing the root ability of the mission. 590 */ 591 virtual void TerminateAndRemoveMission() = 0; 592 593 /** 594 * @brief Starts multiple abilities. 595 * 596 * @param wants Indicates the Want containing information array about the target ability to start. 597 */ 598 virtual void StartAbilities(const std::vector<AAFwk::Want> &wants) = 0; 599 600 /** 601 * @brief Checks whether this ability is the first ability in a mission. 602 * 603 * @return Returns true is first in Mission. 604 */ 605 virtual bool IsFirstInMission() = 0; 606 607 /** 608 * @brief Obtains a task dispatcher that is bound to the UI thread. 609 * 610 * @return Returns the task dispatcher that is bound to the UI thread. 611 */ 612 virtual std::shared_ptr<TaskDispatcher> GetUITaskDispatcher() = 0; 613 614 /** 615 * @brief Obtains a task dispatcher that is bound to the application main thread. 616 * 617 * @return Returns the task dispatcher that is bound to the application main thread. 618 */ 619 virtual std::shared_ptr<TaskDispatcher> GetMainTaskDispatcher() = 0; 620 621 /** 622 * @brief Creates a parallel task dispatcher with a specified priority. 623 * 624 * @param name Indicates the task dispatcher name. This parameter is used to locate problems. 625 * @param priority Indicates the priority of all tasks dispatched by the parallel task dispatcher. 626 * 627 * @return Returns a parallel task dispatcher. 628 */ 629 virtual std::shared_ptr<TaskDispatcher> CreateParallelTaskDispatcher( 630 const std::string &name, const TaskPriority &priority) = 0; 631 632 /** 633 * @brief Creates a serial task dispatcher with a specified priority. 634 * 635 * @param name Indicates the task dispatcher name. This parameter is used to locate problems. 636 * @param priority Indicates the priority of all tasks dispatched by the created task dispatcher. 637 * 638 * @return Returns a serial task dispatcher. 639 */ 640 virtual std::shared_ptr<TaskDispatcher> CreateSerialTaskDispatcher( 641 const std::string &name, const TaskPriority &priority) = 0; 642 643 /** 644 * @brief Obtains a global task dispatcher with a specified priority. 645 * 646 * @param priority Indicates the priority of all tasks dispatched by the global task dispatcher. 647 * 648 * @return Returns a global task dispatcher. 649 */ 650 virtual std::shared_ptr<TaskDispatcher> GetGlobalTaskDispatcher(const TaskPriority &priority) = 0; 651 652 /** 653 * @brief Requires that tasks associated with a given capability token be moved to the background 654 * 655 * @param nonFirst If nonfirst is false and not the lowest ability of the mission, you cannot move mission to end 656 * 657 * @return Returns true on success, others on failure. 658 */ 659 virtual bool MoveMissionToEnd(bool nonFirst) = 0; 660 661 /** 662 * @brief Sets the application to start its ability in lock mission mode. 663 */ 664 virtual void LockMission() = 0; 665 666 /** 667 * @brief Unlocks this ability by exiting the lock mission mode. 668 */ 669 virtual void UnlockMission() = 0; 670 671 /** 672 * @brief Sets description information about the mission containing this ability. 673 * 674 * @param MissionInformation Indicates the object containing information about the 675 * mission. This parameter cannot be null. 676 * @return Returns true on success, others on failure. 677 */ 678 virtual bool SetMissionInformation(const MissionInformation &missionInformation) = 0; 679 680 /** 681 * @brief Checks whether the configuration of this ability is changing. 682 * 683 * @return Returns true if the configuration of this ability is changing and false otherwise. 684 */ 685 virtual bool IsUpdatingConfigurations() = 0; 686 687 /** 688 * @brief Informs the system of the time required for drawing this Page ability. 689 * 690 * @return Returns the notification is successful or fail 691 */ 692 virtual bool PrintDrawnCompleted() = 0; 693 694 friend DataAbilityHelper; 695 friend DataShareHelper; 696 friend ContinuationConnector; 697 698 protected: 699 virtual sptr<IRemoteObject> GetToken() = 0; 700 }; 701 } // namespace AppExecFwk 702 } // namespace OHOS 703 #endif // FOUNDATION_APPEXECFWK_OHOS_CONTEXT_H 704