Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 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 | { |
Igor Murashkin | bef3f23 | 2013-05-30 17:47:38 -0700 | [diff] [blame] | 29 | /** |
| 30 | * Keep up-to-date with ICameraServiceListener.aidl in frameworks/base |
| 31 | */ |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 32 | public: |
| 33 | |
Igor Murashkin | b652df6 | 2013-03-18 13:36:48 -0700 | [diff] [blame] | 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 |
Igor Murashkin | cba2c16 | 2013-03-20 15:56:31 -0700 | [diff] [blame] | 44 | * PRESENT -> NOT_AVAILABLE |
| 45 | * NOT_AVAILABLE -> PRESENT |
Igor Murashkin | b652df6 | 2013-03-18 13:36:48 -0700 | [diff] [blame] | 46 | * |
| 47 | * A state will never immediately transition back to itself. |
| 48 | */ |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 49 | enum Status { |
| 50 | // Device physically unplugged |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 51 | STATUS_NOT_PRESENT = CAMERA_DEVICE_STATUS_NOT_PRESENT, |
Igor Murashkin | b652df6 | 2013-03-18 13:36:48 -0700 | [diff] [blame] | 52 | // Device physically has been plugged in |
Igor Murashkin | cba2c16 | 2013-03-20 15:56:31 -0700 | [diff] [blame] | 53 | // and the camera can be used exlusively |
Igor Murashkin | b652df6 | 2013-03-18 13:36:48 -0700 | [diff] [blame] | 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, |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 58 | |
| 59 | // Camera can be used exclusively |
Igor Murashkin | cba2c16 | 2013-03-20 15:56:31 -0700 | [diff] [blame] | 60 | STATUS_AVAILABLE = STATUS_PRESENT, // deprecated, will be removed |
| 61 | |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 62 | // Camera is in use by another app and cannot be used exclusively |
Igor Murashkin | cba2c16 | 2013-03-20 15:56:31 -0700 | [diff] [blame] | 63 | STATUS_NOT_AVAILABLE = 0x80000000, |
Igor Murashkin | bfc9915 | 2013-02-27 12:55:20 -0800 | [diff] [blame] | 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 | |
| 76 | class BnCameraServiceListener : public BnInterface<ICameraServiceListener> |
| 77 | { |
| 78 | public: |
| 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 |