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
25namespace android {
26
27class ICameraServiceListener : public IInterface
28{
29    /**
30     * Keep up-to-date with ICameraServiceListener.aidl in frameworks/base
31     */
32public:
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    DECLARE_META_INTERFACE(CameraServiceListener);
70
71    virtual void onStatusChanged(Status status, int32_t cameraId) = 0;
72};
73
74// ----------------------------------------------------------------------------
75
76class BnCameraServiceListener : public BnInterface<ICameraServiceListener>
77{
78public:
79    virtual status_t    onTransact( uint32_t code,
80                                    const Parcel& data,
81                                    Parcel* reply,
82                                    uint32_t flags = 0);
83};
84
85}; // namespace android
86
87#endif
88