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 #include "camera_service_callback_stub.h"
17 #include "accesstoken_log.h"
18 #include "permission_record_manager.h"
19
20 namespace OHOS {
21 namespace Security {
22 namespace AccessToken {
23 namespace {
24 static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE,
25 SECURITY_DOMAIN_ACCESSTOKEN, "CameraServiceCallbackStub"};
26 }
CameraServiceCallbackStub()27 CameraServiceCallbackStub::CameraServiceCallbackStub()
28 {
29 ACCESSTOKEN_LOG_INFO(LABEL, "CameraServiceCallbackStub Instance create");
30 }
31
~CameraServiceCallbackStub()32 CameraServiceCallbackStub::~CameraServiceCallbackStub()
33 {
34 ACCESSTOKEN_LOG_INFO(LABEL, "CameraServiceCallbackStub Instance destroy");
35 }
36
OnRemoteRequest(uint32_t code,MessageParcel & data,MessageParcel & reply,MessageOption & option)37 int CameraServiceCallbackStub::OnRemoteRequest(
38 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option)
39 {
40 if (data.ReadInterfaceToken() != GetDescriptor()) {
41 ACCESSTOKEN_LOG_INFO(LABEL, "CameraServiceCallbackStub: ReadInterfaceToken failed");
42 return -1;
43 }
44 CameraMuteServiceCallbackRequestCode msgId = static_cast<CameraMuteServiceCallbackRequestCode>(code);
45 switch (msgId) {
46 case CAMERA_CALLBACK_MUTE_MODE: {
47 bool mute = data.ReadBool();
48 OnCameraMute(mute);
49 return 0;
50 }
51 default: {
52 ACCESSTOKEN_LOG_INFO(LABEL, "default case, need check AudioListenerStub");
53 return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
54 }
55 }
56 }
57
OnCameraMute(bool muteMode)58 int32_t CameraServiceCallbackStub::OnCameraMute(bool muteMode)
59 {
60 ACCESSTOKEN_LOG_INFO(LABEL, "OnCameraMute(%{public}d)", muteMode);
61 PermissionRecordManager::GetInstance().NotifyCameraChange(!muteMode);
62 return 0;
63 }
64 }
65 } // namespace AccessToken
66 } // namespace OHOS
67