2 * Copyright (C) 2013 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef HW_EMULATOR_CAMERA_EMULATED_CAMERA_HOTPLUG_H
18 #define HW_EMULATOR_CAMERA_EMULATED_CAMERA_HOTPLUG_H
21 * This class emulates hotplug events by inotifying on a file, specific
22 * to a camera ID. When the file changes between 1/0 the hotplug
23 * status goes between PRESENT and NOT_PRESENT.
25 * Refer to FAKE_HOTPLUG_FILE in EmulatedCameraHotplugThread.cpp
28 #include "EmulatedCamera2.h"
29 #include <utils/String8.h>
30 #include <utils/Vector.h>
33 class EmulatedCameraHotplugThread : public Thread {
35 EmulatedCameraHotplugThread(const int* cameraIdArray, size_t size);
36 ~EmulatedCameraHotplugThread();
38 virtual void requestExit();
39 virtual status_t requestExitAndWait();
44 virtual status_t readyToRun();
45 virtual bool threadLoop();
47 struct SubscriberInfo {
52 bool addWatch(int cameraId);
53 bool removeWatch(int cameraId);
54 SubscriberInfo* getSubscriberInfo(int cameraId);
56 int getCameraId(String8 filePath) const;
57 int getCameraId(int wd) const;
59 String8 getFilePath(int cameraId) const;
60 int readFile(String8 filePath) const;
62 bool createFileIfNotExists(int cameraId) const;
65 Vector<int> mSubscribedCameraIds;
66 Vector<SubscriberInfo> mSubscribers;
68 // variables above are unguarded:
69 // -- accessed in thread loop or in constructor only
73 bool mRunning; // guarding only when it's important
75 } // namespace android