summaryrefslogtreecommitdiffstats
path: root/power
diff options
context:
space:
mode:
Diffstat (limited to 'power')
-rw-r--r--power/1.1/Android.bp68
-rw-r--r--power/1.1/Android.mk84
-rw-r--r--power/1.1/IPower.hal50
-rw-r--r--power/1.1/default/Android.bp33
-rw-r--r--power/1.1/default/Power.cpp177
-rw-r--r--power/1.1/default/Power.h63
-rw-r--r--power/1.1/default/android.hardware.power@1.1-service.rc4
-rw-r--r--power/1.1/default/service.cpp89
-rw-r--r--power/1.1/types.hal75
-rw-r--r--power/1.1/vts/functional/Android.bp34
-rw-r--r--power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp98
-rw-r--r--power/Android.bp3
12 files changed, 778 insertions, 0 deletions
diff --git a/power/1.1/Android.bp b/power/1.1/Android.bp
new file mode 100644
index 000000000..fb10aba15
--- /dev/null
+++ b/power/1.1/Android.bp
@@ -0,0 +1,68 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+filegroup {
+ name: "android.hardware.power@1.1_hal",
+ srcs: [
+ "types.hal",
+ "IPower.hal",
+ ],
+}
+
+genrule {
+ name: "android.hardware.power@1.1_genc++",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-sources -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.power@1.1",
+ srcs: [
+ ":android.hardware.power@1.1_hal",
+ ],
+ out: [
+ "android/hardware/power/1.1/types.cpp",
+ "android/hardware/power/1.1/PowerAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.power@1.1_genc++_headers",
+ tools: ["hidl-gen"],
+ cmd: "$(location hidl-gen) -o $(genDir) -Lc++-headers -randroid.hardware:hardware/interfaces -randroid.hidl:system/libhidl/transport android.hardware.power@1.1",
+ srcs: [
+ ":android.hardware.power@1.1_hal",
+ ],
+ out: [
+ "android/hardware/power/1.1/types.h",
+ "android/hardware/power/1.1/hwtypes.h",
+ "android/hardware/power/1.1/IPower.h",
+ "android/hardware/power/1.1/IHwPower.h",
+ "android/hardware/power/1.1/BnHwPower.h",
+ "android/hardware/power/1.1/BpHwPower.h",
+ "android/hardware/power/1.1/BsPower.h",
+ ],
+}
+
+cc_library {
+ name: "android.hardware.power@1.1",
+ defaults: ["hidl-module-defaults"],
+ generated_sources: ["android.hardware.power@1.1_genc++"],
+ generated_headers: ["android.hardware.power@1.1_genc++_headers"],
+ export_generated_headers: ["android.hardware.power@1.1_genc++_headers"],
+ vendor_available: true,
+ vndk: {
+ enabled: true,
+ },
+ shared_libs: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "liblog",
+ "libutils",
+ "libcutils",
+ "android.hardware.power@1.0",
+ ],
+ export_shared_lib_headers: [
+ "libhidlbase",
+ "libhidltransport",
+ "libhwbinder",
+ "libutils",
+ "android.hardware.power@1.0",
+ ],
+}
diff --git a/power/1.1/Android.mk b/power/1.1/Android.mk
new file mode 100644
index 000000000..5044cfa61
--- /dev/null
+++ b/power/1.1/Android.mk
@@ -0,0 +1,84 @@
+# This file is autogenerated by hidl-gen. Do not edit manually.
+
+LOCAL_PATH := $(call my-dir)
+
+################################################################################
+
+include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.power-V1.1-java
+LOCAL_MODULE_CLASS := JAVA_LIBRARIES
+
+intermediates := $(call local-generated-sources-dir, COMMON)
+
+HIDL := $(HOST_OUT_EXECUTABLES)/hidl-gen$(HOST_EXECUTABLE_SUFFIX)
+
+LOCAL_JAVA_LIBRARIES := \
+ android.hardware.power-V1.0-java \
+ android.hidl.base-V1.0-java \
+
+LOCAL_NO_STANDARD_LIBRARIES := true
+LOCAL_JAVA_LIBRARIES += core-oj hwbinder
+
+#
+# Build types.hal (PowerStateSubsystem)
+#
+GEN := $(intermediates)/android/hardware/power/V1_1/PowerStateSubsystem.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.power@1.1::types.PowerStateSubsystem
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build types.hal (PowerStateSubsystemSleepState)
+#
+GEN := $(intermediates)/android/hardware/power/V1_1/PowerStateSubsystemSleepState.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.power@1.1::types.PowerStateSubsystemSleepState
+
+$(GEN): $(LOCAL_PATH)/types.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+
+#
+# Build IPower.hal
+#
+GEN := $(intermediates)/android/hardware/power/V1_1/IPower.java
+$(GEN): $(HIDL)
+$(GEN): PRIVATE_HIDL := $(HIDL)
+$(GEN): PRIVATE_DEPS := $(LOCAL_PATH)/IPower.hal
+$(GEN): PRIVATE_DEPS += $(LOCAL_PATH)/types.hal
+$(GEN): $(LOCAL_PATH)/types.hal
+$(GEN): PRIVATE_OUTPUT_DIR := $(intermediates)
+$(GEN): PRIVATE_CUSTOM_TOOL = \
+ $(PRIVATE_HIDL) -o $(PRIVATE_OUTPUT_DIR) \
+ -Ljava \
+ -randroid.hardware:hardware/interfaces \
+ -randroid.hidl:system/libhidl/transport \
+ android.hardware.power@1.1::IPower
+
+$(GEN): $(LOCAL_PATH)/IPower.hal
+ $(transform-generated-source)
+LOCAL_GENERATED_SOURCES += $(GEN)
+include $(BUILD_JAVA_LIBRARY)
+
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/power/1.1/IPower.hal b/power/1.1/IPower.hal
new file mode 100644
index 000000000..086904ee6
--- /dev/null
+++ b/power/1.1/IPower.hal
@@ -0,0 +1,50 @@
+/*
+ * 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.power@1.1;
+
+import android.hardware.power@1.0;
+
+/**
+ * Interface to collect subsystem level sleep information
+ */
+interface IPower extends android.hardware.power@1.0::IPower {
+
+ /**
+ * Subsystem-level sleep state stats:
+ * Report cumulative info on the statistics on subsystem-level sleep states
+ * since boot.
+ *
+ * @return subsystems supported on this device and their sleep states
+ * @return retval SUCCESS on success or FILESYSTEM_ERROR on filesystem
+ * nodes access error.
+ */
+ getSubsystemLowPowerStats()
+ generates (vec<PowerStateSubsystem> subsystems, Status retval);
+
+ /**
+ * powerHintAsync() is called to pass hints on power requirements which
+ * may result in adjustment of power/performance parameters of the
+ * cpufreq governor and other controls.
+ *
+ * A particular platform may choose to ignore any hint.
+ *
+ * @param hint PowerHint which is passed
+ * @param data contains additional information about the hint
+ * and is described along with the comments for each of the hints.
+ */
+ oneway powerHintAsync(PowerHint hint, int32_t data);
+
+};
diff --git a/power/1.1/default/Android.bp b/power/1.1/default/Android.bp
new file mode 100644
index 000000000..0b3598bbf
--- /dev/null
+++ b/power/1.1/default/Android.bp
@@ -0,0 +1,33 @@
+// 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_binary {
+ proprietary: true,
+ defaults: ["hidl_defaults"],
+ relative_install_path: "hw",
+ name: "android.hardware.power@1.1-service",
+ init_rc: ["android.hardware.power@1.1-service.rc"],
+ srcs: ["service.cpp" , "Power.cpp"],
+
+ shared_libs: [
+ "liblog",
+ "libdl",
+ "libutils",
+ "libhardware",
+ "libhidlbase",
+ "libhidltransport",
+ "android.hardware.power@1.0",
+ "android.hardware.power@1.1",
+ ],
+}
diff --git a/power/1.1/default/Power.cpp b/power/1.1/default/Power.cpp
new file mode 100644
index 000000000..b5d0c84bc
--- /dev/null
+++ b/power/1.1/default/Power.cpp
@@ -0,0 +1,177 @@
+/*
+ * 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 "android.hardware.power@1.1-impl"
+
+#include <log/log.h>
+
+#include <hardware/hardware.h>
+#include <hardware/power.h>
+
+#include "Power.h"
+
+namespace android {
+namespace hardware {
+namespace power {
+namespace V1_1 {
+namespace implementation {
+
+using ::android::hardware::power::V1_0::Feature;
+using ::android::hardware::power::V1_0::PowerHint;
+using ::android::hardware::power::V1_0::PowerStatePlatformSleepState;
+using ::android::hardware::power::V1_0::Status;
+using ::android::hardware::power::V1_1::PowerStateSubsystem;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+
+Power::Power(power_module_t *module) : mModule(module) {
+ if (mModule)
+ mModule->init(mModule);
+}
+
+Power::~Power() {
+ delete(mModule);
+}
+
+// Methods from ::android::hardware::power::V1_0::IPower follow.
+Return<void> Power::setInteractive(bool interactive) {
+ if (mModule->setInteractive)
+ mModule->setInteractive(mModule, interactive ? 1 : 0);
+ return Void();
+}
+
+Return<void> Power::powerHint(PowerHint hint, int32_t data) {
+ int32_t param = data;
+ if (mModule->powerHint) {
+ if (data)
+ mModule->powerHint(mModule, static_cast<power_hint_t>(hint), &param);
+ else
+ mModule->powerHint(mModule, static_cast<power_hint_t>(hint), NULL);
+ }
+ return Void();
+}
+
+Return<void> Power::setFeature(Feature feature, bool activate) {
+ if (mModule->setFeature)
+ mModule->setFeature(mModule, static_cast<feature_t>(feature),
+ activate ? 1 : 0);
+ return Void();
+}
+
+Return<void> Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) {
+ hidl_vec<PowerStatePlatformSleepState> states;
+ ssize_t number_platform_modes;
+ size_t *voters = nullptr;
+ power_state_platform_sleep_state_t *legacy_states = nullptr;
+ int ret;
+
+ if (mModule->get_number_of_platform_modes == nullptr ||
+ mModule->get_voter_list == nullptr ||
+ mModule->get_platform_low_power_stats == nullptr)
+ {
+ _hidl_cb(states, Status::SUCCESS);
+ return Void();
+ }
+
+ number_platform_modes = mModule->get_number_of_platform_modes(mModule);
+ if (number_platform_modes)
+ {
+ if ((ssize_t) (SIZE_MAX / sizeof(size_t)) <= number_platform_modes) // overflow
+ goto done;
+ voters = new (std::nothrow) size_t [number_platform_modes];
+ if (voters == nullptr)
+ goto done;
+
+ ret = mModule->get_voter_list(mModule, voters);
+ if (ret != 0)
+ goto done;
+
+ if ((ssize_t) (SIZE_MAX / sizeof(power_state_platform_sleep_state_t))
+ <= number_platform_modes) // overflow
+ goto done;
+ legacy_states = new (std::nothrow)
+ power_state_platform_sleep_state_t [number_platform_modes];
+ if (legacy_states == nullptr)
+ goto done;
+
+ for (int i = 0; i < number_platform_modes; i++)
+ {
+ legacy_states[i].voters = nullptr;
+ legacy_states[i].voters = new power_state_voter_t [voters[i]];
+ if (legacy_states[i].voters == nullptr)
+ goto done;
+ }
+
+ ret = mModule->get_platform_low_power_stats(mModule, legacy_states);
+ if (ret != 0)
+ goto done;
+
+ states.resize(number_platform_modes);
+ for (int i = 0; i < number_platform_modes; i++)
+ {
+ power_state_platform_sleep_state_t& legacy_state = legacy_states[i];
+ PowerStatePlatformSleepState& state = states[i];
+ state.name = legacy_state.name;
+ state.residencyInMsecSinceBoot = legacy_state.residency_in_msec_since_boot;
+ state.totalTransitions = legacy_state.total_transitions;
+ state.supportedOnlyInSuspend = legacy_state.supported_only_in_suspend;
+ state.voters.resize(voters[i]);
+ for(size_t j = 0; j < voters[i]; j++)
+ {
+ state.voters[j].name = legacy_state.voters[j].name;
+ state.voters[j].totalTimeInMsecVotedForSinceBoot = legacy_state.voters[j].total_time_in_msec_voted_for_since_boot;
+ state.voters[j].totalNumberOfTimesVotedSinceBoot = legacy_state.voters[j].total_number_of_times_voted_since_boot;
+ }
+ }
+ }
+done:
+ if (legacy_states)
+ {
+ for (int i = 0; i < number_platform_modes; i++)
+ {
+ if(legacy_states[i].voters)
+ delete(legacy_states[i].voters);
+ }
+ }
+ delete[] legacy_states;
+ delete[] voters;
+ _hidl_cb(states, Status::SUCCESS);
+ return Void();
+}
+
+// Methods from ::android::hardware::power::V1_1::IPower follow.
+Return<void> Power::getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) {
+ hidl_vec<PowerStateSubsystem> subsystems;
+ ssize_t number_subsystems = 0;
+
+ //This API will report zero subsystems to support older devices
+ //For devices that support this API, they will have their own implementation
+ subsystems.resize(number_subsystems);
+ _hidl_cb(subsystems, Status::SUCCESS);
+ return Void();
+}
+
+Return<void> Power::powerHintAsync(PowerHint hint, int32_t data) {
+ // just call the normal power hint in this oneway function
+ return powerHint(hint, data);
+}
+
+} // namespace implementation
+} // namespace V1_1
+} // namespace power
+} // namespace hardware
+} // namespace android
diff --git a/power/1.1/default/Power.h b/power/1.1/default/Power.h
new file mode 100644
index 000000000..e779d64d3
--- /dev/null
+++ b/power/1.1/default/Power.h
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+#ifndef ANDROID_HARDWARE_POWER_V1_1_POWER_H
+#define ANDROID_HARDWARE_POWER_V1_1_POWER_H
+
+#include <android/hardware/power/1.1/IPower.h>
+#include <hidl/MQDescriptor.h>
+#include <hidl/Status.h>
+#include <hardware/power.h>
+
+namespace android {
+namespace hardware {
+namespace power {
+namespace V1_1 {
+namespace implementation {
+
+using ::android::hardware::power::V1_0::Feature;
+using ::android::hardware::power::V1_0::PowerHint;
+using ::android::hardware::power::V1_1::IPower;
+using ::android::hardware::Return;
+using ::android::hardware::Void;
+
+struct Power : public IPower {
+ Power(power_module_t* module);
+ ~Power();
+
+ // Methods from ::android::hardware::power::V1_0::IPower follow
+ Return<void> setInteractive(bool interactive) override;
+ Return<void> powerHint(PowerHint hint, int32_t data) override;
+ Return<void> setFeature(Feature feature, bool activate) override;
+ Return<void> getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) override;
+
+ // Methods from ::android::hardware::power::V1_1::IPower follow.
+ Return<void> getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) override;
+ Return<void> powerHintAsync(PowerHint hint, int32_t data) override;
+
+ // Methods from ::android::hidl::base::V1_0::IBase follow.
+
+ private:
+ power_module_t* mModule;
+};
+
+} // namespace implementation
+} // namespace V1_1
+} // namespace power
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_POWER_V1_1_POWER_H
diff --git a/power/1.1/default/android.hardware.power@1.1-service.rc b/power/1.1/default/android.hardware.power@1.1-service.rc
new file mode 100644
index 000000000..f2512f1b5
--- /dev/null
+++ b/power/1.1/default/android.hardware.power@1.1-service.rc
@@ -0,0 +1,4 @@
+service power-hal-1-1 /vendor/bin/hw/android.hardware.power@1.1-service
+ class hal
+ user system
+ group system
diff --git a/power/1.1/default/service.cpp b/power/1.1/default/service.cpp
new file mode 100644
index 000000000..571db2f31
--- /dev/null
+++ b/power/1.1/default/service.cpp
@@ -0,0 +1,89 @@
+/*
+ * 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 "android.hardware.power@1.1-service"
+
+#include <android/log.h>
+#include <hidl/HidlTransportSupport.h>
+#include <android/hardware/power/1.1/IPower.h>
+#include <hardware/power.h>
+#include "Power.h"
+
+using android::sp;
+using android::status_t;
+using android::OK;
+
+// libhwbinder:
+using android::hardware::configureRpcThreadpool;
+using android::hardware::joinRpcThreadpool;
+
+// Generated HIDL files
+using android::hardware::power::V1_1::IPower;
+using android::hardware::power::V1_1::implementation::Power;
+
+int main() {
+
+ status_t status;
+ android::sp<IPower> service = nullptr;
+ const hw_module_t* hw_module = nullptr;
+ power_module_t* power_module = nullptr;
+ int err;
+
+ ALOGI("Power HAL Service 1.1 (Default) is starting.");
+
+ err = hw_get_module(POWER_HARDWARE_MODULE_ID, &hw_module);
+ if (err) {
+ ALOGE("hw_get_module %s failed: %d", POWER_HARDWARE_MODULE_ID, err);
+ goto shutdown;
+ }
+
+ if (!hw_module->methods || !hw_module->methods->open) {
+ power_module = reinterpret_cast<power_module_t*>(
+ const_cast<hw_module_t*>(hw_module));
+ } else {
+ err = hw_module->methods->open(hw_module, POWER_HARDWARE_MODULE_ID,
+ reinterpret_cast<hw_device_t**>(&power_module));
+ if (err) {
+ ALOGE("Passthrough failed to load legacy HAL.");
+ goto shutdown;
+ }
+ }
+
+ service = new Power(power_module);
+ if (service == nullptr) {
+ ALOGE("Can not create an instance of Power HAL Iface, exiting.");
+
+ goto shutdown;
+ }
+
+ configureRpcThreadpool(1, true /*callerWillJoin*/);
+
+ status = service->registerAsService();
+ if (status != OK) {
+ ALOGE("Could not register service for Power HAL Iface (%d).", status);
+ goto shutdown;
+ }
+
+ ALOGI("Power Service is ready");
+ joinRpcThreadpool();
+ //Should not pass this line
+
+shutdown:
+ // In normal operation, we don't expect the thread pool to exit
+
+ ALOGE("Power Service is shutting down");
+ return 1;
+}
diff --git a/power/1.1/types.hal b/power/1.1/types.hal
new file mode 100644
index 000000000..5298d4e6b
--- /dev/null
+++ b/power/1.1/types.hal
@@ -0,0 +1,75 @@
+/*
+ * 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.power@1.1;
+
+/**
+ * Subsytem-level sleep state stats:
+ * PowerStateSubsystemSleepState represents the sleep states
+ * a subsystem (e.g. wifi, bt) is capable of getting into.
+ *
+ * SoCs like wifi, bt usually have more than one subsystem level sleep state.
+ */
+struct PowerStateSubsystemSleepState {
+ /**
+ * Subsystem-level Sleep state name.
+ */
+ string name;
+
+ /**
+ * Time spent in msec at this subsystem-level sleep state since boot.
+ */
+ uint64_t residencyInMsecSinceBoot;
+
+ /**
+ * Total number of times sub-system entered this state.
+ */
+ uint64_t totalTransitions;
+
+ /**
+ * Timestamp of last entry of this state measured in MSec
+ */
+ uint64_t lastEntryTimestampMs;
+
+ /**
+ * This subsystem-level sleep state can only be reached during system suspend
+ */
+ bool supportedOnlyInSuspend;
+};
+
+/**
+ * Subsytem-level sleep state stats:
+ * PowerStateSubsystem represents a subsystem (e.g. wifi, bt)
+ * and all the sleep states this susbsystem is capable of getting into.
+ *
+ * SoCs like wifi, bt usually have more than one subsystem level sleep state.
+ */
+struct PowerStateSubsystem {
+ /**
+ * Subsystem name (e.g. wifi, bt etc.)
+ */
+ string name;
+
+ /**
+ * states represents the list of sleep states supported by this susbsystem.
+ * Higher the index in the returned <states> vector deeper the state is
+ * i.e. lesser steady-state power is consumed by the subsystem to
+ * to be resident in that state.
+ *
+ * Vector of size zero implies either the info is not available
+ * or the subsystem does not have any sleep states.
+ */
+ vec<PowerStateSubsystemSleepState> states;
+};
diff --git a/power/1.1/vts/functional/Android.bp b/power/1.1/vts/functional/Android.bp
new file mode 100644
index 000000000..f886bd2c0
--- /dev/null
+++ b/power/1.1/vts/functional/Android.bp
@@ -0,0 +1,34 @@
+//
+// 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: "VtsHalPowerV1_1TargetTest",
+ defaults: ["hidl_defaults"],
+ srcs: ["VtsHalPowerV1_1TargetTest.cpp"],
+ shared_libs: [
+ "libbase",
+ "liblog",
+ "libhidlbase",
+ "libhidltransport",
+ "libutils",
+ "android.hardware.power@1.1",
+ ],
+ static_libs: ["VtsHalHidlTargetTestBase"],
+ cflags: [
+ "-O0",
+ "-g",
+ ]
+}
diff --git a/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp b/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp
new file mode 100644
index 000000000..dc843f49d
--- /dev/null
+++ b/power/1.1/vts/functional/VtsHalPowerV1_1TargetTest.cpp
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2017 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 "power_hidl_hal_test"
+#include <android-base/logging.h>
+#include <android/hardware/power/1.1/IPower.h>
+
+#include <VtsHalHidlTargetTestBase.h>
+
+using ::android::hardware::power::V1_1::IPower;
+using ::android::hardware::power::V1_1::PowerStateSubsystem;
+using ::android::hardware::power::V1_0::Status;
+using ::android::hardware::power::V1_0::PowerHint;
+using ::android::hardware::hidl_vec;
+using ::android::hardware::Return;
+using ::android::sp;
+
+class PowerHidlTest : public ::testing::VtsHalHidlTargetTestBase {
+ public:
+ virtual void SetUp() override {
+ power = ::testing::VtsHalHidlTargetTestBase::getService<IPower>();
+ ASSERT_NE(power, nullptr);
+ }
+
+ virtual void TearDown() override {}
+
+ sp<IPower> power;
+};
+
+// Sanity check Power::getSubsystemLowPowerStats().
+TEST_F(PowerHidlTest, GetSubsystemLowPowerStats) {
+ hidl_vec<PowerStateSubsystem> vec;
+ Status s;
+ auto cb = [&vec, &s](hidl_vec<PowerStateSubsystem> subsystems,
+ Status status) {
+ vec = subsystems;
+ s = status;
+ };
+
+ Return<void> ret = power->getSubsystemLowPowerStats(cb);
+ ASSERT_TRUE(ret.isOk());
+ ASSERT_TRUE(s == Status::SUCCESS || s == Status::FILESYSTEM_ERROR);
+}
+
+// Sanity check Power::powerHintAsync on good and bad inputs.
+TEST_F(PowerHidlTest, PowerHintAsync) {
+ PowerHint badHint = static_cast<PowerHint>(0xA);
+ auto hints = {PowerHint::VSYNC, PowerHint::INTERACTION, PowerHint::VIDEO_ENCODE,
+ PowerHint::VIDEO_DECODE, PowerHint::LOW_POWER, PowerHint::SUSTAINED_PERFORMANCE,
+ PowerHint::VR_MODE, PowerHint::LAUNCH, badHint};
+ Return<void> ret;
+ for (auto hint : hints) {
+ ret = power->powerHintAsync(hint, 30000);
+ ASSERT_TRUE(ret.isOk());
+
+ ret = power->powerHintAsync(hint, 0);
+ ASSERT_TRUE(ret.isOk());
+ }
+
+ // Turning these hints on in different orders triggers different code paths,
+ // so iterate over possible orderings.
+ std::vector<PowerHint> hints2 = {PowerHint::LAUNCH, PowerHint::VR_MODE,
+ PowerHint::SUSTAINED_PERFORMANCE, PowerHint::INTERACTION};
+ auto compareHints = [](PowerHint l, PowerHint r) {
+ return static_cast<uint32_t>(l) < static_cast<uint32_t>(r);
+ };
+ std::sort(hints2.begin(), hints2.end(), compareHints);
+ do {
+ for (auto iter = hints2.begin(); iter != hints2.end(); iter++) {
+ ret = power->powerHintAsync(*iter, 0);
+ ASSERT_TRUE(ret.isOk());
+ }
+ for (auto iter = hints2.begin(); iter != hints2.end(); iter++) {
+ ret = power->powerHintAsync(*iter, 30000);
+ ASSERT_TRUE(ret.isOk());
+ }
+ } while (std::next_permutation(hints2.begin(), hints2.end(), compareHints));
+}
+
+int main(int argc, char **argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = RUN_ALL_TESTS();
+ LOG(INFO) << "Test result = " << status;
+ return status;
+}
diff --git a/power/Android.bp b/power/Android.bp
index ed19a3703..7a315faab 100644
--- a/power/Android.bp
+++ b/power/Android.bp
@@ -3,4 +3,7 @@ subdirs = [
"1.0",
"1.0/default",
"1.0/vts/functional",
+ "1.1",
+ "1.1/default",
+ "1.1/vts/functional",
]