• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 **
3 ** Copyright 2013, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 **     http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17 
18 #include <stdint.h>
19 #include <sys/types.h>
20 
21 #include <binder/Parcel.h>
22 #include <binder/IPCThreadState.h>
23 #include <binder/IServiceManager.h>
24 
25 #include <camera/ICameraServiceListener.h>
26 
27 namespace android {
28 
29 namespace {
30     enum {
31         STATUS_CHANGED = IBinder::FIRST_CALL_TRANSACTION,
32     };
33 }; // namespace anonymous
34 
35 class BpCameraServiceListener: public BpInterface<ICameraServiceListener>
36 {
37 
38 public:
BpCameraServiceListener(const sp<IBinder> & impl)39     BpCameraServiceListener(const sp<IBinder>& impl)
40         : BpInterface<ICameraServiceListener>(impl)
41     {
42     }
43 
onStatusChanged(Status status,int32_t cameraId)44     virtual void onStatusChanged(Status status, int32_t cameraId)
45     {
46         Parcel data, reply;
47         data.writeInterfaceToken(
48                               ICameraServiceListener::getInterfaceDescriptor());
49 
50         data.writeInt32(static_cast<int32_t>(status));
51         data.writeInt32(cameraId);
52 
53         remote()->transact(STATUS_CHANGED,
54                            data,
55                            &reply,
56                            IBinder::FLAG_ONEWAY);
57 
58         reply.readExceptionCode();
59     }
60 };
61 
62 IMPLEMENT_META_INTERFACE(CameraServiceListener,
63                          "android.hardware.ICameraServiceListener");
64 
65 // ----------------------------------------------------------------------
66 
onTransact(uint32_t code,const Parcel & data,Parcel * reply,uint32_t flags)67 status_t BnCameraServiceListener::onTransact(
68     uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
69 {
70     switch(code) {
71         case STATUS_CHANGED: {
72             CHECK_INTERFACE(ICameraServiceListener, data, reply);
73 
74             Status status = static_cast<Status>(data.readInt32());
75             int32_t cameraId = data.readInt32();
76 
77             onStatusChanged(status, cameraId);
78             reply->writeNoException();
79 
80             return NO_ERROR;
81         } break;
82         default:
83             return BBinder::onTransact(code, data, reply, flags);
84     }
85 }
86 
87 // ----------------------------------------------------------------------------
88 
89 }; // namespace android
90