• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #include "privacy_session_manager_proxy.h"
17 
18 #include "accesstoken_common_log.h"
19 
20 namespace OHOS {
21 namespace Security {
22 namespace AccessToken {
23 
GetSceneSessionManager()24 sptr<IRemoteObject> PrivacySessionManagerProxy::GetSceneSessionManager()
25 {
26     MessageParcel data;
27     MessageParcel reply;
28     MessageOption option(MessageOption::TF_SYNC);
29 
30     if (!data.WriteInterfaceToken(GetDescriptor())) {
31         LOGE(PRI_DOMAIN, PRI_TAG, "WriteInterfaceToken failed");
32         return nullptr;
33     }
34 
35     sptr<IRemoteObject> remote = Remote();
36     if (remote == nullptr) {
37         LOGE(PRI_DOMAIN, PRI_TAG, "Remote service is null.");
38         return nullptr;
39     }
40     auto ret = remote->SendRequest(
41         static_cast<uint32_t>(SessionManagerServiceMessage::TRANS_ID_GET_SCENE_SESSION_MANAGER),
42         data, reply, option);
43     if (ret != ERR_NONE) {
44         LOGE(PRI_DOMAIN, PRI_TAG, "SendRequest failed, errorCode %{public}d", ret);
45         return nullptr;
46     }
47 
48     return reply.ReadRemoteObject();
49 }
50 
GetSceneSessionManagerLite()51 sptr<IRemoteObject> PrivacySessionManagerProxy::GetSceneSessionManagerLite()
52 {
53     MessageParcel data;
54     MessageParcel reply;
55     MessageOption option(MessageOption::TF_SYNC);
56 
57     if (!data.WriteInterfaceToken(GetDescriptor())) {
58         LOGE(PRI_DOMAIN, PRI_TAG, "WriteInterfaceToken failed");
59         return nullptr;
60     }
61 
62     sptr<IRemoteObject> remote = Remote();
63     if (remote == nullptr) {
64         LOGE(PRI_DOMAIN, PRI_TAG, "Remote service is null.");
65         return nullptr;
66     }
67     auto ret = remote->SendRequest(
68         static_cast<uint32_t>(SessionManagerServiceMessage::TRANS_ID_GET_SCENE_SESSION_MANAGER_LITE),
69         data, reply, option);
70     if (ret != ERR_NONE) {
71         LOGE(PRI_DOMAIN, PRI_TAG, "SendRequest failed, errorCode %{public}d", ret);
72         return nullptr;
73     }
74 
75     return reply.ReadRemoteObject();
76 }
77 }
78 }
79 }