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