diff options
author | Jorge Ruesga <jorge@ruesga.com> | 2015-06-28 01:12:46 +0200 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-10-17 14:04:39 -0700 |
commit | bfcd44395079a34ff496ae960bdde6982064140b (patch) | |
tree | 8a88519b381a5c7ae7b700dfc642d8005aa32fae /services/batteryservice | |
parent | c1c5240aa9a924f371e8f310374d8e1885384274 (diff) | |
download | frameworks_native-bfcd44395079a34ff496ae960bdde6982064140b.zip frameworks_native-bfcd44395079a34ff496ae960bdde6982064140b.tar.gz frameworks_native-bfcd44395079a34ff496ae960bdde6982064140b.tar.bz2 |
native: dock battery
Change-Id: I23eadf0361cbe25029b95dbd022ce1a2cc96e94d
Require: topic:dock_battery
Signed-off-by: Jorge Ruesga <jorge@ruesga.com>
Diffstat (limited to 'services/batteryservice')
-rw-r--r-- | services/batteryservice/BatteryProperties.cpp | 34 | ||||
-rw-r--r-- | services/batteryservice/IBatteryPropertiesRegistrar.cpp | 28 |
2 files changed, 62 insertions, 0 deletions
diff --git a/services/batteryservice/BatteryProperties.cpp b/services/batteryservice/BatteryProperties.cpp index ab636a9..0ae637c 100644 --- a/services/batteryservice/BatteryProperties.cpp +++ b/services/batteryservice/BatteryProperties.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2013 The Android Open Source Project + * Copyright (C) 2015 The CyanogenMod Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,6 +41,27 @@ status_t BatteryProperties::readFromParcel(Parcel* p) { batteryVoltage = p->readInt32(); batteryTemperature = p->readInt32(); batteryTechnology = String8((p->readString16()).string()); + + dockBatterySupported = p->readInt32() == 1 ? true : false; + if (dockBatterySupported) { + chargerDockAcOnline = p->readInt32() == 1 ? true : false; + dockBatteryStatus = p->readInt32(); + dockBatteryHealth = p->readInt32(); + dockBatteryPresent = p->readInt32() == 1 ? true : false; + dockBatteryLevel = p->readInt32(); + dockBatteryVoltage = p->readInt32(); + dockBatteryTemperature = p->readInt32(); + dockBatteryTechnology = String8((p->readString16()).string()); + } else { + chargerDockAcOnline = false; + dockBatteryStatus = BATTERY_STATUS_UNKNOWN; + dockBatteryHealth = BATTERY_HEALTH_UNKNOWN; + dockBatteryPresent = false; + dockBatteryLevel = 0; + dockBatteryVoltage = 0; + dockBatteryTemperature = 0; + dockBatteryTechnology = String8(String8::kEmptyString); + } return OK; } @@ -54,6 +76,18 @@ status_t BatteryProperties::writeToParcel(Parcel* p) const { p->writeInt32(batteryVoltage); p->writeInt32(batteryTemperature); p->writeString16(String16(batteryTechnology)); + + p->writeInt32(dockBatterySupported ? 1 : 0); + if (dockBatterySupported) { + p->writeInt32(chargerDockAcOnline ? 1 : 0); + p->writeInt32(dockBatteryStatus); + p->writeInt32(dockBatteryHealth); + p->writeInt32(dockBatteryPresent ? 1 : 0); + p->writeInt32(dockBatteryLevel); + p->writeInt32(dockBatteryVoltage); + p->writeInt32(dockBatteryTemperature); + p->writeString16(String16(dockBatteryTechnology)); + } return OK; } diff --git a/services/batteryservice/IBatteryPropertiesRegistrar.cpp b/services/batteryservice/IBatteryPropertiesRegistrar.cpp index 46934e0..e18e39c 100644 --- a/services/batteryservice/IBatteryPropertiesRegistrar.cpp +++ b/services/batteryservice/IBatteryPropertiesRegistrar.cpp @@ -60,6 +60,22 @@ public: val->readFromParcel(&reply); return ret; } + + status_t getDockProperty(int id, struct BatteryProperty *val) { + Parcel data, reply; + data.writeInterfaceToken(IBatteryPropertiesRegistrar::getInterfaceDescriptor()); + data.writeInt32(id); + remote()->transact(GET_DOCK_PROPERTY, data, &reply); + int32_t ret = reply.readExceptionCode(); + if (ret != 0) { + return ret; + } + ret = reply.readInt32(); + int parcelpresent = reply.readInt32(); + if (parcelpresent) + val->readFromParcel(&reply); + return ret; + } }; IMPLEMENT_META_INTERFACE(BatteryPropertiesRegistrar, "android.os.IBatteryPropertiesRegistrar"); @@ -97,6 +113,18 @@ status_t BnBatteryPropertiesRegistrar::onTransact(uint32_t code, val.writeToParcel(reply); return OK; } + + case GET_DOCK_PROPERTY: { + CHECK_INTERFACE(IBatteryPropertiesRegistrar, data, reply); + int id = data.readInt32(); + struct BatteryProperty val; + status_t result = getDockProperty(id, &val); + reply->writeNoException(); + reply->writeInt32(result); + reply->writeInt32(1); + val.writeToParcel(reply); + return OK; + } } return BBinder::onTransact(code, data, reply, flags); }; |