static int32_t HdfBatteryInterfaceDriverBind(struct HdfDeviceObject *deviceObject)
{
auto *hdfBatteryInterfaceHost = new (std::nothrow) HdfBatteryInterfaceHost;
if (hdfBatteryInterfaceHost == nullptr) {
BATTERY_HILOGE(COMP_HDI, "%{public}s: failed to create HdfBatteryInterfaceHost object", __func__);
return HDF_FAILURE;
}
//此处绑定了BatteryInterfaceDriverDispatch作为消息处理函数。
hdfBatteryInterfaceHost->ioService.Dispatch = BatteryInterfaceDriverDispatch;
hdfBatteryInterfaceHost->ioService.Open = nullptr;
hdfBatteryInterfaceHost->ioService.Release = nullptr;
auto serviceImpl = IBatteryInterface::Get(true);
if (serviceImpl == nullptr) {
BATTERY_HILOGE(COMP_HDI, "%{public}s: failed to get of implement service", __func__);
delete hdfBatteryInterfaceHost;
return HDF_FAILURE;
}
// lock有效性判断
auto lockInner = GetRunningLockInner(remoteObj);
if (lockInner == nullptr) {
POWER_HILOGE(FEATURE_RUNNING_LOCK, "LockInner is nullptr");
return;
}
if (lockInner->IsProxied()) {
POWER_HILOGW(FEATURE_RUNNING_LOCK, "Runninglock is proxied");
return;
}
if (runninglockProxy_->IsProxied(lockInner->GetPid(), lockInner->GetUid())) {
POWER_HILOGW(FEATURE_RUNNING_LOCK, "Runninglock is proxied, do not allow lock");
return;
}