/*
* 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.
int batteryTemperature;
String8 batteryTechnology;
+ bool dockBatterySupported;
+ bool chargerDockAcOnline;
+ int dockBatteryStatus;
+ int dockBatteryHealth;
+ bool dockBatteryPresent;
+ int dockBatteryLevel;
+ int dockBatteryVoltage;
+ int dockBatteryTemperature;
+ String8 dockBatteryTechnology;
+
status_t writeToParcel(Parcel* parcel) const;
status_t readFromParcel(Parcel* parcel);
};
/*
* 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.
REGISTER_LISTENER = IBinder::FIRST_CALL_TRANSACTION,
UNREGISTER_LISTENER,
GET_PROPERTY,
+ GET_DOCK_PROPERTY,
};
class IBatteryPropertiesRegistrar : public IInterface {
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 status_t getDockProperty(int id, struct BatteryProperty *val) = 0;
};
class BnBatteryPropertiesRegistrar : public BnInterface<IBatteryPropertiesRegistrar> {
/*
* 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.
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;
}
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;
}
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");
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);
};