1 /*
2  * Copyright (c) 2023-2024 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_ABILITY_SESSION_INFO_H
17 #define OHOS_ABILITY_SESSION_INFO_H
18 
19 #include <typeinfo>
20 #include <unistd.h>
21 
22 #include "iremote_object.h"
23 #include "parcel.h"
24 #include "session_info_constants.h"
25 #include "want.h"
26 
27 namespace OHOS {
28 namespace AAFwk {
29 class AbilityStartSetting;
30 class ProcessOptions;
31 class StartWindowOption;
32 
33 class SessionInfo : public Parcelable {
34 public:
35     SessionInfo() = default;
36     virtual ~SessionInfo() = default;
37     bool Marshalling(Parcel& parcel) const override;
38     static SessionInfo* Unmarshalling(Parcel& parcel);
39 
40     sptr<IRemoteObject> sessionToken = nullptr;
41     sptr<IRemoteObject> callerSession = nullptr;
42     sptr<IRemoteObject> callerToken = nullptr;
43     sptr<IRemoteObject> parentToken = nullptr;
44     std::string identityToken;
45     int32_t persistentId = 0;
46     uint32_t hostWindowId = 0;
47     int32_t realHostWindowId = 0;
48     uint32_t parentWindowType = 1;
49     // Status of the UIAbility invoked by the StartABilityByCall
50     CallToState state = CallToState::UNKNOW;
51     // Returned resultCode of terminateSelfWithResult
52     int32_t resultCode = -1;
53     // requestCode of StartAbilityForResult
54     int32_t requestCode = -1;
55     std::string errorReason;
56     int32_t errorCode = -1;
57     int64_t uiAbilityId = 0;
58     std::shared_ptr<AbilityStartSetting> startSetting = nullptr;
59     std::shared_ptr<ProcessOptions> processOptions = nullptr;
60     std::shared_ptr<StartWindowOption> startWindowOption = nullptr;
61     Want want;
62     int32_t userId = -1;
63     bool isNewWant = true;
64     bool isClearSession = false;
65     uint32_t callingTokenId = 0;
66     bool reuse = false;
67     bool canStartAbilityFromBackground = false;
68     int32_t collaboratorType = 0;
69     std::string sessionName = "";
70     bool isAsyncModalBinding = false;
71     bool isAtomicService = false;
72     bool isBackTransition = false;
73     bool isSkipErms = false;
74     // The following attributes are used for UIExtension
75     // To ensure security, this attribute must be rewritten on the server-side.
76     UIExtensionUsage uiExtensionUsage = UIExtensionUsage::MODAL;
77     uint64_t uiExtensionComponentId = 0;
78     uint64_t displayId = 0;
79     float density = 0.0f;
80     int32_t orientation = 0;
81     bool needClearInNotShowRecent = false;
82     std::string instanceKey = "";
83     bool isMinimizedDuringFreeInstall = false;
84     bool isFromIcon = false;
85 
86 private:
87     bool DoMarshallingOne(Parcel& parcel) const;
88     bool DoMarshallingTwo(Parcel& parcel) const;
89     bool DoMarshallingThree(Parcel& parcel) const;
90     bool DoMarshallingFour(Parcel& parcel) const;
91     bool DoMarshallingFive(Parcel& parcel) const;
92     static SessionInfo* ReadParcelOne(SessionInfo* info, Parcel& parcel);
93 };
94 } // namespace AAFwk
95 } // namespace OHOS
96 #endif // OHOS_ABILITY_SESSION_INFO_H
97