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     /**
30      * Keep up-to-date with ICameraServiceListener.aidl in frameworks/base
31      */
32 public:
33 
34     /**
35      * Initial status will be transmitted with onStatusChange immediately
36      * after this listener is added to the service listener list.
37      *
38      * Allowed transitions:
39      *
40      *     (Any)               -> NOT_PRESENT
41      *     NOT_PRESENT         -> PRESENT
42      *     NOT_PRESENT         -> ENUMERATING
43      *     ENUMERATING         -> PRESENT
44      *     PRESENT             -> NOT_AVAILABLE
45      *     NOT_AVAILABLE       -> PRESENT
46      *
47      * A state will never immediately transition back to itself.
48      */
49     enum Status {
50         // Device physically unplugged
51         STATUS_NOT_PRESENT      = CAMERA_DEVICE_STATUS_NOT_PRESENT,
52         // Device physically has been plugged in
53         //  and the camera can be used exlusively
54         STATUS_PRESENT          = CAMERA_DEVICE_STATUS_PRESENT,
55         // Device physically has been plugged in
56         //   but it will not be connect-able until enumeration is complete
57         STATUS_ENUMERATING      = CAMERA_DEVICE_STATUS_ENUMERATING,
58 
59         // Camera can be used exclusively
60         STATUS_AVAILABLE        = STATUS_PRESENT, // deprecated, will be removed
61 
62         // Camera is in use by another app and cannot be used exclusively
63         STATUS_NOT_AVAILABLE    = 0x80000000,
64 
65         // Use to initialize variables only
66         STATUS_UNKNOWN          = 0xFFFFFFFF,
67     };
68 
69     /**
70      * The torch mode status of a camera.
71      *
72      * Initial status will be transmitted with onTorchStatusChanged immediately
73      * after this listener is added to the service listener list.
74      *
75      * The enums should be set to values matching
76      * include/hardware/camera_common.h
77      */
78     enum TorchStatus {
79         // The camera's torch mode has become not available to use via
80         // setTorchMode().
81         TORCH_STATUS_NOT_AVAILABLE  = TORCH_MODE_STATUS_NOT_AVAILABLE,
82         // The camera's torch mode is off and available to be turned on via
83         // setTorchMode().
84         TORCH_STATUS_AVAILABLE_OFF  = TORCH_MODE_STATUS_AVAILABLE_OFF,
85         // The camera's torch mode is on and available to be turned off via
86         // setTorchMode().
87         TORCH_STATUS_AVAILABLE_ON   = TORCH_MODE_STATUS_AVAILABLE_ON,
88 
89         // Use to initialize variables only
90         TORCH_STATUS_UNKNOWN        = 0xFFFFFFFF,
91     };
92 
93     DECLARE_META_INTERFACE(CameraServiceListener);
94 
95     virtual void onStatusChanged(Status status, int32_t cameraId) = 0;
96 
97     virtual void onTorchStatusChanged(TorchStatus status, const String16& cameraId) = 0;
98 };
99 
100 // ----------------------------------------------------------------------------
101 
102 class BnCameraServiceListener : public BnInterface<ICameraServiceListener>
103 {
104 public:
105     virtual status_t    onTransact( uint32_t code,
106                                     const Parcel& data,
107                                     Parcel* reply,
108                                     uint32_t flags = 0);
109 };
110 
111 }; // namespace android
112 
113 #endif
114