summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarpreet \"Eli\" Sangha <eliptus@google.com>2019-12-19 17:37:33 -0800
committerandroid-build-merger <android-build-merger@google.com>2019-12-19 17:37:33 -0800
commitffb4e4d01af3a81710373c0fb2ab37a89d40c610 (patch)
tree5f2aafa6484527bbd23d254922fd2655b63094f8
parenta3e4e7fa149659ef2e0c1158043de81881264760 (diff)
parentaa0f5b0025ccecd91929febc5e3d5fb6c240ecdf (diff)
downloadnative-ffb4e4d01af3a81710373c0fb2ab37a89d40c610.tar.gz
Merge "idlcli: Use ndk_platform Backend for AIDL"
am: aa0f5b0025 Change-Id: I5e48ef1a9d82c5ea69dd77df2cf7c2da84cd069c
-rw-r--r--cmds/idlcli/Android.bp5
-rw-r--r--cmds/idlcli/vibrator.h28
-rw-r--r--cmds/idlcli/vibrator/CommandCompose.cpp2
-rw-r--r--cmds/idlcli/vibrator/CommandGetCapabilities.cpp2
-rw-r--r--cmds/idlcli/vibrator/CommandGetCompositionDelayMax.cpp2
-rw-r--r--cmds/idlcli/vibrator/CommandGetCompositionSizeMax.cpp2
-rw-r--r--cmds/idlcli/vibrator/CommandOff.cpp2
-rw-r--r--cmds/idlcli/vibrator/CommandOn.cpp2
-rw-r--r--cmds/idlcli/vibrator/CommandPerform.cpp2
-rw-r--r--cmds/idlcli/vibrator/CommandSetAmplitude.cpp2
-rw-r--r--cmds/idlcli/vibrator/CommandSetExternalControl.cpp2
11 files changed, 28 insertions, 23 deletions
diff --git a/cmds/idlcli/Android.bp b/cmds/idlcli/Android.bp
index 5476319f31..08a31c1636 100644
--- a/cmds/idlcli/Android.bp
+++ b/cmds/idlcli/Android.bp
@@ -20,15 +20,16 @@ cc_defaults {
"android.hardware.vibrator@1.2",
"android.hardware.vibrator@1.3",
"libbase",
- "libbinder",
+ "libbinder_ndk",
"libhidlbase",
"liblog",
"libutils",
- "vintf-vibrator-cpp",
+ "vintf-vibrator-ndk_platform",
],
cflags: [
"-DLOG_TAG=\"idlcli\"",
],
+ vendor_available: true,
}
cc_library {
diff --git a/cmds/idlcli/vibrator.h b/cmds/idlcli/vibrator.h
index 2f119234c1..ca5142dee9 100644
--- a/cmds/idlcli/vibrator.h
+++ b/cmds/idlcli/vibrator.h
@@ -13,13 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
#ifndef FRAMEWORK_NATIVE_CMDS_IDLCLI_VIBRATOR_H_
#define FRAMEWORK_NATIVE_CMDS_IDLCLI_VIBRATOR_H_
+#include <aidl/android/hardware/vibrator/IVibrator.h>
+#include <android/binder_manager.h>
#include <android/hardware/vibrator/1.3/IVibrator.h>
-#include <android/hardware/vibrator/IVibrator.h>
-#include <binder/IServiceManager.h>
#include "utils.h"
@@ -39,22 +38,27 @@ inline R NullptrStatus() {
}
template <>
-inline binder::Status NullptrStatus() {
- using binder::Status;
- return Status::fromExceptionCode(Status::EX_NULL_POINTER);
+inline ndk::ScopedAStatus NullptrStatus() {
+ return ndk::ScopedAStatus(AStatus_fromExceptionCode(EX_NULL_POINTER));
}
template <typename I>
-inline sp<I> getService() {
+inline auto getService() {
return I::getService();
}
template <>
-inline sp<hardware::vibrator::IVibrator> getService() {
- return waitForVintfService<hardware::vibrator::IVibrator>();
+inline auto getService<aidl::android::hardware::vibrator::IVibrator>() {
+ const auto instance =
+ std::string() + aidl::android::hardware::vibrator::IVibrator::descriptor + "/default";
+ auto vibBinder = ndk::SpAIBinder(AServiceManager_getService(instance.c_str()));
+ return aidl::android::hardware::vibrator::IVibrator::fromBinder(vibBinder);
}
template <typename I>
+using shared_ptr = std::result_of_t<decltype(getService<I>)&()>;
+
+template <typename I>
class HalWrapper {
public:
static std::unique_ptr<HalWrapper> Create() {
@@ -70,10 +74,10 @@ public:
}
private:
- HalWrapper(sp<I>&& hal) : mHal(std::move(hal)) {}
+ HalWrapper(shared_ptr<I>&& hal) : mHal(std::move(hal)) {}
private:
- sp<I> mHal;
+ shared_ptr<I> mHal;
};
template <typename I>
@@ -95,7 +99,7 @@ namespace V1_0 = ::android::hardware::vibrator::V1_0;
namespace V1_1 = ::android::hardware::vibrator::V1_1;
namespace V1_2 = ::android::hardware::vibrator::V1_2;
namespace V1_3 = ::android::hardware::vibrator::V1_3;
-namespace aidl = ::android::hardware::vibrator;
+namespace aidl = ::aidl::android::hardware::vibrator;
} // namespace vibrator
} // namespace idlcli
diff --git a/cmds/idlcli/vibrator/CommandCompose.cpp b/cmds/idlcli/vibrator/CommandCompose.cpp
index 705e40bbf2..4721a5f9ae 100644
--- a/cmds/idlcli/vibrator/CommandCompose.cpp
+++ b/cmds/idlcli/vibrator/CommandCompose.cpp
@@ -80,7 +80,7 @@ class CommandCompose : public Command {
Status ret;
if (auto hal = getHal<aidl::IVibrator>()) {
auto status = hal->call(&aidl::IVibrator::compose, mComposite, nullptr);
- statusStr = status.toString8();
+ statusStr = status.getDescription();
ret = status.isOk() ? OK : ERROR;
} else {
return UNAVAILABLE;
diff --git a/cmds/idlcli/vibrator/CommandGetCapabilities.cpp b/cmds/idlcli/vibrator/CommandGetCapabilities.cpp
index 30d85873c0..303a9895e4 100644
--- a/cmds/idlcli/vibrator/CommandGetCapabilities.cpp
+++ b/cmds/idlcli/vibrator/CommandGetCapabilities.cpp
@@ -48,7 +48,7 @@ class CommandGetCapabilities : public Command {
if (auto hal = getHal<aidl::IVibrator>()) {
auto status = hal->call(&aidl::IVibrator::getCapabilities, &cap);
- statusStr = status.toString8();
+ statusStr = status.getDescription();
ret = status.isOk() ? OK : ERROR;
} else {
return UNAVAILABLE;
diff --git a/cmds/idlcli/vibrator/CommandGetCompositionDelayMax.cpp b/cmds/idlcli/vibrator/CommandGetCompositionDelayMax.cpp
index b4143075b3..10508bd4dc 100644
--- a/cmds/idlcli/vibrator/CommandGetCompositionDelayMax.cpp
+++ b/cmds/idlcli/vibrator/CommandGetCompositionDelayMax.cpp
@@ -50,7 +50,7 @@ class CommandGetCompositionDelayMax : public Command {
if (auto hal = getHal<aidl::IVibrator>()) {
auto status = hal->call(&aidl::IVibrator::getCompositionDelayMax, &maxDelayMs);
- statusStr = status.toString8();
+ statusStr = status.getDescription();
ret = status.isOk() ? OK : ERROR;
} else {
return UNAVAILABLE;
diff --git a/cmds/idlcli/vibrator/CommandGetCompositionSizeMax.cpp b/cmds/idlcli/vibrator/CommandGetCompositionSizeMax.cpp
index 360fc9d9e2..900cb18809 100644
--- a/cmds/idlcli/vibrator/CommandGetCompositionSizeMax.cpp
+++ b/cmds/idlcli/vibrator/CommandGetCompositionSizeMax.cpp
@@ -50,7 +50,7 @@ class CommandGetCompositionSizeMax : public Command {
if (auto hal = getHal<aidl::IVibrator>()) {
auto status = hal->call(&aidl::IVibrator::getCompositionSizeMax, &maxSize);
- statusStr = status.toString8();
+ statusStr = status.getDescription();
ret = status.isOk() ? OK : ERROR;
} else {
return UNAVAILABLE;
diff --git a/cmds/idlcli/vibrator/CommandOff.cpp b/cmds/idlcli/vibrator/CommandOff.cpp
index 53fada0f86..cedb9fec06 100644
--- a/cmds/idlcli/vibrator/CommandOff.cpp
+++ b/cmds/idlcli/vibrator/CommandOff.cpp
@@ -47,7 +47,7 @@ class CommandOff : public Command {
if (auto hal = getHal<aidl::IVibrator>()) {
auto status = hal->call(&aidl::IVibrator::off);
- statusStr = status.toString8();
+ statusStr = status.getDescription();
ret = status.isOk() ? OK : ERROR;
} else if (auto hal = getHal<V1_0::IVibrator>()) {
auto status = hal->call(&V1_0::IVibrator::off);
diff --git a/cmds/idlcli/vibrator/CommandOn.cpp b/cmds/idlcli/vibrator/CommandOn.cpp
index ccb3c19ca8..4e7e493d6d 100644
--- a/cmds/idlcli/vibrator/CommandOn.cpp
+++ b/cmds/idlcli/vibrator/CommandOn.cpp
@@ -55,7 +55,7 @@ class CommandOn : public Command {
if (auto hal = getHal<aidl::IVibrator>()) {
auto status = hal->call(&aidl::IVibrator::on, mDuration, nullptr);
- statusStr = status.toString8();
+ statusStr = status.getDescription();
ret = status.isOk() ? OK : ERROR;
} else if (auto hal = getHal<V1_0::IVibrator>()) {
auto status = hal->call(&V1_0::IVibrator::on, mDuration);
diff --git a/cmds/idlcli/vibrator/CommandPerform.cpp b/cmds/idlcli/vibrator/CommandPerform.cpp
index 58d4e0ac16..69c7e37744 100644
--- a/cmds/idlcli/vibrator/CommandPerform.cpp
+++ b/cmds/idlcli/vibrator/CommandPerform.cpp
@@ -99,7 +99,7 @@ class CommandPerform : public Command {
auto status =
hal->call(&aidl::IVibrator::perform, static_cast<aidl::Effect>(mEffect),
static_cast<aidl::EffectStrength>(mStrength), nullptr, &aidlLengthMs);
- statusStr = status.toString8();
+ statusStr = status.getDescription();
lengthMs = static_cast<uint32_t>(aidlLengthMs);
ret = status.isOk() ? OK : ERROR;
} else {
diff --git a/cmds/idlcli/vibrator/CommandSetAmplitude.cpp b/cmds/idlcli/vibrator/CommandSetAmplitude.cpp
index 33d7eed5be..8b8058c4fd 100644
--- a/cmds/idlcli/vibrator/CommandSetAmplitude.cpp
+++ b/cmds/idlcli/vibrator/CommandSetAmplitude.cpp
@@ -56,7 +56,7 @@ class CommandSetAmplitude : public Command {
if (auto hal = getHal<aidl::IVibrator>()) {
auto status = hal->call(&aidl::IVibrator::setAmplitude,
static_cast<float>(mAmplitude) / UINT8_MAX);
- statusStr = status.toString8();
+ statusStr = status.getDescription();
ret = status.isOk() ? OK : ERROR;
} else if (auto hal = getHal<V1_0::IVibrator>()) {
auto status = hal->call(&V1_0::IVibrator::setAmplitude, mAmplitude);
diff --git a/cmds/idlcli/vibrator/CommandSetExternalControl.cpp b/cmds/idlcli/vibrator/CommandSetExternalControl.cpp
index 5bc827e707..179579310a 100644
--- a/cmds/idlcli/vibrator/CommandSetExternalControl.cpp
+++ b/cmds/idlcli/vibrator/CommandSetExternalControl.cpp
@@ -53,7 +53,7 @@ class CommandSetExternalControl : public Command {
if (auto hal = getHal<aidl::IVibrator>()) {
auto status = hal->call(&aidl::IVibrator::setExternalControl, mEnable);
- statusStr = status.toString8();
+ statusStr = status.getDescription();
ret = status.isOk() ? OK : ERROR;
} else if (auto hal = getHal<V1_3::IVibrator>()) {
auto status = hal->call(&V1_3::IVibrator::setExternalControl, mEnable);