1 /* 2 * Copyright (C) 2015 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 #ifndef HOTPLUG_THREAD_H_ 17 #define HOTPLUG_THREAD_H_ 18 19 #include <utils/Thread.h> 20 #include "CameraHAL.h" 21 22 namespace usb_camera_hal { 23 /** 24 * Thread for managing usb camera hotplug. It does below: 25 * 1. Monitor camera hotplug status, and notify the status changes by calling 26 * module callback methods. 27 * 2. When camera is plugged, create camera device instance, initialize the camera 28 * static info. When camera is unplugged, destroy the camera device instance and 29 * static metadata. As an optimization option, the camera device instance (including 30 * the static info) could be cached when the same camera plugged/unplugged multiple 31 * times. 32 */ 33 34 class CameraHAL; 35 36 class HotplugThread : public android::Thread { 37 38 public: 39 HotplugThread(CameraHAL *hal); 40 ~HotplugThread(); 41 42 // Override below two methods for proper cleanup. 43 virtual bool threadLoop(); 44 virtual void requestExit(); 45 46 private: 47 CameraHAL *mModule; 48 }; 49 50 } // namespace usb_camera_hal 51 52 #endif // HOTPLUG_THREAD_H_ 53