Couple libbatteryservice headers with module.
Also moved these headers to be local to the service.
Test: used headers with BOARD_VNDK_VERSION=current
Bug: 37342627
Change-Id: I1d8142ff53036e99cf509a22855928248c29a924
diff --git a/services/batteryservice/Android.bp b/services/batteryservice/Android.bp
index e441bda..4c7265b 100644
--- a/services/batteryservice/Android.bp
+++ b/services/batteryservice/Android.bp
@@ -1,3 +1,11 @@
+cc_library_headers {
+ name: "libbatteryservice_headers",
+ vendor_available: true,
+ export_include_dirs: ["include"],
+ header_libs: ["libbinder_headers"],
+ export_header_lib_headers: ["libbinder_headers"],
+}
+
cc_library {
name: "libbatteryservice",
@@ -8,6 +16,9 @@
"IBatteryPropertiesRegistrar.cpp",
],
+ header_libs: ["libbatteryservice_headers"],
+ export_header_lib_headers: ["libbatteryservice_headers"],
+
shared_libs: [
"libutils",
"libbinder",
@@ -19,4 +30,4 @@
"-Wunused",
"-Wunreachable-code",
],
-}
\ No newline at end of file
+}
diff --git a/services/batteryservice/include/batteryservice/BatteryService.h b/services/batteryservice/include/batteryservice/BatteryService.h
new file mode 100644
index 0000000..80ab7f3
--- /dev/null
+++ b/services/batteryservice/include/batteryservice/BatteryService.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2013 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_BATTERYSERVICE_H
+#define ANDROID_BATTERYSERVICE_H
+
+#include <binder/Parcel.h>
+#include <sys/types.h>
+#include <utils/Errors.h>
+#include <utils/String8.h>
+
+namespace android {
+
+#include "BatteryServiceConstants.h"
+
+// must be kept in sync with definitions in
+// frameworks/base/core/java/android/os/BatteryManager.java
+enum {
+ BATTERY_PROP_CHARGE_COUNTER = 1, // equals BATTERY_PROPERTY_CHARGE_COUNTER
+ BATTERY_PROP_CURRENT_NOW = 2, // equals BATTERY_PROPERTY_CURRENT_NOW
+ BATTERY_PROP_CURRENT_AVG = 3, // equals BATTERY_PROPERTY_CURRENT_AVERAGE
+ BATTERY_PROP_CAPACITY = 4, // equals BATTERY_PROPERTY_CAPACITY
+ BATTERY_PROP_ENERGY_COUNTER = 5, // equals BATTERY_PROPERTY_ENERGY_COUNTER
+ BATTERY_PROP_BATTERY_STATUS = 6, // equals BATTERY_PROPERTY_BATTERY_STATUS
+};
+
+struct BatteryProperties {
+ bool chargerAcOnline;
+ bool chargerUsbOnline;
+ bool chargerWirelessOnline;
+ int maxChargingCurrent;
+ int maxChargingVoltage;
+ int batteryStatus;
+ int batteryHealth;
+ bool batteryPresent;
+ int batteryLevel;
+ int batteryVoltage;
+ int batteryTemperature;
+ int batteryCurrent;
+ int batteryCycleCount;
+ int batteryFullCharge;
+ int batteryChargeCounter;
+ String8 batteryTechnology;
+
+ status_t writeToParcel(Parcel* parcel) const;
+ status_t readFromParcel(Parcel* parcel);
+};
+
+struct BatteryProperty {
+ int64_t valueInt64;
+
+ status_t writeToParcel(Parcel* parcel) const;
+ status_t readFromParcel(Parcel* parcel);
+};
+
+}; // namespace android
+
+#endif // ANDROID_BATTERYSERVICE_H
diff --git a/services/batteryservice/include/batteryservice/BatteryServiceConstants.h b/services/batteryservice/include/batteryservice/BatteryServiceConstants.h
new file mode 100644
index 0000000..8a90a12
--- /dev/null
+++ b/services/batteryservice/include/batteryservice/BatteryServiceConstants.h
@@ -0,0 +1,32 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+#ifndef HIDL_GENERATED_android_hardware_health_V1_0_EXPORTED_CONSTANTS_H_
+#define HIDL_GENERATED_android_hardware_health_V1_0_EXPORTED_CONSTANTS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum {
+ BATTERY_STATUS_UNKNOWN = 1,
+ BATTERY_STATUS_CHARGING = 2,
+ BATTERY_STATUS_DISCHARGING = 3,
+ BATTERY_STATUS_NOT_CHARGING = 4,
+ BATTERY_STATUS_FULL = 5,
+};
+
+enum {
+ BATTERY_HEALTH_UNKNOWN = 1,
+ BATTERY_HEALTH_GOOD = 2,
+ BATTERY_HEALTH_OVERHEAT = 3,
+ BATTERY_HEALTH_DEAD = 4,
+ BATTERY_HEALTH_OVER_VOLTAGE = 5,
+ BATTERY_HEALTH_UNSPECIFIED_FAILURE = 6,
+ BATTERY_HEALTH_COLD = 7,
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // HIDL_GENERATED_android_hardware_health_V1_0_EXPORTED_CONSTANTS_H_
diff --git a/services/batteryservice/include/batteryservice/IBatteryPropertiesListener.h b/services/batteryservice/include/batteryservice/IBatteryPropertiesListener.h
new file mode 100644
index 0000000..b226dd6
--- /dev/null
+++ b/services/batteryservice/include/batteryservice/IBatteryPropertiesListener.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2013 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_IBATTERYPROPERTIESLISTENER_H
+#define ANDROID_IBATTERYPROPERTIESLISTENER_H
+
+#include <binder/IBinder.h>
+#include <binder/IInterface.h>
+
+#include <batteryservice/BatteryService.h>
+
+namespace android {
+
+// must be kept in sync with interface defined in IBatteryPropertiesListener.aidl
+enum {
+ TRANSACT_BATTERYPROPERTIESCHANGED = IBinder::FIRST_CALL_TRANSACTION,
+};
+
+// ----------------------------------------------------------------------------
+
+class IBatteryPropertiesListener : public IInterface {
+public:
+ DECLARE_META_INTERFACE(BatteryPropertiesListener)
+
+ virtual void batteryPropertiesChanged(struct BatteryProperties props) = 0;
+};
+
+// ----------------------------------------------------------------------------
+
+class BnBatteryPropertiesListener: public BnInterface<IBatteryPropertiesListener> {
+public:
+ virtual status_t onTransact(uint32_t code, const Parcel& data,
+ Parcel* reply, uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif // ANDROID_IBATTERYPROPERTIESLISTENER_H
diff --git a/services/batteryservice/include/batteryservice/IBatteryPropertiesRegistrar.h b/services/batteryservice/include/batteryservice/IBatteryPropertiesRegistrar.h
new file mode 100644
index 0000000..a7dbea6
--- /dev/null
+++ b/services/batteryservice/include/batteryservice/IBatteryPropertiesRegistrar.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2013 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_IBATTERYPROPERTIESREGISTRAR_H
+#define ANDROID_IBATTERYPROPERTIESREGISTRAR_H
+
+#include <binder/IInterface.h>
+#include <batteryservice/IBatteryPropertiesListener.h>
+
+namespace android {
+
+// must be kept in sync with interface defined in IBatteryPropertiesRegistrar.aidl
+enum {
+ REGISTER_LISTENER = IBinder::FIRST_CALL_TRANSACTION,
+ UNREGISTER_LISTENER,
+ GET_PROPERTY,
+ SCHEDULE_UPDATE,
+};
+
+class IBatteryPropertiesRegistrar : public IInterface {
+public:
+ DECLARE_META_INTERFACE(BatteryPropertiesRegistrar)
+
+ virtual void registerListener(const sp<IBatteryPropertiesListener>& listener) = 0;
+ virtual void unregisterListener(const sp<IBatteryPropertiesListener>& listener) = 0;
+ virtual status_t getProperty(int id, struct BatteryProperty *val) = 0;
+ virtual void scheduleUpdate() = 0;
+};
+
+class BnBatteryPropertiesRegistrar : public BnInterface<IBatteryPropertiesRegistrar> {
+public:
+ virtual status_t onTransact(uint32_t code, const Parcel& data,
+ Parcel* reply, uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif // ANDROID_IBATTERYPROPERTIESREGISTRAR_H