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

Commit 28c81f19 authored by Lais Andrade's avatar Lais Andrade
Browse files

Disable cpp backend for android.hardware.vibrator

Disable CPP backend for vibrator HAL. Dependencies should use the
stable NDK instead.

This is also the recommended choice:

https://source.android.com/docs/core/architecture/aidl/aidl-hals#choosing-runtime

The HAL will be allowed to use ndk-stable types like PersistableBundle
after disabling the legacy CPP backend.

Fix: 349595412
Test: VtsHalVibratorTargetTest & VtsHalVibratorManagerTargetTest
Flag: EXEMPT NDK
Change-Id: Id5736e092afd36e786ecf3978ff6ad81c7a4df56
parent ce51bf0f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -37,6 +37,12 @@ aidl_interface {
        java: {
            enabled: false,
        },
        ndk: {
            enabled: true,
        },
        cpp: {
            enabled: false,
        },
    },
    frozen: true,
    versions_with_info: [
+1 −7
Original line number Diff line number Diff line
@@ -16,16 +16,10 @@ cc_test {
    srcs: [
        // system code has the option to use the unstable C++ libbinder API
        // or the NDK one. For maximum code portability, using the ndk client
        // makes the most sense, but both are provided here as an example.
        "test-cpp-client.cpp",
        // makes the most sense.
        "test-ndk-client.cpp",
    ],
    shared_libs: [
        "libbinder",
        "libutils",
        "android.hardware.vibrator-V2-cpp",
        "android.hardware.tests.extension.vibrator-V1-cpp",

        "libbinder_ndk",
        "android.hardware.vibrator-V2-ndk",
        "android.hardware.tests.extension.vibrator-V1-ndk",
+0 −52
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 The Android Open Source Project
 *
 * 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 <android/hardware/tests/extension/vibrator/ICustomVibrator.h>
#include <android/hardware/vibrator/IVibrator.h>
#include <binder/IInterface.h>
#include <binder/IServiceManager.h>
#include <gtest/gtest.h>

using android::checked_interface_cast;
using android::IBinder;
using android::IInterface;
using android::OK;
using android::sp;
using android::waitForVintfService;
using android::hardware::tests::extension::vibrator::Directionality;
using android::hardware::tests::extension::vibrator::ICustomVibrator;
using android::hardware::vibrator::IVibrator;

TEST(Cpp, CallRootMethod) {
    sp<IVibrator> vib = waitForVintfService<IVibrator>();
    ASSERT_NE(nullptr, vib.get());
    ASSERT_TRUE(vib->off().isOk());
}

TEST(Cpp, CallExtMethod) {
    // normally you would want to cache this
    sp<IVibrator> vib = waitForVintfService<IVibrator>();
    ASSERT_NE(nullptr, vib.get());

    // getting the extension
    sp<IBinder> ext;
    ASSERT_EQ(OK, IInterface::asBinder(vib)->getExtension(&ext));
    sp<ICustomVibrator> cvib = checked_interface_cast<ICustomVibrator>(ext);
    ASSERT_NE(nullptr, cvib.get());

    // calling extension method
    ASSERT_TRUE(cvib->setDirectionality(Directionality::TRANSVERSE).isOk());
}
+2 −2
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ using ndk::SpAIBinder;
static const std::string kInstance = std::string() + IVibrator::descriptor + "/default";

TEST(Ndk, CallRootMethod) {
    SpAIBinder vibBinder = SpAIBinder(AServiceManager_getService(kInstance.c_str()));
    SpAIBinder vibBinder = SpAIBinder(AServiceManager_waitForService(kInstance.c_str()));
    ASSERT_NE(nullptr, vibBinder.get());
    std::shared_ptr<IVibrator> vib = IVibrator::fromBinder(vibBinder);
    ASSERT_NE(nullptr, vib.get());
@@ -38,7 +38,7 @@ TEST(Ndk, CallRootMethod) {
TEST(Ndk, CallExtMethod) {
    // normally you would want to cache this
    //
    SpAIBinder vibBinder = SpAIBinder(AServiceManager_getService(kInstance.c_str()));
    SpAIBinder vibBinder = SpAIBinder(AServiceManager_waitForService(kInstance.c_str()));
    ASSERT_NE(nullptr, vibBinder.get());
    std::shared_ptr<IVibrator> vib = IVibrator::fromBinder(vibBinder);
    ASSERT_NE(nullptr, vib.get());
+6 −0
Original line number Diff line number Diff line
@@ -20,6 +20,12 @@ aidl_interface {
        java: {
            sdk_version: "system_current",
        },
        ndk: {
            enabled: true,
        },
        cpp: {
            enabled: false,
        },
    },
    versions: [
        "1",
Loading