forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove platform_channel_tizen.cc * Extract FeedbackManager into a new file * Extract TizenShell into a new file * Minor cleanups
- Loading branch information
Showing
8 changed files
with
299 additions
and
273 deletions.
There are no files selected for viewing
This file contains 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 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,42 @@ | ||
// Copyright 2022 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 "feedback_manager.h" | ||
|
||
#include "flutter/shell/platform/tizen/logger.h" | ||
|
||
namespace flutter { | ||
|
||
FeedbackManager::FeedbackManager() { | ||
int ret = feedback_initialize(); | ||
if (ret != FEEDBACK_ERROR_NONE) { | ||
FT_LOG(Error) << "feedback_initialize() failed with error: " | ||
<< get_error_message(ret); | ||
return; | ||
} | ||
initialized_ = true; | ||
} | ||
|
||
FeedbackManager::~FeedbackManager() { | ||
if (initialized_) { | ||
feedback_deinitialize(); | ||
} | ||
} | ||
|
||
void FeedbackManager::Play(feedback_type_e type, feedback_pattern_e pattern) { | ||
if (!initialized_) { | ||
return; | ||
} | ||
int ret = feedback_play_type(type, pattern); | ||
if (ret == FEEDBACK_ERROR_PERMISSION_DENIED) { | ||
FT_LOG(Error) | ||
<< "Permission denied. Add the http://tizen.org/privilege/haptic " | ||
"privilege to tizen-manifest.xml to use haptic feedbacks."; | ||
} else if (ret != FEEDBACK_ERROR_NONE) { | ||
FT_LOG(Error) << "feedback_play_type() failed with error: " | ||
<< get_error_message(ret); | ||
} | ||
} | ||
|
||
} // namespace flutter |
This file contains 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,39 @@ | ||
// Copyright 2022 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 EMBEDDER_FEEDBACK_MANAGER_H_ | ||
#define EMBEDDER_FEEDBACK_MANAGER_H_ | ||
|
||
#include <feedback.h> | ||
|
||
namespace flutter { | ||
|
||
class FeedbackManager { | ||
public: | ||
static FeedbackManager& GetInstance() { | ||
static FeedbackManager instance; | ||
return instance; | ||
} | ||
|
||
FeedbackManager(const FeedbackManager&) = delete; | ||
FeedbackManager& operator=(const FeedbackManager&) = delete; | ||
|
||
void PlaySound() { Play(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_GENERAL); } | ||
|
||
void PlayTapSound() { Play(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TAP); } | ||
|
||
void Vibrate() { Play(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_SIP); } | ||
|
||
private: | ||
explicit FeedbackManager(); | ||
~FeedbackManager(); | ||
|
||
void Play(feedback_type_e type, feedback_pattern_e pattern); | ||
|
||
bool initialized_ = false; | ||
}; | ||
|
||
} // namespace flutter | ||
|
||
#endif // EMBEDDER_FEEDBACK_MANAGER_H_ |
This file contains 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 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
Oops, something went wrong.