1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 //#define LOG_NDEBUG 0
18 #define LOG_TAG "FakeFakeECOServiceInfoListener"
19 
20 #include "FakeECOServiceInfoListener.h"
21 
22 #include <android-base/unique_fd.h>
23 #include <binder/IPCThreadState.h>
24 #include <binder/IServiceManager.h>
25 #include <binder/Parcel.h>
26 #include <binder/Parcelable.h>
27 #include <cutils/ashmem.h>
28 #include <gtest/gtest.h>
29 #include <math.h>
30 #include <stdlib.h>
31 #include <sys/mman.h>
32 #include <utils/Log.h>
33 
34 namespace android {
35 namespace media {
36 namespace eco {
37 
FakeECOServiceInfoListener(int32_t width,int32_t height,bool isCameraRecording,android::sp<IECOSession> session)38 FakeECOServiceInfoListener::FakeECOServiceInfoListener(int32_t width, int32_t height,
39                                                        bool isCameraRecording,
40                                                        android::sp<IECOSession> session)
41       : mWidth(width),
42         mHeight(height),
43         mIsCameraRecording(isCameraRecording),
44         mECOSession(session) {
45     ALOGD("FakeECOServiceInfoListener construct with w: %d, h: %d, isCameraRecording: %d", mWidth,
46           mHeight, mIsCameraRecording);
47 }
48 
FakeECOServiceInfoListener(int32_t width,int32_t height,bool isCameraRecording)49 FakeECOServiceInfoListener::FakeECOServiceInfoListener(int32_t width, int32_t height,
50                                                        bool isCameraRecording)
51       : mWidth(width), mHeight(height), mIsCameraRecording(isCameraRecording) {
52     ALOGD("FakeECOServiceInfoListener construct with w: %d, h: %d, isCameraRecording: %d", mWidth,
53           mHeight, mIsCameraRecording);
54 }
55 
~FakeECOServiceInfoListener()56 FakeECOServiceInfoListener::~FakeECOServiceInfoListener() {
57     ALOGD("FakeECOServiceInfoListener destructor");
58 }
59 
getType(int32_t *)60 Status FakeECOServiceInfoListener::getType(int32_t* /*_aidl_return*/) {
61     return binder::Status::ok();
62 }
63 
getName(::android::String16 * _aidl_return)64 Status FakeECOServiceInfoListener::getName(::android::String16* _aidl_return) {
65     *_aidl_return = String16("FakeECOServiceInfoListener");
66     return binder::Status::ok();
67 }
68 
getECOSession(sp<::android::IBinder> * _aidl_return)69 Status FakeECOServiceInfoListener::getECOSession(sp<::android::IBinder>* _aidl_return) {
70     *_aidl_return = IInterface::asBinder(mECOSession);
71     return binder::Status::ok();
72 }
73 
onNewInfo(const::android::media::eco::ECOData & newInfo)74 Status FakeECOServiceInfoListener::onNewInfo(const ::android::media::eco::ECOData& newInfo) {
75     ALOGD("FakeECOServiceInfoListener get new info");
76     mInfoAvaiableCallback(newInfo);
77     return binder::Status::ok();
78 }
79 
80 // IBinder::DeathRecipient implementation
binderDied(const wp<IBinder> &)81 void FakeECOServiceInfoListener::binderDied(const wp<IBinder>& /*who*/) {}
82 
83 }  // namespace eco
84 }  // namespace media
85 }  // namespace android
86