• 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_SERVICES_BUNDLE_EXCEPTION_HANDLE_H
17 #define FOUNDATION_APPEXECFWK_SERVICES_BUNDLE_EXCEPTION_HANDLE_H
18 
19 #include "bundle_data_storage_database.h"
20 #include "inner_bundle_info.h"
21 
22 namespace OHOS {
23 namespace AppExecFwk {
24 class BundleExceptionHandler {
25 public:
26     BundleExceptionHandler(const std::shared_ptr<BundleDataStorageDatabase> &dataStorage);
27     virtual ~BundleExceptionHandler();
28 
29     /**
30      * @brief to handle the invalid bundle in the storage.
31      * @param info Indicates the bundle info of the application.
32      * @param path Indicates the base bundle path or data path.
33      */
34     void HandleInvalidBundle(InnerBundleInfo &info, bool &isBundleValid);
35     /**
36      * @brief to remove the bundle path and data path according to the input bundle or data path.
37      * @param info Indicates the bundle info of the application.
38      * @param dataDir Indicates the dir needs to be removed.
39      * @return Returns true for remove successfully, returns false otherwise.
40      */
41     bool RemoveBundleAndDataDir(const std::string &bundleDir, const std::string &dataDir) const;
42     /**
43      * @brief to obtain the bundle path and data path according to the input base bundle or data path.
44      * @param info Indicates the bundle info of the application.
45      * @param basePath Indicates the base bundle path or data path.
46      * @return Returns string of the bundle or data path.
47      */
48     std::string GetBundleAndDataDir(const InnerBundleInfo &info, const std::string &basePath);
49     /**
50      * @brief to delete the bundle info from the storage.
51      * @param info Indicates the bundle info of the application.
52      */
53     void DeleteBundleInfoFromStorage(const InnerBundleInfo &info);
54 private:
55     std::weak_ptr<BundleDataStorageDatabase> dataStorage_;
56 };
57 }  // namespace AppExecFwk
58 }  // namespace OHOS
59 #endif // FOUNDATION_APPEXECFWK_SERVICES_BUNDLE_EXCEPTION_HANDLE_H