-
Notifications
You must be signed in to change notification settings - Fork 52
[geolocator] Refactor the C++ code #387
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
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
1e697e4
[geolocator] Refactor the C++ code
JSUYA 6a97435
[geolocator] Clean up code foramt
JSUYA 7cddeb6
[geolocator] Update ChangeLog
JSUYA a08a644
[geolocator] Fix code format
JSUYA 5fee8d5
[geolocator] Replace PermissionManager code
JSUYA 74e215f
[geolocator] Enhance app setting manager
JSUYA d20a31f
[geolocator] Enhance log message
JSUYA 822e7e6
[geolocator] Change PermissionStatus enum
JSUYA 8de89fb
[geolocator] Refactoring AppSettingsManager
JSUYA 7996eaa
[geolocator] Refactor LocationManager
JSUYA 9e01be1
[geolocator] Fix typo
JSUYA a7edb92
[geolocator] Fix permission manager
JSUYA 6813108
[geolocator] Fix MothodResult handling
JSUYA ef7448e
[geolocator] Fix code
JSUYA dc67c40
[geolocator] Fix build
JSUYA b8444e3
[geolocator] Fix more code
JSUYA 50086e5
[geolocator] Fix stream error handling
JSUYA File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| ## 1.0.3 | ||
|
|
||
| * Refactor the C++ code. | ||
|
|
||
| ## 1.0.2 | ||
|
|
||
| * Update geolocator to 8.0.0 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| // Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #include "app_settings_manager.h" | ||
|
|
||
| #include <app_common.h> | ||
| #include <app_control.h> | ||
| #include <package_manager.h> | ||
|
|
||
| #include <string> | ||
|
|
||
| #include "log.h" | ||
|
|
||
| namespace { | ||
|
|
||
| constexpr char kSettingAppId[] = "com.samsung.clocksetting.apps"; | ||
| constexpr char kLocationSettingAppId[] = "com.samsung.setting-location"; | ||
| constexpr char kLocationSettingOperationId[] = | ||
| "http://tizen.org/appcontrol/operation/configure/location"; | ||
|
|
||
| std::string GetPackageName() { | ||
| char* app_id; | ||
| int ret = app_get_id(&app_id); | ||
| if (ret != APP_ERROR_NONE) { | ||
| LOG_ERROR("The app ID is not found."); | ||
| return ""; | ||
| } | ||
|
|
||
| package_info_h package_info; | ||
| ret = package_info_create(app_id, &package_info); | ||
| free(app_id); | ||
| if (ret != PACKAGE_MANAGER_ERROR_NONE) { | ||
| LOG_ERROR("Failed to create a package info handle."); | ||
| return ""; | ||
| } | ||
|
|
||
| char* package_name; | ||
| ret = package_info_get_package(package_info, &package_name); | ||
| package_info_destroy(package_info); | ||
| if (ret != PACKAGE_MANAGER_ERROR_NONE) { | ||
| LOG_ERROR("Failed to get the package name."); | ||
| return ""; | ||
| } | ||
|
|
||
| std::string result = std::string(package_name); | ||
| free(package_name); | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| bool AppSettingsManager::OpenAppSettings() { | ||
| std::string package_name = GetPackageName(); | ||
| if (package_name.empty()) { | ||
| return false; | ||
| } | ||
|
|
||
| app_control_h app_control; | ||
| int ret = app_control_create(&app_control); | ||
| if (ret != APP_CONTROL_ERROR_NONE) { | ||
| LOG_ERROR("Failed to create an app control handle."); | ||
| return false; | ||
| } | ||
|
|
||
| ret = app_control_set_app_id(app_control, kSettingAppId); | ||
| if (ret != APP_CONTROL_ERROR_NONE) { | ||
| LOG_ERROR("Failed to set an app ID."); | ||
| app_control_destroy(app_control); | ||
| return false; | ||
| } | ||
|
|
||
| ret = app_control_add_extra_data(app_control, "pkgId", package_name.c_str()); | ||
| if (ret != APP_CONTROL_ERROR_NONE) { | ||
| LOG_ERROR("Failed to add extra data."); | ||
| app_control_destroy(app_control); | ||
| return false; | ||
| } | ||
|
|
||
| ret = app_control_send_launch_request(app_control, nullptr, nullptr); | ||
| app_control_destroy(app_control); | ||
| if (ret != APP_CONTROL_ERROR_NONE) { | ||
| LOG_ERROR("Failed to send a launch request."); | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } | ||
|
|
||
| bool AppSettingsManager::OpenLocationSettings() { | ||
| std::string package_name = GetPackageName(); | ||
| if (package_name.empty()) { | ||
| return false; | ||
| } | ||
|
|
||
| app_control_h app_control; | ||
| int ret = app_control_create(&app_control); | ||
| if (ret != APP_CONTROL_ERROR_NONE) { | ||
| LOG_ERROR("Failed to create an app control handle."); | ||
| return false; | ||
| } | ||
|
|
||
| ret = app_control_set_app_id(app_control, kLocationSettingAppId); | ||
| if (ret != APP_CONTROL_ERROR_NONE) { | ||
| LOG_ERROR("Failed to set an app ID."); | ||
| app_control_destroy(app_control); | ||
| return false; | ||
| } | ||
|
|
||
| ret = app_control_set_operation(app_control, kLocationSettingOperationId); | ||
| if (ret != APP_CONTROL_ERROR_NONE) { | ||
| LOG_ERROR("Failed to set operation. (%s)", get_error_message(ret)); | ||
| app_control_destroy(app_control); | ||
| return false; | ||
| } | ||
|
|
||
| ret = app_control_send_launch_request(app_control, nullptr, nullptr); | ||
| app_control_destroy(app_control); | ||
| if (ret != APP_CONTROL_ERROR_NONE) { | ||
| LOG_ERROR("Failed to send a launch request."); | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef FLUTTER_PLUGIN_APP_SETTINGS_MANAGER_H_ | ||
| #define FLUTTER_PLUGIN_APP_SETTINGS_MANAGER_H_ | ||
|
|
||
| class AppSettingsManager { | ||
| public: | ||
| AppSettingsManager() {} | ||
| ~AppSettingsManager() {} | ||
|
|
||
| bool OpenAppSettings(); | ||
| bool OpenLocationSettings(); | ||
| }; | ||
|
|
||
| #endif // FLUTTER_PLUGIN_APP_SETTINGS_MANAGER_H_ | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.