-
Notifications
You must be signed in to change notification settings - Fork 52
[battery_plus] Refactor the C++ code #351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[battery_plus] Refactor the C++ code #351
Conversation
| return std::make_unique<FlStreamHandlerError>( | ||
| std::to_string(battery_.GetLastError()), | ||
| battery_.GetLastErrorString(), nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This currently results in an app crash. There will be a fix in the engine code soon.
Issue: flutter/flutter#101682
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swift-kim Any progress on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swift-kim Actually, I also made a patch to prevent crash. how about this?
First one has intentional leak and the second solution you mentioned doesn't seem very good as it depends on instances of other classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The holder_ suffix seems redundant. Otherwise looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@swift-kim Can I make PR to apply all place where have same problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Just one thing I forgot to mention: the private: section header is missing in the class.
Part of the code refactoring project.
DeviceBatteryclass fromBatteryPlusTizenPluginfor better separation of the platform channel communication and the device API usage. (I referred to the battery_plus_windows implementation.)BatteryStatusto indicate the current status of the device battery or an error status.RegisterObserver/UnregisterObserver→StartListen/StopListenStartListentakesBatteryStatusCallbackas an argument.GetLevel.GetStatus(previouslyGetBatteryStatus) return a value of typeBatteryStatus.BatteryStatusStreamHandlerclass. Now the lifecycle ofEventSinkis solely managed by this class.OnListenInternalreturns aStreamHandlerErroron initialization failure.SetupChannelsand combine withRegisterWithRegistrar.Additional note: The
batteryStategetter API has been added the platform interface and will be implemented in a later PR.