• 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 BASE_NOTIFICATION_ANS_STANDARD_SERVICES_ANS_INCLUDE_BUNDLE_MANAGER_HELPER_H
17 #define BASE_NOTIFICATION_ANS_STANDARD_SERVICES_ANS_INCLUDE_BUNDLE_MANAGER_HELPER_H
18 
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 
23 #include "bundle_mgr_interface.h"
24 #include "ipc_skeleton.h"
25 #include "iremote_object.h"
26 #include "notification_bundle_option.h"
27 #include "refbase.h"
28 #include "remote_death_recipient.h"
29 #include "singleton.h"
30 
31 namespace OHOS {
32 namespace Notification {
33 class BundleManagerHelper : public DelayedSingleton<BundleManagerHelper> {
34 public:
35     std::string GetBundleNameByUid(int uid);
36     bool IsSystemApp(int uid);
37     bool CheckApiCompatibility(const sptr<NotificationBundleOption> &bundleOption);
38     int GetDefaultUidByBundleName(const std::string &bundle, const int32_t userId);
39     bool GetBundleInfoByBundleName(const std::string bundle, const int32_t userId, AppExecFwk::BundleInfo &bundleInfo);
40 #ifdef DISTRIBUTED_NOTIFICATION_SUPPORTED
41     bool GetDistributedNotificationEnabled(const std::string &bundleName, const int userId);
42 #endif
43 
44 private:
45     void Connect();
46     void Disconnect();
47 
48     void OnRemoteDied(const wptr<IRemoteObject> &object);
49 
50 private:
51     sptr<AppExecFwk::IBundleMgr> bundleMgr_ = nullptr;
52     std::mutex connectionMutex_;
53     sptr<RemoteDeathRecipient> deathRecipient_ = nullptr;
54 
55     DECLARE_DELAYED_SINGLETON(BundleManagerHelper)
56 };
57 }  // namespace Notification
58 }  // namespace OHOS
59 
60 #endif  // BASE_NOTIFICATION_ANS_STANDARD_SERVICES_ANS_INCLUDE_BUNDLE_MANAGER_HELPER_H