1 /*
2  * Copyright (c) 2020 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 OHOS_APP_RECORD_H
17 #define OHOS_APP_RECORD_H
18 
19 #include "bundle_info.h"
20 #include "client/ability_thread_client.h"
21 
22 namespace OHOS {
23 class PageAbilityRecord;
24 class AppRecord {
25 public:
26     AppRecord(const BundleInfo& bundleInfo, uint64_t identityId);
27     ~AppRecord();
28 
29     void SetPid(pid_t pid);
30     pid_t GetPid() const;
31     uint64_t GetIdentityId() const;
32     const BundleInfo &GetBundleInfo() const;
33 
34     AbilityMsStatus LoadPermission() const;
35     void UnloadPermission() const;
36     AbilityMsStatus QueryAppCapability(const char *bundleName, uint32_t **caps, uint32_t *capNums);
37     AbilityMsStatus SetAbilityThreadClient(const AbilityThreadClient &client);
38     AbilityMsStatus AbilityTransaction(const TransactionState &state,
39         const Want &want, AbilityType abilityType) const;
40     AbilityMsStatus AppInitTransaction() const;
41     AbilityMsStatus AppExitTransaction() const;
42     AbilityMsStatus DumpAbilityTransaction(const Want &want, uint64_t token) const;
43     void SetPendingAbility(PageAbilityRecord *abilityRecord);
44     AbilityMsStatus LaunchPendingAbility();
45 
46     AbilityMsStatus ConnectTransaction(const Want &want, uint64_t token) const;
47     AbilityMsStatus DisconnectTransaction(const Want &want, uint64_t token) const;
48     AbilityMsStatus ConnectDoneTransaction(const Want &want, const SvcIdentity &serviceSid,
49         const SvcIdentity &connectSid) const;
50     AbilityMsStatus DisconnectDoneTransaction(const Want &want, const SvcIdentity &connectSid) const;
51     void ClearPendingAbility(PageAbilityRecord *abilityRecord);
52 private:
53     pid_t pid_ { 0 };
54     uint64_t identityId_ { 0 };
55     BundleInfo bundleInfo_ {};
56     AbilityThreadClient *abilityThreadClient_ { nullptr };
57     PageAbilityRecord *pendingAbilityRecord_ { nullptr };
58 };
59 }  // namespace OHOS
60 #endif  // OHOS_APP_RECORD_H
61