Begin processing read commands.
[minibind.git] / jni / minibind / minibind.cc
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "minibind.h"
6
7 #include "channel.h"
8 #include "command.h"
9 #include "common.h"
10 #include "parcel.h"
11
12 namespace minibind {
13
14 namespace {
15
16 Channel* GetServiceManager() {
17 static Channel* service_manager = nullptr;
18 if (!service_manager) {
19 service_manager = new Channel(0);
20
21 Parcel in, out;
22 service_manager->Call(Channel::PING_TRANSACTION, in, &out);
23 //service_manager->reader()->Print();
24 }
25
26 return service_manager;
27 }
28
29 } // namespace
30
31 Channel* LookupService(const std::string& name) {
32 Parcel data;
33 data.WriteInterfaceToken("android.os.IServiceManager");
34 data.WriteUTF8(name);
35
36 Channel* channel = GetServiceManager();
37 Parcel reply;
38
39 channel->Call(2 /*CHECK_SERVICE_TRANSACTION*/, data, &reply);
40 }
41
42 } // namespace minibind