Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9e11c898 authored by Arman Uguray's avatar Arman Uguray
Browse files

service: Introduce a command-line client

This CL introduces a CLI for the Bluetooth daemon. The code currently
doesn't do much, other than demonstrate how a native Binder client code
can be placed to the Bluetooth daemon. This objective here is to
extend this with a REPL and send commands to the daemon based on user
input.

Bug: 22743129
Change-Id: I41015e4b639e7099dd9f7086dbe86b01f3a61786
parent a3242475
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -80,3 +80,18 @@ LOCAL_SHARED_LIBRARIES += libchrome-host
LOCAL_STATIC_LIBRARIES += libgmock_host liblog
include $(BUILD_HOST_NATIVE_TEST)
endif

# Native system service CLI for target
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
	$(btserviceBinderSrc) \
	client/main.cpp
LOCAL_C_INCLUDES += $(btserviceCommonIncludes)
LOCAL_CFLAGS += -std=c++11
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := bluetooth-cli
LOCAL_SHARED_LIBRARIES += \
	libbinder \
	libchrome \
	libutils
include $(BUILD_EXECUTABLE)
+40 −0
Original line number Diff line number Diff line
//
//  Copyright (C) 2015 Google, Inc.
//
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at:
//
//  http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//

#include <base/logging.h>

#include "service/ipc/binder/IBluetooth.h"

using android::sp;

using ipc::binder::IBluetooth;

// TODO(armansito): Build a REPL into this client so that we make Binder calls
// based on user input. For now this just tests the IsEnabled() method and
// exits.

int main() {
  sp<IBluetooth> bt_iface = IBluetooth::getClientInterface();
  if (!bt_iface.get()) {
    LOG(ERROR) << "Failed to obtain handle on IBluetooth";
    return EXIT_FAILURE;
  }

  bool enabled = bt_iface->IsEnabled();
  LOG(INFO) << "IsEnabled(): " << enabled;

  return EXIT_SUCCESS;
}