1 /*
2  * Copyright (c) 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_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_BUNDLE_MGR_PROXY_NATIVE_H
17 #define FOUNDATION_APPEXECFWK_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_BUNDLE_MGR_PROXY_NATIVE_H
18 
19 #include <string>
20 
21 #include "application_info.h"
22 #include "bundle_info.h"
23 #include "iremote_broker.h"
24 #include "iremote_object.h"
25 
26 namespace OHOS {
27 namespace AppExecFwk {
28 class BundleMgrProxyNative {
29 public:
30     BundleMgrProxyNative() = default;
31     virtual ~BundleMgrProxyNative() = default;
32 
33     /**
34      * @brief Obtains the BundleInfo based on calling uid.
35      * @param bundleName Indicates the application bundle name to be queried.
36      * @param flags Indicates the information contained in the BundleInfo object to be returned.
37      * @param bundleInfo Indicates the obtained BundleInfo object.
38      * @param userId Indicates the user ID.
39      * @return Returns true if the BundleInfo is successfully obtained; returns false otherwise.
40      */
41     bool GetBundleInfoForSelf(int32_t flags, BundleInfo &bundleInfo);
42 
43     bool GetCompatibleDeviceTypeNative(std::string &deviceType);
44 
45     enum {
46         GET_BUNDLE_INFO_FOR_SELF_NATIVE = 98,
47         GET_COMPATIBLED_DEVICE_TYPE_NATIVE = 166
48     };
49 private:
50     sptr<IRemoteObject> GetBmsProxy();
51     template <typename T>
52     bool GetParcelableInfo(uint32_t code, MessageParcel &data, T &parcelableInfo);
53     bool SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply);
54 };
55 }  // namespace AppExecFwk
56 }  // namespace OHOS
57 #endif  // FOUNDATION_APPEXECFWK_KITS_APPKIT_NATIVE_BUNDLE_INCLUDE_BUNDLE_MGR_PROXY_NATIVE_H