upload android base code part1

This commit is contained in:
August 2018-08-08 15:50:00 +08:00
parent e02f198e2d
commit 0a1de6c4b3
48159 changed files with 9071466 additions and 0 deletions

View file

@ -0,0 +1,19 @@
cc_library_shared {
name: "libthermalcallback",
srcs: [
"ThermalCallback.cpp",
],
cflags: [
"-Wall",
"-Werror",
],
include_dirs: ["frameworks/native"],
shared_libs: [
"android.hardware.thermal@1.1",
"libhidlbase",
"libhidltransport",
"liblog",
"libthermalservice",
"libutils",
],
}

View file

@ -0,0 +1,69 @@
#define LOG_TAG "android.hardware.thermal.thermalcallback@1.1-impl"
#include <log/log.h>
#include "ThermalCallback.h"
#include "services/thermalservice/ThermalService.h"
#include <math.h>
#include <android/os/Temperature.h>
#include <hardware/thermal.h>
namespace android {
namespace hardware {
namespace thermal {
namespace V1_1 {
namespace implementation {
using ::android::os::ThermalService;
using ::android::hardware::thermal::V1_0::TemperatureType;
// Register a binder ThermalService object for sending events
void ThermalCallback::registerThermalService(sp<ThermalService> thermalService)
{
mThermalService = thermalService;
}
// Methods from IThermalCallback::V1_1 follow.
Return<void> ThermalCallback::notifyThrottling(
bool isThrottling,
const android::hardware::thermal::V1_0::Temperature& temperature) {
// Convert HIDL IThermal Temperature to binder IThermalService Temperature.
if (mThermalService != nullptr) {
float value = NAN;
int type = DEVICE_TEMPERATURE_UNKNOWN;
switch(temperature.type) {
case TemperatureType::CPU:
type = DEVICE_TEMPERATURE_CPU;
break;
case TemperatureType::GPU:
type = DEVICE_TEMPERATURE_GPU;
break;
case TemperatureType::BATTERY:
type = DEVICE_TEMPERATURE_BATTERY;
break;
case TemperatureType::SKIN:
type = DEVICE_TEMPERATURE_SKIN;
break;
case TemperatureType::UNKNOWN:
default:
type = DEVICE_TEMPERATURE_UNKNOWN;
break;
}
value = temperature.currentValue == UNKNOWN_TEMPERATURE ? NAN :
temperature.currentValue;
android::os::Temperature thermal_svc_temp(value, type);
mThermalService->notifyThrottling(isThrottling, thermal_svc_temp);
} else {
ALOGE("IThermalService binder service not created, drop throttling event");
}
return Void();
}
} // namespace implementation
} // namespace V1_1
} // namespace thermal
} // namespace hardware
} // namespace android

View file

@ -0,0 +1,43 @@
#ifndef ANDROID_HARDWARE_THERMAL_V1_1_THERMALCALLBACK_H
#define ANDROID_HARDWARE_THERMAL_V1_1_THERMALCALLBACK_H
#include <android/hardware/thermal/1.1/IThermalCallback.h>
#include <android/hardware/thermal/1.0/types.h>
#include <android/os/Temperature.h>
#include <hidl/MQDescriptor.h>
#include <hidl/Status.h>
#include "services/thermalservice/ThermalService.h"
namespace android {
namespace hardware {
namespace thermal {
namespace V1_1 {
namespace implementation {
using ::android::hardware::Return;
using ::android::hardware::Void;
using ::android::os::ThermalService;
class ThermalCallback : public IThermalCallback {
public:
// Register a binder ThermalService object for sending events
void registerThermalService(sp<ThermalService> thermalService);
// Methods from IThermalCallback::V1_1 follow.
Return<void> notifyThrottling(
bool isThrottling,
const android::hardware::thermal::V1_0::Temperature& temperature)
override;
private:
// Our registered binder ThermalService object to use for sending events
sp<android::os::ThermalService> mThermalService;
};
} // namespace implementation
} // namespace V1_1
} // namespace thermal
} // namespace hardware
} // namespace android
#endif // ANDROID_HARDWARE_THERMAL_V1_1_THERMALCALLBACK_H