Merge changes from topic 'tv-input'
* changes:
tv.input: add android.hardware.tv.input@1.0-(impl|service)
tv.input: add HIDL definition for TV Input HAL
diff --git a/Android.bp b/Android.bp
index d948da9..d0278e7 100644
--- a/Android.bp
+++ b/Android.bp
@@ -8,6 +8,7 @@
"biometrics/fingerprint/2.1",
"bluetooth/1.0",
"boot/1.0",
+ "broadcastradio/1.0",
"example/extension/light/2.0",
"gnss/1.0",
"graphics/allocator/2.0",
@@ -35,6 +36,7 @@
"tests/foo/1.0/default",
"tests/foo/1.0/default/lib",
"tests/libhwbinder/1.0",
+ "tests/libhwbinder/1.0/default",
"tests/msgq/1.0",
"tests/pointer/1.0",
"tests/pointer/1.0/default",
diff --git a/boot/1.0/default/service.cpp b/boot/1.0/default/service.cpp
index b059f9a..a594db6 100644
--- a/boot/1.0/default/service.cpp
+++ b/boot/1.0/default/service.cpp
@@ -1,44 +1,11 @@
#define LOG_TAG "android.hardware.boot@1.0-service"
-#include <utils/Log.h>
-
-#include <iostream>
-#include <unistd.h>
#include <android/hardware/boot/1.0/IBootControl.h>
-
-#include <hidl/IServiceManager.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/ProcessState.h>
-#include <utils/Errors.h>
-#include <utils/StrongPointer.h>
-
-using android::sp;
-
-using android::hardware::IPCThreadState;
-using android::hardware::ProcessState;
+#include <hidl/LegacySupport.h>
using ::android::hardware::boot::V1_0::IBootControl;
+using android::hardware::defaultPassthroughServiceImplementation;
int main (int /* argc */, char * /* argv */ []) {
- ALOGI("Service is starting.");
- const char instance[] = "bootctrl";
- ALOGI("Retrieving default implementation of instance %s.",
- instance);
-
- sp<IBootControl> service = IBootControl::getService(instance, true /* getStub */);
-
- if (service.get() == nullptr) {
- ALOGE("IBootControl::getService returned NULL, exiting");
- return -1;
- }
-
- LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
-
- ALOGI("Registering instance %s.", instance);
- service->registerAsService(instance);
- ALOGI("Ready.");
-
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- ProcessState::self()->startThreadPool();
- IPCThreadState::self()->joinThreadPool();
+ return defaultPassthroughServiceImplementation<IBootControl>("bootctrl");
}
diff --git a/broadcastradio/1.0/Android.bp b/broadcastradio/1.0/Android.bp
new file mode 100644
index 0000000..44af4aa
--- /dev/null
+++ b/broadcastradio/1.0/Android.bp
@@ -0,0 +1,70 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+ name: "android.hardware.broadcastradio@1.0_genc++",
+ tool: "hidl-gen",
+ cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.broadcastradio@1.0",
+ srcs: [
+ "types.hal",
+ "IBroadcastRadio.hal",
+ "IBroadcastRadioFactory.hal",
+ "ITuner.hal",
+ "ITunerCallback.hal",
+ ],
+ out: [
+ "android/hardware/broadcastradio/1.0/types.cpp",
+ "android/hardware/broadcastradio/1.0/BroadcastRadioAll.cpp",
+ "android/hardware/broadcastradio/1.0/BroadcastRadioFactoryAll.cpp",
+ "android/hardware/broadcastradio/1.0/TunerAll.cpp",
+ "android/hardware/broadcastradio/1.0/TunerCallbackAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.broadcastradio@1.0_genc++_headers",
+ tool: "hidl-gen",
+ cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.broadcastradio@1.0",
+ srcs: [
+ "types.hal",
+ "IBroadcastRadio.hal",
+ "IBroadcastRadioFactory.hal",
+ "ITuner.hal",
+ "ITunerCallback.hal",
+ ],
+ out: [
+ "android/hardware/broadcastradio/1.0/types.h",
+ "android/hardware/broadcastradio/1.0/IBroadcastRadio.h",
+ "android/hardware/broadcastradio/1.0/IHwBroadcastRadio.h",
+ "android/hardware/broadcastradio/1.0/BnBroadcastRadio.h",
+ "android/hardware/broadcastradio/1.0/BpBroadcastRadio.h",
+ "android/hardware/broadcastradio/1.0/BsBroadcastRadio.h",
+ "android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.0/IHwBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.0/BnBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.0/BpBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.0/BsBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.0/ITuner.h",
+ "android/hardware/broadcastradio/1.0/IHwTuner.h",
+ "android/hardware/broadcastradio/1.0/BnTuner.h",
+ "android/hardware/broadcastradio/1.0/BpTuner.h",
+ "android/hardware/broadcastradio/1.0/BsTuner.h",
+ "android/hardware/broadcastradio/1.0/ITunerCallback.h",
+ "android/hardware/broadcastradio/1.0/IHwTunerCallback.h",
+ "android/hardware/broadcastradio/1.0/BnTunerCallback.h",
+ "android/hardware/broadcastradio/1.0/BpTunerCallback.h",
+ "android/hardware/broadcastradio/1.0/BsTunerCallback.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.broadcastradio@1.0",
+ generated_sources: ["android.hardware.broadcastradio@1.0_genc++"],
+ generated_headers: ["android.hardware.broadcastradio@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.broadcastradio@1.0_genc++_headers"],
+ shared_libs: [
+ "libhidl",
+ "libhwbinder",
+ "libutils",
+ "libcutils",
+ ],
+}
diff --git a/broadcastradio/1.0/IBroadcastRadio.hal b/broadcastradio/1.0/IBroadcastRadio.hal
new file mode 100644
index 0000000..c7fe62d
--- /dev/null
+++ b/broadcastradio/1.0/IBroadcastRadio.hal
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2016 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.broadcastradio@1.0;
+
+import ITunerCallback;
+import ITuner;
+
+interface IBroadcastRadio {
+
+ /*
+ * Retrieve implementation properties.
+ * @return result Operation completion status: OK in case of success,
+ * NOT_INITIALIZED in case of initialization error.
+ * @return properties A Properties structure containing implementation
+ * description and capabilities.
+ */
+ getProperties() generates (Result result, Properties properties);
+
+ /*
+ * Open a tuner interface for the requested configuration.
+ * If no other tuner is opened, this will power on the radio hardware.
+ * The hardware must be powered down when all tuner interface are released.
+ * @param config A BandConfig struct containing the band configuration to apply
+ * @param audio True if this tuner must be used for live radio listening and
+ * should be connected to the radio audio source.
+ * @param callback the callback interface
+ * @return result Operation completion status: OK in case of success,
+ * INVALID_ARGUMENTS if configuration requested is invalid,
+ * INVALID_STATE if called out of sequence
+ * @return tuner The interface to control the tuner
+ *
+ * Callback ITunerCallback.ConfigChanged MUST be called once the
+ * configuration is applied or a failure occurs or after a time out.
+ */
+ openTuner(BandConfig config, bool audio, ITunerCallback callback)
+ generates (Result result, ITuner tuner);
+};
diff --git a/broadcastradio/1.0/IBroadcastRadioFactory.hal b/broadcastradio/1.0/IBroadcastRadioFactory.hal
new file mode 100644
index 0000000..82a97c4
--- /dev/null
+++ b/broadcastradio/1.0/IBroadcastRadioFactory.hal
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2016 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.broadcastradio@1.0;
+
+import IBroadcastRadio;
+
+interface IBroadcastRadioFactory {
+
+ /*
+ * Connects to a broadcast radio HAL module for a given class
+ * (AM/FM, Satellite, DAB).
+ *
+ * @param classId Class of the module to connect to .
+ * @return retval operation completion status. Returns INVALID_ARGUMENTS
+ * if there is no corresponding hardware module found,
+ * NOT_INITIALIZED if an error occurred while opening the hardware
+ * module.
+ * @return result the interface for the created module.
+ */
+ connectModule(Class classId)
+ generates (Result retval, IBroadcastRadio result);
+};
diff --git a/broadcastradio/1.0/ITuner.hal b/broadcastradio/1.0/ITuner.hal
new file mode 100644
index 0000000..5e2bffe
--- /dev/null
+++ b/broadcastradio/1.0/ITuner.hal
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2015 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.broadcastradio@1.0;
+
+import ITunerCallback;
+
+interface ITuner {
+
+ /*
+ * Apply current radio band configuration (band, range, channel spacing...).
+ * Automatically cancels pending scan, step or tune.
+ * ITunerCallback.configChange() method MUST be called once the
+ * configuration is applied or a failure occurs or after a time out.
+ * @param config The band configuration to apply.
+ * @return result OK if configuration could be applied
+ * NOT_INITIALIZED in case of initialization error.
+ * INVALID_ARGUMENTS if configuration requested is invalid
+ *
+ */
+ setConfiguration(BandConfig config) generates(Result result);
+
+ /*
+ * Retrieve current radio band configuration.
+ * @return result OK if valid configuration is returned,
+ * NOT_INITIALIZED in case of initialization error.
+ * @param config Current band configuration
+ */
+ getConfiguration() generates(Result result, BandConfig config);
+
+ /*
+ * Start scanning up to next valid station.
+ * Shall be called only when a valid configuration has been applied.
+ * Automatically cancels pending scan, step or tune.
+ * ITunerCallback.tuneComplete() MUST be called once locked on a station
+ * or after a time out or full band scan if no station found.
+ * The status should indicate if a valid station is tuned or not.
+ * @param direction UP or DOWN.
+ * @param skipSubChannel valid for HD radio or digital radios only:
+ * ignore sub channels (e.g SPS for HD radio).
+ * @return result OK if scan successfully started
+ * INVALID_STATE if called out of sequence
+ * NOT_INITIALIZED if another error occurs
+ */
+ scan(Direction direction, bool skipSubChannel) generates(Result result);
+
+ /*
+ * Move one channel spacing up or down.
+ * Must be called when a valid configuration has been applied.
+ * Automatically cancels pending scan, step or tune.
+ * ITunerCallback.tuneComplete() MUST be called once locked on a station
+ * or after a time out or full band scan if no station found.
+ * The status should indicate if a valid station is tuned or not.
+ * @param direction UP or DOWN.
+ * @param skipSubChannel valid for HD radio or digital radios only:
+ * ignore sub channels (e.g SPS for HD radio).
+ * @return result OK if scan successfully started
+ * INVALID_STATE if called out of sequence
+ * NOT_INITIALIZED if another error occurs
+ */
+ step(Direction direction, bool skipSubChannel) generates(Result result);
+
+ /*
+ * Tune to specified channel.
+ * Must be called when a valid configuration has been applied.
+ * Automatically cancels pending scan, step or tune.
+ * ITunerCallback.tuneComplete() MUST be called once locked on a station
+ * or after a time out or full band scan if no station found.
+ * The status should indicate if a valid station is tuned or not.
+ * @param channel Channel to tune to. A frequency in kHz for AM/FM/HD Radio
+ * bands.
+ * @param subChannel Valid for HD radio or digital radios only
+ * (e.g SPS number for HD radio)..
+ * @return result OK if scan successfully started
+ * INVALID_ARGUMENTS if invalid arguments are passed
+ * INVALID_STATE if called out of sequence
+ * NOT_INITIALIZED if another error occurs
+ */
+ tune(uint32_t channel, uint32_t subChannel) generates(Result result);
+
+ /*
+ * Cancel a scan, step or tune operation.
+ * Shall be called only while a scan, step or tune operation is pending.
+ * ITunerCallback.tuneComplete() MUST NOT be sent by the HAL.
+ * @return result OK if scan successfully started
+ * INVALID_STATE if called out of sequence
+ * NOT_INITIALIZED if another error occurs
+ */
+ cancel() generates(Result result);
+
+ /*
+ * Retrieve current station information.
+ * @param withMetadata True if Metadata should be returned, false otherwise.
+ * @return result OK if scan successfully started
+ * NOT_INITIALIZED if another error occurs
+ * @return info Current program information.
+ */
+ getProgramInformation(bool withMetadata)
+ generates(Result result, ProgramInfo info);
+};
diff --git a/broadcastradio/1.0/ITunerCallback.hal b/broadcastradio/1.0/ITunerCallback.hal
new file mode 100644
index 0000000..f805472
--- /dev/null
+++ b/broadcastradio/1.0/ITunerCallback.hal
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2016 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.broadcastradio@1.0;
+
+
+interface ITunerCallback {
+
+ /*
+ * Method called by the HAL when a HW failure occurs.
+ * The framework MUST close the ITuner interface and open a new one.
+ */
+ oneway hardwareFailure();
+
+ /*
+ * Method called by the HAL when a new configuration is applied
+ * in response to IDevice.openTuner() or ITuner.setConfiguration().
+ * @param result OK if the configuration has been applied,
+ * INVALID_ARGUMENTS if not or TIMEOUT in case of time out.
+ * @param config A BandConfig structure describing the new configuration
+ * applied.
+ */
+ oneway configChange(Result result, BandConfig config);
+
+ /*
+ * Method called by the HAL when a tuning operation completes
+ * following a step(), scan() or tune() command.
+ * @param result OK if tune succeeded or TIMEOUT in case of time out.
+ * @param info A ProgramInfo structure describing the tuned station.
+ */
+ oneway tuneComplete(Result result, ProgramInfo info);
+
+ /*
+ * Method called by the HAL when a frequency switch occurs.
+ * @param info A ProgramInfo structure describing the new tuned station.
+ */
+ oneway afSwitch(ProgramInfo info);
+
+ /*
+ * Method called by the HAL when the antenna connection state changes.
+ * @param connected True if the antenna is connected, false otherwise.
+ */
+ oneway antennaStateChange(bool connected);
+
+ /*
+ * Method called by the HAL when a traffic announcement starts or
+ * stops.
+ * @param active True if the announcement starts, false if it stops.
+ */
+ oneway trafficAnnouncement(bool active);
+
+ /*
+ * Method called by the HAL when an emergency announcement starts
+ * or stops.
+ * @param active True if the announcement starts, false if it stops.
+ */
+ oneway emergencyAnnouncement(bool active);
+
+ /*
+ * Method called by the HAL when metadata for current station
+ * are updated.
+ * @param metadatas A list of all updated metada.
+ */
+ oneway newMetadata(vec<MetaData> metadatas);
+};
\ No newline at end of file
diff --git a/broadcastradio/1.0/types.hal b/broadcastradio/1.0/types.hal
new file mode 100644
index 0000000..c5b4411
--- /dev/null
+++ b/broadcastradio/1.0/types.hal
@@ -0,0 +1,216 @@
+/*
+ * Copyright 2016 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.broadcastradio@1.0;
+
+enum Result {
+ OK,
+ NOT_INITIALIZED,
+ INVALID_ARGUMENTS,
+ INVALID_STATE,
+ TIMEOUT,
+};
+
+/*
+ * Radio hardware module class. A given radio hardware module HAL is of one
+ * class only. The platform can not have more than one hardware module of
+ * each class. Current version of the framework only supports RADIO_CLASS_AM_FM.
+ */
+enum Class : uint32_t {
+ /* FM (including HD radio) and AM */
+ AM_FM = 0,
+ /* Satellite Radio */
+ SAT = 1,
+ /* Digital Radio (DAB) */
+ DT = 2,
+};
+
+/* value for field "type" of radio band described in struct radio_hal_band_config */
+enum Band : uint32_t {
+ /* Amplitude Modulation band: LW, MW, SW */
+ AM = 0,
+ /* Frequency Modulation band: FM */
+ FM = 1,
+ /* FM HD Radio / DRM (IBOC) */
+ FM_HD = 2,
+ /* AM HD Radio / DRM (IBOC) */
+ AM_HD = 3,
+};
+
+/* RDS variant implemented. A struct FmBandConfig can list none or several. */
+enum Rds : uint32_t {
+ NONE = 0,
+ WORLD = (1<<0),
+ RDS_US = (1<<1),
+};
+
+
+/* FM deemphasis variant implemented.
+ * A struct FmBandConfig can list one or more. */
+enum Deemphasis : uint32_t {
+ D50 = (1<<0),
+ D75 = (1<<1),
+};
+
+/* Scanning direction for scan() and step() tuner APIs */
+enum Direction : uint32_t {
+ UP,
+ DOWN
+};
+
+/* Unique handle allocated to a radio module */
+typedef uint32_t Handle;
+
+
+/* Additional attributes for an FM band configuration */
+struct FmBandConfig {
+ /* deemphasis variant */
+ Deemphasis deemphasis;
+ /* stereo supported */
+ bool stereo;
+ /* RDS variants supported */
+ Rds rds;
+ /* Traffic Announcement supported */
+ bool ta;
+ /* Alternate Frequency supported */
+ bool af;
+ /* Emergency announcements supported */
+ bool ea;
+};
+
+/* Additional attributes for an AM band configuration */
+struct AmBandConfig {
+ /* Stereo supported */
+ bool stereo;
+};
+
+/* Radio band configuration. Describes a given band supported by the radio
+ * module. The HAL can expose only one band per type with the the maximum range
+ * supported and all options. The framework will derive the actual regions were
+ * this module can operate and expose separate band configurations for
+ * applications to chose from. */
+struct BandConfig {
+ Band type;
+ bool antennaConnected;
+ uint32_t lowerLimit;
+ uint32_t upperLimit;
+ vec<uint32_t> spacings;
+ union Ext {
+ FmBandConfig fm;
+ AmBandConfig am;
+ };
+};
+
+/* Exposes properties of a given hardware radio module.
+ * NOTE: current framework implementation supports only one audio source
+ * (num_audio_sources = 1). The source corresponds to AUDIO_DEVICE_IN_FM_TUNER.
+ * If more than one tuner is supported (num_tuners > 1), only one can be
+ * connected to the audio source. */
+struct Properties {
+ /* Class of this module. E.g AM_FM */
+ Class classId;
+ /* implementor name */
+ string implementor;
+ /* product name */
+ string product;
+ /* product version */
+ string version;
+ /* serial number (for subscription services) */
+ string serial;
+ /* number of tuners controllable independently */
+ uint32_t numTuners;
+ /* number of audio sources driven simultaneously */
+ uint32_t numAudioSources;
+ /* the hardware supports capture of audio source from audio HAL */
+ bool supportsCapture;
+ vec<BandConfig> bands; /* band descriptors */
+};
+
+enum MetadataType {
+ INVALID = -1,
+ /* Signed 32 bit integer */
+ INT = 0,
+ /* String */
+ TEXT = 1,
+ /* Raw binary data (icon or art)
+ This data must be transparent to the android framework */
+ RAW = 2,
+ /* clock data, see MetaDataClock */
+ CLOCK = 3,
+};
+
+enum MetadataKey {
+ INVALID = -1,
+ /* RDS PI - string */
+ RDS_PI = 0,
+ /* RDS PS - string */
+ RDS_PS = 1,
+ /* RDS PTY - int32_t */
+ RDS_PTY = 2,
+ /* RBDS PTY - int32_t */
+ RBDS_PTY = 3,
+ /* RDS RT - string */
+ RDS_RT = 4,
+ /* Song title - string */
+ TITLE = 5,
+ /* Artist name - string */
+ ARTIST = 6,
+ /* Album name - string */
+ ALBUM = 7,
+ /* Musical genre - string */
+ GENRE = 8,
+ /* Station icon - raw */
+ ICON = 9,
+ /* Album art - raw */
+ ART = 10,
+ /* Clock - MetaDataClock */
+ CLOCK = 11,
+};
+
+struct MetaDataClock {
+ /* Seconds since epoch at GMT + 0. */
+ uint64_t utcSecondsSinceEpoch;
+ /* Minutes offset from the GMT. */
+ int32_t timezoneOffsetInMinutes;
+};
+
+struct MetaData {
+ MetadataType type;
+ MetadataKey key;
+ /* Value used for type MetadataType.INT */
+ int32_t intValue;
+ /* Value used for type MetadataType.CLOCK */
+ MetaDataClock clockValue;
+ /* Value used for type MetadataType.TEXT */
+ string stringValue;
+ /* Value used for type MetadataType.RAW */
+ vec<uint8_t> rawValue;
+};
+
+
+/* Radio program information. Returned by the HAL with event RADIO_EVENT_TUNED.
+ * Contains information on currently tuned channel.
+ */
+struct ProgramInfo {
+ uint32_t channel; /* current channel. (e.g kHz for band type AM_FM) */
+ uint32_t subChannel; /* current sub channel. (FM_HD) */
+ bool tuned; /* tuned to a program or not */
+ bool stereo; /* program is stereo or not */
+ bool digital; /* digital program or not (e.g HD Radio program) */
+ uint32_t signalStrength; /* signal strength from 0 to 100 */
+ vec<MetaData> metadata; /* non empty if meta data are present (e.g PTY, song title ...) */
+};
+
diff --git a/graphics/allocator/2.0/default/service.cpp b/graphics/allocator/2.0/default/service.cpp
index fd89aa8..525b342 100644
--- a/graphics/allocator/2.0/default/service.cpp
+++ b/graphics/allocator/2.0/default/service.cpp
@@ -14,38 +14,15 @@
* limitations under the License.
*/
-#define LOG_TAG "GrallocService"
+#define LOG_TAG "android.hardware.graphics.allocator@2.0-service"
#include <android/hardware/graphics/allocator/2.0/IAllocator.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/ProcessState.h>
-#include <utils/StrongPointer.h>
-using android::sp;
-using android::hardware::IPCThreadState;
-using android::hardware::ProcessState;
+#include <hidl/LegacySupport.h>
+
using android::hardware::graphics::allocator::V2_0::IAllocator;
+using android::hardware::defaultPassthroughServiceImplementation;
-int main()
-{
- const char instance[] = "gralloc";
-
- ALOGI("Service is starting.");
-
- sp<IAllocator> service = IAllocator::getService(instance,
- true /* getStub */);
- if (service == nullptr) {
- ALOGI("getService returned NULL");
- return -1;
- }
-
- LOG_FATAL_IF(service->isRemote(), "Service is REMOTE!");
-
- service->registerAsService(instance);
-
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- ProcessState::self()->startThreadPool();
- IPCThreadState::self()->joinThreadPool();
-
- return 0;
+int main() {
+ return defaultPassthroughServiceImplementation<IAllocator>("gralloc");
}
diff --git a/light/2.0/default/service.cpp b/light/2.0/default/service.cpp
index e446878..b3848e9 100644
--- a/light/2.0/default/service.cpp
+++ b/light/2.0/default/service.cpp
@@ -1,46 +1,27 @@
-#define LOG_TAG "android.hardware.light@2.0-service"
-#include <utils/Log.h>
+/*
+ * Copyright 2016 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 <iostream>
-#include <unistd.h>
+#define LOG_TAG "android.hardware.light@2.0-service"
#include <android/hardware/light/2.0/ILight.h>
+#include <hidl/LegacySupport.h>
-#include <hidl/IServiceManager.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/ProcessState.h>
-#include <utils/Errors.h>
-#include <utils/StrongPointer.h>
-
-using android::sp;
-
-// libhwbinder:
-using android::hardware::IPCThreadState;
-using android::hardware::ProcessState;
-
-// Generated HIDL files
using android::hardware::light::V2_0::ILight;
+using android::hardware::defaultPassthroughServiceImplementation;
int main() {
- ALOGI("Service is starting.");
- const char instance[] = "light";
- ALOGI("Retrieving default implementation of instance %s.",
- instance);
-
- android::sp<ILight> service = ILight::getService(instance, true /* getStub */);
-
- if (service.get() == nullptr) {
- ALOGE("ILight::getService returned NULL, exiting");
- return EXIT_FAILURE;
- }
-
- LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
-
- ALOGI("Registering instance %s.", instance);
- service->registerAsService(instance);
- ALOGI("Ready.");
-
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- ProcessState::self()->startThreadPool();
- IPCThreadState::self()->joinThreadPool();
+ return defaultPassthroughServiceImplementation<ILight>("light");
}
diff --git a/memtrack/1.0/default/service.cpp b/memtrack/1.0/default/service.cpp
index 63ac695..f705b15 100644
--- a/memtrack/1.0/default/service.cpp
+++ b/memtrack/1.0/default/service.cpp
@@ -15,37 +15,13 @@
*/
#define LOG_TAG "android.hardware.memtrack@1.0-service"
-#include <utils/Log.h>
-
-#include <iostream>
-#include <unistd.h>
#include <android/hardware/memtrack/1.0/IMemtrack.h>
-
-#include <hidl/IServiceManager.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/ProcessState.h>
-#include <utils/Errors.h>
-#include <utils/StrongPointer.h>
-
-using android::sp;
-
-using android::hardware::IPCThreadState;
-using android::hardware::ProcessState;
+#include <hidl/LegacySupport.h>
using android::hardware::memtrack::V1_0::IMemtrack;
+using android::hardware::defaultPassthroughServiceImplementation;
int main() {
- const char instance[] = "memtrack";
- android::sp<IMemtrack> service = IMemtrack::getService(instance, true);
- if (service.get() == nullptr) {
- ALOGE("IMemtrack::getService returned NULL, exiting");
- return -1;
- }
- LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
- service->registerAsService(instance);
-
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- ProcessState::self()->startThreadPool();
- IPCThreadState::self()->joinThreadPool();
+ return defaultPassthroughServiceImplementation<IMemtrack>("memtrack");
}
diff --git a/nfc/1.0/vts/functional/Android.bp b/nfc/1.0/vts/functional/Android.bp
new file mode 100644
index 0000000..0f1afbd
--- /dev/null
+++ b/nfc/1.0/vts/functional/Android.bp
@@ -0,0 +1,36 @@
+//
+// Copyright (C) 2016 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.
+//
+
+cc_test {
+ name: "nfc_hidl_hal_test",
+ gtest: true,
+ srcs: ["nfc_hidl_hal_test.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libcutils",
+ "libhidl",
+ "libhwbinder",
+ "libnativehelper",
+ "libutils",
+ "android.hardware.nfc@1.0",
+ ],
+ static_libs: ["libgtest"],
+ cflags: [
+ "-O0",
+ "-g",
+ ],
+}
\ No newline at end of file
diff --git a/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp b/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp
new file mode 100644
index 0000000..e215704
--- /dev/null
+++ b/nfc/1.0/vts/functional/nfc_hidl_hal_test.cpp
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#define LOG_TAG "nfc_hidl_hal_test"
+#include <android-base/logging.h>
+
+#include <hardware/nfc.h>
+#include <android/hardware/nfc/1.0/types.h>
+#include <android/hardware/nfc/1.0/INfc.h>
+#include <android/hardware/nfc/1.0/INfcClientCallback.h>
+
+#include <gtest/gtest.h>
+
+using ::android::hardware::nfc::V1_0::INfc;
+using ::android::hardware::nfc::V1_0::INfcClientCallback;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+using ::android::sp;
+
+#define NFC_NCI_SERVICE_NAME "nfc_nci"
+
+
+// Simple NfcClientCallback used as part of testing.
+class NfcClientCallback : public INfcClientCallback {
+ public:
+ NfcClientCallback() {};
+
+ virtual ~NfcClientCallback() = default;
+
+ // sendEvent callback function - currently no-op.
+ Return<void> sendEvent(
+ ::android::hardware::nfc::V1_0::NfcEvent event,
+ ::android::hardware::nfc::V1_0::NfcStatus event_status) override {
+ return Void();
+ };
+
+ // sendData callback function - currently no-op.
+ Return<void> sendData(const ::android::hardware::nfc::V1_0::NfcData &data ) override {
+ ::android::hardware::nfc::V1_0::NfcData copy = data;
+ return Void();
+ };
+};
+
+
+// The main test class for NFC HIDL HAL.
+class NfcHidlTest : public ::testing::Test {
+ public:
+ virtual void SetUp() override {
+ // currently test passthrough mode only
+ nfc = INfc::getService(NFC_NCI_SERVICE_NAME, true);
+ ASSERT_NE(nfc, nullptr);
+
+ nfc_cb = new NfcClientCallback();
+ ASSERT_NE(nfc_cb, nullptr);
+ }
+
+ virtual void TearDown() override {}
+
+ sp<INfc> nfc;
+ sp<INfcClientCallback> nfc_cb;
+};
+
+
+// A class for test environment setup (kept since this file is a template).
+class NfcHidlEnvironment : public ::testing::Environment {
+ public:
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+
+ private:
+};
+
+TEST_F(NfcHidlTest, OpenAndClose) {
+ EXPECT_EQ(0, (int)nfc->open(nfc_cb));
+ EXPECT_EQ(0, (int)nfc->close());
+}
+
+int main(int argc, char **argv) {
+ ::testing::AddGlobalTestEnvironment(new NfcHidlEnvironment);
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ ALOGI("Test result = %d", status);
+ return status;
+}
diff --git a/power/1.0/default/service.cpp b/power/1.0/default/service.cpp
index bad1adf..f77ff5b 100644
--- a/power/1.0/default/service.cpp
+++ b/power/1.0/default/service.cpp
@@ -15,37 +15,13 @@
*/
#define LOG_TAG "android.hardware.power@1.0-service"
-#include <utils/Log.h>
-
-#include <iostream>
-#include <unistd.h>
#include <android/hardware/power/1.0/IPower.h>
-
-#include <hidl/IServiceManager.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/ProcessState.h>
-#include <utils/Errors.h>
-#include <utils/StrongPointer.h>
-
-using android::sp;
-
-using android::hardware::IPCThreadState;
-using android::hardware::ProcessState;
+#include <hidl/LegacySupport.h>
using android::hardware::power::V1_0::IPower;
+using android::hardware::defaultPassthroughServiceImplementation;
int main() {
- const char instance[] = "power";
- android::sp<IPower> service = IPower::getService(instance, true);
- if (service.get() == nullptr) {
- ALOGE("IPower::getService returned NULL, exiting");
- return -1;
- }
- LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
- service->registerAsService(instance);
-
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- ProcessState::self()->startThreadPool();
- IPCThreadState::self()->joinThreadPool();
+ return defaultPassthroughServiceImplementation<IPower>("power");
}
diff --git a/sensors/1.0/default/service.cpp b/sensors/1.0/default/service.cpp
index da543ef..230ead3 100644
--- a/sensors/1.0/default/service.cpp
+++ b/sensors/1.0/default/service.cpp
@@ -14,38 +14,14 @@
* limitations under the License.
*/
-#include <android-base/logging.h>
+#define LOG_TAG "android.hardware.nfc@1.0-service"
+
#include <android/hardware/sensors/1.0/ISensors.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/ProcessState.h>
+#include <hidl/LegacySupport.h>
+
+using android::hardware::sensors::V1_0::ISensors;
+using android::hardware::defaultPassthroughServiceImplementation;
int main() {
- using android::hardware::sensors::V1_0::ISensors;
- using android::sp;
- using android::OK;
- using namespace android::hardware;
-
- LOG(INFO) << "Service is starting.";
- sp<ISensors> sensors = ISensors::getService("sensors", true /* getStub */);
-
- if (sensors.get() == nullptr) {
- LOG(ERROR) << "ISensors::getService returned nullptr, exiting.";
- return 1;
- }
-
- LOG(INFO) << "Default implementation using sensors is "
- << (sensors->isRemote() ? "REMOTE" : "LOCAL");
-
- CHECK(!sensors->isRemote());
-
- LOG(INFO) << "Registering instance sensors.";
- sensors->registerAsService("sensors");
- LOG(INFO) << "Ready.";
-
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- ProcessState::self()->startThreadPool();
- IPCThreadState::self()->joinThreadPool();
-
- return 0;
+ return defaultPassthroughServiceImplementation<ISensors>("sensors");
}
-
diff --git a/tests/foo/1.0/default/Foo.cpp b/tests/foo/1.0/default/Foo.cpp
index 235a12d..f855f21 100644
--- a/tests/foo/1.0/default/Foo.cpp
+++ b/tests/foo/1.0/default/Foo.cpp
@@ -68,10 +68,7 @@
doStuffAndReturnAString_cb _cb) {
ALOGI("SERVER(Foo) doStuffAndReturnAString");
- hidl_string s;
- s = "Hello, world";
-
- _cb(s);
+ _cb("Hello, world");
return Void();
}
diff --git a/tests/libhwbinder/1.0/default/Android.bp b/tests/libhwbinder/1.0/default/Android.bp
new file mode 100644
index 0000000..91149e8
--- /dev/null
+++ b/tests/libhwbinder/1.0/default/Android.bp
@@ -0,0 +1,16 @@
+cc_library_shared {
+ name: "android.hardware.tests.libhwbinder@1.0-impl",
+ relative_install_path: "hw",
+ srcs: [
+ "Benchmark.cpp",
+ ],
+
+ shared_libs: [
+ "libbase",
+ "libhidl",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "android.hardware.tests.libhwbinder@1.0",
+ ],
+}
\ No newline at end of file
diff --git a/tests/libhwbinder/1.0/default/Benchmark.cpp b/tests/libhwbinder/1.0/default/Benchmark.cpp
new file mode 100644
index 0000000..47b0ea0
--- /dev/null
+++ b/tests/libhwbinder/1.0/default/Benchmark.cpp
@@ -0,0 +1,28 @@
+#define LOG_TAG "libhwbinder_benchmark"
+
+#include "Benchmark.h"
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace libhwbinder {
+namespace V1_0 {
+namespace implementation {
+
+Return<void> Benchmark::sendVec(
+ const ::android::hardware::hidl_vec<uint8_t>& data,
+ sendVec_cb _hidl_cb) {
+ _hidl_cb(data);
+ return Void();
+}
+
+IBenchmark* HIDL_FETCH_IBenchmark(const char* /* name */) {
+ return new Benchmark();
+}
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace libhwbinder
+} // namespace tests
+} // namespace hardware
+} // namespace android
diff --git a/tests/libhwbinder/1.0/default/Benchmark.h b/tests/libhwbinder/1.0/default/Benchmark.h
new file mode 100644
index 0000000..454fdf2
--- /dev/null
+++ b/tests/libhwbinder/1.0/default/Benchmark.h
@@ -0,0 +1,31 @@
+#ifndef HIDL_GENERATED_android_hardware_benchmark_V1_0_Benchmark_H_
+#define HIDL_GENERATED_android_hardware_benchmark_V1_0_Benchmark_H_
+
+#include <android/hardware/tests/libhwbinder/1.0/IBenchmark.h>
+#include <hidl/Status.h>
+
+namespace android {
+namespace hardware {
+namespace tests {
+namespace libhwbinder {
+namespace V1_0 {
+namespace implementation {
+
+using ::android::hardware::tests::libhwbinder::V1_0::IBenchmark;
+using ::android::hardware::Return;
+using ::android::hardware::hidl_vec;
+
+struct Benchmark : public IBenchmark {
+ virtual Return<void> sendVec(const hidl_vec<uint8_t>& data, sendVec_cb _hidl_cb) override;
+};
+
+extern "C" IBenchmark* HIDL_FETCH_IBenchmark(const char* name);
+
+} // namespace implementation
+} // namespace V1_0
+} // namespace libhwbinder
+} // namespace tests
+} // namespace hardware
+} // namespace android
+
+#endif // HIDL_GENERATED_android_hardware_benchmark_V1_0_Benchmark_H_
diff --git a/thermal/1.0/default/service.cpp b/thermal/1.0/default/service.cpp
index b09b5ec..ea86de4 100644
--- a/thermal/1.0/default/service.cpp
+++ b/thermal/1.0/default/service.cpp
@@ -14,40 +14,14 @@
* limitations under the License.
*/
-#include <iostream>
-#include <unistd.h>
+#define LOG_TAG "android.hardware.thermal@1.0-service"
#include <android/hardware/thermal/1.0/IThermal.h>
+#include <hidl/LegacySupport.h>
-#include <hidl/IServiceManager.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/ProcessState.h>
-#include <utils/Errors.h>
-
-#define LOG_TAG "android.hardware.thermal@1.0-service"
-#include <utils/Log.h>
-#include <utils/StrongPointer.h>
-
-using android::sp;
-
-// libhwbinder:
-using android::hardware::IPCThreadState;
-using android::hardware::ProcessState;
-
-// Generated HIDL files
using android::hardware::thermal::V1_0::IThermal;
+using android::hardware::defaultPassthroughServiceImplementation;
int main() {
- const char instance[] = "thermal";
- sp<IThermal> service = IThermal::getService(instance, true /* getStub */);
- if (service.get() == nullptr) {
- ALOGE("IThermal::getService returned NULL, exiting");
- return EXIT_FAILURE;
- }
- LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
- service->registerAsService(instance);
-
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- ProcessState::self()->startThreadPool();
- IPCThreadState::self()->joinThreadPool();
+ return defaultPassthroughServiceImplementation<IThermal>("thermal");
}
diff --git a/vibrator/1.0/default/service.cpp b/vibrator/1.0/default/service.cpp
index a4a7132..064e1e2 100644
--- a/vibrator/1.0/default/service.cpp
+++ b/vibrator/1.0/default/service.cpp
@@ -14,46 +14,13 @@
* limitations under the License.
*/
#define LOG_TAG "android.hardware.vibrator@1.0-service"
-#include <utils/Log.h>
-
-#include <iostream>
-#include <unistd.h>
#include <android/hardware/vibrator/1.0/IVibrator.h>
+#include <hidl/LegacySupport.h>
-#include <hidl/IServiceManager.h>
-#include <hwbinder/IPCThreadState.h>
-#include <hwbinder/ProcessState.h>
-#include <utils/Errors.h>
-#include <utils/StrongPointer.h>
-
-using android::sp;
-
-// libhwbinder:
-using android::hardware::IPCThreadState;
-using android::hardware::ProcessState;
-
-// Generated HIDL files
using android::hardware::vibrator::V1_0::IVibrator;
+using android::hardware::defaultPassthroughServiceImplementation;
int main() {
- ALOGI("Service is starting.");
- const char instance[] = "vibrator";
- ALOGI("Retrieving default implementation of instance %s.",
- instance);
- android::sp<IVibrator> service = IVibrator::getService(instance, true);
- if (service.get() == nullptr) {
- ALOGE("IVibrator::getService returned NULL, exiting");
- return -1;
- }
- ALOGI("Default implementation using %s is %s",
- instance, (service->isRemote() ? "REMOTE" : "LOCAL"));
- LOG_FATAL_IF(service->isRemote(), "Implementation is REMOTE!");
- ALOGI("Registering instance %s.", instance);
- service->registerAsService(instance);
- ALOGI("Ready.");
-
- ProcessState::self()->setThreadPoolMaxThreadCount(0);
- ProcessState::self()->startThreadPool();
- IPCThreadState::self()->joinThreadPool();
+ return defaultPassthroughServiceImplementation<IVibrator>("vibrator");
}