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

Commit c463350d authored by Steven Moreland's avatar Steven Moreland Committed by android-build-merger
Browse files

Merge "example AIDL HAL extension" am: 028bb375

am: 10476a1b

Change-Id: If4239634f148cbfd7aa6f2528af15468fe4be9fd
parents e68c68a2 10476a1b
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
aidl_interface {
    // This is an example test interface showing how to add functionality
    // with setExtension/getExtension
    name: "test-vintf-vibrator-ext",
    vendor_available: true,
    srcs: [
        // Using android.hardware as the package because this is in
        // hardware/interfaces. For custom interfaces, normally you
        // would use a different package.
        "android/hardware/tests/extension/vibrator/Directionality.aidl",
        "android/hardware/tests/extension/vibrator/ICustomVibrator.aidl",
        "android/hardware/tests/extension/vibrator/VendorEffect.aidl",
    ],

    // This is agreeing to keep the interface stable.
    stability: "vintf",

    // This happens to use types from a core interface, so we import it, but
    // this won't always be needed.
    imports: [
        "vintf-vibrator",
    ],

    backend: {
        java: {
            enabled: false,
        },
    },
}
+30 −0
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.
 */
package android.hardware.tests.extension.vibrator;

/**
 * Can add custom enums. If these need to be extended further, new values can
 * simply be added.
 */
@Backing(type="int")
@VintfStability
enum Directionality {
    NONE,
    /** vibrations should be transverse wrt primary screen */
    TRANSVERSE,
    /** vibrations should be longitudinal wrt primary screen */
    LONGITUDINAL,
}
+55 −0
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.
 */
package android.hardware.tests.extension.vibrator;

// it's fine to use types from other interfaces
import android.hardware.vibrator.IVibratorCallback;
import android.hardware.tests.extension.vibrator.Directionality;
import android.hardware.tests.extension.vibrator.VendorEffect;

/**
 * This is an example of an AIDL interface extension. Notice that it does not
 * inherit from any other extension. Instead, it will be tagged onto that
 * extension at runtime.
 */
@VintfStability
interface ICustomVibrator {
    /**
     * Avoid conflicting with vendor properties. Giving this as an example
     * because the core vibrator interface uses capabilities. In reality,
     * since this is only one capability, it's probably not needed to construct
     * a bitfield.
     *
     * This is for longitudinal/transverse waves, see setDirectionality.
     */
    const int CAP_VENDOR_DIRECTIONALITY = 1 << 0;

    /**
     * Any new methods can be added, this returns CAP_VENDOR_*.
     */
    int getVendorCapabilities();

    /**
     * Arbitrary new functionality can be added.
     */
    void setDirectionality(Directionality directionality);

    /**
     * Perform a custom vendor effect. Note, this is a separate effect enum to
     * avoid conflicting with core types.
     */
    int perform(VendorEffect effect, IVibratorCallback callback);
}
+26 −0
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.
 */
package android.hardware.tests.extension.vibrator;

/**
 * Extending enum separately to avoid conflicts w/ upstream.
 */
@Backing(type="int")
@VintfStability
enum VendorEffect {
    CRACKLE,
    WIGGLE,
}
+26 −0
Original line number Diff line number Diff line

// This example client is written as a test, but it is executing from a system
// context. All this code would look the same if it was running in system
// server for example.

cc_test {
    name: "test-vintf-vibrator-ext-client",
    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",
         "test-ndk-client.cpp",
    ],
    shared_libs: [
         "libbinder",
         "libutils",
         "vintf-vibrator-cpp",
         "test-vintf-vibrator-ext-cpp",

         "libbinder_ndk",
         "vintf-vibrator-ndk_platform",
         "test-vintf-vibrator-ext-ndk_platform",
    ],
}
Loading