Home | History | Annotate | Download | only in camera
      1 /*
      2  * Copyright (C) 2013 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_HARDWARE_ICAMERASERVICE_LISTENER_H
     18 #define ANDROID_HARDWARE_ICAMERASERVICE_LISTENER_H
     19 
     20 #include <utils/RefBase.h>
     21 #include <binder/IInterface.h>
     22 #include <binder/Parcel.h>
     23 #include <hardware/camera_common.h>
     24 
     25 namespace android {
     26 
     27 class ICameraServiceListener : public IInterface
     28 {
     29 public:
     30 
     31     /**
     32      * Initial status will be transmitted with onStatusChange immediately
     33      * after this listener is added to the service listener list.
     34      *
     35      * Allowed transitions:
     36      *
     37      *     (Any)               -> NOT_PRESENT
     38      *     NOT_PRESENT         -> PRESENT
     39      *     NOT_PRESENT         -> ENUMERATING
     40      *     ENUMERATING         -> PRESENT
     41      *     PRESENT             -> NOT_AVAILABLE
     42      *     NOT_AVAILABLE       -> PRESENT
     43      *
     44      * A state will never immediately transition back to itself.
     45      */
     46     enum Status {
     47         // Device physically unplugged
     48         STATUS_NOT_PRESENT      = CAMERA_DEVICE_STATUS_NOT_PRESENT,
     49         // Device physically has been plugged in
     50         //  and the camera can be used exlusively
     51         STATUS_PRESENT          = CAMERA_DEVICE_STATUS_PRESENT,
     52         // Device physically has been plugged in
     53         //   but it will not be connect-able until enumeration is complete
     54         STATUS_ENUMERATING      = CAMERA_DEVICE_STATUS_ENUMERATING,
     55 
     56         // Camera can be used exclusively
     57         STATUS_AVAILABLE        = STATUS_PRESENT, // deprecated, will be removed
     58 
     59         // Camera is in use by another app and cannot be used exclusively
     60         STATUS_NOT_AVAILABLE    = 0x80000000,
     61 
     62         // Use to initialize variables only
     63         STATUS_UNKNOWN          = 0xFFFFFFFF,
     64     };
     65 
     66     DECLARE_META_INTERFACE(CameraServiceListener);
     67 
     68     virtual void onStatusChanged(Status status, int32_t cameraId) = 0;
     69 };
     70 
     71 // ----------------------------------------------------------------------------
     72 
     73 class BnCameraServiceListener : public BnInterface<ICameraServiceListener>
     74 {
     75 public:
     76     virtual status_t    onTransact( uint32_t code,
     77                                     const Parcel& data,
     78                                     Parcel* reply,
     79                                     uint32_t flags = 0);
     80 };
     81 
     82 }; // namespace android
     83 
     84 #endif
     85