Home | History | Annotate | Download | only in camera
      1 /*
      2  * Copyright (C) 2008 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_H
     18 #define ANDROID_HARDWARE_ICAMERASERVICE_H
     19 
     20 #include <utils/RefBase.h>
     21 #include <binder/IInterface.h>
     22 #include <binder/Parcel.h>
     23 
     24 namespace android {
     25 
     26 class ICamera;
     27 class ICameraClient;
     28 class IProCameraUser;
     29 class IProCameraCallbacks;
     30 class ICameraServiceListener;
     31 class ICameraDeviceUser;
     32 class ICameraDeviceCallbacks;
     33 class CameraMetadata;
     34 class VendorTagDescriptor;
     35 class String16;
     36 
     37 class ICameraService : public IInterface
     38 {
     39 public:
     40     /**
     41      * Keep up-to-date with ICameraService.aidl in frameworks/base
     42      */
     43     enum {
     44         GET_NUMBER_OF_CAMERAS = IBinder::FIRST_CALL_TRANSACTION,
     45         GET_CAMERA_INFO,
     46         CONNECT,
     47         CONNECT_PRO,
     48         CONNECT_DEVICE,
     49         ADD_LISTENER,
     50         REMOVE_LISTENER,
     51         GET_CAMERA_CHARACTERISTICS,
     52         GET_CAMERA_VENDOR_TAG_DESCRIPTOR,
     53         GET_LEGACY_PARAMETERS,
     54         SUPPORTS_CAMERA_API,
     55         CONNECT_LEGACY,
     56     };
     57 
     58     enum {
     59         USE_CALLING_UID = -1
     60     };
     61 
     62     enum {
     63         API_VERSION_1 = 1,
     64         API_VERSION_2 = 2,
     65     };
     66 
     67     enum {
     68         CAMERA_HAL_API_VERSION_UNSPECIFIED = -1
     69       };
     70 
     71 public:
     72     DECLARE_META_INTERFACE(CameraService);
     73 
     74     virtual int32_t  getNumberOfCameras() = 0;
     75     virtual status_t getCameraInfo(int cameraId,
     76             /*out*/
     77             struct CameraInfo* cameraInfo) = 0;
     78 
     79     virtual status_t getCameraCharacteristics(int cameraId,
     80             /*out*/
     81             CameraMetadata* cameraInfo) = 0;
     82 
     83     virtual status_t getCameraVendorTagDescriptor(
     84             /*out*/
     85             sp<VendorTagDescriptor>& desc) = 0;
     86 
     87     // Returns 'OK' if operation succeeded
     88     // - Errors: ALREADY_EXISTS if the listener was already added
     89     virtual status_t addListener(const sp<ICameraServiceListener>& listener)
     90                                                                             = 0;
     91     // Returns 'OK' if operation succeeded
     92     // - Errors: BAD_VALUE if specified listener was not in the listener list
     93     virtual status_t removeListener(const sp<ICameraServiceListener>& listener)
     94                                                                             = 0;
     95     /**
     96      * clientPackageName and clientUid are used for permissions checking.  if
     97      * clientUid == USE_CALLING_UID, then the calling UID is used instead. Only
     98      * trusted callers can set a clientUid other than USE_CALLING_UID.
     99      */
    100     virtual status_t connect(const sp<ICameraClient>& cameraClient,
    101             int cameraId,
    102             const String16& clientPackageName,
    103             int clientUid,
    104             /*out*/
    105             sp<ICamera>& device) = 0;
    106 
    107     virtual status_t connectPro(const sp<IProCameraCallbacks>& cameraCb,
    108             int cameraId,
    109             const String16& clientPackageName,
    110             int clientUid,
    111             /*out*/
    112             sp<IProCameraUser>& device) = 0;
    113 
    114     virtual status_t connectDevice(
    115             const sp<ICameraDeviceCallbacks>& cameraCb,
    116             int cameraId,
    117             const String16& clientPackageName,
    118             int clientUid,
    119             /*out*/
    120             sp<ICameraDeviceUser>& device) = 0;
    121 
    122     virtual status_t getLegacyParameters(
    123             int cameraId,
    124             /*out*/
    125             String16* parameters) = 0;
    126 
    127     /**
    128      * Returns OK if device supports camera2 api,
    129      * returns -EOPNOTSUPP if it doesn't.
    130      */
    131     virtual status_t supportsCameraApi(
    132             int cameraId, int apiVersion) = 0;
    133 
    134     /**
    135      * Connect the device as a legacy device for a given HAL version.
    136      * For halVersion, use CAMERA_API_DEVICE_VERSION_* for a particular
    137      * version, or CAMERA_HAL_API_VERSION_UNSPECIFIED for a service-selected version.
    138      */
    139     virtual status_t connectLegacy(const sp<ICameraClient>& cameraClient,
    140             int cameraId, int halVersion,
    141             const String16& clientPackageName,
    142             int clientUid,
    143             /*out*/
    144             sp<ICamera>& device) = 0;
    145 };
    146 
    147 // ----------------------------------------------------------------------------
    148 
    149 class BnCameraService: public BnInterface<ICameraService>
    150 {
    151 public:
    152     virtual status_t    onTransact( uint32_t code,
    153                                     const Parcel& data,
    154                                     Parcel* reply,
    155                                     uint32_t flags = 0);
    156 };
    157 
    158 }; // namespace android
    159 
    160 #endif
    161