blob: cb83e2907a224f2cf944357d1a9b3d35efefb9b3 [file] [log] [blame]
Yin-Chia Yehb978c382019-10-30 00:22:37 -07001/*
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#ifndef ANDROID_SERVERS_CAMERA_PHOTOGRAPHY_CAMERAOFFLINESESSIONCLIENT_H
18#define ANDROID_SERVERS_CAMERA_PHOTOGRAPHY_CAMERAOFFLINESESSIONCLIENT_H
19
20#include <android/hardware/camera2/BnCameraOfflineSession.h>
21#include <android/hardware/camera2/ICameraDeviceCallbacks.h>
22#include "CameraService.h"
23
24namespace android {
25
26using android::hardware::camera2::ICameraDeviceCallbacks;
27
28class CameraOfflineSessionClient :
29 public CameraService::OfflineClient,
30 public hardware::camera2::BnCameraOfflineSession
31 // public camera2::FrameProcessorBase::FilteredListener?
32{
33public:
34 CameraOfflineSessionClient(
35 const sp<CameraService>& cameraService,
36 sp<CameraOfflineSessionBase> session,
37 const sp<ICameraDeviceCallbacks>& remoteCallback,
38 const String16& clientPackageName,
39 const String8& cameraIdStr,
40 int clientPid, uid_t clientUid, int servicePid) :
41 CameraService::OfflineClient(cameraService, clientPackageName,
42 cameraIdStr, clientPid, clientUid, servicePid),
43 mRemoteCallback(remoteCallback), mOfflineSession(session) {}
44
45 ~CameraOfflineSessionClient() {}
46
47 virtual binder::Status disconnect() override { return binder::Status::ok(); }
48
49 virtual status_t dump(int /*fd*/, const Vector<String16>& /*args*/) override {
50 return OK;
51 }
52
53 // Block the client form using the camera
54 virtual void block() override {};
55
56 // Return the package name for this client
57 virtual String16 getPackageName() const override { String16 ret; return ret; };
58
59 // Notify client about a fatal error
60 // TODO: maybe let impl notify within block?
61 virtual void notifyError(int32_t /*errorCode*/,
62 const CaptureResultExtras& /*resultExtras*/) override {}
63
64 // Get the UID of the application client using this
65 virtual uid_t getClientUid() const override { return 0; }
66
67 // Get the PID of the application client using this
68 virtual int getClientPid() const override { return 0; }
69
70 status_t initialize() {
71 // TODO: Talk to camera service to add the offline session client book keeping
72 return OK;
73 }
74private:
75 sp<CameraOfflineSessionBase> mSession;
76
77 sp<hardware::camera2::ICameraDeviceCallbacks> mRemoteCallback;
78 // This class is responsible to convert HAL callbacks to AIDL callbacks
79
80 sp<CameraOfflineSessionBase> mOfflineSession;
81};
82
83} // namespace android
84
85#endif // ANDROID_SERVERS_CAMERA_PHOTOGRAPHY_CAMERAOFFLINESESSIONCLIENT_H