Skip to content

Commit 8090172

Browse files
committed
cleanup android platform: fix warns, log -> info, send email
1 parent 256d73e commit 8090172

File tree

10 files changed

+63
-33
lines changed

10 files changed

+63
-33
lines changed

cocos/audio/AudioEngine.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,14 @@ int AudioEngine::play2d(const std::string& filePath, bool loop, float volume, fl
216216
// TODO: remove for release
217217
CCLOGINFO("profile = %p, profileHelper = %p", profile, profileHelper);
218218
}
219-
219+
220+
// TODO: consider this PR - https://github.com/cocos2d/cocos2d-x/pull/18383
221+
// - to allow play by removing oldest instance
220222
if (_audioIDInfoMap.size() >= _maxInstances) {
221223
CCLOGERROR("Fail to play %s cause by limited max instance of AudioEngine",filePath.c_str());
222224
break;
223225
}
226+
224227
if (profileHelper)
225228
{
226229
if(profileHelper->profile.maxInstances != 0 && profileHelper->audioIDs.size() >= profileHelper->profile.maxInstances){

cocos/audio/android/AudioPlayerProvider.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ namespace cocos2d { namespace experimental {
4343

4444
static int getSystemAPILevel()
4545
{
46-
ALOGI("steve");
4746
static int __systemApiLevel = -1;
4847
if (__systemApiLevel > 0)
4948
{

cocos/audio/apple/AudioEngine-inl.mm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,9 @@ AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *bids)
419419
_threadMutex.lock();
420420
auto playerIt = _audioPlayers.find(audioID);
421421
if (playerIt != _audioPlayers.end()) {
422-
ALOGV("found player for audioId");
422+
ALOGV("found player for audioId [%d]", audioID);
423423
if(playerIt->second->play2d()) {
424-
ALOGV("play successful");
424+
ALOGV("play successful, seekToTime = %f", seekToTime);
425425
_scheduler->performFunctionInCocosThread([audioID,seekToTime](){
426426
if (AudioEngine::_audioIDInfoMap.find(audioID) != AudioEngine::_audioIDInfoMap.end()) {
427427
AudioEngine::_audioIDInfoMap[audioID].state = AudioEngine::AudioState::PLAYING;

cocos/base/CCConsole.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ namespace {
230230
{
231231

232232
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
233-
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "steve", 0);
233+
// __android_log_print(ANDROID_LOG_DEBUG, "cocos2d-x debug info", "steve", 0);
234234
#endif
235235

236236
int bufferSize = MAX_LOG_LENGTH;
@@ -242,7 +242,7 @@ namespace {
242242
if (buf == nullptr)
243243
{
244244
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
245-
__android_log_print(ANDROID_LOG_DEBUG, "STEVE", "format: %s", format);
245+
__android_log_print(ANDROID_LOG_DEBUG, "[ST]", "format: %s", format);
246246
#endif
247247
return;
248248
}

cocos/platform/android/CCFileUtils-android.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,15 @@ bool FileUtilsAndroid::isFileExistInternal(const std::string& strFilePath) const
167167
{
168168
const char* s = strFilePath.c_str();
169169

170-
CCLOG("[FileUtilsAndroid::isFileExistInternal] [steve] _defaultResRootPath: %s", _defaultResRootPath.c_str());
170+
CCLOGINFO("[FileUtilsAndroid::isFileExistInternal] [steve] _defaultResRootPath: %s", _defaultResRootPath.c_str());
171171

172172
// Found "assets/" at the beginning of the path and we don't want it
173173
if (strFilePath.find(_defaultResRootPath) == 0) {
174-
CCLOG("[steve] strFilePath: %s", strFilePath.c_str());
174+
CCLOGINFO("[steve] strFilePath: %s", strFilePath.c_str());
175175
s += _defaultResRootPath.length();
176176
}
177177

178-
CCLOG("[FileUtilsAndroid::isFileExistInternal] [steve] find in apk dirPath(%s)", s);
178+
CCLOGINFO("[FileUtilsAndroid::isFileExistInternal] [steve] find in apk dirPath(%s)", s);
179179

180180
if (obbfile && obbfile->fileExists(s))
181181
{
@@ -189,7 +189,7 @@ bool FileUtilsAndroid::isFileExistInternal(const std::string& strFilePath) const
189189
bFound = true;
190190
AAsset_close(aa);
191191
} else {
192-
CCLOG("[FileUtilsAndroid::isFileExistInternal] [steve] [AssetManager] ... in APK %s, found = false!", strFilePath.c_str());
192+
CCLOGINFO("[FileUtilsAndroid::isFileExistInternal] [steve] [AssetManager] ... in APK %s, found = false!", strFilePath.c_str());
193193
}
194194
}
195195
}

cocos/platform/android/CCPlatformDefine-android.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,25 @@ THE SOFTWARE.
5959
#if defined(__has_cpp_attribute)
6060
#if __has_cpp_attribute(maybe_unused)
6161
#define MAYBE_UNUSED [[maybe_unused]]
62+
//#warning MAYBE_UNUSED is [[maybe_unused]]
6263
#elif __has_cpp_attribute(gnu::unused)
6364
#define MAYBE_UNUSED [[gnu::unused]]
65+
#warning MAYBE_UNUSED is GNU:unused
6466
#else
6567
#define MAYBE_UNUSED
68+
#warning MAYBE_UNUSED is NOT DEFINED!!!!!!
6669
#endif
67-
#else
68-
#define MAYBE_UNUSED
69-
#endif
7070

71-
#if defined(__has_cpp_attribute)
71+
// no discard
7272
#if __has_cpp_attribute(nodiscard)
7373
#define NODISCARD [[nodiscard]]
7474
#elif __has_cpp_attribute(gnu::warn_unused_result)
7575
#define NODISCARD [[gnu::warn_unused_result]]
7676
#else
7777
#define NODISCARD
78-
#endif
79-
#else
80-
#define NODISCARD
81-
#endif
78+
#endif
8279

83-
#if defined(__has_cpp_attribute)
80+
// fallthrough
8481
#if __has_cpp_attribute(fallthrough)
8582
#define FALLTHROUGH [[fallthrough]]
8683
#elif __has_cpp_attribute(clang::fallthrough)
@@ -89,19 +86,23 @@ THE SOFTWARE.
8986
#define FALLTHROUGH
9087
#endif
9188
#else
92-
#define FALLTHROUGH
93-
#endif
89+
#warning MAYBE_UNUSED is NOT DEFINED!!!!!!
90+
#define MAYBE_UNUSED
91+
#define NODISCARD
92+
#define FALLTHROUGH
93+
#endif // __has_cpp_attribute
94+
9495

9596
////////////////////////////////////////////////////////////
9697

9798
/* Define NULL pointer value */
9899
#ifndef NULL
99-
#ifdef __cplusplus
100-
#define NULL 0
101-
#else
102-
#define NULL ((void *)0)
103-
#endif
104-
#endif
100+
#ifdef __cplusplus
101+
#define NULL 0
102+
#else
103+
#define NULL ((void *)0)
104+
#endif
105+
#endif // null
105106

106107
#endif // CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
107108

cocos/platform/android/java/src/org/cocos2dx/lib/Cocos2dxHelper.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,36 @@ public static boolean openURL(String url) {
398398
}
399399
return ret;
400400
}
401-
401+
402+
public static void sendEmailMessageToSupport(String subj, String msg) {
403+
404+
// /* Create the Intent */
405+
// final Intent emailIntent = new Intent(android.content.Intent.ACTION_SENDTO);
406+
//
407+
// /* Fill it with Data */
408+
// emailIntent.setType("plain/text");
409+
// emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"[email protected]"});
410+
// emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subj);
411+
// emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, msg);
412+
//
413+
// /* Send it off to the Activity-Chooser */
414+
// Cocos2dxActivity.getContext().startActivity(Intent.createChooser(emailIntent, "Send feedback email..."));
415+
416+
// https://stackoverflow.com/questions/3132889/action-sendto-for-sending-an-email
417+
// ACTION_SENDTO filters for email apps (discard bluetooth and others)
418+
String uriText =
419+
"mailto:[email protected]" +
420+
"?subject=" + Uri.encode(subj) +
421+
"&body=" + Uri.encode(msg);
422+
423+
Uri uri = Uri.parse(uriText);
424+
425+
Intent sendIntent = new Intent(Intent.ACTION_SENDTO);
426+
sendIntent.setData(uri);
427+
Cocos2dxActivity.getContext().startActivity(Intent.createChooser(sendIntent, "Send email"));
428+
429+
}
430+
402431
public static long[] getObbAssetFileDescriptor(final String path) {
403432
long[] array = new long[3];
404433
if (Cocos2dxHelper.getObbFile() != null) {
@@ -727,7 +756,7 @@ public static void setStringForKey(String key, String value) {
727756
editor.putString(key, value);
728757
editor.apply();
729758
}
730-
759+
731760
public static void deleteValueForKey(String key) {
732761
SharedPreferences settings = sActivity.getSharedPreferences(Cocos2dxHelper.PREFS_NAME, 0);
733762
SharedPreferences.Editor editor = settings.edit();

cocos/platform/android/javaactivity-android.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
8585

8686
JNIEXPORT void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thiz, jint w, jint h)
8787
{
88-
LOGD("steve");
88+
//LOGD("steve");
8989
auto director = cocos2d::Director::getInstance();
9090
auto glview = director->getOpenGLView();
9191
if (!glview)

cocos/ui/UILayout.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ class CC_DLL NodeExtension
5151
NS_CC_END
5252

5353

54-
55-
5654
NS_CC_BEGIN
5755

5856
namespace ui {

extensions/GUI/CCControlExtension/CCControlSwitch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ bool ControlSwitchSprite::initWithMaskSprite(
214214
return false;
215215
}
216216

217-
void ControlSwitchSprite::updateTweenAction(float value, const std::string& /* key */)
217+
void ControlSwitchSprite::updateTweenAction(float value, const std::string& key MAYBE_UNUSED)
218218
{
219219
CCLOGINFO("key = %s, value = %f", key.c_str(), value);
220220
setSliderXPosition(value);

0 commit comments

Comments
 (0)