summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHaitao Shan <hshan@google.com>2018-08-17 11:58:33 -0700
committerHaitao Shan <hshan@google.com>2018-08-20 09:13:43 -0700
commitd9689ef63954619b589c32752a790e5336ade746 (patch)
tree37eeb836eebb0518b17582b65225338d4a74da32
parentf891132c58fa7fc12e2c211bacc7099feafa1a9e (diff)
downloadandroid_device_generic_goldfish-d9689ef63954619b589c32752a790e5336ade746.tar.gz
android_device_generic_goldfish-d9689ef63954619b589c32752a790e5336ade746.tar.bz2
android_device_generic_goldfish-d9689ef63954619b589c32752a790e5336ade746.zip
Add power service 1.1 ranchu.
Bug: 79491800 Test: cts android.cts.statsd.atom.HostAtomTests#testSubsystemSleepState Change-Id: Ic15f70ef05233da051ddeb08338e31dafa55a0df
-rw-r--r--manifest.xml2
-rw-r--r--power/Android.mk39
-rw-r--r--power/Power.cpp146
-rw-r--r--power/Power.h61
-rw-r--r--power/android.hardware.power@1.1-service.ranchu.rc4
-rw-r--r--power/power_qemu.c64
-rw-r--r--power/service.cpp67
-rw-r--r--sepolicy/common/file_contexts1
-rw-r--r--vendor.mk5
9 files changed, 299 insertions, 90 deletions
diff --git a/manifest.xml b/manifest.xml
index 0000149..38a22d6 100644
--- a/manifest.xml
+++ b/manifest.xml
@@ -91,7 +91,7 @@
<hal format="hidl">
<name>android.hardware.power</name>
<transport>hwbinder</transport>
- <version>1.0</version>
+ <version>1.1</version>
<interface>
<name>IPower</name>
<instance>default</instance>
diff --git a/power/Android.mk b/power/Android.mk
index e3d07a5..3466c54 100644
--- a/power/Android.mk
+++ b/power/Android.mk
@@ -1,4 +1,4 @@
-# Copyright (C) 2012 The Android Open Source Project
+# 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.
@@ -12,33 +12,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-
LOCAL_PATH := $(call my-dir)
-# HAL module implemenation stored in
-# hw/<POWERS_HARDWARE_MODULE_ID>.<ro.hardware>.so
include $(CLEAR_VARS)
LOCAL_VENDOR_MODULE := true
LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_CFLAGS += -DQEMU_HARDWARE
-LOCAL_SHARED_LIBRARIES := liblog libcutils
-LOCAL_HEADER_LIBRARIES := libutils_headers libhardware_headers
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
-LOCAL_SRC_FILES := power_qemu.c
-LOCAL_MODULE := power.goldfish
-LOCAL_MODULE_TAGS := optional
-include $(BUILD_SHARED_LIBRARY)
-include $(CLEAR_VARS)
+LOCAL_MODULE := android.hardware.power@1.1-service.ranchu
+LOCAL_INIT_RC := android.hardware.power@1.1-service.ranchu.rc
+LOCAL_SRC_FILES := service.cpp Power.cpp
-LOCAL_VENDOR_MODULE := true
-LOCAL_MODULE_RELATIVE_PATH := hw
-LOCAL_CFLAGS += -DQEMU_HARDWARE
-LOCAL_SHARED_LIBRARIES := liblog libcutils
-LOCAL_HEADER_LIBRARIES := libutils_headers libhardware_headers
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/../include
-LOCAL_SRC_FILES := power_qemu.c
-LOCAL_MODULE := power.ranchu
-LOCAL_MODULE_TAGS := optional
-include $(BUILD_SHARED_LIBRARY)
+LOCAL_HEADER_LIBRARIES := libhardware_headers
+
+LOCAL_SHARED_LIBRARIES := \
+ libbase \
+ libcutils \
+ libhidlbase \
+ libhidltransport \
+ liblog \
+ libutils \
+ android.hardware.power@1.1 \
+
+include $(BUILD_EXECUTABLE)
diff --git a/power/Power.cpp b/power/Power.cpp
new file mode 100644
index 0000000..5ba33c8
--- /dev/null
+++ b/power/Power.cpp
@@ -0,0 +1,146 @@
+/*
+ * 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 "android.hardware.power@1.1-service.marlin"
+
+#include <android/log.h>
+#include <utils/Log.h>
+
+#include <android-base/properties.h>
+
+#include "Power.h"
+
+enum subsystem_type {
+ SUBSYSTEM_WLAN,
+
+ //Don't add any lines after that line
+ SUBSYSTEM_COUNT
+};
+
+enum wlan_param_id {
+ CUMULATIVE_SLEEP_TIME_MS,
+ CUMULATIVE_TOTAL_ON_TIME_MS,
+ DEEP_SLEEP_ENTER_COUNTER,
+ LAST_DEEP_SLEEP_ENTER_TSTAMP_MS,
+
+ //Don't add any lines after that line
+ WLAN_PARAM_COUNT
+};
+
+enum wlan_state_id {
+ WLAN_STATE_ACTIVE = 0,
+ WLAN_STATE_DEEP_SLEEP,
+
+ //Don't add any lines after that line
+ WLAN_STATE_COUNT
+};
+
+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() {
+}
+
+// Methods from ::android::hardware::power::V1_0::IPower follow.
+Return<void> Power::setInteractive(bool __attribute__((__unused__)) interactive) {
+ return Void();
+}
+
+Return<void> Power::powerHint(PowerHint __attribute__((__unused__)) hint, int32_t __attribute__((__unused__)) data) {
+ return Void();
+}
+
+Return<void> Power::setFeature(Feature /*feature*/, bool /*activate*/) {
+ return Void();
+}
+
+Return<void> Power::getPlatformLowPowerStats(getPlatformLowPowerStats_cb _hidl_cb) {
+
+ hidl_vec<PowerStatePlatformSleepState> states;
+
+ states.resize(0);
+ _hidl_cb(states, Status::SUCCESS);
+ return Void();
+}
+
+static int get_wlan_low_power_stats(struct PowerStateSubsystem &subsystem) {
+
+ struct PowerStateSubsystemSleepState *state;
+
+ subsystem.name = "wlan";
+ subsystem.states.resize(WLAN_STATE_COUNT);
+
+ /* Update statistics for Active State */
+ state = &subsystem.states[WLAN_STATE_ACTIVE];
+ state->name = "Active";
+ state->residencyInMsecSinceBoot = 1000;
+ state->totalTransitions = 1;
+ state->lastEntryTimestampMs = 0;
+ state->supportedOnlyInSuspend = false;
+
+ /* Update statistics for Deep-Sleep state */
+ state = &subsystem.states[WLAN_STATE_DEEP_SLEEP];
+ state->name = "Deep-Sleep";
+ state->residencyInMsecSinceBoot = 0;
+ state->totalTransitions = 0;
+ state->lastEntryTimestampMs = 0;
+ state->supportedOnlyInSuspend = false;
+
+ return 0;
+}
+
+Return<void> Power::getSubsystemLowPowerStats(getSubsystemLowPowerStats_cb _hidl_cb) {
+
+ hidl_vec<PowerStateSubsystem> subsystems;
+ int ret;
+
+ subsystems.resize(subsystem_type::SUBSYSTEM_COUNT);
+
+ //We currently have only one Subsystem for WLAN
+ ret = get_wlan_low_power_stats(subsystems[subsystem_type::SUBSYSTEM_WLAN]);
+ if (ret != 0) {
+ goto done;
+ }
+
+ //Add query for other subsystems here
+
+done:
+ _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/Power.h b/power/Power.h
new file mode 100644
index 0000000..2676b7d
--- /dev/null
+++ b/power/Power.h
@@ -0,0 +1,61 @@
+/*
+ * 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.
+ */
+
+#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 {
+ // Methods from ::android::hardware::power::V1_0::IPower follow.
+
+ Power();
+
+ 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.
+
+};
+
+} // namespace implementation
+} // namespace V1_1
+} // namespace power
+} // namespace hardware
+} // namespace android
+
+#endif // ANDROID_HARDWARE_POWER_V1_1_POWER_H
diff --git a/power/android.hardware.power@1.1-service.ranchu.rc b/power/android.hardware.power@1.1-service.ranchu.rc
new file mode 100644
index 0000000..f5a05d6
--- /dev/null
+++ b/power/android.hardware.power@1.1-service.ranchu.rc
@@ -0,0 +1,4 @@
+service vendor.power-hal-1-1 /vendor/bin/hw/android.hardware.power@1.1-service.ranchu
+ class hal
+ user system
+ group system
diff --git a/power/power_qemu.c b/power/power_qemu.c
deleted file mode 100644
index 808589a..0000000
--- a/power/power_qemu.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2012 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 "emulator PowerHAL"
-#include <utils/Log.h>
-
-#include <hardware/hardware.h>
-#include <hardware/power.h>
-#include "qemud.h"
-#include <fcntl.h>
-#include <errno.h>
-
-static int qemud_fd;
-
-static void power_qemu_init(struct power_module *module)
-{
- qemud_fd = qemud_channel_open("hw-control");
-
- if (qemud_fd < 0)
- ALOGE("Error connecting to qemud hw-control service\n");
-}
-
-static void power_qemu_set_interactive(struct power_module *module, int on)
-{
- int r;
-
- r = qemud_channel_send(qemud_fd, on ? "power:screen_state:wake"
- : "power:screen_state:standby", -1);
-
- if (r < 0)
- ALOGE("Error sending power command to qemud hw-control service\n");
-}
-
-static struct hw_module_methods_t power_qemu_module_methods = {
- .open = NULL,
-};
-
-struct power_module HAL_MODULE_INFO_SYM = {
- .common = {
- .tag = HARDWARE_MODULE_TAG,
- .version_major = 1,
- .version_minor = 0,
- .id = POWER_HARDWARE_MODULE_ID,
- .name = "Emulator Power HAL",
- .author = "The Android Open Source Project",
- .methods = &power_qemu_module_methods,
- },
-
- .init = power_qemu_init,
- .setInteractive = power_qemu_set_interactive,
-};
diff --git a/power/service.cpp b/power/service.cpp
new file mode 100644
index 0000000..b0fb829
--- /dev/null
+++ b/power/service.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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 "android.hardware.power@1.1-service.ranchu"
+
+#include <android/log.h>
+#include <hidl/HidlTransportSupport.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;
+
+ ALOGI("Power HAL Service 1.1 for Ranchu is starting.");
+
+ service = new Power();
+ 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/sepolicy/common/file_contexts b/sepolicy/common/file_contexts
index c0c7e5e..3c9df34 100644
--- a/sepolicy/common/file_contexts
+++ b/sepolicy/common/file_contexts
@@ -31,6 +31,7 @@
/vendor/bin/hw/android\.hardware\.drm@1\.1-service\.clearkey u:object_r:hal_drm_clearkey_exec:s0
/vendor/bin/hw/android\.hardware\.keymaster@4\.0-strongbox-service u:object_r:hal_keymaster_default_exec:s0
/vendor/bin/hw/android\.hardware\.health@2\.0-service.goldfish u:object_r:hal_health_default_exec:s0
+/vendor/bin/hw/android\.hardware\.power@1\.1-service.ranchu u:object_r:hal_power_default_exec:s0
/vendor/lib(64)?/hw/gralloc\.ranchu\.so u:object_r:same_process_hal_file:s0
/vendor/lib(64)?/hw/gralloc\.goldfish\.default\.so u:object_r:same_process_hal_file:s0
diff --git a/vendor.mk b/vendor.mk
index 958b309..37b170a 100644
--- a/vendor.mk
+++ b/vendor.mk
@@ -101,8 +101,9 @@ PRODUCT_PACKAGES += \
android.hardware.drm@1.1-service.widevine
PRODUCT_PACKAGES += \
- android.hardware.power@1.0-service \
- android.hardware.power@1.0-impl
+ android.hardware.power@1.1-service.ranchu \
+
+PRODUCT_PROPERTY_OVERRIDES += ro.hardware.power=ranchu
PRODUCT_PACKAGES += \
camera.device@1.0-impl \